#!/usr/bin/env python3 """Read-only 3DUD/defaults/oriented-cube collision evidence; executes no originals.""" from pathlib import Path import hashlib import json import re import struct import sys HERE = Path(__file__).resolve().parent PROJECT = HERE.parent.parent sys.path.insert(0, str(HERE)) sys.path.insert(0, str(PROJECT / 'tools/levels')) from pe_inspect import PE from rtti_map import rtti_map from gam import parse def main(): original = PROJECT.parent / 'Original' pe = PE(original / 'Neutron.exe') checks = { 'door_pair_collision_enable': (0x4175b0, '56e80a9b0500'), 'door_mode2_push': (0x4175c6, '6a02'), 'door_mode2_setter': (0x4175ca, 'e861a10500'), 'door_integration_disable': (0x4175cf, '578bcde8599a0500'), 'door_postload_radius40': (0x417cab, '6800002042'), 'door_postload_radius_setter': (0x417cb2, 'ff9210010000'), 'activation_has_collision_sentinel': (0x40e410, '83f8ff747c'), 'activation_enable_pairs': (0x40e427, 'ff90ac030000'), 'activation_disable_pairs': (0x40e44b, 'ff90a4030000'), 'pair_dispatch_box_mode': (0x47a4cf, 'ff9078010000'), 'pair_dispatch_box_first': (0x47a4dc, 'e8ff000000'), 'pair_dispatch_box_second': (0x47a4f4, 'e8e7000000'), 'box_query_other_geometry_gate': (0x47a5f5, 'ff90d0010000'), 'box_query_other_mode': (0x47a707, 'ff9278010000'), 'box_sphere_double_box_radius': (0x47a73f, 'd9842498000000dcc0d8842494000000'), 'box_min_bound_getter': (0x47a776, 'ff90e4020000'), 'box_max_bound_getter': (0x47a7a5, 'ff90dc020000'), 'box_corner_transform': (0x47a7ec, 'ff9084030000'), 'box_triangle_count12': (0x47ab67, 'c784240c0100000c000000'), 'box_triangle_narrowphase': (0x47b277, 'e8040b0000'), 'box_response_inhibition_gate': (0x47b2ef, 'ff90e0010000'), 'box_response_world_clip': (0x47b364, 'e847010000'), 'box_response_position_setter': (0x47b399, 'ff9014030000'), 'shape_change_cube_query': (0x4622d4, 'ff5044'), 'shape_change_min_bound_setter': (0x4622fb, 'ff90e8020000'), 'shape_change_max_bound_setter': (0x462325, 'ff90e0020000'), } for label, (va, expected) in checks.items(): offset = pe.offset(va - pe.base) actual = pe.data[offset:offset + len(expected) // 2].hex() if actual != expected: raise ValueError(f'{label} at{va:#x}: {actual} != {expected}') table = struct.unpack_from('<12I', pe.data, pe.offset(0x47b3ac - pe.base)) assert table == (0x47ab82, 0x47abf3, 0x47ac64, 0x47acd5, 0x47ad46, 0x47adb7, 0x47ae34, 0x47aeb1, 0x47af22, 0x47af93, 0x47aff8, 0x47b075) # These bounded switch cases copy three source corners into the triangle # scratch vectors. Decode their mov EAX/ECX/EDX,[ESP+disp] loads directly. locals_to_corners = {0xdc: 0, 0x70: 1, 0x40: 2, 0xac: 3, 0x50: 4, 0x60: 5, 0xbc: 6, 0x9c: 7} triangles = [] for start, end in zip(table, (*table[1:], 0x47b0ef)): code = pe.data[pe.offset(start - pe.base):pe.offset(end - pe.base)] offsets = [m[1][0] if m[1] else struct.unpack('