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

Macros for keeping .partyFlags, .partySize, and .party in sync #1717

Merged
merged 1 commit into from
Aug 2, 2022

Conversation

mrgriffin
Copy link
Collaborator

@mrgriffin mrgriffin commented Jul 27, 2022

Introduces four macros for keeping .partyFlags, .partySize, and .party in sync, e.g.:

     [TRAINER_SAWYER_1] =
     {
-        .partyFlags = 0,
         .trainerClass = TRAINER_CLASS_HIKER,
         .encounterMusic_gender = TRAINER_ENCOUNTER_MUSIC_HIKER,
         .trainerPic = TRAINER_PIC_HIKER,
         .trainerName = _("SAWYER"),
         .items = {},
         .doubleBattle = FALSE,
         .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE | AI_SCRIPT_TRY_TO_FAINT | AI_SCRIPT_CHECK_VIABILITY,
-        .partySize = ARRAY_COUNT(sParty_Sawyer1),
-        .party = {.NoItemDefaultMoves = sParty_Sawyer1},
+        .party = NO_ITEM_DEFAULT_MOVES(sParty_Sawyer1),
     },

The motivation is that new people often forget or don't know that they have to update .partyFlags and come to #pokeemerald asking about why their trainer's party is acting weirdly.

We had a quick discussion on Discord, and of the three replies I received at time of submitting this PR, they were neutral-to-positive on the .party = NO_ITEM_DEFAULT_MOVES(sParty_Sawyer1), syntax which is a bit gross, because we hide the initializations of .partySize and .partyFlags inside it; but I believe this design is better than having the macro also include .party because then that line wouldn't have a member name and that sticks out in a bad way.

For the benefit of people who find this PR because of a horrific merge conflict, I automated the changes in src/data/trainers.h with:

sed -i -e '/\.partyFlags/d' -e '/\.partySize/d' -e 's/{.NoItemDefaultMoves = \([A-Za-z0-9_]\+\)}/NO_ITEM_DEFAULT_MOVES(\1)/' -e 's/{.NoItemCustomMoves = \([A-Za-z0-9_]\+\)}/NO_ITEM_CUSTOM_MOVES(\1)/' -e 's/{.ItemDefaultMoves = \([A-Za-z0-9_]\+\)}/ITEM_DEFAULT_MOVES(\1)/' -e 's/{.ItemCustomMoves = \([A-Za-z0-9_]\+\)}/ITEM_CUSTOM_MOVES(\1)/' src/data/trainers.h

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.

2 participants