commit 9905e9c88c4e2a963212ff135a7534a8f3630cf4
parent ef2bbf83eef901c2f8fcae581a6d78b71410f344
Author: anon <anon@example.com>
Date: Tue, 27 Oct 2026 17:09:39 +0000
Validate mission lightmaps and resolve authored portal occlusion
Diffstat:
5 files changed, 145 insertions(+), 28 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -1517,10 +1517,18 @@ client rendering fixes and checks are in [nano damage](docs/nano-damage.md).
WASM protocol fixture loads a capped two-room layout, verifies reciprocal
native door links and one exterior exit, and walks both ways with collision.
Door create/status messages now register a real native door and animate it.
- Complete their flag/close-notification lifecycle and trace RoomMonitor/camera
- visibility: adjacent geometry is still black with a fully open door and open
- room link. Closed-link state alone does not explain it. Original door data
- now decodes3692 placements and53 templates; the mission-style mapping is open.
+ Recover the status flag's full lifecycle. Original RoomMonitor delays closure
+ by more than two seconds. Native draw/scene traces identify the black doorway
+ as separate static model42850 at the entrance's other portal. Rotating that
+ entrance to leave its black portal as the exterior verifies a visible adjoining
+ chamber and traversal both ways without a client patch. Validate authored
+ portal choice in addition to reciprocal links and one unmatched exit. Original
+ door data decodes3692 placements and53 templates; full style mapping is open.
+ Published-WASM fixtures verify open/close/reopen and deferred room disablement,
+ but both templates41565/41884 still allow a closed-door crossing with closed
+ flags/link. Recover the native collision/open-request contract and enforce
+ closed/locked/revoked-key admission authoritatively; test denial, auto-open,
+ concurrent use, reconnect and exit instead of relying on animation or visibility.
This is not usable entry, recovered style selection or a private-world boundary.
See [mission interiors](docs/mission-interiors.md) and [doors](docs/mission-doors.md).
- [ ] [P1] Complete mission-key destination metadata and duplication. Check:
diff --git a/docs/mission-doors.md b/docs/mission-doors.md
@@ -59,7 +59,7 @@ hashes are retained in `local/mission-interior/door-catalog.json` and
`door-placements.json`. They do not establish a generated-mission door choice.
Three unmodified original placement fixtures cover each added function and
-preservation of following stats; truncated descriptors are rejected. All48
+preservation of following stats; truncated descriptors are rejected. All50
data-tool tests pass. No generated live world data changes in this milestone.
## Native observation and remaining work
@@ -76,8 +76,8 @@ The unflagged open update changes the room link but the client promptly reverses
the animation. With the additional state flag set, Flags bit128 stays set and
the native animation reaches its0.6-second end pose. A subsequent unflagged
close reaches time0 and clears bit128; another unflagged open reaches0.6 again.
-The room-link close notification had not completed at the one-second sample,
-so its delay must be verified separately. The flag latches native byte0x1c5;
+The room-link close notification is deferred by RoomMonitor: original LLR
+`0x10035250` queues it and `0x10035380` waits more than two seconds. The flag latches native byte0x1c5;
these experiments do not establish every lifetime or producer rule.
Original `bbr.dll` SHA256
@@ -90,11 +90,20 @@ status sequence. Both templates41565 and41884 were tested; only41884's run
establishes a return walk. The sampled movement-counter byte1 was already
present before movement, so it is not evidence of a newly imposed root.
-Adjoining geometry is still black while the real door is fully open and its
-room link is open1. Closed-link state alone therefore does not explain the
-visibility gap. Trace the native RoomMonitor's visible-room/camera selection
-and the generated world's room graph before enabling entry. Keep authoritative
-mission/world/key allocation, movement/terrain, isolation and retirement open.
+The first fixtures' black doorway persisted with a fully open door and open1
+room link. Further [visible-room checks](mission-interiors.md#native-visible-room-checks)
+identify separate static model42850 with a black material at that portal.
+Rotating the entrance template to leave the black portal as the exterior fixes
+the adjoining view without a client patch. Reciprocal links and exactly one
+exterior door do not by themselves validate authored portal selection. Keep
+status flag semantics, mission/world/key allocation, movement/terrain, isolation
+and retirement open.
+
+Corrected-layout published-WASM fixtures281/282 verify open/close/reopen with
+41884 and41565, including room disablement after the deferred close. Both also
+cross the closed door while its open flag/link stay clear. Recover collision and
+open-request semantics before implementing authoritative blocking; these owned
+client-side fixtures do not supply a private server's response.
Final timed captures are in `local/mission-interior/runtime-door-observe/`,
with earlier exterior/interior template runs in `runtime-door/` and
diff --git a/docs/mission-interiors.md b/docs/mission-interiors.md
@@ -57,6 +57,12 @@ names, lightmap metadata, raw water vertices/triangles and camera attractors.
Raw water heights remain source floats; the native collision reader separately
rounds their Y coordinates to hundredths.
+The lightmap's second word is a vertex count, not an encoding selector.
+`LLR:0x10033ce0` decompresses version8 records into two bytes per vertex;
+`0x1001f970` expands their RGB565 colors for the room's vertices. The extractor
+checks the decompressed size against that count. All298 records pass, with
+byte-exact reconstruction of the original resource payloads still verified.
+
| Resource | Original library | Rooms |
| --- | --- | --- |
| 331 | ACD tarm | 42 |
@@ -70,7 +76,7 @@ The catalog is not a recovered booth-style assignment or a connected layout.
Fixtures retain one complete original room from each library, including a cave
water polygon; their test resource headers deliberately change the room count.
-All 44 data-tool tests pass, including 12 room-parser tests covering the four
+All 50 data-tool tests pass, including 14 room-parser tests covering the four
libraries, original water topology, opaque suffix preservation, camera layout
and malformed/truncated input. Independent reconstruction concatenates the
original header, each cataloged room and retained suffix to reproduce all four
@@ -78,6 +84,84 @@ source payloads byte for byte. All candidate room dimensions are multiples of
five, as required by the generated-building loader. The catalog and verifier
are retained under `local/mission-interior/`; extraction changes no live data.
+## Native visible-room checks
+
+Original LLR RoomMonitor `0x10034e40` creates disabled VisualRooms and
+`0x10035000` enables the current room. `0x100351d0` opens the room link;
+`0x10035250` queues closure and `0x10035380` waits more than two seconds before
+closing it. BBR `0x1009e930` enables a VisualRoom and adds it to the render root;
+`0x1009e960` disables and removes it. Its `0x1009eca0` renders the material groups.
+The local LLR VisualRoom vtable forwards into BBR through import thunks.
+
+Owned native fixtures270/271 load both the original capped layout and a second
+layout using room37 (`tarm_hartchamber2`) at X1/Z1. Both retain exactly one
+unmatched exterior door. Read-only probes show both rooms enabled, parented to
+the same render root, with original vertex/material data and world transforms,
+after the fully open door status. Both still show a black adjacent doorway.
+This rules out a disabled neighbor as the sole cause; it does not prove a
+renderer defect. Native n3Room floor is field0xa8 (`0x10030400` / `0x10030410`);
+field0x78 contributes to a render/light group mask, with its meaning unresolved.
+
+Diagnostic fixture275 uses a separately linked WASM bundle with logging in the
+Direct3D adapter; published assets and the sole server are unchanged. Both rooms
+reach GPU drawing with valid indices/colors/transforms and ordinary clip/depth
+settings. A center-of-doorway triangle trace instead finds a16-vertex mesh in
+front of the adjoining room, including after the0.6-second door animation ends.
+Scene traversal identifies it as `Object04` in separate static model42850,
+whose original resource1010001 contains a `blacktexture` material. It is not
+one of animated door41798's parts. Their world transforms update correctly.
+
+The fixture connected room0's black portal at Z30 to the next room, leaving its
+other portal at Z10 as the exterior. Rotating only room0 by two quarter turns
+moves that static black portal to the unmatched Z10 exit and connects the other
+portal to room37 at Z30. Diagnostic fixture280 then sees the adjoining chamber
+through the fully open door and walks both ways; the center trace no longer
+hits the16-vertex blocker. No renderer, lighting or animation patch is needed.
+This establishes a working portal choice for this particular entrance template;
+it does not recover the complete original entrance/style assignment. Exactly
+one unmatched door and reciprocal links alone are insufficient layout checks:
+authored portal content also matters.
+
+The corrected packet still uses template331, dimensions4/6/10, ambient100 each,
+room0 at X1/Z3/rotation2 and room37 at X1/Z1/rotation0, floor0. These fixtures
+establish no production entry, private isolation, authority or persistence.
+
+Published-WASM fixtures281/282 repeat the corrected geometry with door templates
+41884 and41565 respectively. Native snapshots verify open/close/reopen flags,
+the0.6-second animation endpoints, room-link changes and the adjoining room's
+disablement after the deferred close. Screenshots show the chamber through the
+open door. Fixture282 crosses into the chamber and back across Z30. Fixture281
+also reaches the chamber's far wall; its return stops short of the doorway after
+collision shifts X sideways. Do not count that as a successful return walk.
+
+Both fixtures walk through the closed door while Flags bit128 and the room link
+remain closed. This is a failed blocking scenario, not verified admission. Trace
+the original collision/open-request contract and implement authoritative closed,
+locked and revoked-key enforcement before private entry. The fixtures run on
+public-world visitors and cannot establish how a real private server responds.
+There are no page exceptions or adapter errors; browser404s are only favicon.ico.
+`local/mission-interior/entry-native-verification.json` records passing checks
+and the unresolved closed-door traversal separately, with packet/resource hashes.
+
+Captures are in `local/mission-interior/runtime-visibility/`,
+`runtime-visibility-heart/`, `runtime-render-trace-first/`,
+`runtime-render-trace/`, `runtime-scene-model-trace/`, `runtime-correct-entry/`,
+`runtime-entry-published/` and `runtime-solid-entry/`. Complete static records
+are retained in
+`llr-room-visibility-evidence.json`, `bbr-visibility-enable-evidence.json`,
+`bbr-room-render-evidence.json`, `bbr-portal-mesh-evidence.json` and
+`llr-room-geometry-evidence.json` in the same directory. Key records are
+`ev_39719c3fd377d8d3fd017da67997d476c850340d02c5d904e45e973e2cfd4c37`
+(deferred closure),
+`ev_083d9e81a8c45a63e2cc40de5bd8ac871c91b69d4d2177a1de1a50aaab39624b`
+(visibility enable),
+`ev_98875a72181b1461cc1e011400be7602eed717b46ef1032fa41be1990fd1b911`
+(room render) and
+`ev_76dae975e1e40123ad08be346da4e8ed47afbdae9351bd0965423d5177d7ba98`
+(lightmap decompression). Ghidra's large CreateDungeonRoom pseudocode has stack
+and argument recovery failures; runtime checks and lifted instructions must
+corroborate interpretations of that routine.
+
## Remaining integration
`server/mission_geometry.go` now serializes the recovered generator format.
@@ -121,16 +205,15 @@ directions on the same floor within X/Z0.1 and Y0.3, and expects exactly one
unmatched exterior door. Earlier two-corridor fixtures had two unmatched doors;
their successful traversal was insufficient evidence of a complete layout.
-Adjacent geometry remains black through the doorway until crossing. The native
-room-link table contains neighbor1 with open0 and door identity0/0. Original
-`IsDoorOpenBetweenRooms` (`LLR:0x1002bfd0`) returns false for that state, and
-`RoomCanSeeFromTo` calls it. Recover and send the actual door object/status
-lifecycle rather than forcing all rooms visible. `ChangeRoomStatus`
-(`0x1002bf30`) and `RegisterDoorWithRoomLink` (`0x1002ba00`) update that table.
-This is a remaining mission-entry requirement, not a fixed client rendering bug.
-Further [door investigation](mission-doors.md) registers a real door and verifies
-its animation, but adjoining geometry remains black even with open1. Closed
-door-link state alone is insufficient to explain the remaining visibility gap.
+The original fixture's black doorway initially coincided with an unregistered,
+closed room link. Original `IsDoorOpenBetweenRooms` (`LLR:0x1002bfd0`) returns
+false for that state, and `RoomCanSeeFromTo` calls it. Real door creation/status
+corrects that link and its animation, but it did not remove the black doorway.
+The [visible-room checks](#native-visible-room-checks) above identify the separate
+static blocker and verify a corrected portal choice. Preserve the distinction
+between required door lifecycle and authored entrance geometry when admitting
+production layouts. `ChangeRoomStatus` (`0x1002bf30`) and
+`RegisterDoorWithRoomLink` (`0x1002ba00`) update the native link table.
Final captures are in `local/mission-interior/runtime-capped/`, with earlier
fixtures retained separately. There are no page exceptions or native adapter
diff --git a/tools/data/extract_mission_rooms.py b/tools/data/extract_mission_rooms.py
@@ -2,6 +2,7 @@ import hashlib
import json
import pathlib
import struct
+import zlib
import ao_database
@@ -41,10 +42,12 @@ def parse_playfield(payload):
doors = [reader.values('hh') for _ in range(reader.values('H')[0])]
room_name = reader.take(32).split(b'\0', 1)[0].decode('latin1') if flags & 128 else ''
- # The lightmap length includes its four-byte encoding; zero has no body.
- length, encoding = reader.values('II')
+ # Version 8 lightmaps store a vertex count and compressed RGB565 colors.
+ length, vertex_count = reader.values('II')
assert length >= 4, ('invalid lightmap length', ordinal, length)
- lightmap = reader.take(length - 4) if encoding else b''
+ lightmap = reader.take(length - 4) if vertex_count else b''
+ if vertex_count:
+ assert len(zlib.decompress(lightmap)) == vertex_count * 2, ('invalid lightmap vertex count', ordinal, vertex_count)
water_count = reader.values('I')[0]
assert water_count and water_count % 1009 == 0, ('invalid water list', ordinal, water_count)
water = []
@@ -60,7 +63,7 @@ def parse_playfield(payload):
raw = payload[start:reader.offset]
rooms.append(dict(index=ordinal, offset=start, size=len(raw), sha256=hashlib.sha256(raw).hexdigest(),
name=room_name, flags=flags, header_byte=header_byte, bounds=bounds, position=position,
- doors=doors, lightmap=dict(encoding=encoding, declared_length=length, bytes=len(lightmap)), water=water,
+ doors=doors, lightmap=dict(vertex_count=vertex_count, declared_length=length, bytes=len(lightmap)), water=water,
cameras=cameras, raw_hex=raw.hex()))
# The resource has an additional suffix beyond the base reader; retain it verbatim.
trailer = reader.take(len(payload) - reader.offset)
diff --git a/tools/data/test_extract_mission_rooms.py b/tools/data/test_extract_mission_rooms.py
@@ -45,7 +45,7 @@ class MissionRoomTests(unittest.TestCase):
room = extract_mission_rooms.parse_playfield(payload)['rooms'][0]
- self.assertEqual(room['lightmap'], {'encoding': 2305, 'declared_length': 1667, 'bytes': 1663})
+ self.assertEqual(room['lightmap'], {'vertex_count': 2305, 'declared_length': 1667, 'bytes': 1663})
self.assertEqual(len(room['water']), 1)
self.assertEqual(room['water'][0]['flags'], 0)
self.assertEqual(len(room['water'][0]['vertices']), 7)
@@ -109,6 +109,20 @@ class MissionRoomTests(unittest.TestCase):
with self.assertRaisesRegex(AssertionError, 'invalid lightmap length'):
extract_mission_rooms.parse_playfield(payload)
+ def test_lightmap_vertex_count_matches_decompressed_colors(self):
+ payload = self.resource(331)
+
+ room = extract_mission_rooms.parse_playfield(payload)['rooms'][0]
+
+ self.assertEqual(room['lightmap'], {'vertex_count': 464, 'declared_length': 533, 'bytes': 529})
+
+ def test_mismatched_lightmap_vertex_count_is_rejected(self):
+ payload = bytearray(self.resource(331))
+ struct.pack_into('<I', payload, 120, 463)
+
+ with self.assertRaisesRegex(AssertionError, 'invalid lightmap vertex count'):
+ extract_mission_rooms.parse_playfield(payload)
+
def test_invalid_encoded_water_list_is_rejected(self):
payload = bytearray(self.resource(331))
length = struct.unpack_from('<I', payload, 116)[0]