Removed TrainerMonPtr

This commit is contained in:
Eduardo Quezada 2023-07-05 18:23:18 -04:00
parent 2f9e0ecd9f
commit b86184a4f6
7 changed files with 11 additions and 16 deletions

View File

@ -52,17 +52,12 @@ struct TrainerMonCustomized
bool8 isShiny : 1; bool8 isShiny : 1;
}; };
#define EVERYTHING_CUSTOMIZED(party) { .EverythingCustomized = party}, .partySize = ARRAY_COUNT(party) #define EVERYTHING_CUSTOMIZED(partyArray) partyArray, .partySize = ARRAY_COUNT(partyArray)
union TrainerMonPtr
{
const struct TrainerMonCustomized *EverythingCustomized;
};
struct Trainer struct Trainer
{ {
/*0x00*/ u32 aiFlags; /*0x00*/ u32 aiFlags;
/*0x04*/ union TrainerMonPtr party; /*0x04*/ const struct TrainerMonCustomized *party;
/*0x08*/ u16 items[MAX_TRAINER_ITEMS]; /*0x08*/ u16 items[MAX_TRAINER_ITEMS];
/*0x10*/ u8 trainerClass; /*0x10*/ u8 trainerClass;
/*0x11*/ u8 encounterMusic_gender; // last bit is gender /*0x11*/ u8 encounterMusic_gender; // last bit is gender

View File

@ -1883,8 +1883,8 @@ static u32 Crc32B (const u8 *data, u32 size)
static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i) static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i)
{ {
const u8 *buffer = (const u8 *) &trainer->party.EverythingCustomized[i]; const u8 *buffer = (const u8 *) &trainer->party[i];
u32 n = sizeof(*trainer->party.EverythingCustomized); u32 n = sizeof(*trainer->party);
return Crc32B(buffer, n); return Crc32B(buffer, n);
} }
@ -1962,7 +1962,7 @@ u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer
for (i = 0; i < monsCount; i++) for (i = 0; i < monsCount; i++)
{ {
u32 personalityHash = GeneratePartyHash(trainer, i); u32 personalityHash = GeneratePartyHash(trainer, i);
const struct TrainerMonCustomized *partyData = trainer->party.EverythingCustomized; const struct TrainerMonCustomized *partyData = trainer->party;
u32 otIdType = OT_ID_RANDOM_NO_SHINY; u32 otIdType = OT_ID_RANDOM_NO_SHINY;
u32 fixedOtId = 0; u32 fixedOtId = 0;

View File

@ -7337,7 +7337,7 @@ static u32 GetTrainerMoneyToGive(u16 trainerId)
} }
else else
{ {
const struct TrainerMonCustomized *party = gTrainers[trainerId].party.EverythingCustomized; const struct TrainerMonCustomized *party = gTrainers[trainerId].party;
lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl; lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl;
for (; gTrainerMoneyTable[i].classId != 0xFF; i++) for (; gTrainerMoneyTable[i].classId != 0xFF; i++)

View File

@ -765,7 +765,7 @@ static u8 GetSumOfEnemyPartyLevel(u16 opponentId, u8 numMons)
sum = 0; sum = 0;
party = gTrainers[opponentId].party.EverythingCustomized; party = gTrainers[opponentId].party;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
sum += party[i].lvl; sum += party[i].lvl;

View File

@ -3049,7 +3049,7 @@ static void FillPartnerParty(u16 trainerId)
for (i = 0; i < 3 && i < gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].partySize; i++) for (i = 0; i < 3 && i < gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].partySize; i++)
{ {
const struct TrainerMonCustomized *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party.EverythingCustomized; const struct TrainerMonCustomized *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party;
u32 otIdType = OT_ID_RANDOM_NO_SHINY; u32 otIdType = OT_ID_RANDOM_NO_SHINY;
do do
{ {

View File

@ -9,7 +9,7 @@ const struct Trainer gTrainers[] = {
.doubleBattle = FALSE, .doubleBattle = FALSE,
.aiFlags = 0, .aiFlags = 0,
.partySize = 0, .partySize = 0,
.party = {.EverythingCustomized = NULL}, .party = NULL,
}, },
[TRAINER_SAWYER_1] = [TRAINER_SAWYER_1] =

View File

@ -1789,14 +1789,14 @@ static void PopulateSpeciesFromTrainerLocation(int matchCallId, u8 *destStr)
static void PopulateSpeciesFromTrainerParty(int matchCallId, u8 *destStr) static void PopulateSpeciesFromTrainerParty(int matchCallId, u8 *destStr)
{ {
u16 trainerId; u16 trainerId;
union TrainerMonPtr party; const struct TrainerMonCustomized *party;
u8 monId; u8 monId;
const u8 *speciesName; const u8 *speciesName;
trainerId = GetLastBeatenRematchTrainerId(sMatchCallTrainers[matchCallId].trainerId); trainerId = GetLastBeatenRematchTrainerId(sMatchCallTrainers[matchCallId].trainerId);
party = gTrainers[trainerId].party; party = gTrainers[trainerId].party;
monId = Random() % gTrainers[trainerId].partySize; monId = Random() % gTrainers[trainerId].partySize;
speciesName = gSpeciesNames[party.EverythingCustomized[monId].species]; speciesName = gSpeciesNames[party[monId].species];
StringCopy(destStr, speciesName); StringCopy(destStr, speciesName);
} }