aorecomp

Anarchy Online classic in the browser

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


commit 601b2ca4a7c272d693e0649b2cdf34460954050e
parent 91acb4f050db5f1b68cffaa7ca85875005b9062b
Author: anon <anon@example.com>
Date:   Thu,  5 Nov 2026 22:44:00 +0000

Restore required geometry resources in NPC test fixtures

Diffstat:
MTODO.md | 12++++++------
Mserver/fixture_database_test.go | 4++++
Mserver/npc_data_test.go | 24++++++++++++++++++++----
3 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -222,12 +222,12 @@ rewriting this document does not close them. asset tree; the tagged executable runs without external assets; representative resource reads and HTTP responses agree in both modes. Update build/release instructions and resource tests to cover both providers. -- [ ] **Repair the NPC fixture's missing interior resources.** - `useNPCData`'s empty database makes corpse-expiry tests panic while loading - interior resource `1000001/1180`, also reproduced with the pre-change - `98127488` test binary. Keep the authored fake population while supplying - resources required by current server initialization. Completion: the affected - corpse-expiry tests run their assertions successfully. +- [x] **Repair the NPC fixture's missing interior resources.** + The fixture opens the packaged database for required interior geometry while + retaining its fake population, terrain and zone links. Synthetic outdoor + grids remain separate from original scenery. Corpse expiry and respawn tests + now reach and pass their assertions; related roaming, checkpoint, teleport + and fixture-isolation regressions pass as well. - [ ] **Measure server test costs and remove obvious inefficiencies.** The reported full run takes tens of minutes, but `-v` shows progress; quiet output alone does not establish a hang. Establish a baseline before setting diff --git a/server/fixture_database_test.go b/server/fixture_database_test.go @@ -9,6 +9,10 @@ import ( func newServerForTest(t *testing.T) *server { t.Helper() world := newServer() + if _, synthetic := resources.(npcFixtureResources); synthetic { + // Artificial terrain grids do not describe the original outdoor scenery. + world.geometry.playfields = nil + } registerTestDatabaseCleanup(t, world) return world } diff --git a/server/npc_data_test.go b/server/npc_data_test.go @@ -29,6 +29,21 @@ func testNPCData() gamedata.NPCData { } } +type npcFixtureResources struct { + files fstest.MapFS + database fs.FS +} + +func (resources npcFixtureResources) Open(name string) (fs.File, error) { + // Keep synthetic terrain and links while loading required original geometry. + switch name { + case "anarchy-assets-14.9.1/cd_image/data/db/ResourceDatabase.idx", + "anarchy-assets-14.9.1/cd_image/data/db/ResourceDatabase.dat": + return resources.database.Open(name) + } + return resources.files.Open(name) +} + func useNPCData(t *testing.T, data gamedata.NPCData) { t.Helper() previousNPCs, previousGroups, previousResources := gamedata.NPCs, gamedata.NPCGroups, resources @@ -42,12 +57,10 @@ func useNPCData(t *testing.T, data gamedata.NPCData) { } } } - resources = fstest.MapFS{ + resources = npcFixtureResources{database: previousResources, files: fstest.MapFS{ "terrain.bin": {Data: append([]byte("AOTERR02"), 0, 0, 0, 0)}, "zone_links.yaml": {Data: []byte("original: {}\ntarget: {}\n")}, - "anarchy-assets-14.9.1/cd_image/data/db/ResourceDatabase.idx": {Data: make([]byte, 76)}, - "anarchy-assets-14.9.1/cd_image/data/db/ResourceDatabase.dat": {}, - } + }} t.Chdir(t.TempDir()) t.Cleanup(func() { gamedata.NPCs, gamedata.NPCGroups, resources = previousNPCs, previousGroups, previousResources }) } @@ -122,4 +135,7 @@ func TestNPCInstanceKeepsDefinitionID(t *testing.T) { if world.characters[1000000].npcDefinitionID != "test/npc" { t.Fatal("live NPC lost the definition ID used by Go behavior code") } + if len(world.characters) != 1 || len(world.terrain) != 0 || len(world.geometry.playfields) != 0 || len(world.geometry.interiors) != 4 { + t.Fatal("NPC fixture lost its isolated population or required interior geometry") + } }