Snapshot for release 2026.10.21.2 (internal dd171ba)

This commit is contained in:
Tom Bohar 2026-10-21 12:04:02 -04:00
commit b059db4ca2
8 changed files with 181 additions and 41 deletions

View file

@ -53,6 +53,7 @@
<Compile Include="..\RynthCore.App\DecalBridgeCheck.cs" Link="Shared\DecalBridgeCheck.cs" />
<Compile Include="..\RynthCore.App\RealDecalCheckHost.cs" Link="Shared\RealDecalCheckHost.cs" />
<Compile Include="..\RynthCore.App\AcLaunchArgumentBuilder.cs" Link="Shared\AcLaunchArgumentBuilder.cs" />
<Compile Include="..\RynthCore.App\AcClientCommandLine.cs" Link="Shared\AcClientCommandLine.cs" />
<Compile Include="..\RynthCore.App\FirstLoginRules.cs" Link="Shared\FirstLoginRules.cs" />
<Compile Include="..\RynthCore.App\CrashDumpWriterRule.cs" Link="Shared\CrashDumpWriterRule.cs" />
<Compile Include="..\RynthCore.App\AcClientLaunchSettingsService.cs" Link="Shared\AcClientLaunchSettingsService.cs" />

View file

@ -0,0 +1,75 @@
using System.Collections.Generic;
using System.Text;
namespace RynthCore.App;
/// <summary>
/// acclient.exe's own command-line rules, and how to write a value so the client reads it back.
///
/// The client splits its command line itself (ConvertCommandLineToArgList, 0x004098F0, called from
/// WinMain; ArgumentParser::ParseCommandLine uses the same template), not with the C runtime's rules:
/// * arguments are split on spaces (only ' ') outside quotes;
/// * a " switches quoting on or off and is dropped; it is never part of an argument;
/// * nothing is escaped: a backslash is an ordinary character;
/// * a quote left open refuses the whole command line ("Unmatched quote"), so the client starts
/// without the account, password or host.
/// The launcher used to write the C runtime's form ("\"" around the value, \\ for \, \" for ") for a
/// value with a space or a quote; the client kept the backslashes, so a password with a quote mark
/// reached the server changed and the login failed (2026-10-21, a 30-character password with most
/// special characters on Conquest; ThwargLauncher, which passes the password as it is, worked).
/// </summary>
internal static class AcClientCommandLine
{
/// <summary>
/// <paramref name="value"/> as one argument the client reads back as <see cref="ClientValue"/> of it:
/// as it is when it has no space (what ThwargLauncher passes), else in quotes. Quote marks in it are
/// left out, as the client would drop them anyway; that also keeps the quotes balanced.
/// </summary>
public static string Token(string? value)
{
string v = ClientValue(value);
if (v.Length == 0)
return "\"\"";
return v.IndexOf(' ') >= 0 ? "\"" + v + "\"" : v;
}
/// <summary>What the client can receive of <paramref name="value"/>: everything but its quote marks.</summary>
public static string ClientValue(string? value) => (value ?? string.Empty).Replace("\"", string.Empty);
/// <summary>True when the client can't receive <paramref name="value"/> as it is (it has a quote mark).</summary>
public static bool LosesCharacters(string? value) => !string.IsNullOrEmpty(value) && value.IndexOf('"') >= 0;
/// <summary>
/// The arguments the client reads from <paramref name="commandLine"/>, by its own rules; null when it
/// refuses the line (a quote left open). For tests, and for reading the client's -h the way it does.
/// </summary>
public static List<string>? Split(string? commandLine)
{
var args = new List<string>();
if (commandLine == null)
return null;
var cur = new StringBuilder();
bool inArg = false, quoted = false;
foreach (char c in commandLine)
{
if (c == ' ' && !quoted)
{
if (inArg) { args.Add(cur.ToString()); cur.Clear(); inArg = false; }
}
else if (c == '"')
{
quoted = !quoted;
}
else
{
inArg = true;
cur.Append(c);
}
}
if (quoted)
return null;
if (inArg)
args.Add(cur.ToString());
return args;
}
}

View file

@ -128,27 +128,6 @@ internal sealed class AcLaunchArgumentBuilder
return null;
}
private static string Quote(string value)
{
value ??= string.Empty;
if (value.Length == 0)
return "\"\"";
if (!NeedsQuoting(value))
return value;
return "\"" + value.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
}
private static bool NeedsQuoting(string value)
{
foreach (char ch in value)
{
if (char.IsWhiteSpace(ch) || ch == '"')
return true;
}
return false;
}
/// <summary>One argument by acclient's own rules (AcClientCommandLine), not the C runtime's.</summary>
private static string Quote(string value) => AcClientCommandLine.Token(value);
}

View file

@ -95,18 +95,21 @@ internal static class ServerDetect
return host.Length > 0;
}
/// <summary>Windows command-line splitting, enough for the launchers' quoting (quotes group, \" is a quote).</summary>
/// <summary>
/// acclient's own splitting (ConvertCommandLineToArgList, 0x004098F0; the launcher's
/// AcClientCommandLine), so -h is the host the client itself reads: spaces split outside quotes,
/// a quote only toggles and is dropped, a backslash is ordinary. An open quote (the client refuses
/// the whole line) still yields what was read.
/// </summary>
private static List<string> SplitArgs(string s)
{
var list = new List<string>();
var cur = new System.Text.StringBuilder();
bool inQuotes = false, any = false;
for (int i = 0; i < s.Length; i++)
foreach (char c in s)
{
char c = s[i];
if (c == '\\' && i + 1 < s.Length && s[i + 1] == '"') { cur.Append('"'); i++; any = true; continue; }
if (c == '"') { inQuotes = !inQuotes; any = true; continue; }
if (!inQuotes && char.IsWhiteSpace(c))
if (c == '"') { inQuotes = !inQuotes; continue; }
if (c == ' ' && !inQuotes)
{
if (any) { list.Add(cur.ToString()); cur.Clear(); any = false; }
continue;

View file

@ -260,6 +260,8 @@ internal static class LaunchCommand
Log($"No password is saved for account '{acct}'. Launch it once from the launcher to enter it, or edit the account.");
return 2;
}
if (RynthCore.App.AcClientCommandLine.LosesCharacters(pwd))
Log("Note: the password has a quote mark (\"). The AC client can't receive one on its command line, so it logs in with the password less its quote marks.");
string arguments = server.Emulator == EmulatorKind.Gdle
? string.Join(" ",
@ -384,16 +386,8 @@ internal static class LaunchCommand
// Mirrors AcLaunchArgumentBuilder.Quote — only quote when needed, escape
// backslashes + quotes inside.
private static string Quote(string value)
{
value ??= string.Empty;
if (value.Length == 0)
return "\"\"";
bool needs = value.Any(ch => char.IsWhiteSpace(ch) || ch == '"');
if (!needs)
return value;
return "\"" + value.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
}
/// <summary>One argument by acclient's own rules (AcClientCommandLine), as the launcher writes it.</summary>
private static string Quote(string value) => RynthCore.App.AcClientCommandLine.Token(value);
private static string? GetOpt(string[] args, string name)
{

View file

@ -21,6 +21,7 @@
<Compile Include="..\RynthCore.App\DecalAccountModes.cs" Link="Shared\DecalAccountModes.cs" />
<!-- Saved account passwords are DPAPI-encrypted (PasswordProtected in appsettings.json). -->
<Compile Include="..\RynthCore.App\AccountPasswordProtection.cs" Link="Shared\AccountPasswordProtection.cs" />
<Compile Include="..\RynthCore.App\AcClientCommandLine.cs" Link="Shared\AcClientCommandLine.cs" />
</ItemGroup>
<ItemGroup>