aorecomp

Anarchy Online classic in the browser

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


commit 99bd2d9de997b9f1989107d9cddf6f116be90cc6
parent 0a65f5daccf986a4f93661378b61eb6e2f293817
Author: anon <anon@example.com>
Date:   Wed,  4 Nov 2026 00:30:39 +0000

Clear expired mission waypoints without clearing other missions

Diffstat:
MTODO.md | 16+++++++++-------
Mclient/Makefile.linux | 14++++++++++++++
Mclient/game/bbr.dll/lifted-0038.c | 7++++++-
Mclient/game/ddr.dll/lifted-0033.c | 4++++
Mclient/game/ddr.dll/lifted-0034.c | 4++++
Mclient/game/kkr.dll/lifted-0032.c | 12++++++++++++
Mclient/runtime/browser_testing.c | 23+++++++++++++++++++++++
Mclient/tests/browser_testing.c | 35++++++++++++++++++++++++++++++++++-
Aclient/tests/mission_expiry_notification.c | 118+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aclient/tests/mission_waypoint_removal.c | 110+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocs/mission-retirement.md | 60+++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Aserver/browser_mission_waypoint_expiry_test.go | 112+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/client/test_mission_waypoint_expiry.mjs | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13 files changed, 634 insertions(+), 14 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -2676,13 +2676,15 @@ client rendering fixes and checks are in [nano damage](docs/nano-damage.md). Player evacuation, spawned NPCs, unclaimed corpse loot and floor objectives now retire in the same transaction. See [mission retirement](docs/mission-retirement.md). -- [ ] [P2] Retire uploaded waypoints when their mission expires. Native - QuestEvent1 now reports "Quest expired.." and removes the journal/key, but the - GPU local map retains the white X until reconnect. The original expiry - consumer0x3606c060 emits the explicit waypoint-clear UI event only for completion - event2. Trace waypoint ownership/lifetime before changing the client; never - send a false completion event to clear the marker. Captures and original - evidence: `local/mission-retirement/event-expiry-*` and the retirement notes. +- [x] [P2] Retire uploaded waypoints when their mission expires. Native + QuestEvent1 now sends identity-scoped coordinate removal to the local map, + planet map and compass. Each preserves another mission's uploaded marker and + the original explicit0/0 reset. A controlled two-contract WASM regression + uploads B, expires A while retaining B, then expires B and clears all three + stores and the rendered white X. Journal/key removal, exact expiry events, + unchanged ownership/rewards, page replay and cold Go loading pass. No false + completion event is sent. Original routing/identity evidence and captures: + `local/mission-waypoint-expiry/`; see [retirement notes](docs/mission-retirement.md). - [ ] [P2] Establish original14.9.1 key retention/removal on abandonment and copied keys held elsewhere. Current immediate bound-key deletion on abandonment is provisional; original client journal behavior does not prove server key policy. diff --git a/client/Makefile.linux b/client/Makefile.linux @@ -178,6 +178,10 @@ test: build/linux/window build/linux/graphics build/linux/atoi build/linux/stric ./build/linux/bulk-fill-paged ./build/linux/shop-empty-total ./build/linux/shop-empty-total-paged + ./build/linux/mission-expiry-notification + ./build/linux/mission-expiry-notification-paged + ./build/linux/mission-waypoint-removal + ./build/linux/mission-waypoint-removal-paged ./build/linux/reference-persistence ./build/linux/weapon-range ./build/linux/ip-training @@ -734,3 +738,13 @@ build/linux/shop-empty-total build/linux/shop-empty-total-paged: tests/shop_empt $(CC) $(CPPFLAGS) $(CFLAGS) $(if $(filter %-paged,$@),-U__linux__) -ffunction-sections -fdata-sections $(filter %.c,$^) -Wl,--gc-sections -lm -o $@ test: build/linux/shop-empty-total build/linux/shop-empty-total-paged + +build/linux/mission-expiry-notification build/linux/mission-expiry-notification-paged: tests/mission_expiry_notification.c game/kkr.dll/lifted-0032.c runtime/guest_memory.c runtime/recomp_state.c runtime/recomp_types.h runtime/guest_memory.h + @mkdir -p $(@D) + $(CC) $(CPPFLAGS) $(CFLAGS) $(if $(filter %-paged,$@),-U__linux__) -ffunction-sections -fdata-sections $(filter %.c,$^) -Wl,--gc-sections -lm -o $@ + +build/linux/mission-waypoint-removal build/linux/mission-waypoint-removal-paged: tests/mission_waypoint_removal.c game/bbr.dll/lifted-0038.c game/ddr.dll/lifted-0033.c game/ddr.dll/lifted-0034.c runtime/guest_memory.c runtime/recomp_state.c runtime/recomp_types.h runtime/guest_memory.h + @mkdir -p $(@D) + $(CC) $(CPPFLAGS) $(CFLAGS) $(if $(filter %-paged,$@),-U__linux__) -ffunction-sections -fdata-sections $(filter %.c,$^) -Wl,--gc-sections -lm -o $@ + +test: build/linux/mission-expiry-notification build/linux/mission-expiry-notification-paged build/linux/mission-waypoint-removal build/linux/mission-waypoint-removal-paged diff --git a/client/game/bbr.dll/lifted-0038.c b/client/game/bbr.dll/lifted-0038.c @@ -42692,9 +42692,14 @@ void sub_250ABCF0(void) { uint32_t _itail_tgt = 0; RECOMP_REGS_LOCALS RECOMP_ENTER(0x250ABCF0u); + uint32_t identity = MEM32(esp + 4); L_250ABCF0: - MEM8(ecx + 0xDC) = (uint8_t)(0); /* 0x250ABCF0: mov byte ptr [ecx + 0xdc], 0 */ + /* Keep a different mission's marker; zero identity explicitly clears all. */ + if (!(MEM32(identity) || MEM32(identity + 4)) || + (MEM32(identity) == MEM32(ecx + 0xC0) && + MEM32(identity + 4) == MEM32(ecx + 0xC4))) + MEM8(ecx + 0xDC) = 0; RECOMP_FLAGS_OUT(); esp += 8; { RECOMP_REGS_OUT(); return; } /* 0x250ABCF7: ret 4 */ RECOMP_REGS_OUT(); } diff --git a/client/game/ddr.dll/lifted-0033.c b/client/game/ddr.dll/lifted-0033.c @@ -20556,6 +20556,10 @@ L_2B081BB0: ecx = eax; /* 0x2B081BCE: mov ecx, eax */ RECOMP_ICALL(MEM32(0x2B0B53AC)); /* 0x2B081BD0: call dword ptr [0x2b0b53ac] */ RECOMP_FLAGS_IN(); + /* Keep a different mission's marker; zero identity explicitly clears all. */ + if ((MEM32(ebp - 8) || MEM32(ebp - 4)) && + (MEM32(ebp - 8) != MEM32(0x2B0EF070) || + MEM32(ebp - 4) != MEM32(0x2B0EF074))) goto L_2B081BFB; ecx = MEM32(0x2B0EF078); /* 0x2B081BD6: mov ecx, dword ptr [0x2b0ef078] */ /* test ecx, ecx */ /* 0x2B081BDC: test ecx, ecx */ _flag_a = (uint32_t)(ecx); _flag_b = (uint32_t)(ecx); diff --git a/client/game/ddr.dll/lifted-0034.c b/client/game/ddr.dll/lifted-0034.c @@ -2481,6 +2481,10 @@ L_2B083412: RECOMP_ICALL(MEM32(0x2B0B53AC)); /* 0x2B083424: call dword ptr [0x2b0b53ac] */ RECOMP_FLAGS_IN(); edx = MEM32(0x2B0EF0A4); /* 0x2B08342A: mov edx, dword ptr [0x2b0ef0a4] */ + /* Keep a different mission's marker; zero identity explicitly clears all. */ + if ((MEM32(ebp - 8) || MEM32(ebp - 4)) && + (MEM32(ebp - 8) != MEM32(MEM32(edx + 0x3C) + 0x14) || + MEM32(ebp - 4) != MEM32(MEM32(edx + 0x3C) + 0x18))) goto L_2B08343C; ecx = ebp + (-0x8); /* 0x2B083430: lea ecx, [ebp - 8] */ PUSH32(esp, ecx); /* 0x2B083433: push ecx */ ecx = MEM32(edx + 0x3C); /* 0x2B083434: mov ecx, dword ptr [edx + 0x3c] */ diff --git a/client/game/kkr.dll/lifted-0032.c b/client/game/kkr.dll/lifted-0032.c @@ -12240,6 +12240,18 @@ L_3606C0B8: ecx = eax; /* 0x3606C0C3: mov ecx, eax */ RECOMP_ICALL(0x3601C8C0u); /* 0x3606C0C5: call 0x3601c8c0 */ /* not lifted */ RECOMP_FLAGS_IN(); + /* Retire coordinates in the local map, planet map and compass modules. */ + const uint32_t modules[] = {0xEu, 0x1Cu, 0x1Fu}; + for (unsigned i = 0; i < 3; ++i) { + PUSH32(esp, MEM32(ebp + 0x8)); + PUSH32(esp, 0xAFu); + PUSH32(esp, modules[i]); + RECOMP_ICALL(MEM32(0x3616F304)); + RECOMP_FLAGS_IN(); + ecx = eax; + RECOMP_ICALL(MEM32(0x3616F30C)); + RECOMP_FLAGS_IN(); + } edi = POP32_VAL(esp); /* 0x3606C0CA: pop edi */ esi = POP32_VAL(esp); /* 0x3606C0CB: pop esi */ ebx = POP32_VAL(esp); /* 0x3606C0CC: pop ebx */ diff --git a/client/runtime/browser_testing.c b/client/runtime/browser_testing.c @@ -110,6 +110,27 @@ static void icon_grids(FILE *output, uint32_t head) fputc(']', output); } +static void mission_waypoints(FILE *output) +{ + /* BBR NewMapViewSprite_t::SetWaypoint stores one uploaded mission. */ + uint32_t view = MEM32(0x2b0eeb14), sprite = view ? MEM32(view + 0x5c) : 0; + fputs("{\"local\":[", output); + if (sprite && MEM8(sprite + 0xdc)) + fprintf(output, "[%u,%u]", MEM32(sprite + 0xc0), MEM32(sprite + 0xc4)); + fputs("],\"planet\":", output); + + /* DDR PlanetMapModule and BottomBarModule retain their own last upload. */ + if (MEM8(0x2b0ef07c)) + fprintf(output, "[%u,%u]", MEM32(0x2b0ef070), MEM32(0x2b0ef074)); + else fputs("null", output); + uint32_t bottom = MEM32(0x2b0ef0a4), compass = bottom ? MEM32(bottom + 0x3c) : 0; + fputs(",\"compass\":", output); + if (compass && MEM8(compass + 0x30)) + fprintf(output, "[%u,%u]", MEM32(compass + 0x14), MEM32(compass + 0x18)); + else fputs("null", output); + fputc('}', output); +} + static void actor(FILE *output, uint32_t object, uint32_t type, uint32_t id, int local) { uint32_t vehicle = MEM32(object + 0x60); @@ -243,6 +264,8 @@ void browser_test_frame(void) } fputs("],\"grids\":", output); icon_grids(output, head); + fputs(",\"missionWaypoints\":", output); + mission_waypoints(output); fputc('}', output); if (fclose(output)) abort(); ao_test_publish(json); diff --git a/client/tests/browser_testing.c b/client/tests/browser_testing.c @@ -24,6 +24,7 @@ static void snapshot_copies_native_state_without_changing_guest_registers(void) { guest_map("test engine", 0x2d010000, 0x10000); guest_map("test UI", 0x27040000, 0x10000); + guest_map("test action view", 0x2b0e0000, 0x10000); guest_map("test directory", 0x38060000, 0x10000); guest_map("test objects", 0x50000000, 0x10000); MEM32(0x2d01752c) = 0x50000000; @@ -121,7 +122,6 @@ static void snapshots_preserve_wrapped_weapon_results(void) static void completed_picks_record_the_query_pixel_and_result(void) { - guest_map("test action view", 0x2b0e0000, 0x10000); MEM32(0x2b0ee640) = 0x5000f000; MEM32(0x5000f010) = 0x5000f100; memcpy((void *)ADDR(0x5000f12c), (int32_t[]){13, 9, 814, 610}, 16); @@ -268,6 +268,38 @@ static void snapshots_record_dragged_identity_without_mutation(void) assert(strstr(snapshot, "\"dragged\":[0,0]")); } +static void snapshots_record_uploaded_mission_identities_without_mutation(void) +{ + MEM32(0x2b0eeb14) = 0x51002000; + MEM32(0x5100205c) = 0x51002100; + MEM8(0x510021dc) = 1; + MEM32(0x510021c0) = 56003; + MEM32(0x510021c4) = 17; + MEM8(0x2b0ef07c) = 1; + MEM32(0x2b0ef070) = 56003; + MEM32(0x2b0ef074) = 18; + MEM32(0x2b0ef0a4) = 0x51002300; + MEM32(0x5100233c) = 0x51002400; + MEM8(0x51002430) = 1; + MEM32(0x51002414) = 56003; + MEM32(0x51002418) = 19; + + browser_test_request(); + browser_test_frame(); + + assert(strstr(snapshot, "\"missionWaypoints\":{\"local\":[[56003,17]],\"planet\":[56003,18],\"compass\":[56003,19]}")); + assert(MEM8(0x510021dc) == 1 && MEM32(0x510021c4) == 17); + assert(MEM8(0x2b0ef07c) == 1 && MEM32(0x2b0ef074) == 18); + assert(MEM8(0x51002430) == 1 && MEM32(0x51002418) == 19); + assert(g_eax == 123 && g_esp == 456); + + /* Retired coordinates stay in memory but are no longer active markers. */ + MEM8(0x510021dc) = MEM8(0x2b0ef07c) = MEM8(0x51002430) = 0; + browser_test_request(); + browser_test_frame(); + assert(strstr(snapshot, "\"missionWaypoints\":{\"local\":[],\"planet\":null,\"compass\":null}")); +} + int main(void) { snapshot_copies_native_state_without_changing_guest_registers(); @@ -279,6 +311,7 @@ int main(void) snapshots_preserve_wrapped_weapon_results(); snapshots_record_visible_grid_cells_and_scroll_without_mutation(); snapshots_record_dragged_identity_without_mutation(); + snapshots_record_uploaded_mission_identities_without_mutation(); free(snapshot); puts("PASS: frame snapshots, native inventory, directory clearing and guest state preservation"); } diff --git a/client/tests/mission_expiry_notification.c b/client/tests/mission_expiry_notification.c @@ -0,0 +1,118 @@ +#include "recomp_types.h" +#include <assert.h> + +void sub_3606C060(void); +enum { manager = 0x50000000, actor = 0x50000200, identity = 0x50000400, + quest = 0x50000500, bus = 0x50000600 }; +static unsigned found, event, processed, removed, chats, completed, coordinates; + +static void find_quest(void) +{ + assert(g_ecx == manager && MEM32(g_esp + 4) == identity); + g_eax = found ? quest : 0; + g_esp += 8; +} + +static void process_event(void) +{ + assert(g_ecx == quest && MEM32(g_esp + 4) == event); + ++processed; + g_esp += 8; +} + +static void remove_quest(void) +{ + assert(g_ecx == manager && MEM32(g_esp + 4) == quest); + assert(MEM32(g_esp + 8) == (event == 1)); + ++removed; + g_esp += 12; +} + +static void format_text(void) +{ + assert(MEM32(g_esp + 8) == (event == 1 ? 0x361c3778 : 0x361c3760)); + g_esp += 4; +} + +static void get_bus(void) { g_eax = bus; g_esp += 4; } + +static void chat(void) +{ + assert(g_ecx == bus && MEM32(g_esp + 8) == 0); + ++chats; + g_esp += 12; +} + +static void completion_event(void) +{ + assert(g_ecx == bus && MEM32(g_esp + 4) == 0x2c); + assert(MEM32(g_esp + 8) == identity && MEM32(g_esp + 12) == 0); + ++completed; + g_esp += 16; +} + +static void remove_coordinates(void) +{ + const uint32_t modules[] = {0xe, 0x1c, 0x1f}; + assert(coordinates < 3); + assert(g_ecx == bus && MEM32(g_esp + 4) == modules[coordinates]); + assert(MEM32(g_esp + 8) == 0xaf && MEM32(g_esp + 12) == identity); + assert(MEM32(identity) == 56003 && MEM32(identity + 4) == 17); + ++coordinates; + g_esp += 16; +} + +recomp_func_t recomp_lookup_manual(uint32_t address) { return NULL; } +recomp_func_t recomp_lookup_import(uint32_t address) { abort(); } +recomp_func_t recomp_lookup(uint32_t address) +{ + switch (address) { + case 0x3606c1d0: return find_quest; + case 0x3610def0: return process_event; + case 0x3606be30: return remove_quest; + case 1: return format_text; + case 0x3601c590: case 2: return get_bus; + case 0x3601c8c0: return chat; + case 0x3601d080: return completion_event; + case 3: return remove_coordinates; + default: fprintf(stderr, "Unexpected expiry dependency: %08x\n", address); abort(); + } +} + +int main(void) +{ + assert(guest_map("expiry imports", 0x36160000, 0x10000)); + assert(guest_map("expiry objects and stack", 0x50000000, 0x10000)); + const struct { unsigned event, found, local; } cases[] = { + {1, 1, 1}, {1, 1, 0}, {1, 0, 1}, {2, 1, 1}, {2, 1, 0}, {3, 1, 1}, + }; + for (unsigned i = 0; i < sizeof(cases) / sizeof(cases[0]); ++i) { + event = cases[i].event; + found = cases[i].found; + processed = removed = chats = completed = coordinates = 0; + MEM32(0x3616f25c) = 1; + MEM32(0x3616f304) = 2; + MEM32(0x3616f30c) = 3; + MEM32(manager) = actor; + MEM8(actor + 0x128) = cases[i].local; + MEM32(identity) = 56003; + MEM32(identity + 4) = 17; + g_ecx = manager; + g_esp = 0x5000ff00; + MEM32(g_esp + 4) = identity; + MEM32(g_esp + 8) = event; + g_ebp = 123; g_ebx = 234; g_esi = 345; g_edi = 456; + g_fp_top = 8; + + sub_3606C060(); + + assert(processed == found); + assert(removed == (found && event <= 2)); + assert(chats == (found && cases[i].local && event <= 2)); + assert(completed == (found && cases[i].local && event == 2)); + assert(coordinates == 3 * (found && cases[i].local && event == 1)); + assert(g_esp == 0x5000ff0c && g_ebp == 123); + assert(g_ebx == 234 && g_esi == 345 && g_edi == 456 && g_fp_top == 8); + } + puts("mission expiry: local identity removal, original completion, unknown quests and guest ABI passed"); +} diff --git a/client/tests/mission_waypoint_removal.c b/client/tests/mission_waypoint_removal.c @@ -0,0 +1,110 @@ +#include "recomp_types.h" +#include <assert.h> + +void sub_2B081BB0(void); +void sub_2B083400(void); +void sub_250ABCF0(void); +enum { bus = 0x50000000, bottom = 0x50000100, compass = 0x50000200, + overview = 0x50000300, planet = 0x50000400, local = 0x50000500, + identity = 0x50000700 }; +static unsigned type, id, received, refreshed, cleared; + +static void get_bus(void) { g_eax = bus; g_esp += 4; } + +static void receive_identity(void) +{ + assert(g_ecx == bus); + uint32_t target = MEM32(g_esp + 4); + MEM32(target) = type; + MEM32(target + 4) = id; + ++received; + g_esp += 8; +} + +static void refresh_planet(void) +{ + assert(g_ecx == (refreshed ? planet : overview)); + assert(MEM8(0x2b0ef07c) == 0); + ++refreshed; + g_esp += 4; +} + +static void clear_compass(void) +{ + assert(g_ecx == compass); + uint32_t target = MEM32(g_esp + 4); + assert(MEM32(target) == type && MEM32(target + 4) == id); + MEM8(compass + 0x30) = 0; + ++cleared; + g_esp += 8; +} + +recomp_func_t recomp_lookup_manual(uint32_t address) { return NULL; } +recomp_func_t recomp_lookup_import(uint32_t address) { abort(); } +recomp_func_t recomp_lookup(uint32_t address) +{ + switch (address) { + case 1: return get_bus; + case 2: return receive_identity; + case 0x2b07e1e0: return refresh_planet; + case 0x2b076490: return clear_compass; + default: fprintf(stderr, "Unexpected waypoint dependency: %08x\n", address); abort(); + } +} + +int main(void) +{ + assert(guest_map("waypoint imports", 0x2b0b0000, 0x10000)); + assert(guest_map("waypoint globals", 0x2b0e0000, 0x10000)); + assert(guest_map("waypoint objects and stack", 0x50000000, 0x10000)); + const struct { unsigned type, id, views, removes; } cases[] = { + {56003, 17, 1, 1}, {56003, 18, 1, 0}, {56004, 17, 1, 0}, + {0, 0, 1, 1}, {0, 17, 1, 0}, {56003, 0, 1, 0}, + {56003, 17, 0, 1}, {56003, 18, 0, 0}, + }; + for (unsigned i = 0; i < sizeof(cases) / sizeof(cases[0]); ++i) { + type = cases[i].type; + id = cases[i].id; + received = refreshed = cleared = 0; + MEM32(0x2b0b53cc) = 1; + MEM32(0x2b0b53ac) = 2; + MEM32(0x2b0ef070) = MEM32(compass + 0x14) = 56003; + MEM32(0x2b0ef074) = MEM32(compass + 0x18) = 17; + MEM8(0x2b0ef07c) = MEM8(compass + 0x30) = 1; + MEM32(0x2b0ef078) = cases[i].views ? overview : 0; + MEM32(0x2b0ef094) = cases[i].views ? planet : 0; + MEM32(0x2b0ef0a4) = cases[i].views ? bottom : 0; + MEM32(bottom + 0x3c) = compass; + MEM32(local + 0xc0) = 56003; + MEM32(local + 0xc4) = 17; + MEM8(local + 0xdc) = 1; + MEM32(identity) = type; + MEM32(identity + 4) = id; + g_esp = 0x5000ff00; + g_ebp = 123; g_ebx = 234; g_esi = 345; g_edi = 456; + g_fp_top = 8; + + sub_2B081BB0(); + assert(g_esp == 0x5000ff04); + g_esp = 0x5000ff00; + sub_2B083400(); + assert(g_esp == 0x5000ff04); + g_esp = 0x5000ff00; + MEM32(g_esp + 4) = identity; + g_ecx = local; + sub_250ABCF0(); + + assert(MEM8(0x2b0ef07c) == !cases[i].removes); + assert(MEM8(compass + 0x30) == !(cases[i].removes && cases[i].views)); + assert(received == 1 + cases[i].views); + assert(refreshed == 2 * cases[i].removes * cases[i].views); + assert(cleared == cases[i].removes * cases[i].views); + assert(MEM32(0x2b0ef070) == 56003 && MEM32(0x2b0ef074) == 17); + assert(MEM32(compass + 0x14) == 56003 && MEM32(compass + 0x18) == 17); + assert(MEM8(local + 0xdc) == !cases[i].removes); + assert(MEM32(local + 0xc0) == 56003 && MEM32(local + 0xc4) == 17); + assert(g_esp == 0x5000ff08 && g_ebp == 123); + assert(g_ebx == 234 && g_esi == 345 && g_edi == 456 && g_fp_top == 8); + } + puts("mission waypoints: identity/type selection, clear-all, absent views and guest ABI passed"); +} diff --git a/docs/mission-retirement.md b/docs/mission-retirement.md @@ -114,11 +114,61 @@ five controlled generation fees left level1/XP0 and zero credits. Only the owned test character was removed afterward, with unrelated-row hashes and SQLite foreign-key/integrity checks preserved. -Native expiry still leaves an uploaded white waypoint visible until reconnect. -The recovered consumer explicitly emits waypoint-clear UI event0x2c for -completion event2, not expiry event1. This does not establish the original -server's complete notification sequence. Keep the UI cleanup gap open rather -than sending a false completion event. +The original expiry consumer `kkr.dll!1006c060` removes the contract and reports +"Quest expired.." for event1, but emits no coordinate-removal notification +(`ev_e034ea9e1e5bc92de71c0838e0c59e0568e7797ab06505793e6362876b3372a6`). +Its event2 UI event0x2c is completion-specific: it reaches AFCM message0x13e, +`ddr.dll!QuestViewModule_t::MissionCompletedMessage` and command0x29. It is not a +generic waypoint-clear event and must not be sent for expiry. + +All three original map modules register AFCM message0xaf for +`RemoveMissionCoordsMessage`. The local map's BBR sprite, planet map and bottom +bar compass each store just one uploaded identity; uploading another contract +replaces it. Original removal ignores the supplied identity in all three +consumers. The relevant original symbols/addresses are +`bbr.dll!NewMapViewSprite_t::{SetWaypoint,RemoveWaypoint}` at100abc70/100abcf0, +`ddr.dll!PlanetMapModule_t::{UploadMissionCoordsMessage,RemoveMissionCoordsMessage}` +at10081b40/10081bb0 and +`ddr.dll!BottomBarModule_t::{UploadMissionCoordsMessage,RemoveMissionCoordsMessage}` +at10083370/10083400. BBR retains the identity at sprite+c0/c4, the planet module +at globals100ef070/100ef074 and the compass at widget+14/18. Original replacement +uses identity0/0 to clear the previous marker explicitly. + +The maintained client sends message0xaf with the expired identity to the three +registered module IDs0x0e,0x1c,0x1f after the existing local event1 notification. +Removal now checks both identity words +in all three consumers, preserving another mission's marker and the explicit +0/0 reset. This repairs the retained expiry UI defect without adding a server +completion event. It does not establish the original live server's complete +expiry notification sequence. Original evidence is retained in +`local/mission-waypoint-expiry/{kkr,ddr,bbr}-evidence.json`: KKR SHA256 +`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`, DDR +`3c937161de8f690351c3c08e158431417cee9ced77a41b677e7123b61a8c9883`, BBR +`28f196f650edbb1573fb874ccaf7746453d3e4a183e1d86db1d790c1c32ecc2c`. +The three module constructor registrations at10056b30,100818f0,100830e0 are +retained separately in `local/mission-waypoint-expiry/ddr-module-evidence.json`. + +The controlled regression `TestBrowserMissionWaypointExpiry` accepts two +contracts through production code, bypassing only the one-live-contract admission +limit, and advances their production expiry at controlled deadlines. Real journal +input uploads B; expiry A removes its key/journal entry while preserving B in all +three marker stores. Expiry B clears the stores and rendered white X. The exact +two wire events are version1/type56003/IDs2,3/event1; neither is completion2. +The original axe, three remaining credits, level1/XP0 and learned nanos survive +page replay and cold Go loading. This is fixture evidence, not earned progression +or proof of normal multiple-contract admission. The final test passed in 12.38s; +six clean traces, screenshots, accounting and SQLite checkpoint are retained in +`local/mission-waypoint-expiry/20261103-162855/`. + +Native entry regressions cover all three recipient modules, matching and unrelated +identities/types, explicit0/0 reset, absent views, unknown quests, unchanged +completion routing and guest stack/register preservation. Both Linux memory +layouts and standalone WASM pass, as does the semantic snapshot regression. +The 21 related Go retirement/completion roots (106 results) and `go vet ./server` +also pass. The original expiry captures remain in +`local/mission-retirement/event-expiry-*`; the corrected-driver negative capture +at `local/mission-waypoint-expiry/20261103-162338/` retains both real expiry events +and the stale B marker from the incorrect single-module routing. One terminal-opening run aborted before generation/acceptance, with no useful stack retained by its initial recorder. The recorder now captures native diff --git a/server/browser_mission_waypoint_expiry_test.go b/server/browser_mission_waypoint_expiry_test.go @@ -0,0 +1,112 @@ +package main + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "reflect" + "runtime" + "slices" + "testing" + "time" +) + +func TestBrowserMissionWaypointExpiry(t *testing.T) { + if os.Getenv("AO_GAME_TEST") != "1" { + t.Skip("set AO_GAME_TEST=1 for mission waypoint expiry") + } + + _, source, _, _ := runtime.Caller(0) + root := filepath.Dir(filepath.Dir(source)) + output := filepath.Join(root, "local/mission-waypoint-expiry", time.Now().Format("20060102-150405")) + world, _ := newMissionOfferWorld(t) + player, client := world.characters[1], world.clients[1] + expectedItems := slices.Clone(player.inventory.Items) + expectedReferences := player.inventory.references() + expectedReferences.Credits = 3 + expectedNanos := slices.Clone(player.inventory.LearnedNanos) + + // Controlled fixture: bypass only the one-live-mission admission limit. Both + // contracts and keys still pass production acceptance and database writes. + var accepted []acceptedMission + for index := range 2 { + player.missions = nil + if err := world.handleMissionOffers(client, missionOffersRequest()); err != nil { + t.Fatal(err) + } + client.missionOffer.seed = uint32(index + 1) + if err := world.handleMissionAcceptance(client, missionAcceptanceRequest(*client.missionOffer)); err != nil { + t.Fatal(err) + } + if len(player.missions) != 1 { + t.Fatal("controlled contract was not accepted") + } + accepted = append(accepted, player.missions[0]) + } + player.missions = accepted + for index := range accepted { + accepted[index].expiresAt = time.Now().UTC().Add(time.Duration(index+1) * 24 * time.Hour) + world.missionExpiry[index].expiresAt = accepted[index].expiresAt + if _, err := world.db.Exec("UPDATE missions SET expires_at=? WHERE id=?", accepted[index].expiresAt.Format(time.RFC3339Nano), accepted[index].id); err != nil { + t.Fatal(err) + } + } + player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("mission-waypoint-expiry"))) + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + if err := world.db.Close(); err != nil { + t.Fatal(err) + } + world = newServerForTest(t) + + // Advance only production mission expiry at each controlled deadline. + mux := http.NewServeMux() + mux.Handle("/", world.httpHandler()) + mux.HandleFunc("GET /test-state", func(w http.ResponseWriter, r *http.Request) { + world.mutex.Lock() + defer world.mutex.Unlock() + player := world.characters[1] + missions := []uint32{} + for _, mission := range player.missions { + missions = append(missions, mission.id) + } + json.NewEncoder(w).Encode(map[string]any{"missions": missions, "inventory": player.inventory, + "level": player.level, "experience": player.experience}) + }) + for index, name := range []string{"a", "b"} { + mux.HandleFunc("POST /test-expire/"+name, func(w http.ResponseWriter, r *http.Request) { + world.advanceMissions(accepted[index].expiresAt) + w.WriteHeader(http.StatusNoContent) + }) + } + host := httptest.NewServer(mux) + t.Cleanup(host.Close) + closeTestBrowserStreams(t, world) + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) + defer cancel() + + command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_mission_waypoint_expiry.mjs"), host.URL, output) + command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr + if err := command.Run(); err != nil { + t.Fatal(err) + } + if _, err := world.db.Exec("VACUUM INTO ?", filepath.Join(output, "world.sqlite")); err != nil { + t.Fatal(err) + } + cold := newTestInventoryServer(t) + + player = cold.characters[1] + if len(player.missions) != 0 || len(cold.missionExpiry) != 0 || player.inventory.Credits != 3 || + player.level != 1 || player.experience != 0 || !slices.Equal(player.inventory.Items, expectedItems) || + !reflect.DeepEqual(player.inventory.references(), expectedReferences) || !slices.Equal(player.inventory.LearnedNanos, expectedNanos) { + t.Fatalf("cold expiry changed unrelated ownership or rewarded progress: %+v", player.userData()) + } + t.Logf("Browser artifacts: %s", output) +} diff --git a/tools/client/test_mission_waypoint_expiry.mjs b/tools/client/test_mission_waypoint_expiry.mjs @@ -0,0 +1,133 @@ +import assert from 'node:assert/strict'; +import fs from 'node:fs/promises'; +import {createRequire} from 'node:module'; +import {GameTest} from './game_test.mjs'; + +const {chromium} = createRequire(import.meta.url)('playwright'); +const [url, output] = process.argv.slice(2); +const browser = await chromium.launch({executablePath: '/usr/bin/chromium', args: [ + '--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage', + '--disable-background-timer-throttling', '--disable-renderer-backgrounding']}); +let game; +const evidence = {}; + +try { + const context = await browser.newContext({viewport: {width: 1280, height: 900}}); + await context.addCookies([{name: 'ao_client', value: 'mission-waypoint-expiry', url}]); + const page = await context.newPage(); + game = await GameTest.attach(page); + const server = async () => (await page.request.get(url + '/test-state')).json(); + const contains = (identities, id) => identities.some(([type, identity]) => type === 56003 && identity === id); + await page.goto(url); + await game.ready(); + await page.waitForFunction(() => touchRegion(500, 400)?.world === true); + await game.snapshot(); + evidence.initial = await server(); + const [a, b] = evidence.initial.missions; + assert.equal(evidence.initial.missions.length, 2); + assert.equal(evidence.initial.inventory.Credits, 3); + assert.deepEqual(game.state.screen, [1280, 900]); + const unrelated = evidence.initial.inventory.Items.filter(item => item.ID !== a && item.ID !== b); + assert.equal(unrelated.length, 1); + + // Upload B while A remains a distinct accepted contract. + await page.keyboard.down('Control'); + try { await game.key('Digit4'); } + finally { await page.keyboard.up('Control'); } + await game.click(1193, 10); + await game.save(output + '/journal'); + const cell = game.state.grids.flatMap(grid => grid.cells).find(cell => + cell.identity[0] === 56003 && cell.identity[1] === b); + assert(cell, `mission ${b} has no journal icon`); + const x = (cell.bounds[0] + cell.bounds[2]) / 2; + const y = (cell.bounds[1] + cell.bounds[3]) / 2; + const icon = await game.point(x, y); + const upload = await game.point(x - 50, y + 38); + await page.mouse.move(icon.x, icon.y); + const regions = (await game.snapshot()).regions.length; + let sequence = game.sequence; + await page.mouse.down({button: 'right'}); + try { + await game.waitInput(sequence, 1025); + await game.wait('held mission icon opens its action menu', state => state.regions.length > regions); + await game.save(output + '/upload-b-menu'); + await page.mouse.move(upload.x, upload.y); + await game.snapshot(); + } finally { + sequence = game.sequence; + await page.mouse.up({button: 'right'}); + } + await game.waitInput(sequence, 1026); + await game.wait('B uploaded to local map, planet map and compass', state => + JSON.stringify(state.missionWaypoints.local) === JSON.stringify([[56003, b]]) && + JSON.stringify(state.missionWaypoints.planet) === JSON.stringify([56003, b]) && + JSON.stringify(state.missionWaypoints.compass) === JSON.stringify([56003, b])); + await game.save(output + '/uploaded-b'); + evidence.uploaded = game.state.missionWaypoints; + + // Expiring A must preserve B's uploaded marker everywhere. + const expiryStart = game.sequence; + assert((await page.request.post(url + '/test-expire/a')).ok()); + await game.wait('A expired while B retains all three waypoints', state => + !contains(state.grids.flatMap(grid => grid.cells.map(cell => cell.identity)), a) && + !game.local(state).inventory.some(item => item.id === a) && + !contains(state.missionWaypoints.local, a) && contains(state.missionWaypoints.local, b) && + JSON.stringify(state.missionWaypoints.planet) === JSON.stringify([56003, b]) && + JSON.stringify(state.missionWaypoints.compass) === JSON.stringify([56003, b])); + evidence.afterA = await server(); + evidence.waypointsAfterA = game.state.missionWaypoints; + assert(!contains(game.state.grids.flatMap(grid => grid.cells.map(cell => cell.identity)), a)); + assert(contains(game.state.grids.flatMap(grid => grid.cells.map(cell => cell.identity)), b)); + assert(!game.local().inventory.some(item => item.id === a)); + assert(game.local().inventory.some(item => item.id === b)); + assert.deepEqual(evidence.afterA.missions, [b]); + assert.deepEqual(evidence.afterA.inventory.Items, evidence.initial.inventory.Items.filter(item => item.ID !== a)); + assert.equal(evidence.afterA.inventory.Credits, 3); + assert.equal(evidence.afterA.level, 1); + assert.equal(evidence.afterA.experience, 0); + await game.save(output + '/expired-a'); + + // Expiring the selected contract clears its remaining native map consumers. + assert((await page.request.post(url + '/test-expire/b')).ok()); + await game.wait('B expired and every mission waypoint cleared', state => + !contains(state.grids.flatMap(grid => grid.cells.map(cell => cell.identity)), b) && + !game.local(state).inventory.some(item => item.id === b) && + !contains(state.missionWaypoints.local, a) && !contains(state.missionWaypoints.local, b) && + state.missionWaypoints.planet === null && state.missionWaypoints.compass === null); + evidence.afterB = await server(); + evidence.waypointsAfterB = game.state.missionWaypoints; + assert(!contains(game.state.grids.flatMap(grid => grid.cells.map(cell => cell.identity)), b)); + assert(!game.local().inventory.some(item => item.id === b)); + assert.deepEqual(evidence.afterB.missions, []); + assert.deepEqual(evidence.afterB.inventory.Items, unrelated); + assert.equal(evidence.afterB.inventory.Credits, 3); + assert.equal(evidence.afterB.level, 1); + assert.equal(evidence.afterB.experience, 0); + const expiryPackets = game.events.filter(event => event.sequence > expiryStart && + event.direction === 'framereceived' && event.opcode === '5f2e1b19'); + evidence.expiryEvents = expiryPackets.map(event => { + const packet = Buffer.from(event.hex, 'hex'); + return [packet.readUInt32BE(29), packet.readUInt32BE(33), packet.readUInt32BE(37), packet.readUInt32BE(41)]; + }); + assert.deepEqual(evidence.expiryEvents, [[1, 56003, a, 1], [1, 56003, b, 1]]); + await game.save(output + '/expired-b'); + + // A page replay restores neither retired contract and preserves ownership. + await page.reload(); + await game.ready(); + await page.waitForFunction(() => touchRegion(500, 400)?.world === true); + await game.snapshot(); + await game.wait('page replay has no retired mission waypoints', state => + !contains(state.missionWaypoints.local, a) && !contains(state.missionWaypoints.local, b) && + state.missionWaypoints.planet === null && state.missionWaypoints.compass === null); + evidence.replayed = await server(); + assert.deepEqual(evidence.replayed, evidence.afterB); + assert.deepEqual(game.errors, []); + console.log('PASS: native mission uploads, selective expiry, final waypoint cleanup and page replay without rewards'); +} finally { + try { + await fs.mkdir(output, {recursive: true}); + await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n'); + if (game) await game.save(output + '/final'); + } finally { await browser.close(); } +}