Files
gen1recomp/tests/engine/game3_object_subpriority_test.lua
T
Shane McGovern 41935aa2a2 fix(game3): wave 2 - 118 review fixes, seam work, and the gate to 282 suites
Second batch of the Gen 3 review work: the review lanes closed their queues
and the test gate grew with them.

Review census: 139 routed findings -- 118 fixed, 14 invalid (the report had
Gen 4+ semantics in more than one place), 6 struck as stale after
re-verification, 1 re-routed. Every fix carries its own pret citation in
docs/game3/review-v3-triage.md; the E10 opcode closure is itemised in
docs/game3/e10-opcode-spec.md (18 ops wired, 2 reclassified to the seam class).

Representative ROM-grounded changes:
- The POKéMON start-menu entry is now gated on FLAG_SYS_POKEMON_GET the way
  retail does it (pokefirered/src/start_menu.c:217-218, flag 0x828).
- Money ops read their amount raw and gate the change on the disable byte
  (pokefirered/src/scrcmd.c:1798-1830, pokefirered/asm/macros/event.inc:1166-1186);
  random and the warp family VarGet theirs
  (pokefirered/src/scrcmd.c:455-461, :719-731).
- The HM table matches FRLG: there is no Whirlpool HM
  (pokefirered/include/constants/items.h:411-418).
- The day-care party-full guard follows src/daycare.c:525, :1081.
- Knock Off keeps its battle-scoped send-out mask
  (pokefirered/src/battle_script_commands.c:2730-2752, :4489), carried from
  the first batch.

Structural work: the I6/I9/J1 architecture items landed as seams (profile
selector, capability flags, font provider, virtual-object layer), the adopted
footprint register keeps a KEEP verdict, the quantizer target is met, and the
30 drain items plus carves 1-4 are folded in.

Tests: T6 now runs 282 top-level suites (273 + 9 new), the re-sweep ends at
267 pass / 0 fail, the engine tier is 634 suites, modkit 37, and the full
gate ran green twice with T3 active on an imported Red cache. Documented
skips are the lua5.4 oversize-save oracle where lua5.4 is absent and the
config-partials listed in docs/game3/game3-artifact-conversions-v3.md.

Docs shipped: review-v3-triage.md, e10-opcode-spec.md, rse-seams.md,
game3-suite-sweep-v113.md, game3-artifact-conversions-v3.md,
test-baseline-v3.md (plus the first-batch docs already on the branch).
2026-09-22 18:23:06 +01:00

68 lines
3.2 KiB
Lua

-- Producer contract for seam-7 set/resetobjectsubpriority (rse-seams e10
-- spec 5.8): the script op freezes an object's draw-order pair on the
-- EventObject record { fixedPriority, subpriority, fixedClass }; the field_view
-- half (Refactor lane) consumes it, and the freeze points mirror pret:
-- pret src/event_object_movement.c:2089-2101 SetObjectSubpriority
-- (objectEvent->fixedPriority = TRUE; sprite->subpriority = subpriority)
-- pret src/event_object_movement.c:2104-2116 ResetObjectSubpriority
-- (fixedPriority = FALSE — re-enables the dynamic path, does NOT restore
-- a previous value; all three fields drop)
-- pret src/scrcmd.c:1122-1130 (+83 bias) / :1133-1140
-- guard: TryGetObjectEventIdByLocalIdAndMap (mapGroup/mapNum must resolve
-- to the active map or the command does nothing)
-- lua: luajit tests/engine/game3_object_subpriority_test.lua
package.path = "./?.lua;./?/init.lua;" .. package.path
local T = require("tests.harness")
local check, eq = T.check, T.eq
love = love or require("tests.love_stub")
local Objects = require("src.core.game3.objects")
local Catalog = require("src.import.gba.map_catalog")
local here = Catalog.mapIdFor(0, 1)
local other = Catalog.mapIdFor(0, 2)
check(here and other and here ~= other, "the catalog resolves two distinct maps")
local savedMap = Objects._mapId
local savedById = Objects._byId
Objects._mapId = here
Objects._byId = { [7] = { localId = 7 } }
-- 1. set freezes the pair with the +83 bias applied by the script op and
-- nils any stale fixedClass (spec 5.8 record).
local ok = Objects.setSubpriority(7, 0, 1, 5 + 83)
eq(ok, true, "set succeeds for the current map")
eq(Objects._byId[7].fixedPriority, true, "fixedPriority is frozen")
eq(Objects._byId[7].subpriority, 88, "subpriority stores priority + 83")
Objects._byId[7].fixedClass = 1 -- stale class from an earlier freeze
Objects.setSubpriority(7, 0, 1, 10 + 83)
eq(Objects._byId[7].fixedClass, nil, "set nils a stale fixedClass before first observation")
-- 2. cross-map refusal (pret TryGetObjectEventIdByLocalIdAndMap).
local refused = Objects.setSubpriority(7, 0, 2, 7 + 83)
eq(refused, false, "a different (mapGroup, mapNum) is refused")
eq(Objects._byId[7].subpriority, 93, "the refused call left the record alone")
-- 3. unknown localId is a silent no-op (pret lookup failure).
eq(Objects.setSubpriority(99, 0, 1, 1), false, "unknown localId: set is a no-op")
eq(Objects.resetSubpriority(99, 0, 1), false, "unknown localId: reset is a no-op")
-- 4. reset drops all three fields and restores the dynamic path (no old
-- value is restored — pret event_object_movement.c:2104-2116).
Objects._byId[7].fixedClass = 2
eq(Objects.resetSubpriority(7, 0, 1), true, "reset succeeds for the current map")
eq(Objects._byId[7].fixedPriority, nil, "fixedPriority dropped")
eq(Objects._byId[7].subpriority, nil, "subpriority dropped")
eq(Objects._byId[7].fixedClass, nil, "fixedClass dropped (all three per spec 5.8)")
-- 5. no active map / no object: still safe.
Objects._byId = {}
eq(Objects.setSubpriority(7, 0, 1, 1), false, "no object after clear: no-op")
Objects._mapId = savedMap
Objects._byId = savedById
T.finish("game3_object_subpriority_test")