Fixes broken link battles (#5940)

Co-authored-by: Hedara <hedara90@gmail.com>
This commit is contained in:
hedara90 2025-01-03 15:47:45 +01:00 committed by GitHub
parent 8ccb385ce4
commit c3b0f4dd7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -285,7 +285,7 @@ void HandleAction_UseMove(void)
gBattlerTarget = battler; gBattlerTarget = battler;
} }
} }
else if (IsDoubleBattle() && moveTarget & MOVE_TARGET_RANDOM) else if (IsDoubleBattle() && moveTarget & MOVE_TARGET_RANDOM)
{ {
gBattlerTarget = SetRandomTarget(gBattlerAttacker); gBattlerTarget = SetRandomTarget(gBattlerAttacker);
if (gAbsentBattlerFlags & (1u << gBattlerTarget) if (gAbsentBattlerFlags & (1u << gBattlerTarget)
@ -301,7 +301,7 @@ void HandleAction_UseMove(void)
else else
gBattlerTarget = gBattlerAttacker; gBattlerTarget = gBattlerAttacker;
} }
else if (IsDoubleBattle() && moveTarget == MOVE_TARGET_FOES_AND_ALLY) else if (IsDoubleBattle() && moveTarget == MOVE_TARGET_FOES_AND_ALLY)
{ {
for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++)
{ {
@ -932,22 +932,22 @@ static void UNUSED MarkAllBattlersForControllerExec(void)
else else
{ {
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
gBattleControllerExecFlags |= 1 << i; gBattleControllerExecFlags |= 1u << i;
} }
} }
bool32 IsBattlerMarkedForControllerExec(u32 battler) bool32 IsBattlerMarkedForControllerExec(u32 battler)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
return (gBattleControllerExecFlags & (1 << (battler + 28))) != 0; return (gBattleControllerExecFlags & (1u << (battler + 28))) != 0;
else else
return (gBattleControllerExecFlags & (1 << battler)) != 0; return (gBattleControllerExecFlags & (1u << battler)) != 0;
} }
void MarkBattlerForControllerExec(u32 battler) void MarkBattlerForControllerExec(u32 battler)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
gBattleControllerExecFlags |= 1u << (32 - MAX_BATTLERS_COUNT); gBattleControllerExecFlags |= 1u << (battler + 32 - MAX_BATTLERS_COUNT);
else else
gBattleControllerExecFlags |= 1u << battler; gBattleControllerExecFlags |= 1u << battler;
} }