Commit Graph

31 Commits

Author SHA1 Message Date
f10890b34d text_tables: ask report_paths for the report-path guard 2026-12-01 19:44:43 -05:00
d819ad07c5 Merge pull request #2235 from syfyra/fix/text-tables-walk-order
text_tables: read a directory source's subfolders in name order (TEXT-TABLES-WALK-ORDER)
2026-12-01 16:17:54 +01:00
795e0904c2 Merge pull request #1300 from kaoru-maki/psin-native-speaker
Export native speaker hashes from PSIN dialogue turns
2026-11-29 01:46:10 +01:00
13395c4370 text_tables: restore write mode before removing staged and backup files (TEXT-TABLES-RO-CLEANUP) 2026-11-28 20:23:05 +03:00
e231d2cb5f text_tables: refuse a report that would overwrite a file read from a source directory
The output guard compared --dialogue/--tables/--strings only with the
named sources and a carve's index.json. blobs() also reads every file
below a plain source directory and every carved <offset>.bin/.bk2 beside
index.json, so `text_tables.py src --tables src/notes.txt` read the file
and then replaced it with the CSV (exit 0). Refuse such a report before
anything is written; carved streams go through gamedata_index's
carved_stream(). A new report inside a source directory is still allowed:
it is written after the scan, so it was never an input.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 16:57:56 +01:00
25d45dcbe0 text_tables: read a directory source's subfolders in name order (TEXT-TABLES-WALK-ORDER)
blobs() sorted the files of each folder but walked the subfolders in the
order os.walk lists them, which is the file system's: by name on NTFS, by
hash on ext4. The dialogue table keeps the last text read for a label
(docs/text.md, "Labels with two texts"), so the same folder of resources
gave a different text_en, and a different --tables/--strings row order,
on Windows and Linux. Sort the subfolders in place so the walk descends
in name order everywhere.

Tested: new test_subfolders_are_read_in_name_order with a walk that lists
subfolders backwards; it fails before the fix (b before a, the first
table's text wins) and passes after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 10:43:51 +01:00
74838ba5f0 Export native speaker hashes from PSIN dialogue turns 2026-11-25 00:31:56 +03:00
1d2e0848fc Recognize an additional script in text-table language guessing 2026-11-24 18:11:30 +01:00
85dbff479c text_tables: keep indexed video rows as stream boundaries 2026-11-23 22:33:33 +01:00
c69d3c5cc9 Merge pull request #4167 from Marco Luzzaro
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:11:57 -05:00
e6a4680f5c Protect text table carve manifests from report overwrites 2026-11-23 00:45:12 +01:00
22a092e6a5 Merge pull request #3575 from Leonardo Guimaraes 2026-11-22 17:02:47 -05:00
49900018e3 text_tables: read a string table's blob chunks instead of the first chunk only
A string table with more than 1 MiB of text splits its blob into several
tag-0x10 descriptor entries. From the blob on, the descriptor is a run of
16-byte entries (u32 tag, u32 bytes, pointer). An index entry names its chunk
in the low bits of its second word (0b1cc, chunk = flags & 3). string_tables()
read every offset from the first chunk, so 293,292 strings in 23 data.rpf
tables came out with the wrong text and no error. story000.rpf and
shared_minigame000.rpf tables read the same as before.

docs/text.md documents the entries and the chunk bits, updates the
story000.rpf table count to what main reads today (15,951), and lists the
hash entries with byte +8 = 5/7/8 as an open question.
2026-11-22 17:56:20 -03:00
3ce110a6af Merge pull request #3316 from shdann 2026-11-22 15:16:54 -05:00
9736662609 Merge pull request #3267 from kapitche 2026-11-22 15:16:21 -05:00
ff0770d499 text_tables: reject incomplete directory scans 2026-11-22 23:04:54 +03:00
5746ad25d4 text_tables: a labels JSON or index.json of the wrong shape is a clean error, not a traceback 2026-11-22 14:57:13 -05:00
697c01b0e9 Merge pull request #2324 from Leonardo Guimaraes 2026-11-22 13:13:53 -05:00
be9350c3b9 Merge remote-tracking branch 'origin/main' into text-tables-archive-lang
# Conflicts:
#	tools/text_tables.py
2026-11-22 15:05:13 -03:00
f35f12fd7e Merge pull request #2210 from Vonsek 2026-11-22 11:42:51 -05:00
34c47e1793 Merge pull request #2129 from Rafael 2026-11-22 11:42:04 -05:00
63424bee7e text_tables: a string table's language from the nested RPF9 archive it sits in
docs/text.md had "Language per table" open: the tables carry no
language field and each one's language was guessed from its text. In
data.rpf and story000.rpf every string table sits in one of 13 nested
RPF9 archives (9FPR at 4 KiB-aligned offsets), and each archive is one
language.

A table in a nested archive now takes the guess most of that archive's
tables share (xx left out), when it covers more than half of them;
otherwise, and outside nested archives, a table keeps its own guess.
Nested archives come from an .rpf source or from the archive an
rpf9_carve.py directory's index.json names. --tables gains `guess` (the
per-table guess) and `archive` (the nested archive's offset). Scan
keeps the guesses and resolves languages when tables or texts are read.

Measured (counts only): data.rpf 14,440 tables in 13 archives, 2,075
change; story000.rpf 15,831 tables in 13 of 436 nested archives, 849
change. xx, plain es and plain zh drop to 0 in both. Table in
docs/text.md.

tests: nested-archive detection, archive majority over strays and xx,
no majority keeps each guess, a carve directory end to end through its
index.json, and a source with no archive.
2026-11-22 13:40:09 -03:00
7c2e9cfa21 fix(tools): export explicitly empty localized strings
A valid string-table entry may point directly at a NUL terminator. Keep that entry in complete string exports and table totals.
2026-11-22 17:18:20 +01:00
395dee8759 text_tables: a resource's first stream may be any whole number of 64 KiB blocks
_chains joined the next stream only when the previous one was exactly BLOCK (65,536 bytes). But a
resource's first stream can be 128 or 192 KiB (docs/page_directory.md shows one ending at 0x20000 that
the next stream continues), and its string-table descriptors then end in the following stream. On my
1.0.2.1 copy, 41 data.rpf resources start with a 131,072- or 196,608-byte stream: 20 of their tables
were refused as out of range and 21 lost entries through the at + 8 > len(buf) skip. A stream now
continues a previous one whose size is a nonzero multiple of BLOCK.

Real data (counts only): data.rpf 14,440 -> 14,482 tables and 4,118,181 -> 4,197,518 strings, the same
from the archive and from an rpf9_carve folder; shared_minigame000.rpf unchanged (78 tables, 22,371
strings). docs/text.md updated.

Tests: test_resource_across_a_128k_first_stream and
test_whole_block_streams_continue_and_others_end_the_chain (main: the 128/192 KiB cases fail).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:04:06 -03:00
0130a77a3e text_tables.py: validate CSV output paths upfront and handle read errors 2026-11-22 15:57:57 +01:00
8cc9998a96 Merge pull request #1726 from anusara-bemal 2026-11-22 09:14:54 -05:00
18a77d4679 text_tables: move old reports aside before publishing any
A failure in the replacement loop could leave a mixture of old and new CSVs (e.g. Windows WinError 5/32 when a reader holds an output open). Move every existing report to a private backup first, so a failure leaves them all untouched, then publish all staged files and drop the backups.
2026-11-22 19:17:59 +05:30
1fc0786eea text_tables: stage all reports before publishing any
Reject output paths that resolve to the same file before writing anything. Write every CSV to a private file beside its destination, then replace them all only after the writes succeed, so a failed run keeps the previous reports. Preserve published file modes via file_mode.published_mode.
2026-11-22 19:08:03 +05:30
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
21a8e07168 Fix what the merge round broke: w64_graphics fixtures, the R24G8 FORMAT_SUPPORT check, four tools' stdout
- run_gpu_tests.py: #1541's wave64 pixel fixtures (runtime/test/shaders/w64_graphics.py FIXTURES, tiers A-C) are
  checked by that runner; run_gpu_tests picked up their .asm and failed 14 of them with "no checker defined".
  It now leaves w64_graphics.FIXTURES to that runner.
- d3d12_d24_support_test (#1493): expected DEPTH_STENCIL in FORMAT_SUPPORT for R24G8_TYPELESS. Measured here, the
  host D3D12 (RTX 4060 Ti and WARP) reports 0x001010b0 for R24G8_TYPELESS and 0x003110b0 (DEPTH_STENCIL) only for
  D24_UNORM_S8_UINT, which #1511's per-format rules follow; the check now expects the bit for the typed format only.
- fma_mix_probe, text_tables, wave64_halves, xdxr_bvh: new tools without #1428's stdout errors='replace' guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 07:29:31 -05:00
8ef54230a3 tools: decode string tables and join dialogue to its subtitles
Text resources are 0DRP logical resources holding a joaat label hash table,
an index array and a UTF-8 string blob, located by a descriptor of
0x5xxxxxxx resource pointers. text_tables.py joins each 0DRP stream with
its 64 KiB continuations (carve directory or archive via gamedata_index, or
whole-resource files), decodes the tables, guesses each table's language
(script, distinctive letters, common words; es-ES/es-419 and
zh-Hant/zh-Hans by markers; xx when undecided), and joins conversation
key/label pairs (<key>_01.. waves) to their text in every language.

On 1.0.2.1: 30,349 tables / 7.17M strings; 118,351 dialogue keys and
138,104 lines, 88-93% with text per language. docs/text.md records the
format, the per-language conflict counts and the open questions.
Standard library only; tests are synthetic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:42:09 +01:00