diff options
Diffstat (limited to 'src/recorded_battle.c')
-rw-r--r-- | src/recorded_battle.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/recorded_battle.c b/src/recorded_battle.c index 9e03d57f6..5a0579f70 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -10,7 +10,7 @@ #include "string_util.h" #include "palette.h" #include "save.h" -#include "alloc.h" +#include "malloc.h" #include "util.h" #include "task.h" #include "text.h" @@ -37,8 +37,8 @@ struct PlayerInfo struct MovePp { - u16 moves[4]; - u8 pp[4]; + u16 moves[MAX_MON_MOVES]; + u8 pp[MAX_MON_MOVES]; }; struct RecordedBattleSave @@ -91,7 +91,7 @@ EWRAM_DATA static u32 sBattleFlags = 0; EWRAM_DATA static u32 sAI_Scripts = 0; EWRAM_DATA static struct Pokemon sSavedPlayerParty[PARTY_SIZE] = {0}; EWRAM_DATA static struct Pokemon sSavedOpponentParty[PARTY_SIZE] = {0}; -EWRAM_DATA static u16 sPlayerMonMoves[2][4] = {0}; +EWRAM_DATA static u16 sPlayerMonMoves[2][MAX_MON_MOVES] = {0}; EWRAM_DATA static struct PlayerInfo sPlayers[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA static u8 sUnknown_0203CCD0 = 0; EWRAM_DATA static u8 sRecordMixFriendName[PLAYER_NAME_LENGTH + 1] = {0}; @@ -323,7 +323,7 @@ static bool32 RecordedBattleToSave(struct RecordedBattleSave *battleSave, struct saveSection->checksum = CalcByteArraySum((void*)(saveSection), sizeof(*saveSection) - 4); - if (TryWriteSpecialSaveSection(SECTOR_ID_RECORDED_BATTLE, (void*)(saveSection)) != 1) + if (TryWriteSpecialSaveSection(SECTOR_ID_RECORDED_BATTLE, (void*)(saveSection)) != SAVE_STATUS_OK) return FALSE; else return TRUE; @@ -334,9 +334,9 @@ bool32 MoveRecordedBattleToSaveData(void) s32 i, j; bool32 ret; struct RecordedBattleSave *battleSave, *savSection; - u8 var; + u8 saveAttempts; - var = 0; + saveAttempts = 0; battleSave = AllocZeroed(sizeof(struct RecordedBattleSave)); savSection = AllocZeroed(0x1000); @@ -409,12 +409,12 @@ bool32 MoveRecordedBattleToSaveData(void) if (sBattleOutcome == B_OUTCOME_WON) { - for (i = 0; i < 6; i++) + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].speechLost[i]; } else { - for (i = 0; i < 6; i++) + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].speechWon[i]; } battleSave->recordMixFriendLanguage = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].language; @@ -427,12 +427,12 @@ bool32 MoveRecordedBattleToSaveData(void) if (sBattleOutcome == B_OUTCOME_WON) { - for (i = 0; i < 6; i++) + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].speechLost[i]; } else { - for (i = 0; i < 6; i++) + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].speechWon[i]; } battleSave->recordMixFriendLanguage = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].language; @@ -449,15 +449,15 @@ bool32 MoveRecordedBattleToSaveData(void) if (gTrainerBattleOpponent_A >= TRAINER_RECORD_MIXING_APPRENTICE) { battleSave->apprenticeId = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].id; - for (i = 0; i < 6; i++) - battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].easyChatWords[i]; + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) + battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].speechWon[i]; battleSave->apprenticeLanguage = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].language; } else if (gTrainerBattleOpponent_B >= TRAINER_RECORD_MIXING_APPRENTICE) { battleSave->apprenticeId = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].id; - for (i = 0; i < 6; i++) - battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].easyChatWords[i]; + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) + battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].speechWon[i]; battleSave->apprenticeLanguage = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].language; } else if (gPartnerTrainerId >= TRAINER_RECORD_MIXING_APPRENTICE) @@ -480,8 +480,8 @@ bool32 MoveRecordedBattleToSaveData(void) ret = RecordedBattleToSave(battleSave, savSection); if (ret == TRUE) break; - var++; - if (var >= 3) + saveAttempts++; + if (saveAttempts >= 3) break; } @@ -492,7 +492,7 @@ bool32 MoveRecordedBattleToSaveData(void) static bool32 TryCopyRecordedBattleSaveData(struct RecordedBattleSave *dst, struct SaveSection *saveBuffer) { - if (TryReadSpecialSaveSection(SECTOR_ID_RECORDED_BATTLE, (void*)(saveBuffer)) != 1) + if (TryReadSpecialSaveSection(SECTOR_ID_RECORDED_BATTLE, (void*)(saveBuffer)) != SAVE_STATUS_OK) return FALSE; memcpy(dst, saveBuffer, sizeof(struct RecordedBattleSave)); @@ -766,11 +766,11 @@ void sub_818603C(u8 arg0) { if (sBattleRecords[battlerId][sRecordedBytesNo[battlerId]] == ACTION_MOVE_CHANGE) { - u8 ppBonuses[4]; - u8 array1[4]; - u8 array2[4]; + u8 ppBonuses[MAX_MON_MOVES]; + u8 array1[MAX_MON_MOVES]; + u8 array2[MAX_MON_MOVES]; struct MovePp movePp; - u8 array3[8]; + u8 array3[(MAX_MON_MOVES * 2)]; u8 var; RecordedBattle_GetBattlerAction(battlerId); |