gui: thread m2pack runtime key from orchestrator result into play command

Headless Program.cs already passes `result.RuntimeKey` to
GameProcess.Launch, but the GUI Play command dropped it and spawned
Metin2.exe without any env vars. Any m2p-capable client then hit
"Invalid M2PACK_MASTER_KEY_HEX" and refused to load .m2p archives.

Cache the runtime key on the view model when StartUpdateAsync completes
and pass it through on Play. Matches the headless path and the
EnvVarKeyDelivery wiring already in main.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jan Nedbal
2026-04-15 12:22:30 +02:00
parent 027786a79d
commit 8f6f378a23

View File

@@ -14,6 +14,7 @@ using Metin2Launcher.Localization;
using Metin2Launcher.Logging;
using Metin2Launcher.Manifest;
using Metin2Launcher.Orchestration;
using Metin2Launcher.Runtime;
using Velopack;
using Velopack.Sources;
@@ -63,6 +64,7 @@ public sealed partial class MainWindowViewModel : ObservableObject
private LauncherState _state = LauncherState.Idle;
private LoadedManifest? _lastManifest;
private RuntimeKey? _lastRuntimeKey;
private bool _signatureBlocked;
public MainWindowViewModel()
@@ -136,6 +138,7 @@ public sealed partial class MainWindowViewModel : ObservableObject
if (result is not null)
{
_lastManifest = result.Manifest;
_lastRuntimeKey = result.RuntimeKey;
ApplyState(result.FinalState);
await TryFetchNewsAsync(result.Manifest);
}
@@ -293,7 +296,7 @@ public sealed partial class MainWindowViewModel : ObservableObject
{
if (!CanPlay) return;
ApplyState(LauncherState.Launching);
var ok = GameProcess.Launch(_clientRoot, LauncherConfig.GameExecutable);
var ok = GameProcess.Launch(_clientRoot, LauncherConfig.GameExecutable, _lastRuntimeKey);
if (ok)
{
if (Avalonia.Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime d)