Use more constants in Battle Tower code
This commit is contained in:
parent
de153a67cf
commit
6f91f7e0e3
2 changed files with 13 additions and 12 deletions
|
@ -328,11 +328,12 @@ struct BattleDomeTrainer
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DOME_TOURNAMENT_TRAINERS_COUNT 16
|
#define DOME_TOURNAMENT_TRAINERS_COUNT 16
|
||||||
|
#define BATTLE_TOWER_RECORD_COUNT 5
|
||||||
|
|
||||||
struct BattleFrontier
|
struct BattleFrontier
|
||||||
{
|
{
|
||||||
/*0x64C*/ struct EmeraldBattleTowerRecord towerPlayer;
|
/*0x64C*/ struct EmeraldBattleTowerRecord towerPlayer;
|
||||||
/*0x738*/ struct EmeraldBattleTowerRecord towerRecords[5]; // From record mixing.
|
/*0x738*/ struct EmeraldBattleTowerRecord towerRecords[BATTLE_TOWER_RECORD_COUNT]; // From record mixing.
|
||||||
/*0xBEB*/ struct BattleTowerInterview towerInterview;
|
/*0xBEB*/ struct BattleTowerInterview towerInterview;
|
||||||
/*0xBEC*/ struct BattleTowerEReaderTrainer ereaderTrainer;
|
/*0xBEC*/ struct BattleTowerEReaderTrainer ereaderTrainer;
|
||||||
/*0xCA8*/ u8 challengeStatus;
|
/*0xCA8*/ u8 challengeStatus;
|
||||||
|
|
|
@ -999,7 +999,7 @@ static bool8 ChooseSpecialBattleTowerTrainer(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
winStreak = GetCurrentBattleTowerWinStreak(lvlMode, battleMode);
|
winStreak = GetCurrentBattleTowerWinStreak(lvlMode, battleMode);
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < BATTLE_TOWER_RECORD_COUNT; i++)
|
||||||
{
|
{
|
||||||
u32 *record = (u32*)(&gSaveBlock2Ptr->frontier.towerRecords[i]);
|
u32 *record = (u32*)(&gSaveBlock2Ptr->frontier.towerRecords[i]);
|
||||||
u32 recordHasData = 0;
|
u32 recordHasData = 0;
|
||||||
|
@ -1010,7 +1010,7 @@ static bool8 ChooseSpecialBattleTowerTrainer(void)
|
||||||
checksum += record[j];
|
checksum += record[j];
|
||||||
}
|
}
|
||||||
validMons = 0;
|
validMons = 0;
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < MAX_FRONTIER_PARTY_SIZE; j++)
|
||||||
{
|
{
|
||||||
if (gSaveBlock2Ptr->frontier.towerRecords[i].party[j].species != 0
|
if (gSaveBlock2Ptr->frontier.towerRecords[i].party[j].species != 0
|
||||||
&& gSaveBlock2Ptr->frontier.towerRecords[i].party[j].level <= GetFrontierEnemyMonLevel(lvlMode))
|
&& gSaveBlock2Ptr->frontier.towerRecords[i].party[j].level <= GetFrontierEnemyMonLevel(lvlMode))
|
||||||
|
@ -1324,7 +1324,7 @@ void PutNewBattleTowerRecord(struct EmeraldBattleTowerRecord *newRecordEm)
|
||||||
struct EmeraldBattleTowerRecord *newRecord = newRecordEm; // Needed to match.
|
struct EmeraldBattleTowerRecord *newRecord = newRecordEm; // Needed to match.
|
||||||
|
|
||||||
// Find a record slot of the same player and replace it.
|
// Find a record slot of the same player and replace it.
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < BATTLE_TOWER_RECORD_COUNT; i++)
|
||||||
{
|
{
|
||||||
k = 0;
|
k = 0;
|
||||||
for (j = 0; j < TRAINER_ID_LENGTH; j++)
|
for (j = 0; j < TRAINER_ID_LENGTH; j++)
|
||||||
|
@ -1350,19 +1350,19 @@ void PutNewBattleTowerRecord(struct EmeraldBattleTowerRecord *newRecordEm)
|
||||||
if (k == PLAYER_NAME_LENGTH)
|
if (k == PLAYER_NAME_LENGTH)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i < 5)
|
if (i < BATTLE_TOWER_RECORD_COUNT)
|
||||||
{
|
{
|
||||||
gSaveBlock2Ptr->frontier.towerRecords[i] = *newRecord;
|
gSaveBlock2Ptr->frontier.towerRecords[i] = *newRecord;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find an empty record slot.
|
// Find an empty record slot.
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < BATTLE_TOWER_RECORD_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (gSaveBlock2Ptr->frontier.towerRecords[i].winStreak == 0)
|
if (gSaveBlock2Ptr->frontier.towerRecords[i].winStreak == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i < 5)
|
if (i < BATTLE_TOWER_RECORD_COUNT)
|
||||||
{
|
{
|
||||||
gSaveBlock2Ptr->frontier.towerRecords[i] = *newRecord;
|
gSaveBlock2Ptr->frontier.towerRecords[i] = *newRecord;
|
||||||
return;
|
return;
|
||||||
|
@ -1373,7 +1373,7 @@ void PutNewBattleTowerRecord(struct EmeraldBattleTowerRecord *newRecordEm)
|
||||||
slotIds[0] = 0;
|
slotIds[0] = 0;
|
||||||
slotsCount++;
|
slotsCount++;
|
||||||
|
|
||||||
for (i = 1; i < 5; i++)
|
for (i = 1; i < BATTLE_TOWER_RECORD_COUNT; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < slotsCount; j++)
|
for (j = 0; j < slotsCount; j++)
|
||||||
{
|
{
|
||||||
|
@ -2240,7 +2240,7 @@ static void GetRecordMixFriendMultiPartnerParty(u16 trainerId)
|
||||||
u16 species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL);
|
u16 species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < MAX_FRONTIER_PARTY_SIZE; i++)
|
||||||
{
|
{
|
||||||
if (gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[i].species != species1
|
if (gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[i].species != species1
|
||||||
&& gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[i].species != species2
|
&& gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[i].species != species2
|
||||||
|
@ -2362,7 +2362,7 @@ static void LoadMultiPartnerCandidatesData(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
r10 = 0;
|
r10 = 0;
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < BATTLE_TOWER_RECORD_COUNT; i++)
|
||||||
{
|
{
|
||||||
u32 *record = (u32*)(&gSaveBlock2Ptr->frontier.towerRecords[i]);
|
u32 *record = (u32*)(&gSaveBlock2Ptr->frontier.towerRecords[i]);
|
||||||
u32 recordHasData = 0;
|
u32 recordHasData = 0;
|
||||||
|
@ -2379,7 +2379,7 @@ static void LoadMultiPartnerCandidatesData(void)
|
||||||
&& gSaveBlock2Ptr->frontier.towerRecords[i].checksum == checksum)
|
&& gSaveBlock2Ptr->frontier.towerRecords[i].checksum == checksum)
|
||||||
{
|
{
|
||||||
k = 0;
|
k = 0;
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < MAX_FRONTIER_PARTY_SIZE; j++)
|
||||||
{
|
{
|
||||||
if (species1 != gSaveBlock2Ptr->frontier.towerRecords[i].party[j].species
|
if (species1 != gSaveBlock2Ptr->frontier.towerRecords[i].party[j].species
|
||||||
&& species2 != gSaveBlock2Ptr->frontier.towerRecords[i].party[j].species
|
&& species2 != gSaveBlock2Ptr->frontier.towerRecords[i].party[j].species
|
||||||
|
@ -2682,7 +2682,7 @@ static void ValidateBattleTowerRecordChecksums(void)
|
||||||
if (gSaveBlock2Ptr->frontier.towerPlayer.checksum != checksum)
|
if (gSaveBlock2Ptr->frontier.towerPlayer.checksum != checksum)
|
||||||
ClearBattleTowerRecord(&gSaveBlock2Ptr->frontier.towerPlayer);
|
ClearBattleTowerRecord(&gSaveBlock2Ptr->frontier.towerPlayer);
|
||||||
|
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < BATTLE_TOWER_RECORD_COUNT; i++)
|
||||||
{
|
{
|
||||||
record = (u32*)(&gSaveBlock2Ptr->frontier.towerRecords[i]);
|
record = (u32*)(&gSaveBlock2Ptr->frontier.towerRecords[i]);
|
||||||
checksum = 0;
|
checksum = 0;
|
||||||
|
|
Loading…
Reference in a new issue