Files
Triforce-Source/tests/test_patch_hooks_defined.py
ruckus7382sfgsgdf 4fa4f9188b Triforce v0.8.0
Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
2026-11-25 10:21:32 -06:00

35 lines
1.4 KiB
Python

"""Every host function the game's patches call (nx2/oot_patches.py's extern declarations, put into the lifted game) is defined in
host/ or gpu/vk/. A patch that calls a function no source defines fails every build at the link (undefined symbol), which no
source check sees.
python -I -B tests/test_patch_hooks_defined.py
"""
import re
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def main():
patches = (ROOT / "nx2" / "oot_patches.py").read_text(encoding="utf-8")
names = sorted(set(re.findall(r"extern\s+[\w\s\*]+?\b(hos_\w+)\s*\(", patches)))
if not names:
raise SystemExit("FAIL: no extern hos_ declarations found in nx2/oot_patches.py")
sources = []
for d in ("host", "gpu/vk"):
for p in (ROOT / d).rglob("*"):
if p.suffix in (".c", ".cpp") and p.is_file():
sources.append(p.read_text(encoding="utf-8", errors="replace"))
text = "\n".join(sources)
missing = []
for n in names:
# (a definition: the name, its parameter list, then a body's brace, at the start of a line)
if not re.search(r"^[\w \*]*\b" + n + r"\s*\([^;{]*\)\s*\{", text, re.M):
missing.append(n)
if missing:
raise SystemExit("FAIL: called by the game's patches but defined nowhere in host/ or gpu/vk/: " + ", ".join(missing))
print("PASS: the %d host functions the game's patches call are all defined" % len(names))
if __name__ == "__main__":
main()