Cleaned up a bit of code with GetBattlerPartyData (#5378)
* rename GetBattlerPartyData
This commit is contained in:
parent
f6319d8446
commit
25e9ca2ac6
8 changed files with 14 additions and 44 deletions
|
@ -1153,11 +1153,10 @@ static inline u32 GetBattlerSide(u32 battler)
|
|||
return GetBattlerPosition(battler) & BIT_SIDE;
|
||||
}
|
||||
|
||||
static inline struct Pokemon* GetBattlerData(u32 battlerId)
|
||||
static inline struct Pokemon* GetPartyBattlerData(u32 battler)
|
||||
{
|
||||
u32 index = gBattlerPartyIndexes[battlerId];
|
||||
|
||||
return (GetBattlerSide(battlerId) == B_SIDE_OPPONENT) ? &gEnemyParty[index] : &gPlayerParty[index];
|
||||
u32 index = gBattlerPartyIndexes[battler];
|
||||
return (GetBattlerSide(battler) == B_SIDE_OPPONENT) ? &gEnemyParty[index] : &gPlayerParty[index];
|
||||
}
|
||||
|
||||
static inline struct Pokemon *GetSideParty(u32 side)
|
||||
|
@ -1176,3 +1175,4 @@ static inline bool32 IsDoubleBattle(void)
|
|||
}
|
||||
|
||||
#endif // GUARD_BATTLE_H
|
||||
|
||||
|
|
|
@ -116,11 +116,7 @@ u8 GetBattlerSpriteCoord(u8 battlerId, u8 coordType)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
|
||||
mon = &gEnemyParty[gBattlerPartyIndexes[battlerId]];
|
||||
else
|
||||
mon = &gPlayerParty[gBattlerPartyIndexes[battlerId]];
|
||||
|
||||
mon = GetPartyBattlerData(battlerId);
|
||||
illusionMon = GetIllusionMonPtr(battlerId);
|
||||
if (illusionMon != NULL)
|
||||
mon = illusionMon;
|
||||
|
|
|
@ -2269,14 +2269,9 @@ static void UpdateMonData(struct BattleDebugMenu *data)
|
|||
{
|
||||
if (data->battlerWasChanged[i])
|
||||
{
|
||||
struct Pokemon *mon;
|
||||
struct Pokemon *mon = GetPartyBattlerData(i);
|
||||
struct BattlePokemon *battleMon = &gBattleMons[i];
|
||||
|
||||
if (GetBattlerSide(i) == B_SIDE_PLAYER)
|
||||
mon = &gPlayerParty[gBattlerPartyIndexes[i]];
|
||||
else
|
||||
mon = &gEnemyParty[gBattlerPartyIndexes[i]];
|
||||
|
||||
SetMonData(mon, MON_DATA_HELD_ITEM, &battleMon->item);
|
||||
SetMonData(mon, MON_DATA_STATUS, &battleMon->status1);
|
||||
SetMonData(mon, MON_DATA_HP, &battleMon->hp);
|
||||
|
|
|
@ -3091,14 +3091,9 @@ static const u8 *TryGetStatusString(u8 *src)
|
|||
|
||||
static void GetBattlerNick(u32 battler, u8 *dst)
|
||||
{
|
||||
struct Pokemon *mon, *illusionMon;
|
||||
struct Pokemon *illusionMon = GetIllusionMonPtr(battler);
|
||||
struct Pokemon *mon = GetPartyBattlerData(battler);
|
||||
|
||||
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
mon = &gPlayerParty[gBattlerPartyIndexes[battler]];
|
||||
else
|
||||
mon = &gEnemyParty[gBattlerPartyIndexes[battler]];
|
||||
|
||||
illusionMon = GetIllusionMonPtr(battler);
|
||||
if (illusionMon != NULL)
|
||||
mon = illusionMon;
|
||||
GetMonData(mon, MON_DATA_NICKNAME, dst);
|
||||
|
|
|
@ -9877,10 +9877,7 @@ static void Cmd_various(void)
|
|||
case VARIOUS_HANDLE_FORM_CHANGE:
|
||||
{
|
||||
VARIOUS_ARGS(u8 case_);
|
||||
if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
|
||||
mon = &gEnemyParty[gBattlerPartyIndexes[battler]];
|
||||
else
|
||||
mon = &gPlayerParty[gBattlerPartyIndexes[battler]];
|
||||
mon = GetPartyBattlerData(battler);
|
||||
|
||||
// Change species.
|
||||
if (cmd->case_ == 0)
|
||||
|
|
|
@ -338,17 +338,8 @@ void BattleTv_SetDataBasedOnString(u16 stringId)
|
|||
defSide = GetBattlerSide(gBattlerTarget);
|
||||
effSide = GetBattlerSide(gEffectBattler);
|
||||
scriptingSide = GetBattlerSide(gBattleMsgDataPtr->scrActive);
|
||||
|
||||
if (atkSide == B_SIDE_PLAYER)
|
||||
atkMon = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]];
|
||||
else
|
||||
atkMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]];
|
||||
|
||||
if (defSide == B_SIDE_PLAYER)
|
||||
defMon = &gPlayerParty[gBattlerPartyIndexes[gBattlerTarget]];
|
||||
else
|
||||
defMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]];
|
||||
|
||||
atkMon = GetPartyBattlerData(gBattlerAttacker);
|
||||
defMon = GetPartyBattlerData(gBattlerTarget);
|
||||
moveSlot = GetBattlerMoveSlotId(gBattlerAttacker, gBattleMsgDataPtr->currentMove);
|
||||
|
||||
if (moveSlot >= MAX_MON_MOVES && IsNotSpecialBattleString(stringId) && stringId > BATTLESTRINGS_TABLE_START)
|
||||
|
|
|
@ -1571,12 +1571,8 @@ void FreeBallGfx(u8 ballId)
|
|||
|
||||
static u16 GetBattlerPokeballItemId(u8 battlerId)
|
||||
{
|
||||
struct Pokemon *mon, *illusionMon;
|
||||
|
||||
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
|
||||
mon = &gPlayerParty[gBattlerPartyIndexes[battlerId]];
|
||||
else
|
||||
mon = &gEnemyParty[gBattlerPartyIndexes[battlerId]];
|
||||
struct Pokemon *illusionMon;
|
||||
struct Pokemon *mon = GetPartyBattlerData(battlerId);
|
||||
|
||||
illusionMon = GetIllusionMonPtr(battlerId);
|
||||
if (illusionMon != NULL)
|
||||
|
|
|
@ -291,7 +291,7 @@ static bool32 UseDoubleBattleCoords(u32 position)
|
|||
|
||||
static u32 GetMonPublicType(u32 battlerId, u32 typeNum)
|
||||
{
|
||||
struct Pokemon* mon = GetBattlerData(battlerId);
|
||||
struct Pokemon* mon = GetPartyBattlerData(battlerId);
|
||||
u32 monSpecies = GetMonData(mon,MON_DATA_SPECIES,NULL);
|
||||
struct Pokemon* monIllusion;
|
||||
u32 illusionSpecies;
|
||||
|
|
Loading…
Reference in a new issue