Verify that only one of each callback type exists per map
Some checks failed
CI / build (push) Has been cancelled

Fixes #1213
This commit is contained in:
Rangi 2025-12-15 15:43:39 -05:00
parent f9ba82248e
commit a718a256f8
2 changed files with 7 additions and 0 deletions

View File

@ -22,6 +22,7 @@ DEF NUM_MAPSETUP_SCRIPTS EQU const_value - $f1
const MAPCALLBACK_CMDQUEUE
const MAPCALLBACK_SPRITES
const MAPCALLBACK_NEWMAP
DEF NUM_MAPCALLBACK_TYPES EQU const_value - 1
; see data/maps/setup_script_pointers.asm
DEF MAPSETUPSCRIPT_HAS_PARAM_F EQU 7

View File

@ -39,11 +39,17 @@ MACRO def_callbacks
REDEF _NUM_CALLBACKS EQUS "_NUM_CALLBACKS_\@"
db {_NUM_CALLBACKS}
DEF {_NUM_CALLBACKS} = 0
for x, 1, NUM_MAPCALLBACK_TYPES + 1
DEF map_callback_{d:x} = 0
endr
ENDM
MACRO callback
;\1: type: a MAPCALLBACK_* constant
;\2: script pointer
DEF x = \1
assert !map_callback_{d:x}, "Already defined a `callback \1` for this map"
DEF map_callback_{d:x} = 1
dbw \1, \2
DEF {_NUM_CALLBACKS} += 1
ENDM