Skip to content

Commit

Permalink
Revert "Revert map related enum conversion" (#6079)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedara90 authored Jan 22, 2025
1 parent 2b9c5fe commit 2a8f4b0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 67 deletions.
14 changes: 0 additions & 14 deletions include/constants/map_types.h
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -27,7 +14,6 @@ enum MapType
MAP_TYPE_INDOOR,
MAP_TYPE_SECRET_BASE,
};
*/

enum MapBattleScene
{
Expand Down
11 changes: 0 additions & 11 deletions include/overworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions src/dexnav.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 2 additions & 4 deletions src/field_screen_effect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions src/fldeff_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down
3 changes: 1 addition & 2 deletions src/item_use.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
38 changes: 10 additions & 28 deletions src/overworld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 2a8f4b0

Please sign in to comment.