feat(loader): read SVSIM_INSTANCE_ID and derive per-instance identity

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-03 09:12:49 -04:00
parent f0c422aa8f
commit 5bc7d6f184
2 changed files with 26 additions and 0 deletions

View File

@@ -18,6 +18,25 @@ namespace SVSimLoader
{
Instance = this;
Log = base.Logger;
var instanceRaw = System.Environment.GetEnvironmentVariable("SVSIM_INSTANCE_ID");
if (!string.IsNullOrEmpty(instanceRaw) && int.TryParse(instanceRaw, out var instanceId) && instanceId > 0)
{
SvSimConfig.SecondaryInstance = true;
SvSimConfig.InstanceId = instanceId;
SvSimConfig.FakeSteamId = 900000UL + (ulong)instanceId;
// Ticket must be non-empty, even-length, valid hex (the server HexDecodes it before
// the bypass) and DISTINCT per instance (SteamSessionService caches ticket->steamId
// and rejects a reused ticket under a different steamId).
string hex = SvSimConfig.FakeSteamId.ToString("x");
if (hex.Length % 2 == 1) hex = "0" + hex;
SvSimConfig.FakeTicket = hex;
SvSimConfig.IdentityFilePath =
System.IO.Path.Combine(Paths.ConfigPath, $"svsim-identity-{instanceId}.json");
InstanceIdentityStore.Initialize(SvSimConfig.IdentityFilePath);
Logger.LogWarning(
$"MULTI-INSTANCE MODE: id={instanceId}, fakeSteamId={SvSimConfig.FakeSteamId}, " +
$"identity file={SvSimConfig.IdentityFilePath}. Single-instance mutex will be skipped.");
}
// Plugin startup logic
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
_applicationUrl = Config.Bind("Connection", "ApplicationUrl", "https://utoongaize.shadowverse.jp/shadowverse/",

View File

@@ -19,4 +19,11 @@ public static class SvSimConfig
public static bool ProbeEventSection { get; set; }
public static string StorySectionIdFilter { get; set; }
public static bool NukeIdentityOnStartup { get; set; }
// Multi-instance (same-machine two-client PvP smoke) — driven by the SVSIM_INSTANCE_ID env var.
public static bool SecondaryInstance { get; set; } // true when SVSIM_INSTANCE_ID is set
public static int InstanceId { get; set; } // parsed env value
public static string IdentityFilePath { get; set; } // per-instance identity file
public static ulong FakeSteamId { get; set; } // 900000 + InstanceId
public static string FakeTicket { get; set; } // even-length hex of FakeSteamId
}