Skip to content

Commit

Permalink
Replaced 0 and 1 with TYPE_PRIMARY / TYPE_SECONDARY
Browse files Browse the repository at this point in the history
  • Loading branch information
pkmnsnfrn committed Aug 4, 2024
1 parent 02f1dc6 commit 4151e85
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 58 deletions.
6 changes: 3 additions & 3 deletions include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#define NUMBER_OF_MON_TYPES 18

enum {
TYPE_PRIMARY,
TYPE_SECONDARY,
NUM_TYPE_SLOTS,
TYPE_PRIMARY,
TYPE_SECONDARY,
NUM_TYPE_SLOTS,
};

// Pokémon egg groups
Expand Down
4 changes: 2 additions & 2 deletions src/battle_ai_switch_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ u8 GetMostSuitableMonToSwitchInto(void)
&& i != *(gBattleStruct->monToSwitchIntoId + battlerIn1)
&& i != *(gBattleStruct->monToSwitchIntoId + battlerIn2))
{
u8 type1 = gSpeciesInfo[species].types[0];
u8 type2 = gSpeciesInfo[species].types[1];
u8 type1 = gSpeciesInfo[species].types[TYPE_PRIMARY];
u8 type2 = gSpeciesInfo[species].types[TYPE_SECONDARY];
u8 typeDmg = TYPE_MUL_NORMAL;
ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[TYPE_PRIMARY], type1, type2, &typeDmg);
ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[TYPE_SECONDARY], type1, type2, &typeDmg);
Expand Down
16 changes: 8 additions & 8 deletions src/battle_dome.c
Original file line number Diff line number Diff line change
Expand Up @@ -2405,8 +2405,8 @@ static void InitDomeTrainers(void)
rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPDEF, NULL);
rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_SPEED, NULL);
rankingScores[0] += GetMonData(&gPlayerParty[trainerId], MON_DATA_MAX_HP, NULL);
monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[0]];
monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[1]];
monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[TYPE_PRIMARY]];
monTypesBits |= gBitTable[gSpeciesInfo[GetMonData(&gPlayerParty[trainerId], MON_DATA_SPECIES, NULL)].types[TYPE_SECONDARY]];
}

// Count the number of types in the players party, to factor into the ranking
Expand Down Expand Up @@ -2440,8 +2440,8 @@ static void InitDomeTrainers(void)
rankingScores[i] += statValues[STAT_SPDEF];
rankingScores[i] += statValues[STAT_SPEED];
rankingScores[i] += statValues[STAT_HP];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[0]];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[1]];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_PRIMARY]];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_SECONDARY]];
}

for (monTypesCount = 0, j = 0; j < 32; j++)
Expand Down Expand Up @@ -2807,8 +2807,8 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int mode)
if (move == MOVE_NONE || move == MOVE_UNAVAILABLE || gBattleMoves[move].power == 0)
return 0;

defType1 = gSpeciesInfo[targetSpecies].types[0];
defType2 = gSpeciesInfo[targetSpecies].types[1];
defType1 = gSpeciesInfo[targetSpecies].types[TYPE_PRIMARY];
defType2 = gSpeciesInfo[targetSpecies].types[TYPE_SECONDARY];
defAbility = gSpeciesInfo[targetSpecies].abilities[0];
moveType = gBattleMoves[move].type;

Expand Down Expand Up @@ -5940,8 +5940,8 @@ static void InitRandomTourneyTreeResults(void)
statSums[i] += statValues[STAT_SPDEF];
statSums[i] += statValues[STAT_SPEED];
statSums[i] += statValues[STAT_HP];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[0]];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[1]];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_PRIMARY]];
monTypesBits |= gBitTable[gSpeciesInfo[gFacilityTrainerMons[DOME_MONS[i][j]].species].types[TYPE_SECONDARY]];
}

// Because GF hates temporary vars, trainerId acts like monTypesCount here.
Expand Down
30 changes: 15 additions & 15 deletions src/battle_factory.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ static void GetOpponentMostCommonMonType(void)
{
u8 i;
u8 typeCounts[NUMBER_OF_MON_TYPES];
u8 mostCommonTypes[2];
u8 mostCommonTypes[NUM_TYPE_SLOTS];

gFacilityTrainerMons = gBattleFrontierMons;

Expand All @@ -618,33 +618,33 @@ static void GetOpponentMostCommonMonType(void)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
u32 species = gFacilityTrainerMons[gFrontierTempParty[i]].species;
typeCounts[gSpeciesInfo[species].types[0]]++;
if (gSpeciesInfo[species].types[0] != gSpeciesInfo[species].types[1])
typeCounts[gSpeciesInfo[species].types[1]]++;
typeCounts[gSpeciesInfo[species].types[TYPE_PRIMARY]]++;
if (gSpeciesInfo[species].types[TYPE_PRIMARY] != gSpeciesInfo[species].types[TYPE_SECONDARY])
typeCounts[gSpeciesInfo[species].types[TYPE_SECONDARY]]++;
}

// Determine which are the two most-common types.
// The second most-common type is only updated if
// its count is equal to the most-common type.
mostCommonTypes[0] = 0;
mostCommonTypes[1] = 0;
mostCommonTypes[TYPE_PRIMARY] = 0;
mostCommonTypes[TYPE_SECONDARY] = 0;
for (i = 1; i < NUMBER_OF_MON_TYPES; i++)
{
if (typeCounts[mostCommonTypes[0]] < typeCounts[i])
mostCommonTypes[0] = i;
else if (typeCounts[mostCommonTypes[0]] == typeCounts[i])
mostCommonTypes[1] = i;
if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] < typeCounts[i])
mostCommonTypes[TYPE_PRIMARY] = i;
else if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] == typeCounts[i])
mostCommonTypes[TYPE_SECONDARY] = i;
}

if (typeCounts[mostCommonTypes[0]] != 0)
if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] != 0)
{
// The most-common type must be strictly greater than
// the second-most-common type, or the top two must be
// the same type.
if (typeCounts[mostCommonTypes[0]] > typeCounts[mostCommonTypes[1]])
gSpecialVar_Result = mostCommonTypes[0];
else if (mostCommonTypes[0] == mostCommonTypes[1])
gSpecialVar_Result = mostCommonTypes[0];
if (typeCounts[mostCommonTypes[TYPE_PRIMARY]] > typeCounts[mostCommonTypes[TYPE_SECONDARY]])
gSpecialVar_Result = mostCommonTypes[TYPE_PRIMARY];
else if (mostCommonTypes[TYPE_PRIMARY] == mostCommonTypes[TYPE_SECONDARY])
gSpecialVar_Result = mostCommonTypes[TYPE_PRIMARY];
else
gSpecialVar_Result = NUMBER_OF_MON_TYPES;
}
Expand Down
8 changes: 4 additions & 4 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3343,8 +3343,8 @@ void FaintClearSetData(void)

gBattleResources->flags->flags[gActiveBattler] = 0;

gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_PRIMARY];
gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_SECONDARY];

ClearBattlerMoveHistory(gActiveBattler);
ClearBattlerAbilityHistory(gActiveBattler);
Expand Down Expand Up @@ -3411,8 +3411,8 @@ static void BattleIntroDrawTrainersOrMonsSprites(void)
for (i = 0; i < sizeof(struct BattlePokemon); i++)
ptr[i] = gBattleBufferB[gActiveBattler][4 + i];

gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_PRIMARY];
gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_SECONDARY];
gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum);
hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)];
*hpOnSwitchout = gBattleMons[gActiveBattler].hp;
Expand Down
12 changes: 6 additions & 6 deletions src/battle_pike.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,21 +845,21 @@ static bool8 DoesTypePreventStatus(u16 species, u32 status)
switch (status)
{
case STATUS1_TOXIC_POISON:
if (gSpeciesInfo[species].types[0] == TYPE_STEEL || gSpeciesInfo[species].types[0] == TYPE_POISON
|| gSpeciesInfo[species].types[1] == TYPE_STEEL || gSpeciesInfo[species].types[1] == TYPE_POISON)
if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_STEEL || gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_POISON
|| gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_STEEL || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_POISON)
ret = TRUE;
break;
case STATUS1_FREEZE:
if (gSpeciesInfo[species].types[0] == TYPE_ICE || gSpeciesInfo[species].types[1] == TYPE_ICE)
if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_ICE || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_ICE)
ret = TRUE;
break;
case STATUS1_PARALYSIS:
if (gSpeciesInfo[species].types[0] == TYPE_GROUND || gSpeciesInfo[species].types[0] == TYPE_ELECTRIC
|| gSpeciesInfo[species].types[1] == TYPE_GROUND || gSpeciesInfo[species].types[1] == TYPE_ELECTRIC)
if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_GROUND || gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_ELECTRIC
|| gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_GROUND || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_ELECTRIC)
ret = TRUE;
break;
case STATUS1_BURN:
if (gSpeciesInfo[species].types[0] == TYPE_FIRE || gSpeciesInfo[species].types[1] == TYPE_FIRE)
if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_FIRE || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_FIRE)
ret = TRUE;
break;
case STATUS1_SLEEP:
Expand Down
6 changes: 3 additions & 3 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility)
{
s32 i = 0;
u8 flags = 0;
u8 type1 = gSpeciesInfo[targetSpecies].types[0], type2 = gSpeciesInfo[targetSpecies].types[1];
u8 type1 = gSpeciesInfo[targetSpecies].types[TYPE_PRIMARY], type2 = gSpeciesInfo[targetSpecies].types[TYPE_SECONDARY];
u8 moveType;

if (move == MOVE_STRUGGLE)
Expand Down Expand Up @@ -4623,8 +4623,8 @@ static void Cmd_switchindataupdate(void)
for (i = 0; i < sizeof(struct BattlePokemon); i++)
monData[i] = gBattleBufferB[gActiveBattler][4 + i];

gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
gBattleMons[gActiveBattler].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_PRIMARY];
gBattleMons[gActiveBattler].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[TYPE_SECONDARY];
gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum);

// check knocked off item
Expand Down
2 changes: 1 addition & 1 deletion src/contest.c
Original file line number Diff line number Diff line change
Expand Up @@ -5314,7 +5314,7 @@ static void SetMoveSpecificAnimData(u8 contestant)
switch (move)
{
case MOVE_CURSE:
if (gSpeciesInfo[species].types[0] == TYPE_GHOST || gSpeciesInfo[species].types[1] == TYPE_GHOST)
if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_GHOST || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_GHOST)
gAnimMoveTurn = 0;
else
gAnimMoveTurn = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/field_specials.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ void IsGrassTypeInParty(void)
if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && !GetMonData(pokemon, MON_DATA_IS_EGG))
{
species = GetMonData(pokemon, MON_DATA_SPECIES);
if (gSpeciesInfo[species].types[0] == TYPE_GRASS || gSpeciesInfo[species].types[1] == TYPE_GRASS)
if (gSpeciesInfo[species].types[TYPE_PRIMARY] == TYPE_GRASS || gSpeciesInfo[species].types[TYPE_SECONDARY] == TYPE_GRASS)
{
gSpecialVar_Result = TRUE;
return;
Expand Down
12 changes: 6 additions & 6 deletions src/pokedex.c
Original file line number Diff line number Diff line change
Expand Up @@ -4741,9 +4741,9 @@ static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, u8 bodyColor, u8 t
{
species = NationalPokedexNumToSpecies(sPokedexView->pokedexList[i].dexNum);

types[0] = gSpeciesInfo[species].types[0];
types[1] = gSpeciesInfo[species].types[1];
if (types[0] == type1 || types[1] == type1)
types[TYPE_PRIMARY] = gSpeciesInfo[species].types[TYPE_PRIMARY];
types[TYPE_SECONDARY] = gSpeciesInfo[species].types[TYPE_SECONDARY];
if (types[TYPE_PRIMARY] == type1 || types[TYPE_SECONDARY] == type1)
{
sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i];
resultsCount++;
Expand All @@ -4759,9 +4759,9 @@ static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, u8 bodyColor, u8 t
{
species = NationalPokedexNumToSpecies(sPokedexView->pokedexList[i].dexNum);

types[0] = gSpeciesInfo[species].types[0];
types[1] = gSpeciesInfo[species].types[1];
if ((types[0] == type1 && types[1] == type2) || (types[0] == type2 && types[1] == type1))
types[TYPE_PRIMARY] = gSpeciesInfo[species].types[TYPE_PRIMARY];
types[TYPE_SECONDARY] = gSpeciesInfo[species].types[TYPE_SECONDARY];
if ((types[TYPE_PRIMARY] == type1 && types[TYPE_SECONDARY] == type2) || (types[TYPE_PRIMARY] == type2 && types[TYPE_SECONDARY] == type1))
{
sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i];
resultsCount++;
Expand Down
4 changes: 2 additions & 2 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -4670,8 +4670,8 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex)
gBattleMons[battlerId].isEgg = GetMonData(&gPlayerParty[partyIndex], MON_DATA_IS_EGG, NULL);
gBattleMons[battlerId].abilityNum = GetMonData(&gPlayerParty[partyIndex], MON_DATA_ABILITY_NUM, NULL);
gBattleMons[battlerId].otId = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_ID, NULL);
gBattleMons[battlerId].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[0];
gBattleMons[battlerId].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[1];
gBattleMons[battlerId].types[TYPE_PRIMARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[TYPE_PRIMARY];
gBattleMons[battlerId].types[TYPE_SECONDARY] = gSpeciesInfo[gBattleMons[battlerId].species].types[TYPE_SECONDARY];
gBattleMons[battlerId].ability = GetAbilityBySpecies(gBattleMons[battlerId].species, gBattleMons[battlerId].abilityNum);
GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, nickname);
StringCopy_Nickname(gBattleMons[battlerId].nickname, nickname);
Expand Down
6 changes: 3 additions & 3 deletions src/pokemon_summary_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3796,10 +3796,10 @@ static void SetMonTypeIcons(void)
}
else
{
SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[0], 120, 48, SPRITE_ARR_ID_TYPE);
if (gSpeciesInfo[summary->species].types[0] != gSpeciesInfo[summary->species].types[1])
SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[TYPE_PRIMARY], 120, 48, SPRITE_ARR_ID_TYPE);
if (gSpeciesInfo[summary->species].types[TYPE_PRIMARY] != gSpeciesInfo[summary->species].types[TYPE_SECONDARY])
{
SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[1], 160, 48, SPRITE_ARR_ID_TYPE + 1);
SetTypeSpritePosAndPal(gSpeciesInfo[summary->species].types[TYPE_SECONDARY], 160, 48, SPRITE_ARR_ID_TYPE + 1);
SetSpriteInvisibility(SPRITE_ARR_ID_TYPE + 1, FALSE);
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/trade.c
Original file line number Diff line number Diff line change
Expand Up @@ -2532,8 +2532,8 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf
else
{
// Player's Pokémon must be of the type the partner requested
if (gSpeciesInfo[playerSpecies2].types[0] != requestedType
&& gSpeciesInfo[playerSpecies2].types[1] != requestedType)
if (gSpeciesInfo[playerSpecies2].types[TYPE_PRIMARY] != requestedType
&& gSpeciesInfo[playerSpecies2].types[TYPE_SECONDARY] != requestedType)
return UR_TRADE_MSG_NOT_MON_PARTNER_WANTS;
}

Expand Down
2 changes: 1 addition & 1 deletion src/union_room.c
Original file line number Diff line number Diff line change
Expand Up @@ -4187,7 +4187,7 @@ static s32 IsRequestedTradeInPlayerParty(u32 type, u32 species)
for (i = 0; i < gPlayerPartyCount; i++)
{
species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG);
if (gSpeciesInfo[species].types[0] == type || gSpeciesInfo[species].types[1] == type)
if (gSpeciesInfo[species].types[TYPE_PRIMARY] == type || gSpeciesInfo[species].types[TYPE_SECONDARY] == type)
return UR_TRADE_MATCH;
}
return UR_TRADE_NOTYPE;
Expand Down
2 changes: 1 addition & 1 deletion src/wild_encounter.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ static bool8 TryGetRandomWildMonIndexByType(const struct WildPokemon *wildMon, u

for (validMonCount = 0, i = 0; i < numMon; i++)
{
if (gSpeciesInfo[wildMon[i].species].types[0] == type || gSpeciesInfo[wildMon[i].species].types[1] == type)
if (gSpeciesInfo[wildMon[i].species].types[TYPE_PRIMARY] == type || gSpeciesInfo[wildMon[i].species].types[TYPE_SECONDARY] == type)
validIndexes[validMonCount++] = i;
}

Expand Down

0 comments on commit 4151e85

Please sign in to comment.