mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 22:28:38 +00:00
After the merge the tree held this branch's older states of files main maintains. Run against main's code, tests/test_acphal_abi.py and 11 of the 15 translator tests that differed failed, and the C++ runtime would have been built from two generations of its sources. So that the merge cannot break what main builds and tests: - runtime/ is main's, file for file (68 files only this branch had are not carried over); - every file under tools/, tests/ and docs/ that both sides have is main's (80 files); - ten translator tests only this branch has, which test rules main's translator does not have, and their fixtures are left out. What main gains: d3d12/ (the Rust D3D12 runtime), its launchers and helpers (Launcher.bat, scripts/play*.ps1, play-linux.sh, port_ctl.py, smooth-motion.ps1, fetch_vkd3d_proton.py, sync_victory.py), mods/example_lua, eleven notes under docs/, seven tools and the tests that pass with main's code, the README's sections and credits, and the "Runtime traps" section of AGENTS.md. Everything left out here is on the branch port/d3d12-nvidia. Checked: compileall; make_game.py --help; check_no_game_data.py over every file this adds to main; the line-ending, docs-encoding, CI-registration and docs tests; each test file that differs from main, on its own. Not run: the whole translator suite, the C++ build, cargo over d3d12/ after the merge (d3d12/ is byte for byte the branch's), CI. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
69 lines
2.6 KiB
Python
69 lines
2.6 KiB
Python
"""Read back OBJ primitives from a synthetic archive, independently of the writer."""
|
|
import struct
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
sys.path.insert(0, str(HERE))
|
|
from test_navmesh_decode import build_navmesh, make_rpf, nd
|
|
|
|
TOOL = HERE.parent / "tools" / "navmesh_tile_obj.py"
|
|
|
|
|
|
def read_obj(path):
|
|
vertices = []
|
|
groups = {}
|
|
for line in path.read_text(encoding="utf-8").splitlines():
|
|
op, *args = line.split()
|
|
if op == "v":
|
|
vertices.append(tuple(map(float, args)))
|
|
elif op == "g":
|
|
name, = args
|
|
assert name not in groups
|
|
groups[name] = []
|
|
elif op in ("p", "l"):
|
|
refs = list(map(int, args))
|
|
assert all(1 <= i <= len(vertices) for i in refs)
|
|
groups[name].append((op, [vertices[i - 1] for i in refs]))
|
|
elif op not in ("#", "o"):
|
|
raise AssertionError(op)
|
|
return groups
|
|
|
|
|
|
class ExportTest(unittest.TestCase):
|
|
def test_archive_selection_and_record_round_trip(self):
|
|
sizes = (3, 1, 0, 2, 4, 1)
|
|
head, tail = build_navmesh(n_verts=3, poly_sizes=sizes, tiny_bm_cont=True)
|
|
head = bytearray(head)
|
|
(at, _), = nd.split_array(head, 0x70, 6, 3)
|
|
struct.pack_into("<9H", head, at, 0, 0, 0, 65535, 0, 0, 0, 65535, 65535)
|
|
a, b, c = (-768, 512, 0), (-640, 512, 0), (-768, 640, 16)
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
archive = Path(directory) / "input.rpf"
|
|
out = Path(directory) / "tile.obj"
|
|
make_rpf(archive, [*build_navmesh(flags=5), head, tail, *build_navmesh(corrupt_vidx=True)])
|
|
|
|
def run(tile, dest):
|
|
return subprocess.run([sys.executable, "-I", TOOL, archive, "--tile", str(tile),
|
|
"--out", dest], capture_output=True)
|
|
|
|
result = run(1, out)
|
|
self.assertEqual(result.returncode, 0, result.stderr)
|
|
expected = [[("l", [a, b, c, a])], [("p", [a])], [], [("l", [b, c])],
|
|
[("l", [a, b, c, a, a])], [("p", [b])]]
|
|
groups = read_obj(out)
|
|
self.assertEqual(list(groups), [f"polygon_{i}" for i in range(len(sizes))])
|
|
self.assertEqual(list(groups.values()), expected)
|
|
original = out.read_bytes()
|
|
for invalid in (-1, 0, 2, 3):
|
|
self.assertEqual(run(invalid, out).returncode, 2)
|
|
self.assertEqual(out.read_bytes(), original)
|
|
self.assertEqual(run(1, archive).returncode, 2)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|