Commit Graph

28 Commits

Author SHA1 Message Date
1502fbe8aa navmesh_decode: ask report_paths for the report-path guard 2026-12-01 19:44:42 -05:00
04f3f50941 Measure the 4 KiB boundary cases in navmesh directories
ASSET-445

AI-assisted: 6.2 Astra High
2026-11-25 11:15:54 +00:00
7bb0cdad05 Merge pull request #4096 from Marco Luzzaro
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:11:14 -05:00
40aaf73645 Merge pull request #3991 from bbareth
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:10:13 -05:00
886bc79a03 Report navmesh decoder output I/O failures 2026-11-23 00:25:41 +01:00
053b349c1e Protect navmesh carve manifests from JSON and CSV reports 2026-11-22 23:48:06 +01:00
5a57053e09 Merge pull request #3622 from Ewann
# Conflicts:
#	docs/navmesh.md
2026-11-22 17:03:03 -05:00
16ec4ee103 Merge pull request #3609 from eyyun 2026-11-22 17:02:59 -05:00
a3f0a2bb16 Merge pull request #2930 from bobcatchris 2026-11-22 17:00:09 -05:00
002cd455a3 navmesh_decode: keys_octree also requires one slot per key
Two occupied slots with the same key and distinct payload indices passed
values_bijective, then folded into one dict entry in _grid_slots, so the
octree check passed and the depth and leaf counts lost an entry
(reported by Oblyterium on #3622). Require len(keys) == entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:45:35 +01:00
63c566231b navmesh_decode: merge volume counters only after full tile validation 2026-11-23 00:15:31 +03:00
9be689c67f navmesh_decode: Band-3 grid keys are linear octree keys, inner nodes hold 0xff00 (ASSET-287)
--deep now checks that every grid key is a sentinel-bit octree key (root 1,
child = parent << 3 | octant, every parent present) and that every inner
node's u32 word is 0x0000ff00, and reports key depths, the inner-node count
and leaf words by low byte. docs/navmesh.md records the measured layout;
the x/y order of octant bits 0/1 and the leaf fields' meaning stay open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:08:13 +01:00
f0a6adb034 tools: decode navmesh +0xB8 paired obstacle footprint records (ASSET-281) 2026-11-23 00:05:42 +03:00
3e105eba3a navmesh_decode, navmesh_index: a --out that is a folder is a usage error
Both tools validate --out and --csv against the input (they must not overwrite
it) but never against the filesystem object itself, so pointing --out at an
existing directory opened it for writing and ended the run in a
PermissionError traceback after the scan was already done:

    Traceback (most recent call last):
      ...
    PermissionError: [Errno 13] Permission denied: '../reports'

Refuse it up front with the flag name, like the neighbouring checks do, so it
costs one line and the scan never starts.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 14:09:43 -06:00
f206d479a6 tools: classify the gap between streams without copying it
Nine archive scanners sliced every gap out of the mmap to test whether it
was all zero (`gap = m[last:s]; gap.count(0) == len(gap)`). The slice is a
copy, so a gap of N bytes allocated N bytes at once; about half of
story000.rpf (~20 GB) is non-zlib, which ends in MemoryError on a 16 GB
machine.

tools/zero_span.py compares the gap with zeros 4 MiB at a time and stops at
the first non-zero window, with the same counts (all of a gap is padding
when every byte is zero, otherwise all of it is unread). rpf9_carve,
rpf9_names, bvh_index, navmesh_index, navmesh_decode, rbf0_index,
anim_index, restofworld_index and story_index use it.

tests/test_zero_span.py checks the counts against the old expression and
runs each scanner on a 48 MiB gap under tracemalloc: 50-51 MiB heap peak
on main, under 24 MiB with this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:07:15 -03:00
7e16d3ad03 fix(tools): protect carved navmesh inputs from report writes
The archive guard cannot see individual inputs in a carved directory. Use the same file selection for scanning and report validation so an output cannot replace a carved stream under either name.
2026-11-22 16:43:52 +01:00
ec9b6cf22b tools: text reports are written with LF line ends on every platform (BUILD-468)
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.

AI-assisted (Claude), on behalf of dev-ewann.
2026-11-22 14:20:30 +00:00
c334c78477 tools: CSV reports end their lines with LF on Windows too
csv.writer and csv.DictWriter default to lineterminator="\r\n", and every
one of these tools opens its report with newline="", which turns that into
CRLF on Windows and LF elsewhere: the same archive gave different report
bytes depending on the machine that exported it. awc_manifest and awc_shorts
already pin "\n" and bink_index documents why its stdout writer needs it, so
this brings the remaining 16 writers onto the same convention. A structural
test keeps new writers on it, and three tools are run end to end to check the
bytes.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 07:13:06 -06:00
12d4bcbea7 tools: report paths that differ only in case are one file on macOS
bvh_index, anim_index, gamedata_xml, gamedata_index and navmesh_decode compare
two report paths with os.path.normcase, which folds case only on Windows. On
macOS's case-insensitive APFS volume `--out o/B.json --csv o/b.json` passed and
the CSV replaced the JSON. The comparison now folds case and Unicode
normalization when the volume that will hold the path is case-insensitive
(pathconf _PC_CASE_SENSITIVE); case-sensitive volumes keep two reports.
Same fix as world_index in #1576.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:30:32 +03:00
0ac1bfceb2 Merge pull request #1456 from Rafael 2026-11-22 06:38:08 -05:00
ab6b7ac8ed navmesh_decode: --limit carver counts match navmesh_index
A stream that starts inside a --limit window but ends past it was counted in carver_streams with
all its stored bytes, so stored + zero_padding + unread could exceed the span (up to 122% on a
2 MiB window of navmeshes.rpf). navmesh_index.py (#766) does not count such a stream; its bytes
inside the window are left to the tail. navmesh_decode now does the same and reports those
streams under past_window / past_window_stored instead of dropping them. Decoding is unchanged: a
resource that starts inside the window is still read to its end.

Real data (counts only), four 2 MiB windows of navmeshes.rpf: byte classes now add up to exactly
the span (main: 121.97%, 119.01%, 100.23%, 103.64%), and streams, stored, inflated, zero_padding
and unread equal navmesh_index.py's on every window.

Tests: the window-limit test now expects 1 carved stream + 1 past_window (main: 2); a new test
ends the window inside a stream and checks nothing is carved and the classes sum to the span.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 08:29:13 -03:00
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").

tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:27:00 +00:00
a3f0d910f1 navmesh_decode: refuse a report path that is the input
`--out <the archive>` (and `--csv <the archive>`) opened the input for
writing after the scan and replaced it with the JSON summary, exit 0, no
warning. Refuse the combination up front, as the --out/--csv collision
already is, so the archive is never touched.
2026-11-22 03:37:40 -06:00
fe953bf831 navmesh_decode: create the --out and --csv folders instead of losing the run
The scan finished, then a report path in a folder that did not exist ended
the run in a FileNotFoundError traceback and threw away the summary. Create
the parent folder at write time, as navmesh_index.py already does.
2026-11-22 03:22:14 -06:00
9f3ec1ab46 navmesh_decode: reject colliding JSON and CSV reports 2026-11-22 05:04:30 -03:00
36e63f11dc navmesh_decode.py: a header-only PSIN doesn't take the next stream (review)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:41:11 +01:00
6c8337c4f9 navmesh_decode.py: a PSIN header with no section is incomplete
_psin_state() walked the section list and reported a resource complete when
the walk ended exactly at the end of the data. A PSIN header with no section
at all ends there too, so it was counted complete with 0 sections. At least
one section is now required.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:29:25 +01:00
2a41e7a44c Navmesh: decode 0DRP cover-point pages, 0x00010015 tiles and Band-3 grids (ASSET-22) 2026-11-21 22:03:23 -03:00