mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 23:28:38 +00:00
Merge pull request #2730 from AAyberkU
This commit is contained in:
@ -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<byte> system, int graphicsBytes, string expected)
|
||||
{
|
||||
string actual = ModelDecodeFailure.Explain(system, graphicsBytes).Code;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user