From 78f92bcf2e8f61ca9dca4fbea38e194782cb688a Mon Sep 17 00:00:00 2001 From: AAyberkU <97833630+AAyberkU@users.noreply.github.com> Date: Sun, 22 Nov 2026 20:58:01 +0300 Subject: [PATCH] rpf9dump: rescan instead of exporting from a partial index cache rpf9dump shares %LOCALAPPDATA%\RpfPreview\Indexes with the rpf9-explorer GUI, which saves its model index while it is still indexing and when a scan is cancelled, with IsComplete=false. rpf9dump trusted any cache that loaded, so after a stopped GUI scan it exported only what had been indexed so far, published the manifest and exited 0, and make_game.py never redid the step. A cached index now stands in for a full scan only when it is marked complete or carries rpf9dump's own coverage text; otherwise rpf9dump scans again. Its own full scans are saved with the complete mark, which the cache file already had a field for. Co-Authored-By: Claude Mythos 5.2 Claude-Session: https://claude.ai/code/session_016ABh36DZ2sZNq3ChN6EZJs --- tests/Rpf9DumpDiagnostics/Program.cs | 13 +++++++++++++ tools/rpf9dump/Program.cs | 4 +++- tools/rpf9dump/ScanCounts.cs | 7 +++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/Rpf9DumpDiagnostics/Program.cs b/tests/Rpf9DumpDiagnostics/Program.cs index 0ee25d023..704231347 100644 --- a/tests/Rpf9DumpDiagnostics/Program.cs +++ b/tests/Rpf9DumpDiagnostics/Program.cs @@ -114,11 +114,24 @@ Console.WriteLine("Mesh key tests passed."); } Console.WriteLine("Recovered segment tests passed."); +// Only a full scan replaces rpf9dump's own: rpf9-explorer saves partial model indexes while indexing and on cancel. +Check(!ScanCounts.IsFullScan(Index("Dictionary-aware model scan in progress \u00B7 1,001/183,801 containers validated.", false)), "GUI index saved while indexing"); +Check(!ScanCounts.IsFullScan(Index("Dictionary-aware model scan canceled. Validated models are retained; discovery will resume on reopen.", false)), "GUI index saved on cancel"); +Check(ScanCounts.IsFullScan(Index("Full 1,234,567-byte model-container scan \u00B7 149,811 supported models including drawable dictionary children.", true)), "GUI index marked complete"); +Check(ScanCounts.IsFullScan(Index(ScanCounts.Coverage(183801, 149811), true)), "rpf9dump index"); +Check(ScanCounts.IsFullScan(Index(ScanCounts.Coverage(183801, 149811), false)), "rpf9dump index saved without the complete mark"); +Check(ScanCounts.IsFullScan(Index(string.Format(System.Globalization.CultureInfo.GetCultureInfo("de-CH"), "rpf9dump full scan, {0:N0} candidates, {1:N0} recovered", 183801, 149811), false)), "culture-formatted rpf9dump index"); +Check(!ScanCounts.IsFullScan(null), "no cached index"); +Console.WriteLine("Cached index tests passed."); + static void Check(bool ok, string what) { if (!ok) throw new Exception($"Failed: {what}"); } +static RecoveryIndexCache.CachedIndex Index(string coverage, bool complete) => + new("rpfpreview-payload-index/models/4", "models", "levels.rpf", 0, 0, "", coverage, []) { IsComplete = complete }; + static void Expect(ReadOnlySpan system, int graphicsBytes, string expected) { string actual = ModelDecodeFailure.Explain(system, graphicsBytes).Code; diff --git a/tools/rpf9dump/Program.cs b/tools/rpf9dump/Program.cs index ba67d4d5e..aba410a73 100644 --- a/tools/rpf9dump/Program.cs +++ b/tools/rpf9dump/Program.cs @@ -144,12 +144,14 @@ else if (mode is "models" or "textures") { byte[] header; using (var f = File.OpenRead(src)) { header = new byte[64]; f.ReadExactly(header); } var cached = RecoveryIndexCache.Load(mode, src, length, header); + // A partial index (rpf9-explorer stopped or still indexing) would export only part of the archive: scan again. + if (cached != null && !ScanCounts.IsFullScan(cached)) { Console.WriteLine($" cached {mode} index is not marked as a full scan ({cached.Entries.Count:N0} entries), rescanning"); cached = null; } candidates = ScanCounts.Candidates(cached?.Coverage); if (cached == null) { var cands = Scan(src, 0, null); list = Recover(src, length, cands); - RecoveryIndexCache.Save(mode, src, list, ScanCounts.Coverage(cands.Count, list.Select(e => e.Offset).Distinct().Count())); + RecoveryIndexCache.Save(mode, src, list, ScanCounts.Coverage(cands.Count, list.Select(e => e.Offset).Distinct().Count()), complete: true); candidates = cands.Count; } else diff --git a/tools/rpf9dump/ScanCounts.cs b/tools/rpf9dump/ScanCounts.cs index a122418ab..7bbfeabc5 100644 --- a/tools/rpf9dump/ScanCounts.cs +++ b/tools/rpf9dump/ScanCounts.cs @@ -1,4 +1,5 @@ using System.Text.RegularExpressions; +using RpfPreview.Core; // Scan-level counts for the manifest. Candidates that RecoverAtOffsets rejects never reach Program.cs, so // Candidates - Recovered is the only place those rejects show up. @@ -18,4 +19,10 @@ internal static class ScanCounts string digits = new(m.Groups[1].Value.Where(char.IsAsciiDigit).ToArray()); return int.TryParse(digits, out int n) ? n : null; } + + // Whether a cached index can stand in for a full scan. rpf9-explorer saves its model index while it is still + // indexing and when the scan is cancelled, and marks it complete only at the end. rpf9dump before this check saved + // full scans without the mark, so its own coverage text counts too. + public static bool IsFullScan(RecoveryIndexCache.CachedIndex? cached) => + cached is not null && (cached.IsComplete || Candidates(cached.Coverage) is not null); }