aorecomp

Anarchy Online classic in the browser

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


commit 677a43b5c858bebbe30b67cfa9218d14dc23894c
parent 25c2047107c7b31e539f40a6f14698f2920b3a21
Author: anon <anon@example.com>
Date:   Thu, 29 Oct 2026 11:41:58 +0000

Bind starter missions to original backyard entrances

Diffstat:
MTODO.md | 22++++++++++++----------
Adocs/starter-missions.md | 132+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/gamedata/missions.yaml | 534++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Aserver/gamedata/starter_missions_test.go | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/mission_offers_test.go | 7+++++--
Aserver/starter_missions_test.go | 270+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 1001 insertions(+), 17 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -65,7 +65,9 @@ cold recovery and accepted sale passed with an earned part and controlled tool funds; ordinary funding and higher-QL recipe rules remain open. See [Blood Plasma](docs/blood-plasma.md). Starter mission contracts can now be browsed, accepted, abandoned and expired, -with durable journals and bound keys. A fixed private interior supports real +with durable journals and bound keys. All 130 original starter booths now bind +the shared provisional recipe to their own original local entrance; see +[starter missions](docs/starter-missions.md). A fixed private interior supports real entry, traversal, reconnect and return. Its bound book can be collected and survives restart without respawning. Returning that exact book to its issuing booth now completes the fixed contract and atomically grants authored cash @@ -1770,15 +1772,15 @@ client rendering fixes and checks are in [nano damage](docs/nano-damage.md). Cold server/client reconnect retains the fee and an empty accepted journal. Narrative, reward amounts and duration are provisional; acceptance is separate. See [mission offers](docs/mission-offers.md). -- [ ] [P0] Make a starter mission available from each supported starter backyard. - The recipe table currently contains only booth 3221228472 in backyard 3000; - mapped booths such as 3221228482 in backyard 3010 have no generation recipe. - The earned level-4 character's harder-mission check therefore required a city - trip from Backyard 11 to Backyard 1. Recover the original booth/Surveillance - Office pairings and reuse the shared recipe/instance rules with each authored - exterior, rather than adding per-backyard handlers or inventing doorway IDs. - Verify fresh-character access, faction/level gates, independent private worlds, - fees, acceptance/return, expiry and cold ownership from multiple backyards. +- [x] [P0] Make a starter mission available from each supported starter backyard. + All 130 original starter booths now share one provisional recipe, bound to + their original local Surveillance Office, Abandoned House or Subway Entrance. + Original IDs, float32 coordinates and template admission are audited; handlers + remain shared. Tests cover fees, selected rewards, independent private worlds, + entry/return, wrong-booth rejection, exactly-once hand-in, abandonment, expiry + and cold ownership across Omni, Neutral and Clan backyard ranges. + See [starter missions](docs/starter-missions.md) for evidence and native checks. + Historical generation, narrative, population and reward policy remain open. - [x] Accept that mission. Check: its journal entry and assigned destination survive reconnect. Native CreateQuest0x291f361b/version2 validates the session's exact offered diff --git a/docs/starter-missions.md b/docs/starter-missions.md @@ -0,0 +1,132 @@ +# Shared starter backyard missions + +Every authored starter booth now offers the same bounded, provisional Find Item +contract. All 130 bindings use the original matching entrance in that backyard. +The contract's description directs the player to its local waypoint and issuing +booth. Difficulty, fees, admission, saved private worlds, objective ownership, +selected-quality rewards and retirement use the existing shared handlers. + +## Original placements + +A fresh format-aware audit of all original 14.9.1 resource 1000026 statel lists +found 130 template 118128 booths. Each has exactly one same-ID type 56006 entrance +in the same playfield. The repeated numeric identity belongs to different +object types; the booth and entrance remain separate objects. + +| Original entrance name | Placements | Template | Exterior XYZ | +| --- | ---: | ---: | --- | +| Surveillance Office | 60 | 84130 | 89.30216217, 115.14443970, 151.16087341 | +| Abandoned House | 48 | 84130 | 45.70357513, 25.37343216, 47.70779037 | +| Subway Entrance | 22 | 84131 | 72.90743256, 37.53480911, 95.98035431 | + +Names, mesh/style overrides, original transforms and record/resource hashes +are retained in `local/starter-missions/original-pairings.json`. The resource +index SHA256 is +`46e5dc54af9358cc9bff05f4358e86af630e497bc677f361c133c88073b84d71`. +The catalog regression's ordered binding digest independently matches those +original IDs, playfields and float32 coordinates: +`33bdb1c3898844d5dcfe848436c21e386f0cf4ec63b82e05de231ddb88d7b2a0`. + +The three YAML anchors share one recipe and the three original exterior layouts. +An original Subway Entrance name does not turn this private Find Item contract +into the separate public Subway dungeon. The selected interior, Leet population, +book objective, reward pool, amounts and duration remain reconstruction policy; +these placements do not recover the original mission generator. + +## Admission and ownership + +The original starter template 118128 has no faction or level Use criteria. +Its placement supplies OriginatorType 490 and style 801/802; originator 1/3/5 is +not a faction number. Existing range, life/session, inventory-space and context +checks still apply. Generation independently rejects unsupported encounter +levels and insufficient funds before charging. City terminals remain outside +this fixed starter recipe catalog. + +Acceptance saves the exact issuing booth, exterior, selected reward and private +world. Entry validates that saved contract's key against its original entrance. +Completion consumes only its exact objective and keys; another backyard's booth +cannot settle it. Abandonment and expiry return occupants using that entrance's +original orientation without changing another owner's world or contract. + +## Verification + +The catalog checks all 130 original pairings and shared recipe fields. Handler +checks cover the first and another Omni backyard, both Neutral backyard ranges +and the first Clan backyard. They exercise generation fees, selected QL rewards, +saved encounters, entry/exit, wrong-booth rejection, exactly-once hand-in, +abandonment/expiry, original template admission and independent owners with +cold recovery. Existing shared mission failure/rollback and session tests also +remain applicable. + +### Ordinary Neutral character + +A fresh Neutral Atrox Enforcer used normal Options creation and its original +training-ground 954 / return-backyard 3060 assignment. Native purchases spent 206 +of its 1,500 issued IP, training Stamina 13, Agility 9, Body Development 10, 1HB 10, +Evade Close 9 and Treatment 7. Its issued bat remained the only weapon. Two +full-health level-1 Leets each awarded 100 XP; the first corpse expired unclaimed +during camera positioning. The second corpse transferred three credits. Its +generated Monster Part was not picked up, so it is not counted as owned loot. +Four laboratory charges were used during preparation/recovery; this is observed +consumption, not a minimum healing cost. + +The character walked back to Newland Backyard 1. The original local booth +3221228532 charged one earned credit and advertised QL 1 gloves. Acceptance saved +mission 177 / world 65553 with that backyard's original Subway Entrance. Normal +entry, traversal, book 178 pickup, exit and hand-in consumed only key 177 / book 178, +awarded 20 credits and created gloves 179 at QL 1. + +The qualified reward equipped through the native inventory before any reconnect. +Its live AddTemplate representation has no instance ID, uses the exact QL 1 +endpoint 85596/85596 and occupies worn slot 24. All eight native AC values became 1; +the persistent item remains 179. A page reconnect reconstructed that same real +identity, with all five issued instances, worn bat 173, lab 170 / count 21, 84 HP, +22 credits, 1,294 IP and 200 XP intact. No stats, items, cash, positions, enemies, +rolls or outcomes were supplied through admin edits. + +### Ordinary Clan character + +A fresh Clan Atrox Enforcer started in training-ground 952 with its six issued +items, including its Merit Board. Normal skill purchases spent 206 IP on the +same preparation as the Neutral run. Two laboratory charges were consumed. +Its issued bat defeated one full-health level-1 Leet for 100 XP; opening the +corpse transferred three credits. Its generated Monster Part remained unclaimed. +The character then walked through the original training return into Tir Backyard 1. + +Booth 3221228572 charged one credit and advertised the QL 1 Advanced Baseballbat. +Mission 187 / world 65554 retained that choice and its local Abandoned House. +Normal entry, traversal, book 188 pickup, exit and hand-in consumed only its +key/book, awarded 20 credits and delivered weapon 189. All six issued instances +remained owned; the balance was 22 credits with 100 XP and 1,294 IP. + +Unqualified wear reported a minimum Dimach requirement of 6 and retained the +reward. The skill window +refused Dimach training at Sense 3; normal purchases raised Sense to 4 and +Dimach to 6 for 29 IP. After removing issued bat 183 into inventory, reward 189 +equipped in right-hand slot 6 before reconnect. All seven instances remained +owned, with laboratory 180 / count 23 and 1,265 IP. These checks use ordinary +native controls without admin changes or substituted rewards. + +### Regression and restart checks + +The complete server/data regression passed 1,710 test roots / 16,720 results. +Mission/world-pickup race checks passed 169 roots / 1,043 results. After the city +rejection fixture was strengthened to satisfy its original Omni admission gate, +that case separately passed under the race detector (one root / 25 results). +Vet and the development-server build passed. + +Both ordinary characters retained their exact item identities, slots, charges, +quality, cash, XP and IP after a page reconnect. The single preview then stopped +and flushed normally. A private SQLite backup preceded a cold restart of the +same binary. Every player character record, wallet, item/location, mission, +mission encounter and learned nano matched across restart; database integrity +and foreign-key checks passed. The retained evidence is under +`local/starter-missions/`, including `original-pairings.json`, +`tests-verified.json`, native command/probe/screenshot logs and `cold-restart.json`. + +Fresh GPU WASM sessions after that server restart loaded both retained +characters. Native inventories matched every saved instance, slot, charge count +and exact QL 1 endpoint. Neutral gloves remained worn with all eight AC values +at 1; the Clan reward remained the right-hand weapon and its issued bat remained +in inventory. Both retained their cash, XP, IP and full 84 HP, with no page errors +or native aborts. Test browser processes were closed after verification. diff --git a/server/gamedata/missions.yaml b/server/gamedata/missions.yaml @@ -1,14 +1,15 @@ -# Fixed starter reconstruction; narrative and rewards are provisional. -# Exterior position: original 14.9.1 Surveillance Office, type56006/3221228472. +# Shared starter reconstruction; narrative, layout, encounters and rewards are provisional. +# Each binding retains its original 14.9.1 type56006 entrance and exterior position. # Objective: original QL1 Blue Book of Secrets40822, a documented mission item. -3221228472: +3221228472: &starter description: |- Recover the Blue Book of Secrets - Locate the Blue Book of Secrets inside the Surveillance Office and recover it. + Recover the Blue Book of Secrets from the marked mission location. Return it to the mission booth where you accepted this contract. Pick up the book in your inventory and use it on that booth to collect your reward. - The entrance is in Omni-1 Entertainment Backyard 1, near the mission booth. + The entrance is in this backyard, near the mission booth. + Follow the mission waypoint to find it. playfield: 3000 entrance: 3221228472 position: [89.30216217041016, 115.14443969726562, 151.16087341308594] @@ -32,3 +33,526 @@ - [15, 0, 36] - [15, 0, 28] - [15, 1, 20] + +3221228473: + <<: *starter + playfield: 3001 + entrance: 3221228473 +3221228474: + <<: *starter + playfield: 3002 + entrance: 3221228474 +3221228475: + <<: *starter + playfield: 3003 + entrance: 3221228475 +3221228476: + <<: *starter + playfield: 3004 + entrance: 3221228476 +3221228477: + <<: *starter + playfield: 3005 + entrance: 3221228477 +3221228478: + <<: *starter + playfield: 3006 + entrance: 3221228478 +3221228479: + <<: *starter + playfield: 3007 + entrance: 3221228479 +3221228480: + <<: *starter + playfield: 3008 + entrance: 3221228480 +3221228481: + <<: *starter + playfield: 3009 + entrance: 3221228481 +3221228482: + <<: *starter + playfield: 3010 + entrance: 3221228482 +3221228483: + <<: *starter + playfield: 3011 + entrance: 3221228483 +3221228484: + <<: *starter + playfield: 3012 + entrance: 3221228484 +3221228485: + <<: *starter + playfield: 3013 + entrance: 3221228485 +3221228486: + <<: *starter + playfield: 3014 + entrance: 3221228486 +3221228487: + <<: *starter + playfield: 3015 + entrance: 3221228487 +3221228488: + <<: *starter + playfield: 3016 + entrance: 3221228488 +3221228489: + <<: *starter + playfield: 3017 + entrance: 3221228489 +3221228490: + <<: *starter + playfield: 3018 + entrance: 3221228490 +3221228491: + <<: *starter + playfield: 3019 + entrance: 3221228491 +3221228492: + <<: *starter + playfield: 3020 + entrance: 3221228492 +3221228493: + <<: *starter + playfield: 3021 + entrance: 3221228493 +3221228494: + <<: *starter + playfield: 3022 + entrance: 3221228494 +3221228495: + <<: *starter + playfield: 3023 + entrance: 3221228495 +3221228496: + <<: *starter + playfield: 3024 + entrance: 3221228496 +3221228497: + <<: *starter + playfield: 3025 + entrance: 3221228497 +3221228498: + <<: *starter + playfield: 3026 + entrance: 3221228498 +3221228499: + <<: *starter + playfield: 3027 + entrance: 3221228499 +3221228500: + <<: *starter + playfield: 3028 + entrance: 3221228500 +3221228501: + <<: *starter + playfield: 3029 + entrance: 3221228501 +3221228502: + <<: *starter + playfield: 3030 + entrance: 3221228502 +3221228503: + <<: *starter + playfield: 3031 + entrance: 3221228503 +3221228504: + <<: *starter + playfield: 3032 + entrance: 3221228504 +3221228505: + <<: *starter + playfield: 3033 + entrance: 3221228505 +3221228506: + <<: *starter + playfield: 3034 + entrance: 3221228506 +3221228507: + <<: *starter + playfield: 3035 + entrance: 3221228507 +3221228508: + <<: *starter + playfield: 3036 + entrance: 3221228508 +3221228509: + <<: *starter + playfield: 3037 + entrance: 3221228509 +3221228510: + <<: *starter + playfield: 3038 + entrance: 3221228510 +3221228511: + <<: *starter + playfield: 3039 + entrance: 3221228511 +3221228512: + <<: *starter + playfield: 3040 + entrance: 3221228512 +3221228513: + <<: *starter + playfield: 3041 + entrance: 3221228513 +3221228514: + <<: *starter + playfield: 3042 + entrance: 3221228514 +3221228515: + <<: *starter + playfield: 3043 + entrance: 3221228515 +3221228516: + <<: *starter + playfield: 3044 + entrance: 3221228516 +3221228517: + <<: *starter + playfield: 3045 + entrance: 3221228517 +3221228518: + <<: *starter + playfield: 3046 + entrance: 3221228518 +3221228519: + <<: *starter + playfield: 3047 + entrance: 3221228519 +3221228520: + <<: *starter + playfield: 3048 + entrance: 3221228520 +3221228521: + <<: *starter + playfield: 3049 + entrance: 3221228521 +3221228522: + <<: *starter + playfield: 3050 + entrance: 3221228522 +3221228523: + <<: *starter + playfield: 3051 + entrance: 3221228523 +3221228524: + <<: *starter + playfield: 3052 + entrance: 3221228524 +3221228525: + <<: *starter + playfield: 3053 + entrance: 3221228525 +3221228526: + <<: *starter + playfield: 3054 + entrance: 3221228526 +3221228527: + <<: *starter + playfield: 3055 + entrance: 3221228527 +3221228528: + <<: *starter + playfield: 3056 + entrance: 3221228528 +3221228529: + <<: *starter + playfield: 3057 + entrance: 3221228529 +3221228530: + <<: *starter + playfield: 3058 + entrance: 3221228530 +3221228531: + <<: *starter + playfield: 3059 + entrance: 3221228531 + +# Original Subway Entrance placements. +3221228532: &backyard_3060 + <<: *starter + playfield: 3060 + entrance: 3221228532 + position: [72.90743255615234, 37.53480911254883, 95.98035430908203] +3221228533: + <<: *backyard_3060 + playfield: 3061 + entrance: 3221228533 +3221228534: + <<: *backyard_3060 + playfield: 3062 + entrance: 3221228534 +3221228535: + <<: *backyard_3060 + playfield: 3063 + entrance: 3221228535 +3221228536: + <<: *backyard_3060 + playfield: 3064 + entrance: 3221228536 +3221228537: + <<: *backyard_3060 + playfield: 3065 + entrance: 3221228537 +3221228538: + <<: *backyard_3060 + playfield: 3066 + entrance: 3221228538 +3221228539: + <<: *backyard_3060 + playfield: 3067 + entrance: 3221228539 +3221228540: + <<: *backyard_3060 + playfield: 3068 + entrance: 3221228540 +3221228541: + <<: *backyard_3060 + playfield: 3069 + entrance: 3221228541 +3221228542: + <<: *backyard_3060 + playfield: 3070 + entrance: 3221228542 +3221228543: + <<: *backyard_3060 + playfield: 3071 + entrance: 3221228543 +3221228552: + <<: *backyard_3060 + playfield: 3080 + entrance: 3221228552 +3221228553: + <<: *backyard_3060 + playfield: 3081 + entrance: 3221228553 +3221228554: + <<: *backyard_3060 + playfield: 3082 + entrance: 3221228554 +3221228555: + <<: *backyard_3060 + playfield: 3083 + entrance: 3221228555 +3221228556: + <<: *backyard_3060 + playfield: 3084 + entrance: 3221228556 +3221228557: + <<: *backyard_3060 + playfield: 3085 + entrance: 3221228557 +3221228558: + <<: *backyard_3060 + playfield: 3086 + entrance: 3221228558 +3221228559: + <<: *backyard_3060 + playfield: 3087 + entrance: 3221228559 +3221228560: + <<: *backyard_3060 + playfield: 3088 + entrance: 3221228560 +3221228561: + <<: *backyard_3060 + playfield: 3089 + entrance: 3221228561 + +# Original Abandoned House placements. +3221228572: &backyard_3100 + <<: *starter + playfield: 3100 + entrance: 3221228572 + position: [45.703575134277344, 25.373432159423828, 47.70779037475586] +3221228573: + <<: *backyard_3100 + playfield: 3101 + entrance: 3221228573 +3221228574: + <<: *backyard_3100 + playfield: 3102 + entrance: 3221228574 +3221228575: + <<: *backyard_3100 + playfield: 3103 + entrance: 3221228575 +3221228576: + <<: *backyard_3100 + playfield: 3104 + entrance: 3221228576 +3221228577: + <<: *backyard_3100 + playfield: 3105 + entrance: 3221228577 +3221228578: + <<: *backyard_3100 + playfield: 3106 + entrance: 3221228578 +3221228579: + <<: *backyard_3100 + playfield: 3107 + entrance: 3221228579 +3221228580: + <<: *backyard_3100 + playfield: 3108 + entrance: 3221228580 +3221228581: + <<: *backyard_3100 + playfield: 3109 + entrance: 3221228581 +3221228582: + <<: *backyard_3100 + playfield: 3110 + entrance: 3221228582 +3221228583: + <<: *backyard_3100 + playfield: 3111 + entrance: 3221228583 +3221228584: + <<: *backyard_3100 + playfield: 3112 + entrance: 3221228584 +3221228585: + <<: *backyard_3100 + playfield: 3113 + entrance: 3221228585 +3221228586: + <<: *backyard_3100 + playfield: 3114 + entrance: 3221228586 +3221228587: + <<: *backyard_3100 + playfield: 3115 + entrance: 3221228587 +3221228588: + <<: *backyard_3100 + playfield: 3116 + entrance: 3221228588 +3221228589: + <<: *backyard_3100 + playfield: 3117 + entrance: 3221228589 +3221228592: + <<: *backyard_3100 + playfield: 3120 + entrance: 3221228592 +3221228593: + <<: *backyard_3100 + playfield: 3121 + entrance: 3221228593 +3221228594: + <<: *backyard_3100 + playfield: 3122 + entrance: 3221228594 +3221228595: + <<: *backyard_3100 + playfield: 3123 + entrance: 3221228595 +3221228596: + <<: *backyard_3100 + playfield: 3124 + entrance: 3221228596 +3221228597: + <<: *backyard_3100 + playfield: 3125 + entrance: 3221228597 +3221228598: + <<: *backyard_3100 + playfield: 3126 + entrance: 3221228598 +3221228599: + <<: *backyard_3100 + playfield: 3127 + entrance: 3221228599 +3221228600: + <<: *backyard_3100 + playfield: 3128 + entrance: 3221228600 +3221228601: + <<: *backyard_3100 + playfield: 3129 + entrance: 3221228601 +3221228602: + <<: *backyard_3100 + playfield: 3130 + entrance: 3221228602 +3221228603: + <<: *backyard_3100 + playfield: 3131 + entrance: 3221228603 +3221228604: + <<: *backyard_3100 + playfield: 3132 + entrance: 3221228604 +3221228605: + <<: *backyard_3100 + playfield: 3133 + entrance: 3221228605 +3221228606: + <<: *backyard_3100 + playfield: 3134 + entrance: 3221228606 +3221228607: + <<: *backyard_3100 + playfield: 3135 + entrance: 3221228607 +3221228608: + <<: *backyard_3100 + playfield: 3136 + entrance: 3221228608 +3221228609: + <<: *backyard_3100 + playfield: 3137 + entrance: 3221228609 +3221228610: + <<: *backyard_3100 + playfield: 3138 + entrance: 3221228610 +3221228611: + <<: *backyard_3100 + playfield: 3139 + entrance: 3221228611 +3221228612: + <<: *backyard_3100 + playfield: 3140 + entrance: 3221228612 +3221228613: + <<: *backyard_3100 + playfield: 3141 + entrance: 3221228613 +3221228614: + <<: *backyard_3100 + playfield: 3142 + entrance: 3221228614 +3221228615: + <<: *backyard_3100 + playfield: 3143 + entrance: 3221228615 +3221228616: + <<: *backyard_3100 + playfield: 3144 + entrance: 3221228616 +3221228617: + <<: *backyard_3100 + playfield: 3145 + entrance: 3221228617 +3221228618: + <<: *backyard_3100 + playfield: 3146 + entrance: 3221228618 +3221228619: + <<: *backyard_3100 + playfield: 3147 + entrance: 3221228619 +3221228620: + <<: *backyard_3100 + playfield: 3148 + entrance: 3221228620 +3221228621: + <<: *backyard_3100 + playfield: 3149 + entrance: 3221228621 diff --git a/server/gamedata/starter_missions_test.go b/server/gamedata/starter_missions_test.go @@ -0,0 +1,53 @@ +package gamedata + +import ( + "crypto/sha256" + "encoding/binary" + "fmt" + "math" + "reflect" + "slices" + "testing" +) + +func TestStarterMissionsCoverOriginalBackyardEntrances(t *testing.T) { + var identities []uint32 + for id := range MissionTemplates { + identities = append(identities, id) + } + slices.Sort(identities) + digest := sha256.New() + + for _, id := range identities { + mission := MissionTemplates[id] + var data []byte + for _, value := range []uint32{id, mission.Playfield, mission.Entrance} { + data = binary.BigEndian.AppendUint32(data, value) + } + for _, value := range mission.Position { + data = binary.BigEndian.AppendUint32(data, math.Float32bits(value)) + } + digest.Write(data) + } + + if len(identities) != 130 || fmt.Sprintf("%x", digest.Sum(nil)) != "33bdb1c3898844d5dcfe848436c21e386f0cf4ec63b82e05de231ddb88d7b2a0" { + t.Fatal("starter recipes do not match all 130 original booth/entrance pairings") + } + for id, booth := range MissionBooths { + mission, exists := MissionTemplates[id] + if exists != (booth.Template == 118128) { + t.Fatal("starter recipe is missing or attached to a city booth", id) + } + if !exists { + continue + } + if mission.Playfield != booth.Playfield || Playfields[mission.Playfield].Unavailable { + t.Fatal("starter recipe has an unavailable or foreign backyard", id) + } + base := MissionTemplates[3221228472] + mission.Playfield, mission.Entrance, mission.Position = base.Playfield, base.Entrance, base.Position + if !reflect.DeepEqual(mission, base) { + t.Fatal("starter backyard overrides the shared mission rules", id) + } + } +} diff --git a/server/mission_offers_test.go b/server/mission_offers_test.go @@ -57,8 +57,11 @@ func TestMissionOffersRejectInvalidRequestsWithoutCharges(t *testing.T) { binary.BigEndian.PutUint32(request[33:37], 42) empty = true case "unsupported booth": - binary.BigEndian.PutUint32(request[33:37], 3221228509) - player.playfield, empty = 3037, true + binary.BigEndian.PutUint32(request[33:37], 3221357254) + booth := gamedata.MissionBooths[3221357254] + player.playfield, player.position = booth.Playfield, booth.Position + player.appearance = player.appearance&^(3<<9) | 2<<9 + request[28], empty = 3, true case "far": player.position[0], empty = 110, true case "other playfield": diff --git a/server/starter_missions_test.go b/server/starter_missions_test.go @@ -0,0 +1,270 @@ +package main + +import ( + "ao/server/gamedata" + "encoding/binary" + "fmt" + "math" + "reflect" + "testing" + "time" +) + +var starterMissionBackyards = []struct { + booth uint32 + originator byte + playfield uint32 + returnPosition [3]float32 +}{ + {3221228472, 5, 3000, [3]float32{89.30216, 115.14444, 153.66087}}, + {3221228482, 5, 3010, [3]float32{89.30216, 115.14444, 153.66087}}, + {3221228532, 1, 3060, [3]float32{75.40743, 37.53481, 95.98035}}, + {3221228552, 1, 3080, [3]float32{75.40743, 37.53481, 95.98035}}, + {3221228572, 3, 3100, [3]float32{48.203575, 25.373432, 47.70779}}, +} + +func newBackyardMissionWorld(t *testing.T, boothID uint32) (*server, *combatTestConn) { + t.Helper() + world, output := newEquipmentWorld(t) + t.Cleanup(func() { world.db.Close() }) + world.geometry = missionGeometryFixture(t) + world.geometry.models = make(map[uint32]collisionSphere) + world.nextNPC = 2000000 + world.combatRoll = func(uint32) uint32 { return 0 } + player, booth := world.characters[1], gamedata.MissionBooths[boothID] + player.playfield, player.position, player.geometry = booth.Playfield, booth.Position, world.geometry + player.inventory.Credits = 5 + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + if err := world.saveInventory_locked(player, player.inventory); err != nil { + t.Fatal(err) + } + output.packets = nil + return world, output +} + +func TestStarterMissionBackyardsCompleteAtTheirOwnBooths(t *testing.T) { + for _, backyard := range starterMissionBackyards { + t.Run(fmt.Sprint(backyard.playfield), func(t *testing.T) { + world, _ := newBackyardMissionWorld(t, backyard.booth) + player, client := world.characters[1], world.clients[1] + request := missionOffersRequest() + request[28] = backyard.originator + binary.BigEndian.PutUint32(request[33:37], backyard.booth) + + if err := world.handleMissionOffers(client, request); err != nil { + t.Fatal(err) + } + if client.missionOffer == nil { + t.Fatal("authored starter booth has no offer") + } + if err := world.handleMissionAcceptance(client, missionAcceptanceRequest(*client.missionOffer)); err != nil { + t.Fatal(err) + } + cold := reloadMissionEntranceWorld(t) + mission := player.missions[0] + + if player.inventory.Credits != 4 || len(player.inventory.Items) != 2 || mission.world != 65536 || + mission.offer.booth != backyard.booth || mission.offer.originator != backyard.originator || + mission.offer.definition.Playfield != backyard.playfield || mission.offer.definition.Entrance != backyard.booth || + mission.offer.definition.RewardItem != 85596 || mission.offer.definition.RewardQuality != 1 || + !reflect.DeepEqual(mission, cold.characters[1].missions[0]) || len(cold.mobileNPCs[mission.world]) != 5 { + t.Fatal("starter fee, selected reward, exterior or population changed on acceptance/restart", mission) + } + + player.position = mission.offer.definition.Position + if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil { + t.Fatal(err) + } + client.ready, world.clients[1] = true, client + objective := world.worldItems[player.missions[0].objective] + player.position, player.movement = objective.position, playerMovement{} + if err := world.handleInventory(client, worldPickupRequest(1, player.missions[0].objective)); err != nil { + t.Fatal(err) + } + player.position = world.geometry.mission(mission.world).exitPosition + if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil { + t.Fatal(err) + } + + if player.playfield != backyard.playfield { + t.Fatal("mission exit selected a different backyard", player.playfield) + } + for axis, expected := range backyard.returnPosition { + if math.Abs(float64(player.position[axis]-expected)) > .001 { + t.Fatal("mission exit lost the original entrance transform", player.position) + } + } + + client.ready, world.clients[1] = true, client + player.position = gamedata.MissionBooths[backyard.booth].Position + returned := missionReturnRequest(1) + wrongBooth := uint32(3221228472) + if backyard.booth == wrongBooth { + wrongBooth = 3221228482 + } + binary.BigEndian.PutUint32(returned[52:56], wrongBooth) + if err := world.handleMissionReturn(client, returned); err != nil { + t.Fatal(err) + } + if len(player.missions) != 1 || len(player.inventory.Items) != 3 || player.inventory.Credits != 4 { + t.Fatal("another backyard's booth consumed the objective or awarded a reward") + } + binary.BigEndian.PutUint32(returned[20:24], 2) + binary.BigEndian.PutUint32(returned[52:56], backyard.booth) + if err := world.handleMissionReturn(client, returned); err != nil { + t.Fatal(err) + } + binary.BigEndian.PutUint32(returned[20:24], 3) + if err := world.handleMissionReturn(client, returned); err != nil { + t.Fatal(err) + } + cold = reloadMissionEntranceWorld(t) + + if player.inventory.Credits != 24 || len(player.missions) != 0 || player.experience != 0 || + !reflect.DeepEqual(player.inventory, cold.characters[1].inventory) || len(player.inventory.Items) != 2 || + player.inventory.Items[1] != (ownedItem{ID: 4, Type: 51022, Template: 85596, Quality: 1, Count: 1, Slot: 65}) || + !cold.missionExpiry[0].completed || cold.characters[1].playfield != backyard.playfield { + t.Fatal("starter hand-in lost or duplicated a selected reward or retained its key/book", player.inventory) + } + }) + } +} + +func TestStarterMissionBackyardsRetireToTheirOwnEntrances(t *testing.T) { + for _, backyard := range starterMissionBackyards { + for _, expiry := range []bool{false, true} { + t.Run(fmt.Sprintf("%d/expiry=%v", backyard.playfield, expiry), func(t *testing.T) { + world, _ := newBackyardMissionWorld(t, backyard.booth) + player, client := world.characters[1], world.clients[1] + request := missionOffersRequest() + request[28] = backyard.originator + binary.BigEndian.PutUint32(request[33:37], backyard.booth) + if err := world.handleMissionOffers(client, request); err != nil { + t.Fatal(err) + } + if client.missionOffer == nil { + t.Fatal("authored starter booth has no offer") + } + if err := world.handleMissionAcceptance(client, missionAcceptanceRequest(*client.missionOffer)); err != nil { + t.Fatal(err) + } + mission := player.missions[0] + player.position = mission.offer.definition.Position + if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil { + t.Fatal(err) + } + client.ready, world.clients[1] = true, client + + if expiry { + world.advanceMissions(mission.expiresAt.Add(time.Second)) + } else if err := world.handleMissionRemoval(client, missionRemovalPacket(1, mission.id)[20:]); err != nil { + t.Fatal(err) + } + cold := reloadMissionEntranceWorld(t) + + if player.playfield != backyard.playfield || len(player.missions) != 0 || len(player.inventory.Items) != 1 || + player.inventory.Credits != 4 || len(cold.missionExpiry) != 0 || len(cold.mobileNPCs[mission.world]) != 0 || + !reflect.DeepEqual(player.userData(), cold.characters[1].userData()) { + t.Fatal("starter retirement lost its exterior or retained rewards/assignment/population", player.userData()) + } + for axis, expected := range backyard.returnPosition { + if math.Abs(float64(player.position[axis]-expected)) > .001 { + t.Fatal("retirement lost the original entrance transform", player.position) + } + } + }) + } + } +} + +func TestStarterMissionBoothsPreserveOriginalTemplateAdmission(t *testing.T) { + for _, backyard := range starterMissionBackyards { + t.Run(fmt.Sprint(backyard.playfield), func(t *testing.T) { + world, output := newBackyardMissionWorld(t, backyard.booth) + player, client := world.characters[1], world.clients[1] + sequence := uint32(0) + + // Original template118128 has no faction or level Use criteria. + for _, level := range []uint16{1, 26} { + for side := uint16(0); side <= 2; side++ { + player.level = level + player.appearance = player.appearance&^(3<<9) | side<<9 + sequence++ + if err := world.handleMissionBoothUse(client, missionBoothUseRequest(backyard.booth, sequence)); err != nil { + t.Fatal(err) + } + } + } + + if len(output.packets) != 6 || player.inventory.Credits != 5 || len(player.inventory.Items) != 1 || len(player.missions) != 0 { + t.Fatal("opening a starter booth changed ownership or allocated a mission") + } + for _, packet := range output.packets { + if binary.BigEndian.Uint32(packet[29:33]) != 1 { + t.Fatal("starter booth acquired an unauthored faction/level restriction", packet) + } + } + }) + } +} + +func TestStarterMissionBackyardsKeepIndependentOwnersAcrossRetirement(t *testing.T) { + world, _ := newBackyardMissionWorld(t, 3221228482) + data := world.characters[1].userData() + data.ID, data.Name = 2, "Other backyard owner" + data.Playfield, data.Position = 3100, gamedata.MissionBooths[3221228572].Position + other := data.character() + other.geometry, other.inventory.Credits = world.geometry, 5 + world.characters[2] = other + world.clients[2] = &worldClient{id: 2, target: true, ready: true, conn: &combatTestConn{}} + if err := world.saveUser_locked(other); err != nil { + t.Fatal(err) + } + if err := world.saveInventory_locked(other, other.inventory); err != nil { + t.Fatal(err) + } + + for _, owner := range []struct { + id, booth uint32 + originator byte + }{{1, 3221228482, 5}, {2, 3221228572, 3}} { + client := world.clients[owner.id] + request := missionOffersRequest() + binary.BigEndian.PutUint32(request[8:12], owner.id) + binary.BigEndian.PutUint32(request[33:37], owner.booth) + request[28] = owner.originator + if err := world.handleMissionOffers(client, request); err != nil { + t.Fatal(err) + } + if client.missionOffer == nil { + t.Fatal("another backyard's accepted mission blocked generation", owner.id) + } + request = missionAcceptanceRequest(*client.missionOffer) + binary.BigEndian.PutUint32(request[8:12], owner.id) + if err := world.handleMissionAcceptance(client, request); err != nil { + t.Fatal(err) + } + player := world.characters[owner.id] + player.position = player.missions[0].offer.definition.Position + if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil { + t.Fatal(err) + } + client.ready, world.clients[owner.id] = true, client + } + cold := reloadMissionEntranceWorld(t) + retained := other.userData() + if err := world.handleMissionRemoval(world.clients[1], missionRemovalPacket(1, 2)[20:]); err != nil { + t.Fatal(err) + } + retired := reloadMissionEntranceWorld(t) + + if cold.characters[1].playfield != 65536 || cold.characters[2].playfield != 65537 || + cold.characters[1].missions[0].offer.definition.Playfield != 3010 || cold.characters[2].missions[0].offer.definition.Playfield != 3100 || + retired.characters[1].playfield != 3010 || len(retired.characters[1].missions) != 0 || + !reflect.DeepEqual(retained, retired.characters[2].userData()) || len(retired.mobileNPCs[65536]) != 0 || + len(retired.mobileNPCs[65537]) != 5 || len(retired.characters[2].missions) != 1 || retired.characters[2].inventory.Credits != 4 { + t.Fatal("backyard bindings merged owners, changed their exterior or retired another assignment") + } +}