mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 19:54:21 +01:00
Merge pull request #1416 from ProjectRevoTPP/apprentice_fix
[LEAK INFORMED] Fix apprentice.c do{}while(0)
This commit is contained in:
commit
f823cd224f
@ -322,17 +322,12 @@ static void SetRandomQuestionData(void)
|
|||||||
FREE_AND_SET_NULL(gApprenticePartyMovesData);
|
FREE_AND_SET_NULL(gApprenticePartyMovesData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No idea why a do-while loop is needed, but it will not match without it.
|
#define APPRENTICE_SPECIES_ID(monId) \
|
||||||
|
((monId < MULTI_PARTY_SIZE) ? (PLAYER_APPRENTICE.speciesIds[monId] >> (((PLAYER_APPRENTICE.party >> monId) & 1) << 2) & 0xF) : 0)
|
||||||
|
|
||||||
#define APPRENTICE_SPECIES_ID(speciesArrId, monId) speciesArrId = (PLAYER_APPRENTICE.speciesIds[monId] >> \
|
#define APPRENTICE_SPECIES_ID_NO_COND(monId, count) \
|
||||||
(((PLAYER_APPRENTICE.party >> monId) & 1) << 2)) & 0xF; \
|
monId = ((PLAYER_APPRENTICE.party >> count) & 1); \
|
||||||
do {} while (0)
|
monId = ((PLAYER_APPRENTICE.speciesIds[count]) >> (monId << 2)) & 0xF; \
|
||||||
|
|
||||||
// Why the need to have two macros do the exact thing differently?
|
|
||||||
#define APPRENTICE_SPECIES_ID_2(speciesArrId, monId) { u8 a0 = ((PLAYER_APPRENTICE.party >> monId) & 1);\
|
|
||||||
speciesArrId = PLAYER_APPRENTICE.speciesIds[monId]; \
|
|
||||||
speciesArrId = ((speciesArrId) >> (a0 << 2)) & 0xF; \
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the second move choice for the "Which move" question
|
// Get the second move choice for the "Which move" question
|
||||||
// Unlike the first move choice, this can be either a level up move or a TM/HM move
|
// Unlike the first move choice, this can be either a level up move or a TM/HM move
|
||||||
@ -348,15 +343,7 @@ static u16 GetRandomAlternateMove(u8 monId)
|
|||||||
bool32 shouldUseMove;
|
bool32 shouldUseMove;
|
||||||
u8 level;
|
u8 level;
|
||||||
|
|
||||||
if (monId < MULTI_PARTY_SIZE)
|
id = APPRENTICE_SPECIES_ID(monId);
|
||||||
{
|
|
||||||
APPRENTICE_SPECIES_ID(id, monId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
species = gApprentices[PLAYER_APPRENTICE.id].species[id];
|
species = gApprentices[PLAYER_APPRENTICE.id].species[id];
|
||||||
learnset = gLevelUpLearnsets[species];
|
learnset = gLevelUpLearnsets[species];
|
||||||
j = 0;
|
j = 0;
|
||||||
@ -551,7 +538,7 @@ static void SaveApprenticeParty(u8 numQuestions)
|
|||||||
// Save party species
|
// Save party species
|
||||||
for (i = 0; i < MULTI_PARTY_SIZE; i++)
|
for (i = 0; i < MULTI_PARTY_SIZE; i++)
|
||||||
{
|
{
|
||||||
APPRENTICE_SPECIES_ID(speciesTableId, i);
|
speciesTableId = APPRENTICE_SPECIES_ID(i);
|
||||||
apprenticeMons[i]->species = gApprentices[PLAYER_APPRENTICE.id].species[speciesTableId];
|
apprenticeMons[i]->species = gApprentices[PLAYER_APPRENTICE.id].species[speciesTableId];
|
||||||
GetLatestLearnedMoves(apprenticeMons[i]->species, apprenticeMons[i]->moves);
|
GetLatestLearnedMoves(apprenticeMons[i]->species, apprenticeMons[i]->moves);
|
||||||
}
|
}
|
||||||
@ -605,7 +592,7 @@ static void CreateApprenticeMenu(u8 menu)
|
|||||||
u16 species;
|
u16 species;
|
||||||
u32 speciesTableId;
|
u32 speciesTableId;
|
||||||
|
|
||||||
APPRENTICE_SPECIES_ID(speciesTableId, i);
|
speciesTableId = APPRENTICE_SPECIES_ID(i);
|
||||||
species = gApprentices[PLAYER_APPRENTICE.id].species[speciesTableId];
|
species = gApprentices[PLAYER_APPRENTICE.id].species[speciesTableId];
|
||||||
strings[i] = gSpeciesNames[species];
|
strings[i] = gSpeciesNames[species];
|
||||||
}
|
}
|
||||||
@ -1016,7 +1003,7 @@ static void InitQuestionData(void)
|
|||||||
{
|
{
|
||||||
// count re-used as monId
|
// count re-used as monId
|
||||||
count = PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].monId;
|
count = PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].monId;
|
||||||
APPRENTICE_SPECIES_ID_2(id1, count);
|
APPRENTICE_SPECIES_ID_NO_COND(id1, count);
|
||||||
gApprenticeQuestionData->speciesId = gApprentices[PLAYER_APPRENTICE.id].species[id1];
|
gApprenticeQuestionData->speciesId = gApprentices[PLAYER_APPRENTICE.id].species[id1];
|
||||||
gApprenticeQuestionData->moveId1 = GetDefaultMove(count, id1, PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].moveSlot);
|
gApprenticeQuestionData->moveId1 = GetDefaultMove(count, id1, PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].moveSlot);
|
||||||
gApprenticeQuestionData->moveId2 = PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].data;
|
gApprenticeQuestionData->moveId2 = PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].data;
|
||||||
@ -1030,7 +1017,7 @@ static void InitQuestionData(void)
|
|||||||
{
|
{
|
||||||
// count re-used as monId
|
// count re-used as monId
|
||||||
count = PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].monId;
|
count = PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].monId;
|
||||||
APPRENTICE_SPECIES_ID_2(id2, count);
|
APPRENTICE_SPECIES_ID_NO_COND(id2, count);
|
||||||
gApprenticeQuestionData->speciesId = gApprentices[PLAYER_APPRENTICE.id].species[id2];
|
gApprenticeQuestionData->speciesId = gApprentices[PLAYER_APPRENTICE.id].species[id2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1097,14 +1084,7 @@ static void ApprenticeBufferString(void)
|
|||||||
StringCopy(stringDst, gStringVar4);
|
StringCopy(stringDst, gStringVar4);
|
||||||
break;
|
break;
|
||||||
case APPRENTICE_BUFF_LEAD_MON_SPECIES:
|
case APPRENTICE_BUFF_LEAD_MON_SPECIES:
|
||||||
if (PLAYER_APPRENTICE.leadMonId < MULTI_PARTY_SIZE)
|
speciesArrayId = APPRENTICE_SPECIES_ID(PLAYER_APPRENTICE.leadMonId);
|
||||||
{
|
|
||||||
APPRENTICE_SPECIES_ID(speciesArrayId, PLAYER_APPRENTICE.leadMonId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
speciesArrayId = 0;
|
|
||||||
}
|
|
||||||
StringCopy(stringDst, gSpeciesNames[gApprentices[PLAYER_APPRENTICE.id].species[speciesArrayId]]);
|
StringCopy(stringDst, gSpeciesNames[gApprentices[PLAYER_APPRENTICE.id].species[speciesArrayId]]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user