Reconstruction layout: generated-src/ (generated) and src/ (curated), CMake, the first takeover: RNG

The decompiled C++ tree moves to generated-src/ (classes.h, C++20); src/ is for code written by hand. A curated function
defines the generated declaration and starts its comment with its address, and source_tree.py stops emitting that body.
src/rng.cpp takes over RNG (SetSeed, the constructor, Next, RandomInt, RandomFloat, Shuffle) with the shift table read
from the exe as a constexpr array; src/log.h names KAGE_LogMessage's levels (1 INFO, 2 NET, 4 WARN, 8 ERROR, 16 ASSERT,
from its prefix jump table). CMakeLists.txt builds src/*.cpp against generated-src/classes.h (clean with -Wall -Wextra).
structs.hpp and headers.py are retired: scripts/merge_fields.py writes the merged field list, classes.h checks the layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-11-19 21:10:23 -05:00
1 parent 2ff2d5d87f
commit 3ce74c6e2d
331 files changed
+485 -7835

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# Merges the confirmed struct fields into the one list ApplyTypes.java and source_tree.py read.
# Inputs in order (later rows win at the same class and offset): zhl_fields.tsv, lua_fields.tsv, db/fields.tsv, class sizes.
# Rows: "Class<TAB>0x2d4<TAB>type _name<TAB>why", "Class<TAB>base<TAB>Base", "Class<TAB>size<TAB>0x2f00".
# A row whose type is "- " ("Entity<TAB>0x2d4<TAB>- _mass<TAB>why") deletes a wrong field from the earlier files.
# Usage: merge_fields.py out.tsv in.tsv...
import sys
out, *sources = sys.argv[1:]
bases = {}
sizes = {}
rows = {}
for path in sources:
for line in open(path):
if line.startswith('#') or not line.strip(): continue
cols = line.rstrip('\n').split('\t')
if cols[1] == 'base': bases[cols[0]] = cols[2]; continue
if cols[1] == 'size': sizes[cols[0]] = int(cols[2], 0); continue
key = (cols[0], int(cols[1], 16))
if cols[2].startswith('- '): rows.pop(key, None); continue
rows[key] = line if line.endswith('\n') else line + '\n'
with open(out, 'w') as o:
o.writelines([f'{c}\tbase\t{b}\n' for c, b in bases.items()] + [f'{c}\tsize\t{n:#x}\n' for c, n in sizes.items()] + list(rows.values()))
print(f'merge_fields: {len(rows)} fields, {len(bases)} bases, {len(sizes)} sizes')