Verify data table sizes with table_width and assert_table_length macros

This was discussed in #706

It also uncovered some off-by-one issues with defining some constants.

A few structs now use rsreset/_RS to define their offset constants, as discussed in #739
This commit is contained in:
Rangi
2021-03-03 22:22:41 -05:00
parent 9c17fb14c8
commit 40902ffe24
148 changed files with 608 additions and 237 deletions

View File

@@ -7,6 +7,7 @@ ENDM
FishGroups:
; entries correspond to FISHGROUP_* constants
table_width FISHGROUP_DATA_LENGTH, FishGroups
fishgroup 50 percent + 1, .Shore_Old, .Shore_Good, .Shore_Super
fishgroup 50 percent + 1, .Ocean_Old, .Ocean_Good, .Ocean_Super
fishgroup 50 percent + 1, .Lake_Old, .Lake_Good, .Lake_Super
@@ -20,6 +21,7 @@ FishGroups:
fishgroup 50 percent + 1, .Qwilfish_Old, .Qwilfish_Good, .Qwilfish_Super
fishgroup 50 percent + 1, .Remoraid_Old, .Remoraid_Good, .Remoraid_Super
fishgroup 50 percent + 1, .Qwilfish_NoSwarm_Old, .Qwilfish_NoSwarm_Good, .Qwilfish_NoSwarm_Super
assert_table_length NUM_FISHGROUPS
.Shore_Old:
db 70 percent + 1, MAGIKARP, 10

View File

@@ -4,6 +4,7 @@ mon_prob: MACRO
ENDM
GrassMonProbTable:
table_width 2, GrassMonProbTable
mon_prob 30, 0 ; 30% chance
mon_prob 60, 1 ; 30% chance
mon_prob 80, 2 ; 20% chance
@@ -11,8 +12,11 @@ GrassMonProbTable:
mon_prob 95, 4 ; 5% chance
mon_prob 99, 5 ; 4% chance
mon_prob 100, 6 ; 1% chance
assert_table_length NUM_GRASSMON
WaterMonProbTable:
table_width 2, WaterMonProbTable
mon_prob 60, 0 ; 60% chance
mon_prob 90, 1 ; 30% chance
mon_prob 100, 2 ; 10% chance
assert_table_length NUM_WATERMON

View File

@@ -1,5 +1,6 @@
TreeMons:
; entries correspond to TREEMON_SET_* constants
table_width 2, TreeMons
dw TreeMonSet_City
dw TreeMonSet_Canyon
dw TreeMonSet_Town
@@ -8,7 +9,8 @@ TreeMons:
dw TreeMonSet_Lake
dw TreeMonSet_Forest
dw TreeMonSet_Rock
dw TreeMonSet_City
assert_table_length NUM_TREEMON_SETS
dw TreeMonSet_City ; unused
; Two tables each (common, rare).
; Structure: