#!/usr/bin/env python3 """ Offline check of the AC facts behind the nameplates' "behind walls" rule (src/RynthCore.Engine/Compatibility/AcCellSight.cs, 2026-11-04, problem report R-20261105-020337-67aa) against an acclient.exe. Read-only: maps the file, runs nothing. pe_pattern.py CHECK already proves the embedded CEnvCell::GetDrawnThisFrame pattern is unique and lands on its VA. This checks the layout the engine reads, so a different client build fails here instead of hiding plates in game: * CEnvCell::GetDrawnThisFrame compares cell+0x130 with [device global]+0xB0, and SetDrawnThisFrame writes that stamp to cell+0x130 (the same global); * PView::DrawCells adds 1 to [global]+0xB0 before it draws, RenderDeviceD3D::Flip adds 1 to its own +0xB0, and DrawEnvCell marks the cell before drawing it; * CPhysicsObj::enter_cell stores the cell at +0x90 and the cell's +0x28 id at +0x4C; * SmartBox::RenderNormalMode reads the viewer cell id at +0x0C and the viewer cell's seen_outside through [+0x50]+0xE8; * PView::DrawInside hands the cell's +0xE0 / +0xE4 (visible-cell list) to add_views; * PView::ClipPortals walks the portal count at +0x108 and the array at +0x10C; * D3DPolyRender::DrawPortalPolyInternal reads the polygon's point count at +0x0E; * CCellPortal::UnPack stores 0xFFFFFFFF as the other cell of a doorway to outside; * CEnvCell::UnPack stores seen_outside (flags & 1) at +0xE8 (this-0x30 frame: +0xB8). Usage: python tools/plate_sight_check.py [""] Exit 0 = every check passed. """ import os import struct import sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from pe_pattern import read_window, matches # noqa: E402 DEFAULT_CLIENT = r"C:\Turbine\Asheron's Call\acclient.exe" N = None fails = 0 def check(ok, msg): global fails print(("ok " if ok else "FAIL ") + msg) if not ok: fails += 1 def main(): path = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_CLIENT if not os.path.exists(path): print(f"acclient.exe not found: {path}") return 2 W, BASE = read_window(path) def at(va, n): o = va - BASE return W[o:o + n] def body_has(va, needle, span=0x200): return W.find(bytes(needle), va - BASE, va - BASE + span) >= 0 # CEnvCell::GetDrawnThisFrame: mov eax,[ecx+130h]; mov ecx,[global]; cmp eax,[ecx+0B0h]; sete al; ret pat = [0x8B, 0x81, 0x30, 0x01, 0x00, 0x00, 0x8B, 0x0D, N, N, N, N, 0x3B, 0x81, 0xB0, 0x00, 0x00, 0x00, 0x0F, 0x94, 0xC0, 0xC3] ms = matches(W, pat, limit=4) check(len(ms) == 1, f"GetDrawnThisFrame pattern unique ({len(ms)} match)") if len(ms) != 1: return 1 get_drawn = BASE + ms[0] g = struct.unpack_from("