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

GetSideParty/GetBattlerParty #2910

Merged
merged 2 commits into from
Apr 26, 2023
Merged

Conversation

mrgriffin
Copy link
Collaborator

@mrgriffin mrgriffin commented Apr 14, 2023

Very minor change, introduces GetSideParty and GetBattlerParty for two reasonably common patterns:

-struct Pokemon *party = side == B_SIDE_PLAYER ? gPlayerParty : gEnemyParty;
+struct Pokemon *party = GetSideParty(side);

-struct Pokemon *party = GetBattlerSide(battlerId) == B_SIDE_PLAYER ? gPlayerParty : gEnemyParty;
+struct Pokemon *party = GetBattlerParty(battlerId);


static inline struct Pokemon *GetBattlerParty(u32 battlerId)
{
extern u8 GetBattlerSide(u8 battler);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have added #include "battle_anim.h" to the top of this file instead of declaring GetBattlerSide. I don't really mind which approach is chosen.

@ghoulslash
Copy link
Collaborator

GetBattlerPartyData already exists so I think GetBattlerParty is redundant

@mrgriffin
Copy link
Collaborator Author

GetBattlerPartyData already exists so I think GetBattlerParty is redundant

I don't think they do the same thing—GetBattlerPartyData seems to return the Pokemon for the specific battler, whereas GetBattlerParty returns the whole party—that said, I think the names would be confusing, do you have a better suggestion for GetBattlerPartyData, I was thinking maybe GetBattlerPokemon or something?

@ghoulslash
Copy link
Collaborator

GetBattlerPartyData already exists so I think GetBattlerParty is redundant

I don't think they do the same thing—GetBattlerPartyData seems to return the Pokemon for the specific battler, whereas GetBattlerParty returns the whole party—that said, I think the names would be confusing, do you have a better suggestion for GetBattlerPartyData, I was thinking maybe GetBattlerPokemon or something?

Oh I gotcha. How about GetBattlerPartySource?

@AsparagusEduardo
Copy link
Collaborator

Oh I gotcha. How about GetBattlerPartySource?

"Source" doesn't really mean anything imo

@ghoulslash
Copy link
Collaborator

I don't care, then. This PR is simple enough to not be dragged down by semantics.

Inline GetBattlerPartyData into its callers because its name is
confusing and we couldn't think of a better one.

This seems to fix a bug in one place where GetBattlerPartyData was being
used as if it had GetBattlerParty semantics.
ghoulslash
ghoulslash previously approved these changes Apr 23, 2023
@ghoulslash
Copy link
Collaborator

fix conflicts

@ghoulslash ghoulslash merged commit 5afe3f5 into rh-hideout:upcoming Apr 26, 2023
@AsparagusEduardo AsparagusEduardo mentioned this pull request May 31, 2023
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.

3 participants