From 70924c64b43ec89df27353569654b8ff16334149 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Mon, 19 Feb 2024 13:11:53 -0300 Subject: [PATCH] Better handling of disabling followers --- include/pokemon.h | 2 ++ src/data/pokemon/species_info.h | 2 ++ src/event_object_movement.c | 16 ++++++++-------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index 1b82018da6..102ed848f8 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -444,7 +444,9 @@ struct SpeciesInfo /*0x8C*/ /* 0x88 */ const struct Evolution *evolutions; /* 0x84 */ const u16 *formSpeciesIdTable; /* 0x84 */ const struct FormChange *formChangeTable; +#if OW_FOLLOWERS_ENABLED struct ObjectEventGraphicsInfo followerData; +#endif }; struct MoveInfo diff --git a/src/data/pokemon/species_info.h b/src/data/pokemon/species_info.h index 988be68b2e..1e637562ff 100644 --- a/src/data/pokemon/species_info.h +++ b/src/data/pokemon/species_info.h @@ -291,7 +291,9 @@ const struct SpeciesInfo gSpeciesInfo[] = .backAnimId = BACK_ANIM_NONE, PALETTES(CircledQuestionMark), ICON(QuestionMark, 0), + #if OW_FOLLOWERS_ENABLED .followerData = {TAG_NONE, OBJ_EVENT_PAL_TAG_SUBSTITUTE, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, COMP, TRACKS_FOOT, &gObjectEventBaseOam_32x32, sOamTables_32x32, sAnimTable_Following, sPicTable_Substitute, gDummySpriteAffineAnimTable}, + #endif LEARNSETS(None), }, diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 078bfe25ea..3de6799743 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1836,7 +1836,8 @@ struct ObjectEvent * GetFollowerObject(void) // Return graphicsInfo for a pokemon species & form static const struct ObjectEventGraphicsInfo * SpeciesToGraphicsInfo(u16 species, u8 form) { - const struct ObjectEventGraphicsInfo *graphicsInfo; + const struct ObjectEventGraphicsInfo *graphicsInfo = NULL; +#if OW_FOLLOWERS_ENABLED switch (species) { case SPECIES_UNOWN: // Letters >A are defined as species >= NUM_SPECIES, so are not contiguous with A @@ -1852,8 +1853,8 @@ static const struct ObjectEventGraphicsInfo * SpeciesToGraphicsInfo(u16 species, return &gSpeciesInfo[SPECIES_NONE].followerData; else if (graphicsInfo->tileTag != TAG_NONE && species >= NUM_SPECIES) return &gSpeciesInfo[SPECIES_NONE].followerData; - else - return graphicsInfo; +#endif + return graphicsInfo; } // Find, or load, the palette for the specified pokemon info @@ -2023,9 +2024,10 @@ void UpdateFollowingPokemon(void) // 1. GetFollowerInfo returns FALSE // 2. Map is indoors and gfx is larger than 32x32 // 3. flag is set - if (!GetFollowerInfo(&species, &form, &shiny) || - (gMapHeader.mapType == MAP_TYPE_INDOOR && SpeciesToGraphicsInfo(species, 0)->oam->size > ST_OAM_SIZE_2) || - FlagGet(FLAG_TEMP_HIDE_FOLLOWER)) + if (OW_FOLLOWERS_ENABLED == FALSE + || !GetFollowerInfo(&species, &form, &shiny) + || (gMapHeader.mapType == MAP_TYPE_INDOOR && SpeciesToGraphicsInfo(species, 0)->oam->size > ST_OAM_SIZE_2) + || FlagGet(FLAG_TEMP_HIDE_FOLLOWER)) { RemoveFollowingPokemon(); return; @@ -2080,8 +2082,6 @@ void RemoveFollowingPokemon(void) // Determine whether follower *should* be visible static bool32 IsFollowerVisible(void) { - if (OW_FOLLOWERS_ENABLED == FALSE) - return FALSE; return !(TestPlayerAvatarFlags(FOLLOWER_INVISIBLE_FLAGS) || MetatileBehavior_IsSurfableWaterOrUnderwater(gObjectEvents[gPlayerAvatar.objectEventId].previousMetatileBehavior)