Skip to content

Commit bde8f8d

Browse files
committed
Fixed Invalid Discord URL for Button
Added Exit Codes to Program.cs Minor stylistic changes
1 parent 37c051a commit bde8f8d

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

SS14.Launcher/Api/AuthApi.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ public async Task<AuthenticateResult> AuthenticateAsync(AuthenticateRequest requ
5353
Log.Debug("Response for error:\n{response}\n{content}", resp, await resp.Content.ReadAsStringAsync());
5454
// Unknown error? uh oh.
5555
return new AuthenticateResult(
56-
new[] { "Server returned unknown error" },
56+
["Server returned unknown error"],
5757
AuthenticateDenyResponseCode.UnknownError);
5858
}
5959
catch (JsonException e)
6060
{
6161
Log.Error(e, "JsonException in AuthenticateAsync");
6262
return new AuthenticateResult(
63-
new[] { "Server sent invalid response" },
63+
["Server sent invalid response"],
6464
AuthenticateDenyResponseCode.UnknownError);
6565
}
6666
catch (HttpRequestException httpE)
6767
{
6868
Log.Error(httpE, "HttpRequestException in AuthenticateAsync");
6969
HttpSelfTest.StartSelfTest();
7070
return new AuthenticateResult(
71-
new[] { $"Connection error to authentication server: {httpE.Message}" },
71+
[$"Connection error to authentication server: {httpE.Message}"],
7272
AuthenticateDenyResponseCode.UnknownError);
7373
}
7474
}
@@ -99,18 +99,18 @@ public async Task<RegisterResult> RegisterAsync(string username, string email, s
9999
Log.Error("Server returned unexpected HTTP status code: {responseCode}", resp.StatusCode);
100100
Log.Debug("Response for error:\n{response}\n{content}", resp, await resp.Content.ReadAsStringAsync());
101101
// Unknown error? uh oh.
102-
return new RegisterResult(new[] { "Server returned unknown error" });
102+
return new RegisterResult(["Server returned unknown error"]);
103103
}
104104
catch (JsonException e)
105105
{
106106
Log.Error(e, "JsonException in RegisterAsync");
107-
return new RegisterResult(new[] { "Server sent invalid response" });
107+
return new RegisterResult(["Server sent invalid response"]);
108108
}
109109
catch (HttpRequestException httpE)
110110
{
111111
Log.Error(httpE, "HttpRequestException in RegisterAsync");
112112
HttpSelfTest.StartSelfTest();
113-
return new RegisterResult(new[] { $"Connection error to authentication server: {httpE.Message}" });
113+
return new RegisterResult([$"Connection error to authentication server: {httpE.Message}"]);
114114
}
115115
}
116116

@@ -133,12 +133,12 @@ public async Task<RegisterResult> RegisterAsync(string username, string email, s
133133
// Unknown error? uh oh.
134134
Log.Error("Server returned unexpected HTTP status code: {responseCode}", resp.StatusCode);
135135
Log.Debug("Response for error:\n{response}\n{content}", resp, await resp.Content.ReadAsStringAsync());
136-
return new[] { "Server returned unknown error" };
136+
return ["Server returned unknown error"];
137137
}
138138
catch (HttpRequestException httpE)
139139
{
140140
Log.Error(httpE, "HttpRequestException in ForgotPasswordAsync");
141-
return new[] { $"Connection error to authentication server: {httpE.Message}" };
141+
return [$"Connection error to authentication server: {httpE.Message}"];
142142
}
143143
}
144144

@@ -160,13 +160,13 @@ public async Task<RegisterResult> RegisterAsync(string username, string email, s
160160
// Unknown error? uh oh.
161161
Log.Error("Server returned unexpected HTTP status code: {responseCode}", resp.StatusCode);
162162
Log.Debug("Response for error:\n{response}\n{content}", resp, await resp.Content.ReadAsStringAsync());
163-
return new[] { "Server returned unknown error" };
163+
return ["Server returned unknown error"];
164164
}
165165
catch (HttpRequestException httpE)
166166
{
167167
Log.Error(httpE, "HttpRequestException in ResendConfirmationAsync");
168168
HttpSelfTest.StartSelfTest();
169-
return new[] { $"Connection error to authentication server: {httpE.Message}" };
169+
return [$"Connection error to authentication server: {httpE.Message}"];
170170
}
171171
}
172172

SS14.Launcher/ConfigConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static class ConfigConstants
3939
new("https://hub.singularity14.co.uk/"),
4040
new("https://hub.spacestation14.com/"),
4141
};
42-
public const string DiscordUrl = "https://discord.gg/49KeKwXc8g/";
42+
public const string DiscordUrl = "https://discord.gg/Z5PsYHY6fM";
4343
public const string AccountBaseUrl = "https://account.spacestation14.com/Identity/Account/";
4444
public const string AccountManagementUrl = $"{AccountBaseUrl}Manage";
4545
public const string AccountRegisterUrl = $"{AccountBaseUrl}Register";

SS14.Loader/ContentDbFileApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal sealed class ContentDbFileApi : IFileApi, IDisposable
2121
{
2222
private readonly Dictionary<string, (long id, int length, ContentCompressionScheme compr)> _files = new();
2323
private readonly SemaphoreSlim _dbConnectionsSemaphore;
24-
private readonly ConcurrentBag<ConPoolEntry> _dbConnections = new();
24+
private readonly ConcurrentBag<ConPoolEntry> _dbConnections = [];
2525
private readonly int _connectionPoolSize;
2626

2727
public unsafe ContentDbFileApi(string contentDbPath, long version)

SS14.Loader/Program.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,29 @@
99
using NSec.Cryptography;
1010
using Robust.LoaderApi;
1111

12+
1213
namespace SS14.Loader;
1314

15+
internal enum ExitCode
16+
{
17+
Success = 0,
18+
InvalidSignature = 1,
19+
InvalidFilename = 2,
20+
FailedProgramExecution = 3,
21+
}
22+
1423
internal class Program
1524
{
1625
private readonly string[] _engineArgs;
1726
private const string RobustAssemblyName = "Robust.Client";
1827

1928
private readonly IFileApi _fileApi;
2029

30+
/// <summary>
31+
/// Main Program class constructor. Loads assembly contexts.
32+
/// </summary>
33+
/// <param name="robustPath"></param>
34+
/// <param name="engineArgs"></param>
2135
private Program(string robustPath, string[] engineArgs)
2236
{
2337
_engineArgs = engineArgs;
@@ -45,9 +59,13 @@ private IntPtr LoadContextOnResolvingUnmanaged(Assembly assembly, string unmanag
4559
return IntPtr.Zero;
4660
}
4761

62+
/// <summary>
63+
/// Runs the program.
64+
/// </summary>
65+
/// <returns></returns>
4866
private bool Run()
4967
{
50-
if (!TryOpenAssembly(RobustAssemblyName, out var clientAssembly))
68+
if (!TryOpenAssembly(RobustAssemblyName, out Assembly? clientAssembly))
5169
{
5270
Console.WriteLine("Unable to locate Robust.Client.dll in engine build!");
5371
return false;
@@ -80,6 +98,7 @@ private bool Run()
8098
{
8199
contentApi?.Dispose();
82100
}
101+
83102
return true;
84103
}
85104

@@ -101,7 +120,7 @@ private static bool TryGetLoader(Assembly clientAssembly, [NotNullWhen(true)] ou
101120
return false;
102121
}
103122

104-
loader = (ILoaderEntryPoint) Activator.CreateInstance(type)!;
123+
loader = (ILoaderEntryPoint)Activator.CreateInstance(type)!;
105124
return true;
106125
}
107126

@@ -137,10 +156,11 @@ private bool TryOpenAssemblyStream(string name, [NotNullWhen(true)] out Stream?
137156
[STAThread]
138157
internal static int Main(string[] args)
139158
{
159+
// TEMP: Arguments can be parsed separately for tighter error handling.
140160
if (args.Length < 3)
141161
{
142162
Console.WriteLine("Usage: SS14.Loader <robustPath> <signature> <public key> [engineArg [engineArg...]]");
143-
return 1;
163+
return (int)ExitCode.InvalidSignature;
144164
}
145165

146166
var robustPath = args[0];
@@ -167,16 +187,17 @@ internal static int Main(string[] args)
167187
#endif
168188
{
169189
Console.WriteLine("Failed to verify engine signature!");
170-
return 2;
190+
return (int)ExitCode.InvalidSignature;
171191
}
172192
}
173193

174194
var program = new Program(robustPath, args[3..]);
175195
if (!program.Run())
176196
{
177-
return 3;
197+
return (int)ExitCode.FailedProgramExecution;
178198
}
179199

200+
// WIP: Remove if not needed.
180201
/*Console.WriteLine("lsasm dump:");
181202
foreach (var asmLoadContext in AssemblyLoadContext.All)
182203
{
@@ -187,6 +208,6 @@ internal static int Main(string[] args)
187208
}
188209
}*/
189210

190-
return 0;
211+
return (int)ExitCode.Success;
191212
}
192213
}

0 commit comments

Comments
 (0)