Require a non-empty file before the manifest or exporter considers a DDS complete. Rebuild empty outputs through the atomic writer and cover skipped rows and surviving siblings with synthetic tests.
A mistyped source path, or a directory passed as one, created <out>/<name> and then failed in FileInfo.Length with an unhandled FileNotFoundException and exit -532462766. Check the source after the argument checks and before Directory.CreateDirectory, print one line to stderr, and exit 2 like the other input errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Nsrb3M85XUG34gwsU9emJ
An unknown first argument fell through every mode branch: it created <outdir>/<source>, printed ok=0 fail=0 skip=0 and exited 0, which make_game reads as a finished stage. Check the mode first, print one usage listing all five modes (audio and xma were missing) and exit 2.
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
The fixture wrote the resource page counts at 0x88/0x89, which is the
texture descriptor's width field (t+0x38 at t=0x50): width read 257 and
Parse rejected the record (layout 20480 vs allocation 4096), so no entry
reached Export and the committed test failed before any DDS write. Move
the page-count pointer to 0x40 (counts at 0x48, below the descriptor);
the same binary now recovers one texture, hits the blocked DDS write,
withholds manifest.json and exits 1. The test also asserts the DDS is
absent, not only the return code.
Review gaps closed: embedded-texture DDS writes are no longer swallowed
by catch {} (decode failures count like the textures branch, write
failures count into writeFail and fail the run); dictionary-directory
and models _tex directory creation failures return WriteFail=1; a
retryable IOException while reading a resource or decoding (CreateDds)
also counts as a write failure, so a locked source no longer publishes
a manifest with missing files; marker withdrawal goes through
WithdrawMarker, which clears a read-only attribute first and turns any
remaining delete failure into a one-line error with exit 1 instead of a
traceback.
Verified offline: Program.cs compiles 0 warnings/0 errors against the
real Core sources with a BCnEncoder stub (BCnEncoder.Net is not cached
offline, so the DLL build runs in CI); a Python mirror of Recover/
RecoverAtOffsets/TryInflate/LooksLikeDictionary/Parse/ComputeLayout
recovers the committed fixture 1/1 (system 208 B, graphics 4096 B,
pages 1/1, texture 'probe' 4x4, allocation 4096) through both scan
paths, and rejects the pre-fix bytes with the reported mismatch
(layout 20480 != allocation 4096). python -I skip path: 2 skipped, OK.
Models and textures no longer open the archive document. The entry list comes from this run's
scan or from the index cache, and every resource is read from its own compression blocks
(tools/rpf9dump/Segments.cs), which mirrors the checks ArchiveReader.ReadResourceData makes. That
makes a raw slice of an archive exportable: a window cut out of levels.rpf has no 9FPR header, so
there was nothing to open before, and the mode simply failed on it.
--start/--length scan one window instead of the whole file. A sub-range is never written to the
index cache, which is keyed by the file rather than by the window; the manifest records
Scan.Start and Scan.Length for it.
The manifest gains MeshTris, MeshModels and MeshGeoms: the per-geometry triangles and the
(model, geometry) pair the decoder puts in each mesh name, in the order of the OBJ's `o` groups.
A dehydrated BLAS leaf stores that pair as its geometry index (docs/bvh.md 4a), so a matching tool
can filter candidates on the manifest instead of reading every OBJ.
Measured: one 1 GiB slice of levels.rpf scans, recovers, decodes and exports 1,228 models in about
2 s. The project builds clean with no warnings; tests/Rpf9DumpDiagnostics covers the segment reader
(compressed and raw blocks, a block past the end, a short block, an entry without blocks) and the
mesh key parsing, and still passes.
Each mode ran on one thread, so the assets stage left the rest of the CPU idle (levels.rpf models took 46 min
on a 16-thread machine). Core's readers open their own read handle per call (ReadResourceData, RecoverAtOffsets,
TtpfReader.CreateDds, AwcInfo.Inspect, AwcRecovery.WriteXmaWave), so the work splits across threads:
- scan validation: 32-offset chunks in parallel, indexes reassigned in offset order as before
- models/textures: entries decoded and written in parallel in batches of 1,024; rows, counters and failure
messages are taken in list order, so the manifest and the log match a one-thread run
- ttpf, xma, audio manifest rows: per texture / bank in parallel, rows kept in source order
Outputs are byte-identical to the one-thread build (diff -r on shared_minigame000 models and textures, and a
texture pool). models shared_minigame000: 34 s -> 7 s; ttdb_terrain_image_based: 8 s -> 1 s.
make_game writes audio/xma.done after rpf9dump xma exits 0. The xma branch
counted failed writes but fell through to the final return, which only
fails for ttpf, so a failed stream was never written on a later run.
Candidates that RecoverAtOffsets rejects never reach the per-item loop,
so ModelDecodeFailures stays empty even when candidates are missing.
Write Scan { Candidates, Recovered, NotRecovered, Entries } into the
manifest and print the shortfall. Recovered counts resources (distinct
candidate offsets): since the 917e9b9 pin a drawable dictionary yields
one entry per child, so Entries can exceed Candidates.
On a cached run the candidate count comes from the index cache's coverage
text, which rpf9dump now writes with invariant digits; older caches with
grouped digits still parse. The count is null when another tool wrote the
cache.
Suggested by Kam471 in the review of #30; that follow-up commit was pushed
after #30 had been merged, so it is resubmitted here on current main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 48557ea pin predates the merged model-layout recovery, the packs.rpf drawable-dictionary roots, the TTPF compact/array/cubemap/volume layouts and the external skeleton reader. Re-pin to upstream 917e9b9.
rpf9dump now passes e.ResourceDrawableOffset to RageModelDecoder.Decode; without it every dictionary child would decode as the first child. The manifest also records Drawable so a row can be traced to its dictionary offset.
Measured on the 1.0.2.1 package with .NET 8.0.428: a fresh packs.rpf scan recovers 24,034 models (23,720 dictionary children plus 314 fragments) from 23,838 candidates, against 314 at the old pin. docs/models.md keeps the 48557ea/c3708fb table as the control and adds the new packs.rpf result; docs/design.md notes the other archives were not re-counted at the new pin. Build: 0 warnings, 0 errors.
make_game.py takes ttpf manifest.json and audio_manifest.json as proof that
a step finished, and every exporter skips a file that already exists. Both
were written in place, so a stopped run or a full disk could leave:
- a truncated manifest, after which make_game.py skips that texture pool
or the audio banks on every later run, or
- a truncated .dds / .obj / .xma.wav under its final name, kept forever
because the next run sees it exists.
All outputs (ttpf DDS + manifest, audio_manifest.json, XMA2 .xma.wav,
model .obj, embedded and dictionary .dds) now go through Util.WriteAtomic:
written to <path>.partial, then File.Move'd over the final name; the
temporary is removed on failure, and a stale one from a stopped run is
deleted first (WriteXmaWave opens its target with FileMode.CreateNew).
The models manifest already worked this way.
Util moves to its own file so tests/Rpf9DumpDiagnostics can link it; the
diagnostics program gains four checks for WriteAtomic.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rows held lazy projections that kept every decoded model alive; 149,811 models on levels.rpf exhausted
memory at the final serialization. Rows are now written as they are produced, to a .partial file renamed
when complete. Design notes record that most shaders are wave64 (32-wide subgroups on NVIDIA) and that
mesh shaders are NGG wave64 with the merged-shader SGPR layout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shader pipeline (carve, FSSM unpack, gfx1013 disassembly, RDNA2 to SPIR-V),
asset export via rpf9-explorer's Core (submodule), PE loader and shim
skeleton, and make_game.py, which builds from the user's own copy of the game.
No game data, keys or executables are included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>