tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
ByondInstallation.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Globalization;
4using System.Threading.Tasks;
5
10
12{
17 {
19 public override EngineVersion Version { get; }
20
22 public override string ServerExePath { get; }
23
25 public override string CompilerExePath { get; }
26
28 public override bool PromptsForNetworkAccess { get; }
29
31 public override bool HasStandardOutput { get; }
32
34 public override bool PreferFileLogging => false;
35
37 public override bool UseDotnetDump => false;
38
40 public override Task InstallationTask { get; }
41
45 readonly bool supportsMapThreads;
46
52 static string SecurityWord(DreamDaemonSecurity securityLevel)
53 {
54 return securityLevel switch
55 {
56 DreamDaemonSecurity.Safe => "safe",
57 DreamDaemonSecurity.Trusted => "trusted",
58 DreamDaemonSecurity.Ultrasafe => "ultrasafe",
59 _ => throw new ArgumentOutOfRangeException(nameof(securityLevel), securityLevel, String.Format(CultureInfo.InvariantCulture, "Bad DreamDaemon security level: {0}", securityLevel)),
60 };
61 }
62
68 static string VisibilityWord(DreamDaemonVisibility visibility)
69 {
70 return visibility switch
71 {
72 DreamDaemonVisibility.Public => "public",
73 DreamDaemonVisibility.Private => "private",
74 DreamDaemonVisibility.Invisible => "invisible",
75 _ => throw new ArgumentOutOfRangeException(nameof(visibility), visibility, String.Format(CultureInfo.InvariantCulture, "Bad DreamDaemon visibility level: {0}", visibility)),
76 };
77 }
78
90 IIOManager installationIOManager,
91 Task installationTask,
92 EngineVersion version,
93 string dreamDaemonPath,
94 string dreamMakerPath,
95 bool supportsCli,
97 : base(installationIOManager)
98 {
99 InstallationTask = installationTask ?? throw new ArgumentNullException(nameof(installationTask));
100 ArgumentNullException.ThrowIfNull(version);
101
102 if (version.Engine != EngineType.Byond)
103 throw new ArgumentException($"Invalid EngineType: {version.Engine}", nameof(version));
104
105 Version = version ?? throw new ArgumentNullException(nameof(version));
106 ServerExePath = dreamDaemonPath ?? throw new ArgumentNullException(nameof(dreamDaemonPath));
107 CompilerExePath = dreamMakerPath ?? throw new ArgumentNullException(nameof(dreamMakerPath));
108 HasStandardOutput = supportsCli;
109 PromptsForNetworkAccess = !supportsCli;
110 this.supportsMapThreads = supportsMapThreads;
111 }
112
114 public override string FormatServerArguments(
115 IDmbProvider dmbProvider,
116 IReadOnlyDictionary<string, string> parameters,
117 DreamDaemonLaunchParameters launchParameters,
118 string? logFilePath)
119 {
120 ArgumentNullException.ThrowIfNull(dmbProvider);
121 ArgumentNullException.ThrowIfNull(parameters);
122 ArgumentNullException.ThrowIfNull(launchParameters);
123
124 var parametersString = EncodeParameters(parameters, launchParameters);
125
126 var arguments = String.Format(
127 CultureInfo.InvariantCulture,
128 "\"{0}\" -port {1} -ports 1-65535 {2}-close -verbose -{3} -{4}{5}{6}{7} -params \"{8}\"",
129 dmbProvider.DmbName,
130 launchParameters.Port!.Value,
131 launchParameters.AllowWebClient!.Value
132 ? "-webclient "
133 : String.Empty,
134 SecurityWord(launchParameters.SecurityLevel!.Value),
135 VisibilityWord(launchParameters.Visibility!.Value),
136 logFilePath != null
137 ? $" -logself -log {logFilePath}"
138 : String.Empty, // DD doesn't output anything if -logself is set???
139 launchParameters.StartProfiler!.Value
140 ? " -profile"
141 : String.Empty,
142 supportsMapThreads && launchParameters.MapThreads!.Value != 0
143 ? $" -map-threads {launchParameters.MapThreads.Value}"
144 : String.Empty,
145 parametersString);
146 return arguments;
147 }
148
150 public override string FormatCompilerArguments(string dmePath, string? additionalArguments)
151 {
152 if (String.IsNullOrWhiteSpace(additionalArguments))
153 additionalArguments = String.Empty;
154 else
155 additionalArguments = $"{additionalArguments.Trim()} ";
156
157 return $"-clean {additionalArguments}\"{dmePath ?? throw new ArgumentNullException(nameof(dmePath))}\"";
158 }
159 }
160}
Information about an engine installation.
ushort? Port
The port DreamDaemon uses. This should be publically accessible.
DreamDaemonVisibility? Visibility
The DreamDaemonVisibility level of DreamDaemon. No-op for EngineType.OpenDream.
bool? AllowWebClient
If the BYOND web client can be used to connect to the game server. No-op for EngineType....
bool? StartProfiler
If -profile is passed in on the DreamDaemon command line. No-op for EngineType.OpenDream.
DreamDaemonSecurity? SecurityLevel
The DreamDaemonSecurity level of DreamDaemon. No-op for EngineType.OpenDream.
uint? MapThreads
If DreamDaemon supports it, the value added as the -map-threads parameter. 0 uses the default BYOND v...
Implementation of IEngineInstallation for EngineType.Byond.
readonly bool supportsMapThreads
If map threads are supported by the Version.
override bool PromptsForNetworkAccess
If ServerExePath may create network prompts.
static string VisibilityWord(DreamDaemonVisibility visibility)
Change a given visibility into the appropriate DreamDaemon command line word.
static string SecurityWord(DreamDaemonSecurity securityLevel)
Change a given securityLevel into the appropriate DreamDaemon command line word.
override string ServerExePath
The full path to the game server executable.
override string FormatCompilerArguments(string dmePath, string? additionalArguments)
Return the command line arguments for compiling a given dmePath if compilation is necessary....
override Task InstallationTask
The Task that completes when the BYOND version finished installing.
override bool UseDotnetDump
If dotnet-dump should be used to create process dumps for this installation.
ByondInstallation(IIOManager installationIOManager, Task installationTask, EngineVersion version, string dreamDaemonPath, string dreamMakerPath, bool supportsCli, bool supportsMapThreads)
Initializes a new instance of the ByondInstallation class.
override string FormatServerArguments(IDmbProvider dmbProvider, IReadOnlyDictionary< string, string > parameters, DreamDaemonLaunchParameters launchParameters, string? logFilePath)
Return the command line arguments for launching with given launchParameters .The formatted arguments ...
override bool HasStandardOutput
If ServerExePath supports being run as a command-line application and outputs log information to be c...
override EngineVersion Version
The EngineVersion of the IEngineInstallation.
override bool PreferFileLogging
If HasStandardOutput is set, this indicates that the engine server has good file logging that should ...
override string CompilerExePath
The full path to the dm/DreamMaker executable.
static string EncodeParameters(IReadOnlyDictionary< string, string > parameters, DreamDaemonLaunchParameters launchParameters)
Encode given parameters for passing as world.params on the command line.
Provides absolute paths to the latest compiled .dmbs.
Interface for using filesystems.
Definition IIOManager.cs:13
DreamDaemonVisibility
The visibility setting for DreamDaemon.
DreamDaemonSecurity
DreamDaemon's security level.
EngineType
The type of engine the codebase is using.
Definition EngineType.cs:7