mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
launcher: pass PhotonCloudRegion to patcher template
DorkNet.ClientMod's config reads PhotonCloudRegion alongside the
AppIds, and the joining client needs the host's region to connect
to the right Photon cloud. Adds {PHOTON_REGION} to the substitution
map and threads region through ClientPatcher.ApplyAsync from both
host (AppState.PhotonRegion) and join (JoinPayload.PhotonRegion)
flows.
This commit is contained in:
@@ -28,7 +28,8 @@ namespace DorkNet.Launcher.Backend;
|
||||
/// }
|
||||
/// </code>
|
||||
/// Config template placeholders: <c>{HOST}</c>, <c>{PHOTON_APPID}</c>,
|
||||
/// <c>{PHOTON_VOICE_APPID}</c>. Anything else passes through unchanged.</para></summary>
|
||||
/// <c>{PHOTON_VOICE_APPID}</c>, <c>{PHOTON_REGION}</c>. Anything else
|
||||
/// passes through unchanged.</para></summary>
|
||||
public sealed class ClientPatcher
|
||||
{
|
||||
private const string DefaultPluginDest = "MelonLoader/Mods";
|
||||
@@ -39,11 +40,12 @@ public sealed class ClientPatcher
|
||||
string recRoomDataPath,
|
||||
string photonAppId,
|
||||
string photonVoiceAppId,
|
||||
string photonRegion,
|
||||
string apexHost,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
return Task.Run(() => ApplyCore(patcherDir, recRoomDataPath,
|
||||
photonAppId, photonVoiceAppId, apexHost), ct);
|
||||
photonAppId, photonVoiceAppId, photonRegion, apexHost), ct);
|
||||
}
|
||||
|
||||
private PatchResult ApplyCore(
|
||||
@@ -51,6 +53,7 @@ public sealed class ClientPatcher
|
||||
string recRoomDataPath,
|
||||
string photonAppId,
|
||||
string photonVoiceAppId,
|
||||
string photonRegion,
|
||||
string apexHost)
|
||||
{
|
||||
var log = new System.Text.StringBuilder();
|
||||
@@ -133,7 +136,8 @@ public sealed class ClientPatcher
|
||||
.Replace("{HOST}", apexHost ?? "")
|
||||
.Replace("{PHOTON_APPID}", photonAppId ?? "")
|
||||
.Replace("{PHOTON_VOICE_APPID}",
|
||||
string.IsNullOrEmpty(photonVoiceAppId) ? photonAppId ?? "" : photonVoiceAppId);
|
||||
string.IsNullOrEmpty(photonVoiceAppId) ? photonAppId ?? "" : photonVoiceAppId)
|
||||
.Replace("{PHOTON_REGION}", string.IsNullOrEmpty(photonRegion) ? "us" : photonRegion);
|
||||
File.WriteAllText(configDest, rendered);
|
||||
log.AppendLine($"[patch] wrote config: {Path.GetFileName(configDest)}");
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ public partial class MainWindow : Window
|
||||
HostStatusText.Text = "Patching your Rec Room client…";
|
||||
var patch = await _patcher.ApplyAsync(
|
||||
patcherDir, _state.RecRoomPath!,
|
||||
_state.PhotonAppId, _state.PhotonVoiceAppId, _hostApex);
|
||||
_state.PhotonAppId, _state.PhotonVoiceAppId, _state.PhotonRegion, _hostApex);
|
||||
if (!patch.Ok) { ShowError("Patcher failed: " + Truncate(patch.Log, 500)); return; }
|
||||
|
||||
var code = JoinCode.Encode(new JoinPayload
|
||||
@@ -324,7 +324,7 @@ public partial class MainWindow : Window
|
||||
JoinStatusText.Text = "Patching your Rec Room client…";
|
||||
var patch = await _patcher.ApplyAsync(
|
||||
patcherDir, _state.RecRoomPath!,
|
||||
payload.PhotonAppId, payload.PhotonVoiceAppId, payload.Host);
|
||||
payload.PhotonAppId, payload.PhotonVoiceAppId, payload.PhotonRegion, payload.Host);
|
||||
if (!patch.Ok) { ShowError("Patcher failed: " + Truncate(patch.Log, 500)); return; }
|
||||
|
||||
JoinStatusText.Text = $"Patched and ready. Connecting to {payload.Host}. " +
|
||||
|
||||
@@ -95,6 +95,7 @@ Defaults:
|
||||
| `{HOST}` | Host's tunnel hostname (or join code's `host` field) |
|
||||
| `{PHOTON_APPID}` | Host's Photon Realtime AppId |
|
||||
| `{PHOTON_VOICE_APPID}` | Host's Photon Voice AppId (falls back to Realtime if empty) |
|
||||
| `{PHOTON_REGION}` | Photon Cloud region (us/eu/asia/jp/sa/kr/in/au); defaults to `us` |
|
||||
|
||||
Example template:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user