-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically detect invalid object_event or bg_event text IDs #376
Comments
Since we already have MACRO bg_event
db \2, \1, \3
+ DEF _BG_EVENT_{d:{_NUM_BG_EVENTS}}_TEXT_ID = \3
DEF {_NUM_BG_EVENTS} += 1
ENDM MACRO object_event
...
+ ; items and trainers don't use a typical text id
+ IF _NARG > 6
+ DEF _OBJECT_EVENT_{d:{_NUM_OBJECT_EVENTS}}_TEXT_ID = 0
+ ELSE
+ DEF _OBJECT_EVENT_{d:{_NUM_OBJECT_EVENTS}}_TEXT_ID = \6
+ ENDC
DEF {_NUM_OBJECT_EVENTS} += 1
ENDM MACRO def_warps_to
+ ; text ID values are significant (see DisplayTextID in home/text_script.asm)
+ FOR n, {_NUM_BG_EVENTS}
+ ASSERT _BG_EVENT_{d:n}_TEXT_ID > {_NUM_OBJECT_EVENTS}, \
+ "A bg_event has text ID {d:_BG_EVENT_{d:n}_TEXT_ID} expected for an object_event ({d:{_NUM_OBJECT_EVENTS}} or below)"
+ ENDR
+ FOR n, {_NUM_OBJECT_EVENTS}
+ ASSERT _OBJECT_EVENT_{d:n}_TEXT_ID <= {_NUM_OBJECT_EVENTS}, \
+ "An object_event has text ID {d:_OBJECT_EVENT_{d:n}_TEXT_ID} expected for a bg_event (above {d:{_NUM_OBJECT_EVENTS}})"
+ ENDR
- FOR n, _NUM_WARP_EVENTS
+ FOR n, {_NUM_WARP_EVENTS}
warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH
ENDR
ENDM This would go well with how |
This should be documented as a design flaw (in the wiki since we don't yet have a definitive document worth putting in the repo), which could be fixed by editing |
Whatever the case, a design flaws wiki page now exists for those willing to put it in: |
@Rangi42 Your suggested changes causes a conflict with the constants being created in my PR:
Could this be because the macros are being called before the constants are defined? |
Yeah, the problem is Using MACRO bg_event
db \2, \1, \3
+ REDEF _BG_EVENT_{d:{_NUM_BG_EVENTS}}_TEXT_ID EQUS "\3"
DEF {_NUM_BG_EVENTS} += 1
ENDM MACRO object_event
...
+ ; items and trainers don't use a typical text id
+ IF _NARG > 6
+ REDEF _OBJECT_EVENT_{d:{_NUM_OBJECT_EVENTS}}_TEXT_ID EQUS "0"
+ ELSE
+ REDEF _OBJECT_EVENT_{d:{_NUM_OBJECT_EVENTS}}_TEXT_ID EQUS "\6"
+ ENDC
DEF {_NUM_OBJECT_EVENTS} += 1
ENDM MACRO def_warps_to
+ ; text ID values are significant (see DisplayTextID in home/text_script.asm)
+ FOR n, {_NUM_BG_EVENTS}
+ ASSERT {_BG_EVENT_{d:n}_TEXT_ID} > {_NUM_OBJECT_EVENTS}, \
+ "A bg_event has a text ID {_BG_EVENT_{d:n}_TEXT_ID} expected for an object_event ({d:{_NUM_OBJECT_EVENTS}} or below)"
+ ENDR
+ FOR n, {_NUM_OBJECT_EVENTS}
+ ASSERT {_OBJECT_EVENT_{d:n}_TEXT_ID} <= {_NUM_OBJECT_EVENTS}, \
+ "An object_event has a text ID {_OBJECT_EVENT_{d:n}_TEXT_ID} expected for a bg_event (above {d:{_NUM_OBJECT_EVENTS}})"
+ ENDR
- FOR n, _NUM_WARP_EVENTS
+ FOR n, {_NUM_WARP_EVENTS}
warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH
ENDR
ENDM |
That worked and is functional with the changes in my new PR (Tested by purposely changing around some TEXT constants). I'm going to incorporate this into my PR and will push an update a bit later. |
See #367 (comment)
The text was updated successfully, but these errors were encountered: