From f6f305ef1d6599bb38e74b53830ac8f79b280436 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Mon, 20 Nov 2023 11:06:20 +0100 Subject: [PATCH] Clean up time of day code --- src/battle_script_commands.c | 3 +-- src/pokemon.c | 6 ++---- src/rtc.c | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 08081d030d..9268e99ca2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14878,8 +14878,7 @@ static void Cmd_handleballthrow(void) ballMultiplier = 400; break; case ITEM_DUSK_BALL: - RtcCalcLocalTime(); - if ((gLocalTime.hours >= 20 && gLocalTime.hours <= 3) || gMapHeader.cave || gMapHeader.mapType == MAP_TYPE_UNDERGROUND) + if ((GetTimeOfDay() == TIME_DUSK || GetTimeOfDay() == TIME_NIGHT) || gMapHeader.cave || gMapHeader.mapType == MAP_TYPE_UNDERGROUND) ballMultiplier = (B_DUSK_BALL_MODIFIER >= GEN_7 ? 300 : 350); break; case ITEM_QUICK_BALL: diff --git a/src/pokemon.c b/src/pokemon.c index 4c021f040e..97577efbb0 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -9072,13 +9072,11 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 switch (formChanges[i].param1) { case DAY: - RtcCalcLocalTime(); - if (gLocalTime.hours >= DAY_EVO_HOUR_BEGIN && gLocalTime.hours < DAY_EVO_HOUR_END) + if (GetTimeOfDay() != TIME_NIGHT) targetSpecies = formChanges[i].targetSpecies; break; case NIGHT: - RtcCalcLocalTime(); - if (gLocalTime.hours >= NIGHT_EVO_HOUR_BEGIN && gLocalTime.hours < NIGHT_EVO_HOUR_END) + if (GetTimeOfDay() == TIME_NIGHT) targetSpecies = formChanges[i].targetSpecies; break; } diff --git a/src/rtc.c b/src/rtc.c index 085a05b24c..d6f5377d98 100644 --- a/src/rtc.c +++ b/src/rtc.c @@ -310,8 +310,7 @@ u8 GetTimeOfDay(void) return TIME_DUSK; else if (IsBetweenHours(gLocalTime.hours, NIGHT_EVO_HOUR_BEGIN, NIGHT_EVO_HOUR_END)) return TIME_NIGHT; - else - return TIME_DAY; + return TIME_DAY; } void RtcInitLocalTimeOffset(s32 hour, s32 minute)