tgstation-server 6.19.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 accessIdentifier,
119 string? logFilePath)
120 {
121 ArgumentNullException.ThrowIfNull(dmbProvider);
122 ArgumentNullException.ThrowIfNull(launchParameters);
123 ArgumentNullException.ThrowIfNull(accessIdentifier);
124
125 var encodedParameters = EncodeParameters(parameters, launchParameters);
126 var parametersString = !String.IsNullOrEmpty(encodedParameters)
127 ? $" -params \"{encodedParameters}\""
128 : String.Empty;
129
130 // important to run on all ports to allow port changing
131 var arguments = String.Format(
132 CultureInfo.InvariantCulture,
133 "\"{0}\" -port {1} -ports 1-65535 {2}-close -verbose -{3} -{4}{5}{6}{7}{8}",
134 dmbProvider.DmbName,
135 launchParameters.Port!.Value,
136 launchParameters.AllowWebClient!.Value
137 ? "-webclient "
138 : String.Empty,
139 SecurityWord(launchParameters.SecurityLevel!.Value),
140 VisibilityWord(launchParameters.Visibility!.Value),
141 logFilePath != null
142 ? $" -logself -log {logFilePath}"
143 : String.Empty, // DD doesn't output anything if -logself is set???
144 launchParameters.StartProfiler!.Value
145 ? " -profile"
146 : String.Empty,
147 supportsMapThreads && launchParameters.MapThreads!.Value != 0
148 ? $" -map-threads {launchParameters.MapThreads.Value}"
149 : String.Empty,
150 parametersString);
151 return arguments;
152 }
153
155 public override string FormatCompilerArguments(string dmePath, string? additionalArguments)
156 {
157 if (String.IsNullOrWhiteSpace(additionalArguments))
158 additionalArguments = String.Empty;
159 else
160 additionalArguments = $"{additionalArguments.Trim()} ";
161
162 return $"-clean {additionalArguments}\"{dmePath ?? throw new ArgumentNullException(nameof(dmePath))}\"";
163 }
164 }
165}
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.
static string VisibilityWord(DreamDaemonVisibility visibility)
Change a given visibility into the appropriate DreamDaemon command line word.
override string FormatServerArguments(IDmbProvider dmbProvider, IReadOnlyDictionary< string, string >? parameters, DreamDaemonLaunchParameters launchParameters, string accessIdentifier, string? logFilePath)
static string SecurityWord(DreamDaemonSecurity securityLevel)
Change a given securityLevel into the appropriate DreamDaemon command line word.
override string FormatCompilerArguments(string dmePath, string? additionalArguments)
ByondInstallation(IIOManager installationIOManager, Task installationTask, EngineVersion version, string dreamDaemonPath, string dreamMakerPath, bool supportsCli, bool supportsMapThreads)
Initializes a new instance of the ByondInstallation class.
Provides absolute paths to the latest compiled .dmbs.
Interface for using filesystems.
Definition IIOManager.cs:14
DreamDaemonVisibility
The visibility setting for DreamDaemon.
DreamDaemonSecurity
DreamDaemon's security level.
EngineType
The type of engine the codebase is using.
Definition EngineType.cs:7