From 2a8f4b03dcc63af895f125254f12f1f379259bcc Mon Sep 17 00:00:00 2001 From: hedara90 <90hedara@gmail.com> Date: Wed, 22 Jan 2025 21:25:24 +0100 Subject: [PATCH] Revert "Revert map related enum conversion" (#6079) --- include/constants/map_types.h | 14 ------------- include/overworld.h | 11 ---------- src/dexnav.c | 6 ++---- src/field_screen_effect.c | 6 ++---- src/fldeff_flash.c | 4 ---- src/item_use.c | 3 +-- src/overworld.c | 38 +++++++++-------------------------- 7 files changed, 15 insertions(+), 67 deletions(-) diff --git a/include/constants/map_types.h b/include/constants/map_types.h index cb3001f265c..86571434e4a 100755 --- a/include/constants/map_types.h +++ b/include/constants/map_types.h @@ -1,19 +1,6 @@ #ifndef GUARD_CONSTANTS_MAP_TYPES_H #define GUARD_CONSTANTS_MAP_TYPES_H -#define MAP_TYPE_NONE 0 -#define MAP_TYPE_TOWN 1 -#define MAP_TYPE_CITY 2 -#define MAP_TYPE_ROUTE 3 -#define MAP_TYPE_UNDERGROUND 4 -#define MAP_TYPE_UNDERWATER 5 -#define MAP_TYPE_OCEAN_ROUTE 6 -#define MAP_TYPE_UNKNOWN 7 // Not used by any map. -#define MAP_TYPE_INDOOR 8 -#define MAP_TYPE_SECRET_BASE 9 - -// Commented out until the release of Porymap 6 -/* enum MapType { MAP_TYPE_NONE, @@ -27,7 +14,6 @@ enum MapType MAP_TYPE_INDOOR, MAP_TYPE_SECRET_BASE, }; -*/ enum MapBattleScene { diff --git a/include/overworld.h b/include/overworld.h index 4dfb07ea255..2a4cdc326cb 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -118,24 +118,13 @@ void TryFadeOutOldMapMusic(void); bool8 BGMusicStopped(void); void Overworld_FadeOutMapMusic(void); void UpdateAmbientCry(s16 *state, u16 *delayCounter); -/* enum MapType GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum); enum MapType GetMapTypeByWarpData(struct WarpData *warp); enum MapType GetCurrentMapType(void); enum MapType GetLastUsedWarpMapType(void); -*/ -u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum); -u8 GetMapTypeByWarpData(struct WarpData *warp); -u8 GetCurrentMapType(void); -u8 GetLastUsedWarpMapType(void); -bool8 IsMapTypeOutdoors(u8 mapType); -bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType); -bool8 IsMapTypeIndoors(u8 mapType); -/* bool8 IsMapTypeOutdoors(enum MapType mapType); bool8 Overworld_MapTypeAllowsTeleportAndFly(enum MapType mapType); bool8 IsMapTypeIndoors(enum MapType mapType); -*/ u8 GetSavedWarpRegionMapSectionId(void); u8 GetCurrentRegionMapSectionId(void); enum MapBattleScene GetCurrentMapBattleScene(void); diff --git a/src/dexnav.c b/src/dexnav.c index c6af17f8ed6..8abaf31e8b3 100644 --- a/src/dexnav.c +++ b/src/dexnav.c @@ -612,8 +612,7 @@ static bool8 DexNavPickTile(u8 environment, u8 areaX, u8 areaY, bool8 smallScan) bool8 nextIter; u8 scale = 0; u8 weight = 0; - //enum MapType currMapType = GetCurrentMapType(); - u8 currMapType = GetCurrentMapType(); + enum MapType currMapType = GetCurrentMapType(); u8 tileBehaviour; u8 tileBuffer = 2; u8 *xPos = AllocZeroed((botX - topX) * (botY - topY) * sizeof(u8)); @@ -725,8 +724,7 @@ static bool8 DexNavPickTile(u8 environment, u8 areaX, u8 areaY, bool8 smallScan) static bool8 TryStartHiddenMonFieldEffect(u8 environment, u8 xSize, u8 ySize, bool8 smallScan) { - //enum MapType currMapType = GetCurrentMapType(); - u8 currMapType = GetCurrentMapType(); + enum MapType currMapType = GetCurrentMapType(); u8 fldEffId = 0; if (DexNavPickTile(environment, xSize, ySize, smallScan)) diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index 338886e7a8d..3fe73c1cc59 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -86,8 +86,7 @@ static void FillPalBufferBlack(void) void WarpFadeInScreen(void) { - //enum MapType previousMapType = GetLastUsedWarpMapType(); - u8 previousMapType = GetLastUsedWarpMapType(); + enum MapType previousMapType = GetLastUsedWarpMapType(); switch (GetMapPairFadeFromType(previousMapType, GetCurrentMapType())) { case 0: @@ -114,8 +113,7 @@ void FadeInFromBlack(void) void WarpFadeOutScreen(void) { - //enum MapType currentMapType = GetCurrentMapType(); - u8 currentMapType = GetCurrentMapType(); + enum MapType currentMapType = GetCurrentMapType(); switch (GetMapPairFadeToType(currentMapType, GetDestinationWarpMapHeader()->mapType)) { case 0: diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c index 421bd9b7d7b..5663c86c27c 100644 --- a/src/fldeff_flash.c +++ b/src/fldeff_flash.c @@ -153,12 +153,8 @@ void CB2_DoChangeMap(void) static bool8 TryDoMapTransition(void) { u8 i; - /* enum MapType fromType = GetLastUsedWarpMapType(); enum MapType toType = GetCurrentMapType(); - */ - u8 fromType = GetLastUsedWarpMapType(); - u8 toType = GetCurrentMapType(); for (i = 0; sTransitionTypes[i].fromType; i++) { diff --git a/src/item_use.c b/src/item_use.c index 05e21cf60b2..09eceaf6e7a 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -1471,8 +1471,7 @@ static bool32 IsValidLocationForVsSeeker(void) { u16 mapGroup = gSaveBlock1Ptr->location.mapGroup; u16 mapNum = gSaveBlock1Ptr->location.mapNum; - //enum MapType mapType = gMapHeader.mapType; - u8 mapType = gMapHeader.mapType; + enum MapType mapType = gMapHeader.mapType; typedef struct { u16 mapGroup; diff --git a/src/overworld.c b/src/overworld.c index 6cd71d0f32a..2a717b75861 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -172,12 +172,8 @@ static void SetKeyInterceptCallback(u16 (*func)(u32)); static void SetFieldVBlankCallback(void); static void FieldClearVBlankHBlankCallbacks(void); static void TransitionMapMusic(void); -/* static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 metatileBehavior, enum MapType mapType); static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, enum MapType mapType); -*/ -static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 metatileBehavior, u8 mapType); -static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, u8 mapType); static u16 GetCenterScreenMetatileBehavior(void); static void *sUnusedOverworldCallback; @@ -722,12 +718,8 @@ void SetLastHealLocationWarp(u8 healLocationId) void UpdateEscapeWarp(s16 x, s16 y) { - /* enum MapType currMapType = GetCurrentMapType(); enum MapType destMapType = GetMapTypeByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum); - */ - u8 currMapType = GetCurrentMapType(); - u8 destMapType = GetMapTypeByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum); if (IsMapTypeOutdoors(currMapType) && IsMapTypeOutdoors(destMapType) != TRUE) SetEscapeWarp(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, WARP_ID_NONE, x - MAP_OFFSET, y - MAP_OFFSET + 1); } @@ -972,8 +964,7 @@ void StoreInitialPlayerAvatarState(void) static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void) { struct InitialPlayerAvatarState playerStruct; - u8 mapType = GetCurrentMapType(); - //enum MapType mapType = GetCurrentMapType(); + enum MapType mapType = GetCurrentMapType(); u16 metatileBehavior = GetCenterScreenMetatileBehavior(); u8 transitionFlags = GetAdjustedInitialTransitionFlags(&sInitialPlayerAvatarState, metatileBehavior, mapType); playerStruct.transitionFlags = transitionFlags; @@ -982,8 +973,7 @@ static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void) return &sInitialPlayerAvatarState; } -//static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 metatileBehavior, enum MapType mapType) -static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 metatileBehavior, u8 mapType) +static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 metatileBehavior, enum MapType mapType) { if (mapType != MAP_TYPE_INDOOR && FlagGet(FLAG_SYS_CRUISE_MODE)) return PLAYER_AVATAR_FLAG_ON_FOOT; @@ -1001,8 +991,7 @@ static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *pla return PLAYER_AVATAR_FLAG_ACRO_BIKE; } -//static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, enum MapType mapType) -static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, u8 mapType) +static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, enum MapType mapType) { if (FlagGet(FLAG_SYS_CRUISE_MODE) && mapType == MAP_TYPE_OCEAN_ROUTE) return DIR_EAST; @@ -1411,32 +1400,27 @@ static void ChooseAmbientCrySpecies(void) } } -//enum MapType GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum) -u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum) +enum MapType GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum) { return Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum)->mapType; } -//enum MapType GetMapTypeByWarpData(struct WarpData *warp) -u8 GetMapTypeByWarpData(struct WarpData *warp) +enum MapType GetMapTypeByWarpData(struct WarpData *warp) { return GetMapTypeByGroupAndId(warp->mapGroup, warp->mapNum); } -//enum MapType GetCurrentMapType(void) -u8 GetCurrentMapType(void) +enum MapType GetCurrentMapType(void) { return GetMapTypeByWarpData(&gSaveBlock1Ptr->location); } -//enum MapType GetLastUsedWarpMapType(void) -u8 GetLastUsedWarpMapType(void) +enum MapType GetLastUsedWarpMapType(void) { return GetMapTypeByWarpData(&gLastUsedWarp); } -//bool8 IsMapTypeOutdoors(enum MapType mapType) -bool8 IsMapTypeOutdoors(u8 mapType) +bool8 IsMapTypeOutdoors(enum MapType mapType) { if (mapType == MAP_TYPE_ROUTE || mapType == MAP_TYPE_TOWN @@ -1448,8 +1432,7 @@ bool8 IsMapTypeOutdoors(u8 mapType) return FALSE; } -//bool8 Overworld_MapTypeAllowsTeleportAndFly(enum MapType mapType) -bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType) +bool8 Overworld_MapTypeAllowsTeleportAndFly(enum MapType mapType) { if (mapType == MAP_TYPE_ROUTE || mapType == MAP_TYPE_TOWN @@ -1460,8 +1443,7 @@ bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType) return FALSE; } -//bool8 IsMapTypeIndoors(enum MapType mapType) -bool8 IsMapTypeIndoors(u8 mapType) +bool8 IsMapTypeIndoors(enum MapType mapType) { if (mapType == MAP_TYPE_INDOOR || mapType == MAP_TYPE_SECRET_BASE)