Snapshot unreviewed LocalMP battle work as rework baseline

Records the uncommitted battle-session work exactly as it was left
(local service matchmaking, settlement, chat, native LocalMP hooks,
battle gui/exe patches) so the following review and rework commits
show every correction as a diff against this state.

This commit is not reviewed and is known to be incomplete: in-game
testing reported wrong settlement rewards, single-country teams,
missing random/fixed supplement slots, misattributed hit messages and
other regressions. Do not merge this branch before the rework lands.
This commit is contained in:
N0VAN0M4LY committed 2026-11-28 03:15:47 +08:00
1 parent aa272fc82b
commit 6a189513b0
97 files changed
+7676 -396

No files matched your search

+3 -2
View File
@@ -2,6 +2,7 @@
Each group of commands lives in its own module and registers itself here:
- exe_commands: check-patches, patch-exe
- gui_commands: check-gui
Run `wtotools <command> --help` for the arguments of one command.
"""
@@ -9,14 +10,14 @@ from __future__ import annotations
import argparse
from . import exe_commands
from . import exe_commands, gui_commands
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(prog="wtotools", description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
commands = parser.add_subparsers(dest="command", required=True)
for group in (exe_commands,):
for group in (exe_commands, gui_commands):
group.register(commands)
args = parser.parse_args(argv)
return args.handler(args)
+16
View File
@@ -1,6 +1,7 @@
"""Commands that work on the game executable.
wtotools check-patches --exe <aces.exe> [--patches exe-patches]
wtotools check-offsets --exe <aces.exe> [--header native/wto-net/src/local_mp_offsets.h]
wtotools patch-exe --exe <aces.exe> --out <aces.exe> [--patches exe-patches] [--force]
The input executable is only ever read. `patch-exe` refuses to write over its input and
@@ -15,9 +16,11 @@ from pathlib import Path
from ..exepatch import apply_writes, changed_ranges, load_patches, plan_patches
from ..exepatch.assemble import disagreement
from ..offset_check import parse_offset_header, verify_offsets
from ..pe import PeImage
DEFAULT_PATCHES = Path("exe-patches")
DEFAULT_OFFSET_HEADER = Path("native/wto-net/src/local_mp_offsets.h")
def register(commands: argparse._SubParsersAction) -> None:
@@ -25,6 +28,11 @@ def register(commands: argparse._SubParsersAction) -> None:
_add_common(check)
check.set_defaults(handler=_check_patches)
offsets = commands.add_parser("check-offsets", help="verify native LocalMP signatures and anchor strings")
offsets.add_argument("--exe", type=Path, required=True, help="the game executable to read")
offsets.add_argument("--header", type=Path, default=DEFAULT_OFFSET_HEADER, help="C header with LMP_SIG_* and @anchor tags")
offsets.set_defaults(handler=_check_offsets)
patch = commands.add_parser("patch-exe", help="apply every patch to a copy of the executable")
_add_common(patch)
patch.add_argument("--out", type=Path, required=True, help="where to write the patched copy")
@@ -55,6 +63,14 @@ def _check_patches(args: argparse.Namespace) -> int:
return 0 if plan.complete and not mismatched else 1
def _check_offsets(args: argparse.Namespace) -> int:
spec = parse_offset_header(args.header)
ok, lines = verify_offsets(PeImage(args.exe.read_bytes()), spec)
for line in lines:
print(line)
return 0 if ok else 1
def _patch_exe(args: argparse.Namespace) -> int:
if args.out.resolve() == args.exe.resolve():
print("refusing to write over the input executable; choose a different --out", file=sys.stderr)
+39
View File
@@ -0,0 +1,39 @@
"""Command to verify `gui-patches/` against `gui.vromfs.bin` with Quirrel bytecode compilation.
wtotools check-gui --gui <gui.vromfs.bin> [--patches gui-patches] [--sq build/quirrel-check/sq.exe]
"""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
from ..gui_check import verify_gui_patches
DEFAULT_GUI_PATCHES = Path("gui-patches")
DEFAULT_SQ_EXE = Path("build/quirrel-check/sq.exe")
def register(commands: argparse._SubParsersAction) -> None:
check = commands.add_parser(
"check-gui",
help="apply gui-patches in memory and bytecode-compile every modified .nut script",
)
check.add_argument("--gui", type=Path, required=True, help="stock gui.vromfs.bin to read")
check.add_argument("--patches", type=Path, default=DEFAULT_GUI_PATCHES, help="gui-patches directory")
check.add_argument("--sq", type=Path, default=DEFAULT_SQ_EXE, help="Quirrel compiler sq.exe path")
check.set_defaults(handler=_check_gui)
def _check_gui(args: argparse.Namespace) -> int:
if not args.sq.exists():
print(f"Quirrel compiler not found: {args.sq}", file=sys.stderr)
return 2
report = verify_gui_patches(args.gui, args.patches, args.sq)
print(f"{report.patches_applied} GUI patch(es) applied across {report.files_checked} .nut file(s)")
if report.errors:
for error in report.errors:
print(f" {error}", file=sys.stderr)
return 1
print(" every patched .nut file compiled to Quirrel bytecode with zero lexical/constant errors")
return 0