Skip to content
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

Generate local IDs from map.json files #2047

Open
wants to merge 7 commits into
base: porymap-6
Choose a base branch
from

Conversation

GriffinRichards
Copy link
Member

@GriffinRichards GriffinRichards commented Oct 12, 2024

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:

  • All local ID constants are now defined in a single .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.
  • Using the new 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.
  • Similar support was set up for warp IDs. These aren't referenced in the repo outside of the warps themselves, but the same confusing problems can happen when you re-order warp events. If there's enough interest I'll go through and define warp IDs for all the warps as well.
  • OBJ_EVENT_ID_PLAYER and OBJ_EVENT_ID_CAMERA have been renamed to LOCALID_PLAYER and LOCALID_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 into gObjectEvents)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant