diff options
Diffstat (limited to 'src/pokemon.c')
-rw-r--r-- | src/pokemon.c | 174 |
1 files changed, 90 insertions, 84 deletions
diff --git a/src/pokemon.c b/src/pokemon.c index 074ee2d19..5a4e6df08 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1,5 +1,5 @@ #include "global.h" -#include "alloc.h" +#include "malloc.h" #include "apprentice.h" #include "battle.h" #include "battle_anim.h" @@ -60,6 +60,7 @@ static void EncryptBoxMon(struct BoxPokemon *boxMon); static void DecryptBoxMon(struct BoxPokemon *boxMon); static void sub_806E6CC(u8 taskId); static bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId); +static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move); // EWRAM vars EWRAM_DATA static u8 sLearningMoveTableID = 0; @@ -1333,7 +1334,7 @@ const struct SpindaSpot gSpindaSpotGraphics[] = #include "data/pokemon/item_effects.h" -const s8 gNatureStatTable[][5] = +const s8 gNatureStatTable[][NUM_EV_STATS] = { // Atk Def Spd Sp.Atk Sp.Def { 0, 0, 0, 0, 0}, // Hardy @@ -1886,7 +1887,7 @@ const u16 gLinkPlayerFacilityClasses[] = FACILITY_CLASS_PKMN_BREEDER_M, FACILITY_CLASS_GUITARIST, FACILITY_CLASS_COOLTRAINER_F, FACILITY_CLASS_HEX_MANIAC, FACILITY_CLASS_PICNICKER, FACILITY_CLASS_LASS, FACILITY_CLASS_PSYCHIC_F, FACILITY_CLASS_BATTLE_GIRL, - FACILITY_CLASS_POKEMON_BREEDER_F, FACILITY_CLASS_BEAUTY + FACILITY_CLASS_PKMN_BREEDER_F, FACILITY_CLASS_BEAUTY }; static const u8 sHoldEffectToType[][2] = @@ -2042,7 +2043,8 @@ static const u8 sGetMonDataEVConstants[] = MON_DATA_SPATK_EV }; -static const u8 gUnknown_08329EC8[] = +// For stat-raising items +static const u8 sStatsToRaise[] = { STAT_ATK, STAT_ATK, STAT_SPEED, STAT_DEF, STAT_SPATK, STAT_ACC }; @@ -2082,10 +2084,10 @@ static const struct SpeciesItem sAlteringCaveWildMonHeldItems[] = static const struct OamData sOamData_8329F20 = { .y = 0, - .affineMode = 0, - .objMode = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, .mosaic = 0, - .bpp = 0, + .bpp = ST_OAM_4BPP, .shape = SPRITE_SHAPE(64x64), .x = 0, .matrixNum = 0, @@ -2879,22 +2881,22 @@ u16 GiveMoveToMon(struct Pokemon *mon, u16 move) return GiveMoveToBoxMon(&mon->box, move); } -u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move) +static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move) { s32 i; for (i = 0; i < MAX_MON_MOVES; i++) { u16 existingMove = GetBoxMonData(boxMon, MON_DATA_MOVE1 + i, NULL); - if (!existingMove) + if (existingMove == MOVE_NONE) { SetBoxMonData(boxMon, MON_DATA_MOVE1 + i, &move); SetBoxMonData(boxMon, MON_DATA_PP1 + i, &gBattleMoves[move].pp); return move; } if (existingMove == move) - return -2; + return MON_ALREADY_KNOWS_MOVE; } - return 0xFFFF; + return MON_HAS_MAX_MOVES; } u16 GiveMoveToBattleMon(struct BattlePokemon *mon, u16 move) @@ -2942,14 +2944,14 @@ void GiveBoxMonInitialMoveset(struct BoxPokemon *boxMon) u16 moveLevel; u16 move; - moveLevel = (gLevelUpLearnsets[species][i] & 0xFE00); + moveLevel = (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_LV); if (moveLevel > (level << 9)) break; - move = (gLevelUpLearnsets[species][i] & 0x1FF); + move = (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID); - if (GiveMoveToBoxMon(boxMon, move) == 0xFFFF) + if (GiveMoveToBoxMon(boxMon, move) == MON_HAS_MAX_MOVES) DeleteFirstMoveAndGiveMoveToBoxMon(boxMon, move); } } @@ -2968,7 +2970,7 @@ u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove) { sLearningMoveTableID = 0; - while ((gLevelUpLearnsets[species][sLearningMoveTableID] & 0xFE00) != (level << 9)) + while ((gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_LV) != (level << 9)) { sLearningMoveTableID++; if (gLevelUpLearnsets[species][sLearningMoveTableID] == LEVEL_UP_END) @@ -2976,9 +2978,9 @@ u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove) } } - if ((gLevelUpLearnsets[species][sLearningMoveTableID] & 0xFE00) == (level << 9)) + if ((gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_LV) == (level << 9)) { - gMoveToLearn = (gLevelUpLearnsets[species][sLearningMoveTableID] & 0x1FF); + gMoveToLearn = (gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_ID); sLearningMoveTableID++; retVal = GiveMoveToMon(mon, gMoveToLearn); } @@ -2989,11 +2991,11 @@ u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove) void DeleteFirstMoveAndGiveMoveToMon(struct Pokemon *mon, u16 move) { s32 i; - u16 moves[4]; - u8 pp[4]; + u16 moves[MAX_MON_MOVES]; + u8 pp[MAX_MON_MOVES]; u8 ppBonuses; - for (i = 0; i < 3; i++) + for (i = 0; i < MAX_MON_MOVES - 1; i++) { moves[i] = GetMonData(mon, MON_DATA_MOVE2 + i, NULL); pp[i] = GetMonData(mon, MON_DATA_PP2 + i, NULL); @@ -3016,11 +3018,11 @@ void DeleteFirstMoveAndGiveMoveToMon(struct Pokemon *mon, u16 move) void DeleteFirstMoveAndGiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move) { s32 i; - u16 moves[4]; - u8 pp[4]; + u16 moves[MAX_MON_MOVES]; + u8 pp[MAX_MON_MOVES]; u8 ppBonuses; - for (i = 0; i < 3; i++) + for (i = 0; i < MAX_MON_MOVES - 1; i++) { moves[i] = GetBoxMonData(boxMon, MON_DATA_MOVE2 + i, NULL); pp[i] = GetBoxMonData(boxMon, MON_DATA_PP2 + i, NULL); @@ -3270,7 +3272,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de } // any weather except sun weakens solar beam - if ((gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_HAIL)) && gCurrentMove == MOVE_SOLAR_BEAM) + if ((gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_HAIL_ANY)) && gCurrentMove == MOVE_SOLAR_BEAM) damage /= 2; // sunny @@ -3304,21 +3306,21 @@ u8 CountAliveMonsInBattle(u8 caseId) switch (caseId) { case BATTLE_ALIVE_EXCEPT_ACTIVE: - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { if (i != gActiveBattler && !(gAbsentBattlerFlags & gBitTable[i])) retVal++; } break; case BATTLE_ALIVE_ATK_SIDE: - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { if (GetBattlerSide(i) == GetBattlerSide(gBattlerAttacker) && !(gAbsentBattlerFlags & gBitTable[i])) retVal++; } break; case BATTLE_ALIVE_DEF_SIDE: - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { if (GetBattlerSide(i) == GetBattlerSide(gBattlerTarget) && !(gAbsentBattlerFlags & gBitTable[i])) retVal++; @@ -4329,7 +4331,7 @@ u8 SendMonToPC(struct Pokemon* mon) { s32 boxNo, boxPos; - set_unknown_box_id(VarGet(VAR_STORAGE_UNKNOWN)); + SetPCBoxToSendMon(VarGet(VAR_PC_BOX_TO_SEND_MON)); boxNo = StorageGetCurrentBox(); @@ -4344,9 +4346,9 @@ u8 SendMonToPC(struct Pokemon* mon) CopyMon(checkingMon, &mon->box, sizeof(mon->box)); gSpecialVar_MonBoxId = boxNo; gSpecialVar_MonBoxPos = boxPos; - if (get_unknown_box_id() != boxNo) - FlagClear(FLAG_SYS_STORAGE_UNKNOWN_FLAG); - VarSet(VAR_STORAGE_UNKNOWN, boxNo); + if (GetPCBoxToSendMon() != boxNo) + FlagClear(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE); + VarSet(VAR_PC_BOX_TO_SEND_MON, boxNo); return MON_GIVEN_TO_PC; } } @@ -4690,7 +4692,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov gBattleMons[battlerId].status2 &= ~STATUS2_INFATUATION; retVal = FALSE; } - if ((itemEffect[cmdIndex] & ITEM0_HIGH_CRIT) + if ((itemEffect[cmdIndex] & ITEM0_DIRE_HIT) && !(gBattleMons[gActiveBattler].status2 & STATUS2_FOCUS_ENERGY)) { gBattleMons[gActiveBattler].status2 |= STATUS2_FOCUS_ENERGY; @@ -4744,7 +4746,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov } break; case 3: - if ((itemEffect[cmdIndex] & ITEM3_MIST) + if ((itemEffect[cmdIndex] & ITEM3_GUARD_SPEC) && gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer == 0) { gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer = 5; @@ -4817,11 +4819,11 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov { if (evCount >= MAX_TOTAL_EVS) return TRUE; - if (dataSigned >= 100) + if (dataSigned >= EV_ITEM_RAISE_LIMIT) break; - if (dataSigned + r2 > 100) - r5 = 100 - (dataSigned + r2) + r2; + if (dataSigned + r2 > EV_ITEM_RAISE_LIMIT) + r5 = EV_ITEM_RAISE_LIMIT - (dataSigned + r2) + r2; else r5 = r2; @@ -4860,7 +4862,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov if (battlerId != 4) { gAbsentBattlerFlags &= ~gBitTable[battlerId]; - CopyPlayerPartyMonToBattleData(battlerId, pokemon_order_func(gBattlerPartyIndexes[battlerId])); + CopyPlayerPartyMonToBattleData(battlerId, GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battlerId])); if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER && gBattleResults.numRevivesUsed < 255) gBattleResults.numRevivesUsed++; } @@ -5021,11 +5023,11 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov { if (evCount >= MAX_TOTAL_EVS) return TRUE; - if (dataSigned >= 100) + if (dataSigned >= EV_ITEM_RAISE_LIMIT) break; - if (dataSigned + r2 > 100) - r5 = 100 - (dataSigned + r2) + r2; + if (dataSigned + r2 > EV_ITEM_RAISE_LIMIT) + r5 = EV_ITEM_RAISE_LIMIT - (dataSigned + r2) + r2; else r5 = r2; @@ -5084,8 +5086,8 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov } if (friendship < 0) friendship = 0; - if (friendship > 255) - friendship = 255; + if (friendship > MAX_FRIENDSHIP) + friendship = MAX_FRIENDSHIP; SetMonData(mon, MON_DATA_FRIENDSHIP, &friendship); retVal = FALSE; } @@ -5110,8 +5112,8 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov } if (friendship < 0) friendship = 0; - if (friendship > 255) - friendship = 255; + if (friendship > MAX_FRIENDSHIP) + friendship = MAX_FRIENDSHIP; SetMonData(mon, MON_DATA_FRIENDSHIP, &friendship); retVal = FALSE; } @@ -5135,8 +5137,8 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov } if (friendship < 0) friendship = 0; - if (friendship > 255) - friendship = 255; + if (friendship > MAX_FRIENDSHIP) + friendship = MAX_FRIENDSHIP; SetMonData(mon, MON_DATA_FRIENDSHIP, &friendship); retVal = FALSE; } @@ -5284,15 +5286,15 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit) return offset; } -static void sub_806CF24(s32 arg0) +static void BufferStatRoseMessage(s32 arg0) { gBattlerTarget = gBattlerInMenuId; - StringCopy(gBattleTextBuff1, gStatNamesTable[gUnknown_08329EC8[arg0]]); + StringCopy(gBattleTextBuff1, gStatNamesTable[sStatsToRaise[arg0]]); StringCopy(gBattleTextBuff2, gText_StatRose); BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2); } -u8 *sub_806CF78(u16 itemId) +u8 *UseStatIncreaseItem(u16 itemId) { int i; const u8 *itemEffect; @@ -5313,13 +5315,14 @@ u8 *sub_806CF78(u16 itemId) for (i = 0; i < 3; i++) { - if (itemEffect[i] & 0xF) - sub_806CF24(i * 2); - if (itemEffect[i] & 0xF0) + if (itemEffect[i] & (ITEM0_X_ATTACK | ITEM1_X_SPEED | ITEM2_X_SPATK)) + BufferStatRoseMessage(i * 2); + + if (itemEffect[i] & (ITEM0_DIRE_HIT | ITEM1_X_DEFEND | ITEM2_X_ACCURACY)) { - if (i) + if (i != 0) // Dire Hit is the only ITEM0 above { - sub_806CF24(i * 2 + 1); + BufferStatRoseMessage(i * 2 + 1); } else { @@ -5329,7 +5332,7 @@ u8 *sub_806CF78(u16 itemId) } } - if (itemEffect[3] & ITEM3_MIST) + if (itemEffect[3] & ITEM3_GUARD_SPEC) { gBattlerAttacker = gBattlerInMenuId; BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist); @@ -5657,21 +5660,23 @@ void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies) SetMonData(mon, MON_DATA_NICKNAME, gSpeciesNames[newSpecies]); } -bool8 sub_806D7EC(void) +// The below two functions determine which side of a multi battle the trainer battles on +// 0 is the left (top in party menu), 1 is right (bottom in party menu) +u8 GetPlayerFlankId(void) { - bool8 retVal = FALSE; + u8 flankId = 0; switch (gLinkPlayers[GetMultiplayerId()].id) { case 0: case 3: - retVal = FALSE; + flankId = 0; break; case 1: case 2: - retVal = TRUE; + flankId = 1; break; } - return retVal; + return flankId; } u16 GetLinkTrainerFlankId(u8 linkPlayerId) @@ -5704,7 +5709,7 @@ u8 GetTrainerEncounterMusicId(u16 trainerOpponentId) { if (InBattlePyramid()) return GetBattlePyramindTrainerEncounterMusicId(trainerOpponentId); - else if (sub_81D5C18()) + else if (InTrainerHillChallenge()) return GetTrainerEncounterMusicIdInTrainerHill(trainerOpponentId); else return TRAINER_ENCOUNTER_MUSIC(trainerOpponentId); @@ -5712,7 +5717,8 @@ u8 GetTrainerEncounterMusicId(u16 trainerOpponentId) u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex) { - if (statIndex < 1 || statIndex > 5) + // Dont modify HP, Accuracy, or Evasion by nature + if (statIndex <= STAT_HP || statIndex > NUM_EV_STATS) { // Should just be "return n", but it wouldn't match without this. u16 retVal = n; @@ -5724,9 +5730,9 @@ u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex) switch (gNatureStatTable[nature][statIndex - 1]) { case 1: - return (u16)(n * 110) / 100; + return (u16)(n * 110) / 100; // NOTE: will overflow for n > 595 because the intermediate value is cast to u16 before the division. Fix by removing (u16) cast case -1: - return (u16)(n * 90) / 100; + return (u16)(n * 90) / 100; // NOTE: will overflow for n > 728, see above } return n; @@ -5783,8 +5789,8 @@ void AdjustFriendship(struct Pokemon *mon, u8 event) } if (friendship < 0) friendship = 0; - if (friendship > 255) - friendship = 255; + if (friendship > MAX_FRIENDSHIP) + friendship = MAX_FRIENDSHIP; SetMonData(mon, MON_DATA_FRIENDSHIP, &friendship); } } @@ -6096,7 +6102,7 @@ u32 CanSpeciesLearnTMHM(u16 species, u8 tm) u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves) { - u16 learnedMoves[4]; + u16 learnedMoves[MAX_MON_MOVES]; u8 numMoves = 0; u16 species = GetMonData(mon, MON_DATA_SPECIES, 0); u8 level = GetMonData(mon, MON_DATA_LEVEL, 0); @@ -6109,23 +6115,23 @@ u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves) { u16 moveLevel; - if (gLevelUpLearnsets[species][i] == 0xFFFF) + if (gLevelUpLearnsets[species][i] == LEVEL_UP_END) break; - moveLevel = gLevelUpLearnsets[species][i] & 0xFE00; + moveLevel = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_LV; if (moveLevel <= (level << 9)) { - for (j = 0; j < MAX_MON_MOVES && learnedMoves[j] != (gLevelUpLearnsets[species][i] & 0x1FF); j++) + for (j = 0; j < MAX_MON_MOVES && learnedMoves[j] != (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID); j++) ; if (j == MAX_MON_MOVES) { - for (k = 0; k < numMoves && moves[k] != (gLevelUpLearnsets[species][i] & 0x1FF); k++) + for (k = 0; k < numMoves && moves[k] != (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID); k++) ; if (k == numMoves) - moves[numMoves++] = gLevelUpLearnsets[species][i] & 0x1FF; + moves[numMoves++] = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID; } } } @@ -6138,15 +6144,15 @@ u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves) u8 numMoves = 0; int i; - for (i = 0; i < 20 && gLevelUpLearnsets[species][i] != 0xFFFF; i++) - moves[numMoves++] = gLevelUpLearnsets[species][i] & 0x1FF; + for (i = 0; i < 20 && gLevelUpLearnsets[species][i] != LEVEL_UP_END; i++) + moves[numMoves++] = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID; return numMoves; } u8 GetNumberOfRelearnableMoves(struct Pokemon *mon) { - u16 learnedMoves[4]; + u16 learnedMoves[MAX_MON_MOVES]; u16 moves[20]; u8 numMoves = 0; u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); @@ -6163,23 +6169,23 @@ u8 GetNumberOfRelearnableMoves(struct Pokemon *mon) { u16 moveLevel; - if (gLevelUpLearnsets[species][i] == 0xFFFF) + if (gLevelUpLearnsets[species][i] == LEVEL_UP_END) break; - moveLevel = gLevelUpLearnsets[species][i] & 0xFE00; + moveLevel = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_LV; if (moveLevel <= (level << 9)) { - for (j = 0; j < MAX_MON_MOVES && learnedMoves[j] != (gLevelUpLearnsets[species][i] & 0x1FF); j++) + for (j = 0; j < MAX_MON_MOVES && learnedMoves[j] != (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID); j++) ; if (j == MAX_MON_MOVES) { - for (k = 0; k < numMoves && moves[k] != (gLevelUpLearnsets[species][i] & 0x1FF); k++) + for (k = 0; k < numMoves && moves[k] != (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID); k++) ; if (k == numMoves) - moves[numMoves++] = gLevelUpLearnsets[species][i] & 0x1FF; + moves[numMoves++] = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID; } } } @@ -6439,11 +6445,11 @@ void SetMonPreventsSwitchingString(void) gBattleTextBuff1[4] = B_BUFF_EOS; if (GetBattlerSide(gBattleStruct->battlerPreventingSwitchout) == B_SIDE_PLAYER) - gBattleTextBuff1[3] = pokemon_order_func(gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout]); + gBattleTextBuff1[3] = GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout]); else gBattleTextBuff1[3] = gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout]; - PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff2, gBattlerInMenuId, pokemon_order_func(gBattlerPartyIndexes[gBattlerInMenuId])) + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff2, gBattlerInMenuId, GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[gBattlerInMenuId])) BattleStringExpandPlaceholders(gText_PkmnsXPreventsSwitching, gStringVar4); } @@ -6683,7 +6689,7 @@ u8 sub_806EF08(u8 arg0) var = (arg0 != 0) ? 2 : 0; break; } - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_LINK_PLAYERS; i++) { if (gLinkPlayers[i].id == (s16)(var)) break; @@ -6706,7 +6712,7 @@ u8 sub_806EF84(u8 arg0, u8 arg1) var = (arg0 != 0) ? 2 : 0; break; } - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_LINK_PLAYERS; i++) { if (gLinkPlayers[i].id == (s16)(var)) break; |