Commit Graph

21 Commits

Author SHA1 Message Date
66e2262b2b Merge pull request #2388 from syfyra/fix/restofworld-index-text-sample
restofworld_index: judge text on the same 512 bytes in an archive (RESTOFWORLD-INDEX-TEXT-SAMPLE)
2026-12-01 16:22:12 +01:00
16dde22775 restofworld_index: judge text on the same 512 bytes in an archive (RESTOFWORLD-INDEX-TEXT-SAMPLE)
_printable decides "text" from the first 512 bytes of a stream (more
than 90% printable). A carved file is classified from its whole data,
but scan_rpf passed only a 256-byte head for streams it does not keep
whole, so one stream could get two signatures: a stream whose first
306 bytes are printable read as "text" from the archive and as
"raw:..." from its carved file. af55ea1b4 removed the same split for
PSIN streams.

Keep a 512-byte head in the archive scan, the sample _printable takes.
The other head checks read at most 16 bytes, so nothing else changes.

Tested: new test_text_is_judged_on_the_same_512_bytes_as_a_carved_file
(fails before: 'text' from the archive, 'raw:6e616d65' from the data).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:55:47 +01:00
1ca8b83b4a restofworld_index: validate scan bounds, fix carve index .bk2/BOM, harden I/O 2026-11-25 04:46:44 +01:00
8731cfed53 restofworld_index: stage JSON and CSV reports so failure keeps old file 2026-11-24 00:12:24 +03:00
0af07f09b1 Merge pull request #4217 from Alpaca-exe
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:12:27 -05:00
5948c690b8 tests: skip the hard-link cases where hard links are unavailable
Guard the remaining unguarded os.link() calls in test_awc_names.py, test_gamedata_graph.py, test_navmesh_decode.py, test_restofworld_index.py, test_rtti_scan.py, test_save_keys.py, test_swizzle_search.py, and test_tex_headers_report_paths.py with try/except (OSError, NotImplementedError) so only the hard-link subtest/check is skipped when hard links are unavailable and the rest of each test still runs.
2026-11-23 01:01:33 +01:00
a4c23feb47 Report restofworld_index write failures without a traceback 2026-11-22 23:36:25 +01:00
9fc3b2931f Merge pull request #2958 from Vonsek 2026-11-22 15:13:34 -05:00
f847748cc7 Merge origin/main (7 pull requests merged on GitHub)
# Conflicts:
#	docs/design.md
#	tools/psin_data.py
2026-11-22 14:46:26 -05:00
24c30012cf fix(assets): count small textures in resource dictionaries
The independent rest-of-world scanner dropped textures below four pixels and misclassified dictionaries when their declared count included those descriptors.
2026-11-22 19:55:33 +01:00
8686aaf028 Merge pull request #2459 from bbareth 2026-11-22 13:15:28 -05:00
a5a490efab restofworld_index: identify embedded 0x980 textures and companion TTPF pools (ASSET-148) 2026-11-22 19:12:22 +01:00
8b02dc9ae9 restofworld_index: protect directory-mode carve inputs 2026-11-22 18:06:54 +01:00
74de9c73dc restofworld_index: folder mode takes stored sizes and span from the carve's index.json
scan_dir passed each carved file's inflated length as its stored size, so in folder mode
compressed_bytes equalled inflated_bytes and readable_fraction was always 1.0, while the same numbers
in archive mode are the compressed sizes and stored / span. With rpf9_carve.py's index.json in the
folder, each file's stored size and the carve's span, zero padding and unread bytes now come from it;
without one, the length on disk is still used.

Real data (counts only), script.rpf: archive mode and its carve folder now give the same summary,
1,057 files, compressed 2,581,192, inflated 6,180,256, zero padding 1,335,290, unread 441,870,
readable 0.59224; main's folder mode gave compressed 6,180,256 and readable 1.0.

Tests: FolderModeStoredBytesTest (main: the index case reports 1,000 stored bytes instead of 300).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:20:50 -03:00
0f5aafea60 Merge commit 'd3841c0c0ee41ec014699a985846c6dc76026440' into codex/restofworld-preserve-source 2026-11-22 04:53:44 -03:00
9e50ef29af restofworld_index: prevent overwriting the source archive 2026-11-22 04:40:19 -03:00
af55ea1b44 restofworld_index: an archive scan classifies a PSIN from its whole stream, not 256 bytes
scan_rpf passed classify only the first 256 inflated bytes, so a PSIN whose
section chain runs past them lost its tags and complete flag, while scan_dir
read the same resource whole. The PSIN stream is kept (already capped by
max_inflate) and classified like a carved file.
2026-11-22 12:08:47 +05:30
16b4d32e9c restofworld_index.py: validate directory options, enforce --max-inflate in scan_dir, and close mmap with context manager
Follow-up to #498 and #530 (claimed in #374):
- Reject --start and --limit when source is a directory (exit code 2 via ap.error).
- Pass --max-inflate to scan_dir() and skip .bin files larger than max_inflate, incrementing skipped_candidates.
- Wrap mmap.mmap() in scan_rpf() with a context manager so out-of-range start errors always close the mapping.
- Add unit tests covering all three fixes.
2026-11-22 00:44:10 +00:00
1e7b22f445 restofworld_index.py: report a missing source, and check the output path before scanning
Same two problems as rbf0_index.py: a missing source ended in a traceback from
os.path.getsize, and an unwritable --out was found only after the full scan.
The source error is now "<source>: No such file or directory" (exit 1) and the
output path is checked first (exit 2).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 02:47:04 +03:00
fe8cd6bc72 Tools: reject out-of-range --start/--limit in RPF index tools
Adds the #283 argparse validators to anim_index, rbf0_index, restofworld_index and rpf9_carve: --start >= 0, --limit >= 1 (decimal or 0x hex), and --max-inflate >= 1 in restofworld_index. Bad ranges now exit 2 before any scan or output instead of silently scanning everything, less, or nothing. Synthetic CLI tests in all four test files; docs notes for each tool.

New item claimed in #156. AI-assisted (OpenCode).
2026-11-21 16:53:41 -06:00
d3f69013c1 Docs: measure rest-of-world and script archive composition
Add the full core_restofworld scan (1.21 GiB, 96% Bink 2 plus model/page data), re-measure story000_restofworld and story000_script, and cover the three small archives. Cross-check PSIN against script.rpf/story000 and core pages/models against packs.rpf/levels.rpf. Add a stdlib-only stream index tool and synthetic-header tests. No game data.
2026-11-21 20:30:47 +00:00