Skip to content

Commit d8900c9

Browse files
committed
feat(dbg): Improve debug flags
1 parent 08a8844 commit d8900c9

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

Hi3Helper.Plugin.Wuwa/Management/WuwaGameInstaller.Patch.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,12 @@ await installer.RunAsync(kind, progressDelegate, progressStateDelegate, token)
460460
// Check whether the installed files already match the TARGET version's hashes.
461461
// This handles the case where both version JSONs are stale (e.g. game updated
462462
// externally) but all files on disk are already at the target version.
463-
if (!onlyDownload && patchIndex.GroupInfos.Length > 0)
463+
if (manager.DEBUG_SkipPreflight)
464+
{
465+
SharedStatic.InstanceLogger.LogWarning(
466+
"[Patch::RunAsync] Pre-flight validation SKIPPED (DEBUG_skipPreflight=true). Proceeding to download + patch.");
467+
}
468+
else if (!onlyDownload && patchIndex.GroupInfos.Length > 0)
464469
{
465470
currentProgressState = InstallProgressState.Verify;
466471

Hi3Helper.Plugin.Wuwa/Management/WuwaGameManager.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ private HttpClient ApiDownloadHttpClient
8585
/// </summary>
8686
internal GameVersion DEBUG_DowngradeVersionTarget { get; set; } = GameVersion.Empty;
8787

88+
/// <summary>
89+
/// When true, the pre-flight validation (which checks whether local files already
90+
/// match the target version) is skipped, forcing the patch flow to always download
91+
/// and apply krpdiff patches. Useful for testing the actual patch-apply logic when
92+
/// the game is already at the target version.
93+
/// Persisted as <c>DEBUG_skipPreflight</c> in <c>app-game-config.json</c>.
94+
/// The key is never written by default — add it manually to the JSON to enable.
95+
/// </summary>
96+
internal bool DEBUG_SkipPreflight { get; set; }
97+
8898
protected override GameVersion CurrentGameVersion
8999
{
90100
get
@@ -367,10 +377,10 @@ private void LogGameStateOnce()
367377
SharedStatic.InstanceLogger.LogDebug(
368378
"[WuwaGameManager::GameState] IsInstalled={IsInstalled}, ApiGameVersion={ApiVer}, CurrentGameVersion={CurVer}, " +
369379
"ApiPreloadGameVersion={PreloadVer}, HasPendingPreloadPatch={PendingPatch}, PatchDir={PatchDir}, " +
370-
"HasUpdate={HasUpdate}, HasPreload={HasPreload}, DEBUG_AllowDowngrade={AllowDowngrade}, DEBUG_DowngradeVersionTarget={DowngradeTarget}",
380+
"HasUpdate={HasUpdate}, HasPreload={HasPreload}, DEBUG_AllowDowngrade={AllowDowngrade}, DEBUG_DowngradeVersionTarget={DowngradeTarget}, DEBUG_SkipPreflight={SkipPreflight}",
371381
IsInstalled, ApiGameVersion, CurrentGameVersion,
372382
ApiPreloadGameVersion, HasPendingPreloadPatch, patchTempPath,
373-
HasUpdate, HasPreload, DEBUG_AllowDowngrade, DEBUG_DowngradeVersionTarget);
383+
HasUpdate, HasPreload, DEBUG_AllowDowngrade, DEBUG_DowngradeVersionTarget, DEBUG_SkipPreflight);
374384
}
375385

376386
protected override Task DownloadAssetAsyncInner(HttpClient? client, string fileUrl, Stream outputStream,
@@ -543,9 +553,11 @@ private void LoadDowngradeSettings()
543553
#if !USELIGHTWEIGHTJSONPARSER
544554
DEBUG_AllowDowngrade = CurrentGameConfigNode.GetConfigValue<bool?>("DEBUG_allowDowngrade") ?? false;
545555
string? targetStr = CurrentGameConfigNode.GetConfigValue<string?>("DEBUG_downgradeVersionTarget");
556+
DEBUG_SkipPreflight = CurrentGameConfigNode.GetConfigValue<bool?>("DEBUG_skipPreflight") ?? false;
546557
#else
547558
DEBUG_AllowDowngrade = CurrentGameConfigNode["DEBUG_allowDowngrade"]?.GetValue<bool>() ?? false;
548559
string? targetStr = CurrentGameConfigNode["DEBUG_downgradeVersionTarget"]?.GetValue<string>();
560+
DEBUG_SkipPreflight = CurrentGameConfigNode["DEBUG_skipPreflight"]?.GetValue<bool>() ?? false;
549561
#endif
550562

551563
if (!string.IsNullOrEmpty(targetStr) &&
@@ -565,6 +577,12 @@ private void LoadDowngradeSettings()
565577
"[WuwaGameManager::LoadDowngradeSettings] Downgrade enabled. Target version: {Ver}",
566578
DEBUG_DowngradeVersionTarget);
567579
}
580+
581+
if (DEBUG_SkipPreflight)
582+
{
583+
SharedStatic.InstanceLogger.LogWarning(
584+
"[WuwaGameManager::LoadDowngradeSettings] Pre-flight validation will be SKIPPED (DEBUG_skipPreflight=true).");
585+
}
568586
}
569587

570588
/// <summary>
@@ -682,6 +700,8 @@ public override void SaveConfig()
682700
else
683701
CurrentGameConfigNode.Remove("DEBUG_downgradeVersionTarget");
684702
}
703+
if (CurrentGameConfigNode.ContainsKey("DEBUG_skipPreflight"))
704+
CurrentGameConfigNode["DEBUG_skipPreflight"] = DEBUG_SkipPreflight;
685705

686706
if (CurrentGameVersion == GameVersion.Empty)
687707
{

0 commit comments

Comments
 (0)