From 8c8682a0dd0eb1e9c5311214464bbcee406b1941 Mon Sep 17 00:00:00 2001 From: Oscar Bailey <79094698+ozgb@users.noreply.github.com> Date: Mon, 30 Nov 2026 08:52:22 +0000 Subject: [PATCH 1/3] Update: Pin the orders spec to interfaces-v109 Assisted-by: Claude:claude-sonnet-5-5 --- specs/orders.md | 80 +++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/specs/orders.md b/specs/orders.md index 4b4c467..d04de73 100644 --- a/specs/orders.md +++ b/specs/orders.md @@ -45,7 +45,7 @@ and 9.1): - `name` and `interface`: `orders`. - `majors`: `orders` 6, `movement` 5, `units` 7, `scripts` 3, `weapons` 4, `map` 9, `network` 2, `los_radar` 5, - `features` 5, `targeting` 4, `mission` 2, `services` 4. + `features` 5, `targeting` 4, `mission` 2, `economy` 5, `services` 4. - `data_base` 458752 (0x70000) and `table_base` 304: the module's window of `window` (32768) bytes and its `table_slots` table entries (ABI 2.2 and 2.3). Everything the module keeps outside the block (none between calls: ABI section 12) and every buffer it passes to an import lies in that window. @@ -125,6 +125,7 @@ and only its low byte is used. | `map.SnapWorldPosToFootprint` | `[block, linear] -> void` | `MobileBuild`, `VTOL_MobileBuild`: the build site | | `map.CanPlaceFootprintAt` | `[block, linear] -> int` | `VTOL_LandIfCan` | | `map.IsPadSlotFree` | `[block, int] -> int` | "the landing pad search", `VTOL_Landing` state 6 | +| `map.PickRandomReclaimableResourcesInRadius` | `[linear, int, linear, linear, linear, linear] -> int` | "the reclaim pick": `RepairPatrol`, `VTOL_RepairPatrol` | | `map.GetGroundHeight` | `[linear] -> int` | "the site point", "the feature box", `VTOL_LandIfCan`, `VTOL_Reclaim` | | `network.SendFeatureReclaimed` | `[block, int, int] -> void` | `Resurrect` state 5, in game type 3 | | `network.SendScriptCall` | `[block, int, int, int, int, int, int] -> int` | "start the building script", "stop the building script" | @@ -149,16 +150,16 @@ and only its low byte is used. The recordings carry `services.Emit` as `services.SchedPublish 3 ` (3 is orders' outbox), `targeting.FindBestTargetIfFireAtWill` as `services.ScheduleTargetingFireAtWill`, `targeting.GetWeaponTargetUnit` as `services.ScheduleTargetingTargetUnit`, `map.CanPlaceUnitFootprint` as -`services.ScheduleMapCanPlaceUnitFootprint` and `economy.RequestGranted` as `services.ScheduleEconomyRequestGranted` -(ABI 9.3, "Routes in the recordings"). A line of the last gives the unit and the resources, then the answer: +`services.ScheduleMapCanPlaceUnitFootprint`, `economy.RequestGranted` as `services.ScheduleEconomyRequestGranted` and +`map.PickRandomReclaimableResourcesInRadius` as `services.ScheduleMapPickReclaimable` (ABI 9.3, "Routes in the recordings"). +A line of `economy.RequestGranted` gives the unit and the resources, then the answer: `i services.ScheduleEconomyRequestGranted Unit#2 3 = 1` (`orders-weapon-build.txt`, tick 700). -**A call that is not in the entry.** Section 4 names one more call, "the reclaim pick" -(`map.PickRandomReclaimableResourcesInRadius`, whose signature the manifest has under `signatures.map`, and which -`docs/schedule.md` lists among the imports of `orders.RunOrders`), in `RepairPatrol` and `VTOL_RepairPatrol`. It is -not an import of the entry above, and the module imports the entry's imports and nothing else (ABI 9.1). It is a kit -gap ("Gaps in the kit"): the rows of section 4 that use it are the behaviour, and no recording of orders reaches the -call (section 7). The host runs the engine's native orders for a `blocked` entry (ABI 4.2). +The recording of the reclaim pick is `i services.ScheduleMapPickReclaimable = ` followed by the four +lines `o energy`, `o energyAmount`, `o metal` and `o metalAmount` (ABI 9.3, the paragraph on the pick). Two +recordings reach it: `mission-build-unit.txt`, tick 121 (radius 13107200, answer 0, both points `null` and both amounts 0), and +`mission-kill-of-type.txt`, tick 128 (radius 15728640, answer 1: energy at (46661632, 13107200) with amount +`f32:0x41c80000`, metal at (46661632, 9961472) with amount `f32:0x42480000`). The module makes no draw for the pick (section 4, "The reclaim pick"). The host runs the engine's native orders for a `blocked` entry (ABI 4.2). - Hooks: `interfaces/orders.h` names AllowBuild, AircraftSeekRepair, GuardResponse and IdleBuilderAction on `RunOrders`, and AllowCommand on `GetOrderType` and on the event kind COMMAND; every other slot says "Hooks: @@ -347,12 +348,13 @@ and *end* (the block offset one past the storage), each a `Ref` stored as a bloc `value` and `name` are text the engine slot sets: the `name` and `value` columns of the table below, as the recordings carry them (`r SimGlobals.g_missionOrderTableVec[K].name "..."`, a text line). The module never writes them. `name` is a `char *` (`layout.json`), so the word holds the linear address of the kind's zero-terminated name, -not a block offset: the replayer allocates each recorded string and stores its address in the word -(`docs/replay-format.md`, the field of kind `cstring`). The module reads the bytes for the comparison of +not a block offset: in a WASM replay, as in a WASM game, it is an address of the load data region, where the host has +placed the recorded text and where it stays unchanged for the match (`docs/orders-interface.md`, "The order type table's text +words"; `docs/replay-format.md`, the field of kind `cstring`). The module reads the bytes for the comparison of `MissionTypeFromName` only; it never keeps the address or changes the bytes. No slot of orders reads `value`. **Which behaviour runs.** `notify` is an engine code address: the module never calls through it or computes with -it. The engine slot fills the table identically every game, so the behaviour of an order of kind K is the +it. The engine slot fills the table identically in every recorded game, so there the behaviour of an order of kind K is the `orderNotify` index j that the table below gives for K (the recordings write the field as that index, `r SimGlobals.g_missionOrderTableVec[K].notify orderNotify[j]`); `data/replay_schema.json` (`annotations.code_tables.orderNotify.entries`) names entry j by the order type it stands for. Section 4, "Order @@ -526,7 +528,13 @@ Each term is defined once; section 4 uses it by its name, in quotes where the na menu update arguments `[U.id]` are U's index in the unit array. - **Order type names.** A rule that names an order type by a string, such as `MOBILEBUILD`, means the index that `MissionTypeFromName` gives that string at the moment the rule uses it (0, `Ready`, when the table lacks it). The - indices of the recordings' table are given in brackets: `MOBILEBUILD` (`MobileBuild`, 25). The rule is the name. + indices of the recordings' table are given in brackets: `MOBILEBUILD` (`MobileBuild`, 25). The rule is the name, and the + number is only that of the recordings' table: the table is in the order of its names, so a table with other entries (a + mod's) gives a kind another index. Every kind this spec names, in a row, a heading or a bracket, is found by its name at + the moment it is used; a module that compared with the recorded numbers would differ on `mission-passes-z-renumbered.txt`, + which is `mission-passes-z.txt` with two entries added to its table, `Aa_Extra` at 1 and `Bu_Extra` at 13, and every kind + after each one up by one (`BuildingBuild` is 14 there). The run of an order is the `notify` word of the table entry at + the order's own kind, never a number fixed by the module. - **A kind byte** is a 32-bit payload field truncated to its low 8 bits, as an index in the order type table. - **whole(v)**: the high 16 bits of a 32-bit word, as a signed 16-bit value (`Unit.xWhole` is whole(`Unit.posX`), `Unit.zWhole` whole(`Unit.posZ`)). @@ -807,8 +815,7 @@ SET_BUILD_STATE, and orders' COMMAND, CLEAR_NET_DIRTY, UNLINK) are written out w - **The feature box**: lo = (cell.x << 20, *h* << 16, cell.y << 20) with *h* = `map.GetGroundHeight` of lo (its y word not set before the call); hi = lo + (`F.footprintX` << 20, `F.height` << 16, `F.footprintZ` << 20), wrapping. - **The reclaim pick (P, r)** answers four things: an energy point and amount and a metal point and amount. It is a - call to map, `map.PickRandomReclaimableResourcesInRadius(P, r, &E, &eAmount, &M, &mAmount)` (an import the entry - does not list yet: "Gaps in the kit"): P a `Vec3` passed by address; E and M two words of the module that hold, + call to map, `map.PickRandomReclaimableResourcesInRadius(P, r, &E, &eAmount, &M, &mAmount)` (an import of the entry, section 2): P a `Vec3` passed by address; E and M two words of the module that hold, before the call, the linear addresses of two `Vec3` records of the module; eAmount and mAmount two floats. For a kind the pick found, map writes the chosen point's `x` and `z` into the record the word points at (its `y` is never set, so it is not compared), writes the amount into the float, and leaves the word as it is; for a kind it found nothing @@ -1813,7 +1820,10 @@ Every run starts with the site cell and size (one `features.FindFeatureAtPos`), | state 5 | features' RECLAIM 35 (20): `unit` *U*, `pos` `O.pos` | none | 5 | | any other state | none | none | 7 | -The time: `F.energy` + `F.metal` summed in double, times 0.5, plus 15, then ftol. Recorded: unrecorded. +The time: `F.energy` + `F.metal` summed in double, times 0.5, plus 15, then ftol. Recorded: `orders-reclaim-feature.txt`, `Unit#1`, `Order#1`. Tick 243, state 4: CLEAR_NET_DIRTY (12), then +`features.FindFeatureAtPos (41943040,65536,17039360) = 1` (cell (40,16), size (1,1)); `ticks` becomes −2, `wakeFrame` 245, `state` 5. +Tick 245, state 5: CLEAR_NET_DIRTY, the find again, features' RECLAIM 35 (20 bytes), then the order ends (the stop-building script +call and a new default order). #### `ReclaimUnit` (kind 33) @@ -1951,7 +1961,9 @@ index is its offset from `Game.cells` divided by 13; "mod" and "div" truncate. ` low 16 bits, unsigned. With `D.buildRate` below 30 the divisor is 0.0, the quotient an infinity or a NaN, and ftol gives 0: `radius` is 0. The SET_ANGLES uses the spot of the cell the import answers without testing it, and a cell feature of 0xfffb or more ends the order with N already made (Q32). Failure answers: `CreateUnit` 0 keeps the state at 5 (the next run retries); `GetGameType` is only -compared with 3. Recorded: unrecorded. +compared with 3. Recorded: `orders-tier2-core.txt`, `Unit#3`, `Order#2`. Tick 614: CLEAR_NET_DIRTY, the find (answer 204, cell (38,14), +size (4,4)), the nano point, one `map.GetGroundHeight`, one `RecordSimEvent` of kind 3, a 12-byte publish; `wakeFrame` 615. Tick 615: +the find twice, then `units.CreateUnit 0 246 (41943040,65536,17039360) 0 1 0 = Unit#2`, whose fields the recording gives as `o` lines. #### `SelfDestruct` (kind 38) and `SelfDestructFG` (kind 39) @@ -2327,7 +2339,9 @@ Otherwise, when `F.flags` lacks 0x80: result 8. | 4 | | features' RECLAIM 35 (20): `unit` *U*, `pos` `O.pos` | 5 | | other | | none | 7 | -Recorded: unrecorded. +Recorded: `mission-kill-of-type.txt`, tick 128, `Unit#304`, `Order#198`, made by the `VTOL_RepairPatrol` run of the same call: +`features.FindFeatureAtPos (46661632,0,9961472) = 22` (cell (44,8), size (2,2)), a 12-byte and a 16-byte publish, the find again, +`movement.NewPathOrderAt Order#198 (46661632,0,9961472) = PathOrder#3`, a 12-byte publish; `state` 2, `attached` `PathOrder#3`, `flags` 224. #### `VTOL_ReclaimUnit` (kind 59) @@ -2381,7 +2395,10 @@ The state 1 run. It always starts with a path target to `O.pos`, SET_ALTITUDE (* | none of the above, the reclaim pick (`U.pos`, 0xf00000) answers 1 and a reclaim row gives X | the diversion's test; the repair test's; the pick; release the target; a new order (`VTOL_RECLAIM` (`VTOL_Reclaim`, 58), no target, position X, 0, 0, 0) at the front | `flags` becomes 0 | 3 | | otherwise | the diversion's test; the repair test's; the pick | none | 2 | -The pick is asked whatever the resources are. Recorded: unrecorded. +The pick is asked whatever the resources are. Recorded: `mission-kill-of-type.txt`, tick 128, `Unit#304`, `Order#197` (the pick's +answer 1 with energy and metal both found: the order made is `VTOL_Reclaim`, `Order#198`, at the position of the metal point (46661632, 0, +9961472) with `y` 0). In the same call the new order runs its first pass; the call ends with `Order#197`'s `state` 1 and `wakeFrame` 172. +`mission-build-unit.txt`, tick 121 shows the pick answering 0 (section 2). #### `VTOL_RepairUnit` (kind 61) @@ -2821,20 +2838,19 @@ other modes run inside `ExpandGroupCommand` and inside runs); an order in `Unit. runs of `Ready`, `Activate`, `AirToAir`, `AirToGround`, `AirToGroundHover`, `Attack_Kamikaze`, `Attack_NoMove`, `AttackSpecial`, `AttackUType`, `Capture`, `Cloak_Off`, `Cloak_On`, `Deactivate`, `MakeSelectable`, `Paralyze`, `Park`, `Patrol`, `QMove`, -`QPatrol`, `Reclaim`, `RepairUnit`, `RepairUnitNoMove`, `Resurrect`, `SelfDestruct`, `SelfDestructFG`, +`QPatrol`, `RepairUnit`, `RepairUnitNoMove`, `SelfDestruct`, `SelfDestructFG`, `Standby_Mine`, `Standing_FireOrder`, `Standing_MoveOrder`, `Stop`, `Suppress`, `Teleport`, `VTOL_Evade`, -`VTOL_GetRepaired`, `VTOL_HelpBuild`, `VTOL_MobileBuild`, `VTOL_Move`, `VTOL_Reclaim`, -`VTOL_ReclaimUnit`, `VTOL_RepairPatrol`, `VTOL_Unload`, `Wait` and +`VTOL_GetRepaired`, `VTOL_HelpBuild`, `VTOL_MobileBuild`, `VTOL_Move`, +`VTOL_ReclaimUnit`, `VTOL_Unload`, `Wait` and `WaitForAttack`; and of the recorded kinds, `SelfRepair` state 0, `BeCarried` state 0, the `RepairPatrol` reclaim and `VTOL_Patrol` with a pad diversion or a target. `Ground_Unload` is recorded in state 1 only. QUEUE_BUILD (`mission-passes-z.txt` tick 30), ATTACKED (`mission-build-unit.txt` ticks 73 and 74) and `GetOrderFlags` (`mission-build-unit.txt` ticks 73 and 74) are recorded as calls of their own. -No recording calls 10 of the entry's 53 imports: `movement.NewPathOrderToUnitAt`, `movement.NewAirManeuverOrder`, -`units.GetFactoriesInRadius`, `scripts.GetPieceOffset`, `network.SendFeatureReclaimed`, -`network.SendScriptCallByName`, `los_radar.GetOriginCellAtPosition`, `features.GetCellFeature`, -`features.FindFeatureAtPos` and `mission.GetGameType`. The kit gives the reason for each (`data/replay_schema.json`, -`annotations.subsystems.orders.unrecorded_imports`; `docs/replay-format.md`). Its list has twelve names: the other two, +No recording calls 6 of the entry's 54 imports: `movement.NewPathOrderToUnitAt`, `movement.NewAirManeuverOrder`, +`units.GetFactoriesInRadius`, `scripts.GetPieceOffset`, `network.SendFeatureReclaimed` and +`network.SendScriptCallByName`. The kit gives the reason for each (`data/replay_schema.json`, +`annotations.subsystems.orders.unrecorded_imports`; `docs/replay-format.md`). Its list has eight names: the other two, `movement.LoadTarget` and `units.LoadUnit`, are calls of the engine's `LoadOrders` (load class), not imports of the entry. The recordings route can't judge a call of them; only the scenarios would, and those are not played while the entry is blocked ("Gaps in the kit"). @@ -2842,15 +2858,9 @@ scenarios would, and those are not played while the entry is blocked ("Gaps in t - **Payloads by size.** The recordings carry each publish as `services.SchedPublish 3 `, without its fields, so the gate compares an effect by its size and by what its subscribers write (the `o` lines after it), not by its payload. -- **The reclaim pick.** `RepairPatrol` and `VTOL_RepairPatrol` choose resources to reclaim through - `map.PickRandomReclaimableResourcesInRadius`, which the manifest has under `signatures.map` but the entry does not - import, and no row of ABI 9.3's table maps a recorded call to it. The kit records map's slot (`docs/replay-format.md`, - the map recordings, with the `outptr` and `scalar` out argument forms), but no recording of - orders carries the call. The pick's choice and draws are map's; until the entry lists the import, a module can't make - the call (section 2, "A call that is not in the entry"). - **A blocked entry.** `blocked` is `true` in the kit's manifest, so the entry has no `fuel_budget` and no `size_budget` until the kit sets them; the gate judges a module of it on the recordings route (ABI 4.2, section 15), with `scenarios: not_judged`. -- **Unrecorded imports.** The 10 imports of section 7 that no recording calls have no recorded argument or answer form, +- **Unrecorded imports.** The 6 imports of section 7 that no recording calls have no recorded argument or answer form, so no check judges them while the entry is blocked. - **Fields no recording carries.** No recording has a line of a `UnitTypeSet` (`bits`), `Cell` (`feature`, `offsetX`, `offsetY`, `spot`), `Feature` or `FeatureSpot` field. An object an import answers starts zeroed in the replay @@ -2867,6 +2877,6 @@ scenarios would, and those are not played while the entry is blocked ("Gaps in t ## 8. Kit version -Kit `interfaces-v84` and `reference-traces-v58`, the versions the gate judges against. Interface `orders` 6.2. The +Kit `interfaces-v109` and `reference-traces-v65`, the versions the gate judges against. Interface `orders` 6.2. The imports are against `movement` 5, `units` 7, `scripts` 3, `weapons` 4, `map` 9, `network` 2, `los_radar` 5, `features` 5, `targeting` 4, `mission` 2, `economy` 5 and `services` 4. From 227849a0f0a6ceec96a23591852d9a006f24205e Mon Sep 17 00:00:00 2001 From: Oscar Bailey <79094698+ozgb@users.noreply.github.com> Date: Mon, 30 Nov 2026 08:57:18 +0000 Subject: [PATCH 2/3] Fix: Give the VTOL_Reclaim recording in order Assisted-by: Claude:claude-sonnet-5-5 --- specs/orders.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/orders.md b/specs/orders.md index d04de73..275bebb 100644 --- a/specs/orders.md +++ b/specs/orders.md @@ -2340,8 +2340,8 @@ Otherwise, when `F.flags` lacks 0x80: result 8. | other | | none | 7 | Recorded: `mission-kill-of-type.txt`, tick 128, `Unit#304`, `Order#198`, made by the `VTOL_RepairPatrol` run of the same call: -`features.FindFeatureAtPos (46661632,0,9961472) = 22` (cell (44,8), size (2,2)), a 12-byte and a 16-byte publish, the find again, -`movement.NewPathOrderAt Order#198 (46661632,0,9961472) = PathOrder#3`, a 12-byte publish; `state` 2, `attached` `PathOrder#3`, `flags` 224. +`services.RandomInt 15 = 14`, a 12-byte publish, `features.FindFeatureAtPos (46661632,0,9961472) = 22` (cell (44,8), size (2,2)), publishes +of 12, 16 and 12 bytes, the find again, `movement.NewPathOrderAt Order#198 (46661632,0,9961472) = PathOrder#3`, a 12-byte publish; `state` 2, `attached` `PathOrder#3`, `flags` 224. #### `VTOL_ReclaimUnit` (kind 59) From f35842615c35c77dc0a03b710487905838f1a651 Mon Sep 17 00:00:00 2001 From: Oscar Bailey <79094698+ozgb@users.noreply.github.com> Date: Mon, 30 Nov 2026 09:16:14 +0000 Subject: [PATCH 3/3] Fix: Say how a module tells the table entries apart Assisted-by: Claude:claude-sonnet-5-5 --- specs/orders.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/specs/orders.md b/specs/orders.md index 275bebb..0111ad4 100644 --- a/specs/orders.md +++ b/specs/orders.md @@ -360,7 +360,10 @@ SimGlobals.g_missionOrderTableVec[K].notify orderNotify[j]`); `data/replay_schem (`annotations.code_tables.orderNotify.entries`) names entry j by the order type it stands for. Section 4, "Order kinds", gives the behaviour each index j runs, under the kind whose entry names it: `orderNotify[64]` is the behaviour of both `QMove` and `QPatrol`, and `orderNotify[54]` of both `SelfDestruct` and `SelfDestructFG`. The run is given (the -order's `Order.unit`, the order, the code) and answers a *result*. +order's `Order.unit`, the order, the code) and answers a *result*. The `notify` word is an engine code address that a module +cannot decode: it identifies the entry's behaviour by the entry's name, through the table below. An entry whose name the table +below lacks has `notify` `orderNotify[0]` in the recordings (the two added entries of `mission-passes-z-renumbered.txt`) and +runs as `Ready` (result 5, no import and no write). The table as the recordings hold it (flags in hex; `notify` as the `orderNotify` index): @@ -533,8 +536,8 @@ Each term is defined once; section 4 uses it by its name, in quotes where the na mod's) gives a kind another index. Every kind this spec names, in a row, a heading or a bracket, is found by its name at the moment it is used; a module that compared with the recorded numbers would differ on `mission-passes-z-renumbered.txt`, which is `mission-passes-z.txt` with two entries added to its table, `Aa_Extra` at 1 and `Bu_Extra` at 13, and every kind - after each one up by one (`BuildingBuild` is 14 there). The run of an order is the `notify` word of the table entry at - the order's own kind, never a number fixed by the module. + after each one up by one (`BuildingBuild` is 14 there). The run of an order is that of the table entry at the order's own + kind, which a module identifies by the entry's name ("Which behaviour runs"), never by a number fixed by the module. - **A kind byte** is a 32-bit payload field truncated to its low 8 bits, as an index in the order type table. - **whole(v)**: the high 16 bits of a 32-bit word, as a signed 16-bit value (`Unit.xWhole` is whole(`Unit.posX`), `Unit.zWhole` whole(`Unit.posZ`)).