mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 23:18:37 +00:00
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016ABh36DZ2sZNq3ChN6EZJs
29 lines
1.6 KiB
C#
29 lines
1.6 KiB
C#
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.
|
|
internal static class ScanCounts
|
|
{
|
|
// Written into the index cache's coverage text on a full scan.
|
|
public static string Coverage(int candidates, int recovered) =>
|
|
FormattableString.Invariant($"rpf9dump full scan, {candidates} candidates, {recovered} recovered");
|
|
|
|
// Reads the candidate count back from a cached index. Older caches wrote culture-formatted numbers
|
|
// ("183,801", "183'801", "183\u2019801", ...), so any punctuation or space between the digits is dropped. Null when the text is not ours or not readable.
|
|
public static int? Candidates(string? coverage)
|
|
{
|
|
if (coverage is null) return null;
|
|
var m = Regex.Match(coverage, @"^rpf9dump full scan, ([0-9][0-9\p{P}\p{Zs}]*) candidates,");
|
|
if (!m.Success) return null;
|
|
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);
|
|
}
|