aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 2485586d1ce1dfea3437aff581816f7f3fcfc34d
parent e315dbe7d8d2efcc71d8eb49850ec69f2ad842f4
Author: anon <anon@example.com>
Date:   Tue, 27 Oct 2026 15:32:54 +0000

Serialize original mission building geometry without truncation

Diffstat:
MTODO.md | 14+++++++++-----
Mdocs/mission-interiors.md | 80++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Aserver/mission_geometry.go | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/mission_geometry_test.go | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/target_protocol.go | 15+++++++++++++--
5 files changed, 263 insertions(+), 10 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -1507,14 +1507,18 @@ client rendering fixes and checks are in [nano damage](docs/nano-damage.md). See [mission acceptance](docs/mission-acceptance.md). - [ ] [P0] Enter and leave one fixed mission interior. Check: the assigned door selects the right instance and returns the player to the right entrance. - Introduce explicit instance isolation across visibility, combat, nanos, loot, - inspection, trading and vicinity chat. Persist significant assignment/return + Introduce explicit instance isolation across movement/terrain, visibility, + combat, nanos, loot, inspection, trading and vicinity chat. Persist assignment/return transitions immediately; ordinary periodic position checkpoints are insufficient. Include private-instance retirement on abandonment/expiry without affecting another owner's assignment or admitting holders of revoked key bindings. - Original 14.9.1 proxy/generator and room-library research is underway; the - extractor decodes 298 rooms from four original ACD libraries. This is not - usable entry, recovered style selection or a completed private-world boundary. + Original 14.9.1 generator serialization now preserves variable room lists; + the extractor decodes 298 rooms from four original ACD libraries. An GPU + WASM protocol fixture loads a capped two-room layout, verifies reciprocal + native door links and one exterior exit, and walks both ways with collision. + Recover the door object/status lifecycle too: the fixture's room link remains + closed with no door identity, and adjacent geometry is black until crossing. + This is not usable entry, recovered style selection or a private-world boundary. See [mission interiors](docs/mission-interiors.md). - [ ] [P1] Complete mission-key destination metadata and duplication. Check: keys identify their assigned destination in the native UI, copies retain the diff --git a/docs/mission-interiors.md b/docs/mission-interiors.md @@ -11,6 +11,7 @@ The inspected original 14.9.1 binaries are: - `kkr.dll`, SHA256 `a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`. - `llr.dll`, SHA256 `ebb09047f6ead192388f7ddfb4795da5013a60f7c2d1c3933ec02eef58a10132`. +- `hhr.dll`, SHA256 `782a212c2ca8b5b90eab835fae689b40ae0c2bcf1b3d0165b117d4fb1505908e`. LLR's proxy reader `0x1004ac70` requires byte `a`, then six uint32 fields: model type/instance, group selector, subgroup, and running playfield type/instance. @@ -31,6 +32,13 @@ reads an ACGBuildingGeneratorData object, loads its template playfield, and buil rooms through `KKR:0x100f5540`. Earlier protocol reports contain addresses from other builds; use the exact artifact hashes when following these symbols. +HHR `DbObject_t::ReadBlob` / `WriteBlob` (`0x10005650` / `0x100055e0`) +prefix subclass data with uint32 type, instance and revision. The derived +14.9.1 PlayfieldAnarchyFIIR reader/writer (`KKR:0x10145f00` / `0x10145f40`) +then append two uint32 world origins after the base full update. They do not +carry the display name used by the shared 11.0 serializer. Activation +`0x10145de0` selects a RoomMonitor for dungeon tilemaps. + ## Generator and building pieces `KKR:0x100f1850` reads generator format 3 after the base database-object header: @@ -72,15 +80,67 @@ are retained under `local/mission-interior/`; extraction changes no live data. ## Remaining integration -Resolve the enclosing database-object header, derived full-update fields, -generator assignment and original room-door connection/placement rules. Then -verify one connected layout with the actual WASM loader before admitting entry. +`server/mission_geometry.go` now serializes the recovered generator format. +The target adapter previously truncated every playfield update to the fixed +public-map length; it now preserves the complete variable generator and both +origins, removing only the legacy name. Golden packet tests cover native bytes, +negative floors, rotations, unsigned dimensions, invalid fields and room counts +1, 2 and 10000. These are serialization checks, not asset-reference, overlap or +connected-layout admission checks. There is no production entry consumer yet. + +Resolve generator/style assignment, validate actual room references and complete +the native door lifecycle before admitting entry. The server needs durable mission-to-world/key bindings, significant entry/return commits, and retirement that safely removes only that mission's private world. Unique running identities are the intended isolation boundary, subject to an audit of every visibility, combat, nano, loot, inspection, trade and vicinity-chat consumer. No second instance may see or interact with the first one's contents. +## Native geometry verification + +An owned Chromium client on the GPU receives the actual Go-produced packet +through a recorded, client-side WebSocket fixture. The live server still hosts +the visitor in its public world; this does not test authoritative private entry, +key admission, persistence, mission rewards or instance isolation. No guest heap +writes or gameplay rewards are used. The published WASM is unchanged. + +The final fixture uses template331, dimensions4/6/10, ambient100/100/100 and two +placements: original room0 at X1/Z3 and room12 at X1/Z2, both floor0/rotation0. +Read-only native probes confirm running identity40016/9000001, proxy51105 and +two original rooms. Their reciprocal door positions are approximately +[15,0,29.999] and [15,0,30.001]; exactly one door remains unconnected for the +exterior exit. Normal W/S controls cross the join and return; sustained forward +movement against the far wall stops at Z38.639. Screenshots and floor-height +samples corroborate the native geometry and collision. + +LLR `GetDoorPosRot` (`0x10033650`) decodes the packed door as a tile index in the +upper14 bits and direction in the lower2 bits, adjusted by room rotation. +KKR `0x100f5e10` reverses layout Z against the building depth before adding the +transformed room origin. Its connection builder `0x100f2f30` pairs opposite +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. + +Final captures are in `local/mission-interior/runtime-capped/`, with earlier +fixtures retained separately. There are no page exceptions or native adapter +errors; both browser404s identify `favicon.ico`. All owned test browsers close +after each run, and the sole shared HTTPS8443 preview remains available. + +Final packet/world tests pass27 roots/67 results under the race detector; +the separate fixture producer also passes. Build and `go vet` pass. The full +server/gamedata run passes1474 roots/15161 results. That run compiled before +removing an unsupported width/depth32 cap; final focused/race runs cover the +corrected unsigned-dimension contract. Logs and source hashes remain in +`local/mission-interior/`. + Complete REA evidence is retained in `local/mission-interior/kkr-loader-evidence.json`, `llr-evidence.json` and `llr-room-evidence.json`, including procedure addresses, provider versions and analysis limitations. Key records are @@ -91,3 +151,17 @@ provider versions and analysis limitations. Key records are `ev_a7bf2942b2052a01d0c86ecb264575c434ba5420d1dcb1208b6851d60b5a7bb1` (room reader). Pseudocode is a static observation, not original source or an observed successful mission-entry run. Owned native analysis sessions are closed. + +Additional complete evidence bundles in the same directory are +`hhr-blob-evidence.json`, `kkr-iir-evidence.json`, `llr-door-evidence.json`, +`kkr-door-evidence.json` and `llr-door-state-evidence.json`. Key records are +`ev_874d6db31f1b87de2ec24d7bc57fb7ac5bc3f142c2f6f0961bc6d3efdde23715` +(database-object reader), +`ev_a305b7e17a14f3a93139401da3d969cbb183cea511332c81b14da14f487130e7` +(derived playfield reader), +`ev_a9df50f794ee3535183564ca4f4868bf11313457b62bb3b8ee8e5ed0737287af` +(door decoding), +`ev_0714be8f9bdafd8ab68f97e5eac08949655d7fcbc0392fef235e4e0cfd2518ac` +(connection matching), and +`ev_71bd9ed49c16e7a4976985009e92caa6d47a22847fae67061f224d10b6a13600` +(door-open query). diff --git a/server/mission_geometry.go b/server/mission_geometry.go @@ -0,0 +1,64 @@ +package main + +import ( + "encoding/binary" + "fmt" + "math" +) + +type missionRoom struct { + template uint16 + floor int8 + x, z byte + rotation byte +} + +type missionLayout struct { + template uint32 + width, depth, floorHeight uint16 + ambient [3]byte + rooms []missionRoom +} + +func missionPlayfieldPacket(player *character, layout missionLayout) ([]byte, error) { + // KKR 14.9.1 0x100f1850 / 0x100f5e80: serialized generator and room fields. + if layout.template == 0 || layout.width == 0 || layout.depth == 0 || + layout.floorHeight == 0 || layout.floorHeight > 1000 || len(layout.rooms) == 0 || len(layout.rooms) > 10000 { + return nil, fmt.Errorf("invalid mission building dimensions or room count") + } + for _, room := range layout.rooms { + if room.template > 10000 || room.floor < -16 || room.floor > 16 || room.x > 32 || room.z > 32 || room.rotation > 3 { + return nil, fmt.Errorf("invalid mission building room") + } + } + + // Model 51105 selects the generated-building factory; running identity is separate. + body := binary.BigEndian.AppendUint32(nil, 4) + for _, value := range player.position { + body = binary.BigEndian.AppendUint32(body, math.Float32bits(value)) + } + body = append(body, 'a') + for _, value := range []uint32{51105, player.playfield, player.playfield, 0, 40016, player.playfield} { + body = binary.BigEndian.AppendUint32(body, value) + } + + // HHR DbObject_t::WriteBlob 0x100055e0 writes identity and revision first. + for _, value := range []uint32{51103, player.playfield, 0} { + body = binary.BigEndian.AppendUint32(body, value) + } + for _, value := range []uint16{3, layout.width, layout.depth, layout.floorHeight} { + body = binary.BigEndian.AppendUint16(body, value) + } + body = binary.BigEndian.AppendUint32(body, layout.template) + body = append(body, layout.ambient[:]...) + body = binary.BigEndian.AppendUint32(body, uint32(len(layout.rooms))) + for _, room := range layout.rooms { + body = binary.BigEndian.AppendUint16(body, room.template) + body = append(body, byte(room.floor), room.x, room.z, room.rotation) + } + // KKR PlayfieldAnarchyFIIR 0x10145f00 reads two origins; conversion removes the legacy empty name. + for _, value := range []uint32{0, 0, 0} { + body = binary.BigEndian.AppendUint32(body, value) + } + return n3Packet(0x5f4b1a39, 40016, player.playfield, body), nil +} diff --git a/server/mission_geometry_test.go b/server/mission_geometry_test.go @@ -0,0 +1,100 @@ +package main + +import ( + "encoding/binary" + "encoding/hex" + "fmt" + "testing" +) + +func TestMissionBuildingPacketKeepsGeneratorAndWorldOrigins(t *testing.T) { + player := &character{id: 1, playfield: 9000001, position: [3]float32{16, 1, 16}} + layout := missionLayout{template: 331, width: 4, depth: 4, floorHeight: 10, + ambient: [3]byte{30, 40, 50}, rooms: []missionRoom{{template: 0, x: 1, z: 1}, {template: 1, floor: -1, x: 2, z: 3, rotation: 3}}} + + packet, err := missionPlayfieldPacket(player, layout) + if err != nil { + t.Fatal(err) + } + packet = targetPacket(packet) + packet = packet[:binary.BigEndian.Uint16(packet[6:8])] + + if len(packet) != 121 { + t.Fatalf("generator was truncated or retained the legacy name: %d", len(packet)) + } + if got := hex.EncodeToString(packet[29:]); got != "00000004418000003f80000041800000610000c7a100895441008954410000000000009c50008954410000c79f0089544100000000000300040004000a0000014b1e2832000000020000000101000001ff0203030000000000000000" { + t.Fatalf("native generator, room placement or origins changed: %s", got) + } +} + +func TestMissionBuildingPacketRejectsInvalidGeneratorContracts(t *testing.T) { + for _, scenario := range []struct { + name string + change func(*missionLayout) + }{ + {"no template", func(layout *missionLayout) { layout.template = 0 }}, + {"zero width", func(layout *missionLayout) { layout.width = 0 }}, + {"zero depth", func(layout *missionLayout) { layout.depth = 0 }}, + {"zero floor height", func(layout *missionLayout) { layout.floorHeight = 0 }}, + {"high floor", func(layout *missionLayout) { layout.floorHeight = 1001 }}, + {"no rooms", func(layout *missionLayout) { layout.rooms = nil }}, + {"many rooms", func(layout *missionLayout) { layout.rooms = make([]missionRoom, 10001) }}, + {"room index", func(layout *missionLayout) { layout.rooms[0].template = 10001 }}, + {"low floor", func(layout *missionLayout) { layout.rooms[0].floor = -17 }}, + {"high floor", func(layout *missionLayout) { layout.rooms[0].floor = 17 }}, + {"room x", func(layout *missionLayout) { layout.rooms[0].x = 33 }}, + {"room z", func(layout *missionLayout) { layout.rooms[0].z = 33 }}, + {"room rotation", func(layout *missionLayout) { layout.rooms[0].rotation = 4 }}, + } { + t.Run(scenario.name, func(t *testing.T) { + layout := missionLayout{template: 331, width: 4, depth: 4, floorHeight: 10, rooms: []missionRoom{{}}} + scenario.change(&layout) + + packet, err := missionPlayfieldPacket(&character{playfield: 9000001}, layout) + + if err == nil || packet != nil { + t.Fatal("invalid generator produced a partial native packet") + } + }) + } +} + +func TestMissionBuildingPacketKeepsVariableRoomCountsAndOrigins(t *testing.T) { + for _, scenario := range []struct{ rooms, length int }{{1, 115}, {2, 121}, {10000, 60109}} { + t.Run(fmt.Sprint(scenario.rooms), func(t *testing.T) { + layout := missionLayout{template: 331, width: 32, depth: 32, floorHeight: 1000, rooms: make([]missionRoom, scenario.rooms)} + layout.rooms[0] = missionRoom{template: 10000, floor: -16, x: 32, z: 32, rotation: 3} + packet, err := missionPlayfieldPacket(&character{playfield: 9000001}, layout) + if err != nil { + t.Fatal(err) + } + end := int(binary.BigEndian.Uint16(packet[6:8])) + binary.BigEndian.PutUint32(packet[end-12:end-8], 123) + binary.BigEndian.PutUint32(packet[end-8:end-4], 456) + + packet = targetPacket(packet) + packet = packet[:binary.BigEndian.Uint16(packet[6:8])] + + if len(packet) != scenario.length || hex.EncodeToString(packet[len(packet)-8:]) != "0000007b000001c8" { + t.Fatal("native conversion lost rooms or moved the world origins", len(packet)) + } + if got := hex.EncodeToString(packet[101:107]); got != "2710f0202003" { + t.Fatal("valid room boundaries changed", got) + } + }) + } +} + +func TestMissionBuildingPacketKeepsUnsignedDimensions(t *testing.T) { + layout := missionLayout{template: 331, width: 65535, depth: 32768, floorHeight: 10, rooms: []missionRoom{{}}} + + packet, err := missionPlayfieldPacket(&character{playfield: 9000001}, layout) + if err != nil { + t.Fatal(err) + } + packet = targetPacket(packet) + + if got := hex.EncodeToString(packet[84:90]); got != "ffff8000000a" { + t.Fatal("unsigned generator dimensions changed", got) + } +} diff --git a/server/target_protocol.go b/server/target_protocol.go @@ -15,8 +15,19 @@ func targetPacket(packet []byte) []byte { binary.BigEndian.PutUint32(packet[56:60], binary.BigEndian.Uint32(packet[56:60])-16) } case 0x5f4b1a39: - // Playfield initialization ends after its two world origins. - packet = packet[:93] + // Preserve the variable generator object, then strip only the legacy name. + end := 93 + switch binary.BigEndian.Uint32(packet[77:81]) { + case 0: + case 51103: + if binary.BigEndian.Uint16(packet[89:91]) != 3 { + panic("unsupported mission generator version") + } + end = 116 + 6*int(binary.BigEndian.Uint32(packet[104:108])) + default: + panic("unsupported playfield generator") + } + packet = packet[:end] case 0x271b3a6b: packet[36] = '0' flags := binary.BigEndian.Uint32(packet[37:41])