From 11044c6d89907428ca81df9451e6aca842fed5b3 Mon Sep 17 00:00:00 2001 From: tertu marybig Date: Fri, 9 Aug 2024 21:44:07 -0500 Subject: [PATCH 1/2] Fix some null pointer uses --- src/field_control_avatar.c | 8 +++++++- src/pokemon_storage_system.c | 16 +++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 5e709a9fb0d0..877eb6cf4e11 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -664,8 +664,14 @@ static void UpdateLetsGoEvolutionTracker(void) { u32 i; u16 count; + const struct Evolution *evolutions; struct Pokemon *followingMon = GetFirstLiveMon(); - const struct Evolution *evolutions = GetSpeciesEvolutions(GetMonData(followingMon, MON_DATA_SPECIES)); + if (!followingMon) + { + return; + } + + evolutions = GetSpeciesEvolutions(GetMonData(followingMon, MON_DATA_SPECIES)); if (evolutions == NULL) return; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index c846e8facf82..379d1603f15e 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1997,7 +1997,10 @@ static void VBlankCB_PokeStorage(void) ProcessSpriteCopyRequests(); UnkUtil_Run(); TransferPlttBuffer(); - SetGpuReg(REG_OFFSET_BG2HOFS, sStorage->bg2_X); + if (sStorage != NULL) + { + SetGpuReg(REG_OFFSET_BG2HOFS, sStorage->bg2_X); + } } static void CB2_PokeStorage(void) @@ -4205,11 +4208,14 @@ static void StopFlashingCloseBoxButton(void) static void UpdateCloseBoxButtonFlash(void) { - if (sStorage->closeBoxFlashing && ++sStorage->closeBoxFlashTimer > 30) + if (sStorage != NULL) { - sStorage->closeBoxFlashTimer = 0; - sStorage->closeBoxFlashState = (sStorage->closeBoxFlashState == FALSE); - UpdateCloseBoxButtonTilemap(sStorage->closeBoxFlashState); + if (sStorage->closeBoxFlashing && ++sStorage->closeBoxFlashTimer > 30) + { + sStorage->closeBoxFlashTimer = 0; + sStorage->closeBoxFlashState = (sStorage->closeBoxFlashState == FALSE); + UpdateCloseBoxButtonTilemap(sStorage->closeBoxFlashState); + } } } From 561d079bc1d59eccc90205804d8dd53b928d8fb1 Mon Sep 17 00:00:00 2001 From: tertu marybig Date: Fri, 9 Aug 2024 21:48:38 -0500 Subject: [PATCH 2/2] fix bad merge --- src/field_control_avatar.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index bcbde8dd59fe..582617d555a1 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -662,35 +662,8 @@ static void UpdateFriendshipStepCounter(void) static void UpdateFollowerStepCounter(void) { -<<<<<<< HEAD - u32 i; - u16 count; - const struct Evolution *evolutions; - struct Pokemon *followingMon = GetFirstLiveMon(); - if (!followingMon) - { - return; - } - - evolutions = GetSpeciesEvolutions(GetMonData(followingMon, MON_DATA_SPECIES)); - - if (evolutions == NULL) - return; - - for (i = 0; evolutions[i].method != EVOLUTIONS_END; i++) - { - if (evolutions[i].method != EVO_OVERWORLD_STEPS || SanitizeSpeciesId(evolutions[i].targetSpecies) == SPECIES_NONE) - continue; - - // We only have 10 bits to use - count = min(1023, GetMonData(followingMon, MON_DATA_EVOLUTION_TRACKER) + 1); - SetMonData(followingMon, MON_DATA_EVOLUTION_TRACKER, &count); - return; - } -======= if (gPlayerPartyCount > 0 && gFollowerSteps < (u16)-1) gFollowerSteps++; ->>>>>>> ex-upcoming } void ClearPoisonStepCounter(void)