Generate local IDs from map.json files #2047
Open
+3,212
−3,279
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal with this is to address a recurring problem with referring to object event templates using "local IDs" (which are really just 1 + their index in the templates array). Currently we have constants for these IDs wherever they're explicitly referenced -- these constants need to be updated when users change the order of object events at all or they'll be referring to a different object. This makes it really easy to encounter confusing behavior, like movement scripts suddenly acting on a different event after an unrelated event is deleted.
Now local IDs are listed in
map.json
alongside the rest of an event's data, and a define will be generated for each ID. Any changes to the order of events will automatically be reflected in the value of the define.A few notes:
.h
file together. This means it's easier to use them elsewhere in the repo, but because they're not defined with.set
you're not allowed to use the same name for multiple values. This is the safer thing to do anyway, but it does mean some of the names are getting longer so that they can be unique.local_id
field is optional, repos downstream that continue to use.set
(or hard-coded values for that matter) for local IDs won't be affected.OBJ_EVENT_ID_PLAYER
andOBJ_EVENT_ID_CAMERA
have been renamed toLOCALID_PLAYER
andLOCALID_CAMERA
, though the old names were kept as aliases for now. These IDs are "local IDs", not "object event IDs" (which normally refers to an index intogObjectEvents
)