Skip to content

Commit

Permalink
REGION_CURRENT to inline function
Browse files Browse the repository at this point in the history
  • Loading branch information
AsparagusEduardo committed Dec 31, 2024
1 parent 96b58c0 commit bcccbaf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
3 changes: 0 additions & 3 deletions include/constants/regions.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@ enum Region
REGION_COUNT,
};

// TODO: Since there's no current multi-region support, we have this constant for the purposes of regional form comparisons.
#define REGION_CURRENT REGION_HOENN

#endif // GUARD_CONSTANTS_REGIONS_H
12 changes: 12 additions & 0 deletions include/regions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef GUARD_REGIONS_H
#define GUARD_REGIONS_H

#include "constants/regions.h"

static inline u32 GetCurrentRegion(void)
{
// TODO: Since there's no current multi-region support, we have this constant for the purposes of regional form comparisons.
return REGION_HOENN;
}

#endif // GUARD_REGIONS_H
14 changes: 8 additions & 6 deletions src/daycare.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "list_menu.h"
#include "overworld.h"
#include "item.h"
#include "regions.h"
#include "constants/form_change_types.h"
#include "constants/items.h"
#include "constants/hold_effects.h"
Expand Down Expand Up @@ -979,11 +980,12 @@ STATIC_ASSERT(P_SCATTERBUG_LINE_FORM_BREED == SPECIES_SCATTERBUG_ICY_SNOW || (P_

static u16 DetermineEggSpeciesAndParentSlots(struct DayCare *daycare, u8 *parentSlots)
{
u16 i;
u16 species[DAYCARE_MON_COUNT];
u16 eggSpecies, parentSpecies;
u32 i;
u32 species[DAYCARE_MON_COUNT];
u32 eggSpecies, parentSpecies;
bool32 hasMotherEverstone, hasFatherEverstone, motherIsForeign, fatherIsForeign;
bool32 motherEggSpecies, fatherEggSpecies;
u32 currentRegion = GetCurrentRegion();

for (i = 0; i < DAYCARE_MON_COUNT; i++)
{
Expand All @@ -1004,15 +1006,15 @@ static u16 DetermineEggSpeciesAndParentSlots(struct DayCare *daycare, u8 *parent
fatherEggSpecies = GetEggSpecies(species[parentSlots[1]]);
hasMotherEverstone = ItemId_GetHoldEffect(GetBoxMonData(&daycare->mons[parentSlots[0]].mon, MON_DATA_HELD_ITEM)) == HOLD_EFFECT_PREVENT_EVOLVE;
hasFatherEverstone = ItemId_GetHoldEffect(GetBoxMonData(&daycare->mons[parentSlots[1]].mon, MON_DATA_HELD_ITEM)) == HOLD_EFFECT_PREVENT_EVOLVE;
motherIsForeign = IsSpeciesForeignRegionalForm(motherEggSpecies, REGION_CURRENT);
fatherIsForeign = IsSpeciesForeignRegionalForm(fatherEggSpecies, REGION_CURRENT);
motherIsForeign = IsSpeciesForeignRegionalForm(motherEggSpecies, currentRegion);
fatherIsForeign = IsSpeciesForeignRegionalForm(fatherEggSpecies, currentRegion);

if (hasMotherEverstone)
parentSpecies = motherEggSpecies;
else if (fatherIsForeign && hasFatherEverstone)
parentSpecies = fatherEggSpecies;
else if (motherIsForeign)
parentSpecies = GetRegionalForm(motherEggSpecies, REGION_CURRENT);
parentSpecies = GetRegionalForm(motherEggSpecies, currentRegion);
else
parentSpecies = motherEggSpecies;

Expand Down
3 changes: 2 additions & 1 deletion test/daycare.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "event_data.h"
#include "malloc.h"
#include "party_menu.h"
#include "regions.h"
#include "test/overworld_script.h"
#include "test/test.h"

Expand Down Expand Up @@ -71,7 +72,7 @@ TEST("Daycare Pokémon with regional forms give the correct offspring")
ASSUME(P_FAMILY_MEOWTH == TRUE);
ASSUME(P_ALOLAN_FORMS == TRUE);
ASSUME(P_GALARIAN_FORMS == TRUE);
ASSUME(REGION_CURRENT == REGION_HOENN);
ASSUME(GetCurrentRegion() == REGION_HOENN);

ZeroPlayerPartyMons();
PARAMETRIZE { offspring = SPECIES_MEOWTH; RUN_OVERWORLD_SCRIPT(givemon SPECIES_MEOWTH, 1, gender=MON_MALE; givemon SPECIES_MEOWTH_ALOLA, 1, gender=MON_FEMALE;); }
Expand Down

0 comments on commit bcccbaf

Please sign in to comment.