diff --git a/include/cutscenes/boat_cutscene.h b/include/cutscenes/boat_cutscene.h index 6fe038e727..9e498d3120 100644 --- a/include/cutscenes/boat_cutscene.h +++ b/include/cutscenes/boat_cutscene.h @@ -2,6 +2,7 @@ #define POKEPLATINUM_BOAT_CUTSCENE_H #include "constants/boat_cutscene.h" +#include "generated/map_headers.h" #include "field/field_system_decl.h" #include "overlay005/model_attributes.h" @@ -28,7 +29,7 @@ typedef struct BoatTravelCutscene { ModelAttributes *areaModelAttrs; } BoatTravelCutscene; -void FieldSystem_PlayBoatCutscene(FieldSystem *fieldSystem, const u8 travelDir, const u8 exitDir, const int mapID, const int x, const int z); +void FieldSystem_PlayBoatCutscene(FieldSystem *fieldSystem, const u8 travelDir, const u8 exitDir, const enum MapHeaderID mapHeaderID, const int x, const int z); BOOL BoatCutscene_CanalaveShip_Init(ApplicationManager *appMan, int *state); BOOL BoatCutscene_CanalaveShip_Main(ApplicationManager *appMan, int *state); diff --git a/include/field/field_system.h b/include/field/field_system.h index beb2208793..d08ee573a7 100644 --- a/include/field/field_system.h +++ b/include/field/field_system.h @@ -120,7 +120,7 @@ typedef struct FieldSystem_t { BattleTower *battleTower; const BattleRegulation *battleRegulation; PokedexMemory *pokedexMemory; - BOOL unk_B8; + BOOL temporaryMapChange; u8 *battleSubscreenCursorOn; u32 unk_C0; UnkStruct_ov66_0222DCE0_sub1 unk_C4; diff --git a/include/field_bgm.h b/include/field_bgm.h index 3e9d4b96a0..e1b4ec4c5d 100644 --- a/include/field_bgm.h +++ b/include/field_bgm.h @@ -11,12 +11,12 @@ void FieldBGM_Stop(void); void FieldBGM_SetOverride(FieldSystem *fieldSystem, u16 bgmID); u16 FieldBGM_GetOverride(FieldSystem *fieldSystem); void FieldBGM_ClearOverride(FieldSystem *fieldSystem); -u16 FieldBGM_GetEffective(FieldSystem *fieldSystem, enum MapHeaderID mapID); -u16 FieldBGM_GetForMapHeader(FieldSystem *fieldSystem, int mapID); +u16 FieldBGM_GetEffective(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID); +u16 FieldBGM_GetForMapHeader(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID); BOOL FieldBGM_TryFadeOut(FieldSystem *fieldSystem, u16 bgmID, int mode); u16 FieldBGM_GetEyesMeetForTrainer(enum TrainerID trainerID); -void FieldBGM_TryFadeIn(FieldSystem *fieldSystem, int mapID); -void FieldBGM_PlayForMapHeader(FieldSystem *fieldSystem, int mapID); -void FieldBGM_PlayEffectiveForMapHeader(FieldSystem *fieldSystem, int mapID); +void FieldBGM_TryFadeIn(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID); +void FieldBGM_PlayForMapHeader(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID); +void FieldBGM_PlayEffectiveForMapHeader(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID); #endif // POKEPLATINUM_FIELD_BGM_H diff --git a/include/field_map_change.h b/include/field_map_change.h index ca4c43860e..5f403efecf 100644 --- a/include/field_map_change.h +++ b/include/field_map_change.h @@ -1,6 +1,8 @@ #ifndef POKEPLATINUM_FIELD_MAP_CHANGE_H #define POKEPLATINUM_FIELD_MAP_CHANGE_H +#include "generated/map_headers.h" + #include "field/field_system_decl.h" #include "overlay005/save_info_window.h" #include "overlay006/field_warp.h" @@ -14,7 +16,7 @@ typedef struct MapChangeUndergroundContext { int state; int transitionState; - int mapId; + enum MapHeaderID mapHeaderID; int dummy; int destX; int destZ; @@ -36,10 +38,10 @@ void FieldSystem_SetLoadSavedGameMapTask(FieldSystem *fieldSystem); void FieldSystem_StartLoadMapFromErrorTask(FieldSystem *fieldSystem); void FieldSystem_StartChangeMapTask(FieldTask *task, const Location *param1); void FieldTask_ChangeMapByLocation(FieldTask *task, const Location *param1); -void FieldTask_ChangeMapToLocation(FieldTask *task, int mapId, int warpId, int x, int z, int dir); -void FieldTask_StartMapChangeFull(FieldTask *task, int mapId, int warpId, int x, int z, int dir); -void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, int mapId, int warpId, int x, int z, int dir); -void FieldTask_ChangeMapChangeFly(FieldTask *task, int mapId, int warpId, int x, int z, int dir); +void FieldTask_ChangeMapToLocation(FieldTask *task, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int dir); +void FieldTask_StartMapChangeFull(FieldTask *task, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int dir); +void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int dir); +void FieldTask_ChangeMapChangeFly(FieldTask *task, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int dir); void FieldTask_ChangeMapByFieldWarp(FieldTask *task, const Location *location, enum FieldWarpType param2); void FieldSystem_StartMapChangeWarpTask(FieldSystem *fieldSystem, int param1, int param2); MapChangeUndergroundContext *MapChangeUndergroundContext_New(FieldSystem *fieldSystem); @@ -50,7 +52,7 @@ FieldTaskFunc FieldMapChange_GetMapChangeUndergroundTask(const FieldSystem *fiel void sub_020544F0(FieldTask *task, const Location *param1); void sub_020545EC(FieldSystem *fieldSystem); void sub_02054708(FieldTask *task); -void FieldTask_StartChangeMapColosseum(FieldTask *task, int mapId, int warpId, int x, int z, int dir); +void FieldTask_StartChangeMapColosseum(FieldTask *task, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int dir); void sub_02054864(FieldTask *task); #endif // POKEPLATINUM_FIELD_MAP_CHANGE_H diff --git a/include/unk_02070428.h b/include/field_map_change_flags.h similarity index 56% rename from include/unk_02070428.h rename to include/field_map_change_flags.h index 30b3c9c286..08f11ba416 100644 --- a/include/unk_02070428.h +++ b/include/field_map_change_flags.h @@ -1,15 +1,15 @@ -#ifndef POKEPLATINUM_UNK_02070428_H -#define POKEPLATINUM_UNK_02070428_H +#ifndef POKEPLATINUM_FIELD_MAP_CHANGE_FLAGS_H +#define POKEPLATINUM_FIELD_MAP_CHANGE_FLAGS_H #include "field/field_system_decl.h" -void sub_02070428(FieldSystem *fieldSystem, BOOL param1); +void FieldSystem_SetTemporaryMapChange(FieldSystem *fieldSystem, BOOL temporaryMapChange); void FieldSystem_InitFlagsOnMapChange(FieldSystem *fieldSystem); void FieldSystem_InitFlagsWarp(FieldSystem *fieldSystem); void FieldSystem_SetFlyFlags(FieldSystem *fieldSystem); void FieldSystem_SetTeleportFlags(FieldSystem *fieldSystem); void FieldSystem_SetEscapeFlags(FieldSystem *fieldSystem); void FieldSystem_ClearPartnerTrainer(FieldSystem *fieldSystem); -void sub_020705CC(FieldSystem *fieldSystem); +void FieldSystem_RandomizeRoamingPokemonLocations(FieldSystem *fieldSystem); -#endif // POKEPLATINUM_UNK_02070428_H +#endif // POKEPLATINUM_FIELD_MAP_CHANGE_FLAGS_H diff --git a/include/field_move_tasks.h b/include/field_move_tasks.h index 843f657763..21c0be3184 100644 --- a/include/field_move_tasks.h +++ b/include/field_move_tasks.h @@ -1,6 +1,8 @@ #ifndef POKEPLATINUM_FIELD_MOVE_TASKS_H #define POKEPLATINUM_FIELD_MOVE_TASKS_H +#include "generated/map_headers.h" + #include "struct_decls/map_object.h" #include "field/field_system_decl.h" @@ -9,7 +11,7 @@ #include "pokemon.h" typedef struct FieldMoveContext { - u32 mapId; + enum MapHeaderID mapHeaderID; FieldSystem *fieldSystem; MapObject *mapObj; u16 usableMoves; diff --git a/include/inlines.h b/include/inlines.h index 3962b9822f..3cec373efe 100644 --- a/include/inlines.h +++ b/include/inlines.h @@ -130,7 +130,7 @@ static inline void PoketchMap_GetPlayerLocation(FieldSystem *fieldSystem, int *x FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); Location *location = FieldOverworldState_GetExitLocation(fieldState); - if (MapHeader_IsOnMainMatrix(fieldSystem->location->mapId)) { + if (MapHeader_IsOnMainMatrix(fieldSystem->location->mapHeaderID)) { *x = fieldSystem->location->x; *z = fieldSystem->location->z; } else { diff --git a/include/location.h b/include/location.h index de66846da8..1b7f5a992b 100644 --- a/include/location.h +++ b/include/location.h @@ -1,6 +1,8 @@ #ifndef POKEPLATINUM_LOCATION_H #define POKEPLATINUM_LOCATION_H +#include "generated/map_headers.h" + #include "savedata.h" #define WARP_ID_NONE -1 @@ -14,16 +16,16 @@ enum FaceDirection { }; typedef struct Location { - int mapId; + enum MapHeaderID mapHeaderID; int warpId; int x; int z; int faceDirection; } Location; -static inline void Location_Set(Location *location, int mapId, int warpId, int x, int z, int faceDirection) +static inline void Location_Set(Location *location, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int faceDirection) { - location->mapId = mapId; + location->mapHeaderID = mapHeaderID; location->warpId = warpId; location->x = x; location->z = z; diff --git a/include/map_header.h b/include/map_header.h index b1285215de..e59447fba7 100644 --- a/include/map_header.h +++ b/include/map_header.h @@ -3,6 +3,7 @@ #include "generated/battle_backgrounds.h" #include "generated/evolution_methods.h" +#include "generated/map_headers.h" #define ENCOUNTERS_NONE 0xFFFF @@ -29,40 +30,40 @@ typedef struct MapHeader { u16 isFlyAllowed : 1; } MapHeader; -u32 MapHeader_IDBoundsCheck(u32 headerID); -u16 MapHeader_GetAreaDataArchiveID(u32 headerID); -u16 MapHeader_GetPreloadedMapObjectsArchiveID(u32 headerID); -u16 MapHeader_GetMapMatrixID(u32 headerID); -u32 MapHeader_GetMsgArchiveID(u32 headerID); -u32 MapHeader_GetScriptsArchiveID(u32 headerID); -u32 MapHeader_GetInitScriptsArchiveID(u32 headerID); -u16 MapHeader_GetDayMusicID(u32 headerID); -u16 MapHeader_GetNightMusicID(u32 headerID); -BOOL MapHeader_HasWildEncounters(u32 headerID); -u32 MapHeader_GetWildEncountersArchiveID(u32 headerID); -u32 MapHeader_GetEventsArchiveID(u32 headerID); -u32 MapHeader_GetMapLabelTextID(u32 headerID); -u8 MapHeader_GetMapLabelWindowID(u32 headerID); -u32 MapHeader_GetWeatherType(u32 headerID); -u32 MapHeader_GetCameraType(u32 headerID); -enum BattleBackground MapHeader_GetBattleBG(u32 headerID); -BOOL MapHeader_IsEscapeRopeAllowed(u32 headerID); -BOOL MapHeader_IsFlyAllowed(u32 headerID); -BOOL MapHeader_IsBikeAllowed(u32 headerID); -u32 MapHeader_GetMapType(u32 headerID); -BOOL MapHeader_IsTeleportAllowed(u32 headerID); -BOOL MapHeader_IsOnMainMatrix(u32 headerID); -BOOL MapHeader_IsPokemonCenter(u32 headerID); -BOOL MapHeader_IsCave(u32 headerID); -BOOL MapHeader_IsBuilding(u32 headerID); -BOOL MapHeader_IsOutdoors(u32 headerID); -BOOL MapHeader_IsPokemonCenter2(u32 headerID); -BOOL MapHeader_IsUnionRoom(const u32 headerID); -BOOL MapHeader_HasFeebasTiles(const u32 headerID); -BOOL MapHeader_IsTrophyGarden(const u32 headerID); -BOOL MapHeader_IsAmitySquare(const u32 headerID); -BOOL MapHeader_IsAzureFluteAllowed(const u32 headerID); -BOOL MapHeader_IsPokemonCenter2F(const u32 headerID); -enum EvolutionMethod MapHeader_GetMapEvolutionMethod(u32 headerID); +enum MapHeaderID MapHeader_IDBoundsCheck(enum MapHeaderID mapHeaderID); +u16 MapHeader_GetAreaDataArchiveID(enum MapHeaderID mapHeaderID); +u16 MapHeader_GetPreloadedMapObjectsArchiveID(enum MapHeaderID mapHeaderID); +u16 MapHeader_GetMapMatrixID(enum MapHeaderID mapHeaderID); +u32 MapHeader_GetMsgArchiveID(enum MapHeaderID mapHeaderID); +u32 MapHeader_GetScriptsArchiveID(enum MapHeaderID mapHeaderID); +u32 MapHeader_GetInitScriptsArchiveID(enum MapHeaderID mapHeaderID); +u16 MapHeader_GetDayMusicID(enum MapHeaderID mapHeaderID); +u16 MapHeader_GetNightMusicID(enum MapHeaderID mapHeaderID); +BOOL MapHeader_HasWildEncounters(enum MapHeaderID mapHeaderID); +u32 MapHeader_GetWildEncountersArchiveID(enum MapHeaderID mapHeaderID); +u32 MapHeader_GetEventsArchiveID(enum MapHeaderID mapHeaderID); +u32 MapHeader_GetMapLabelTextID(enum MapHeaderID mapHeaderID); +u8 MapHeader_GetMapLabelWindowID(enum MapHeaderID mapHeaderID); +u32 MapHeader_GetWeatherType(enum MapHeaderID mapHeaderID); +u32 MapHeader_GetCameraType(enum MapHeaderID mapHeaderID); +enum BattleBackground MapHeader_GetBattleBG(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsEscapeRopeAllowed(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsFlyAllowed(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsBikeAllowed(enum MapHeaderID mapHeaderID); +u32 MapHeader_GetMapType(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsTeleportAllowed(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsOnMainMatrix(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsPokemonCenter(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsCave(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsBuilding(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsOutdoors(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsPokemonCenter2(enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsUnionRoom(const enum MapHeaderID mapHeaderID); +BOOL MapHeader_HasFeebasTiles(const enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsTrophyGarden(const enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsAmitySquare(const enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsAzureFluteAllowed(const enum MapHeaderID mapHeaderID); +BOOL MapHeader_IsPokemonCenter2F(const enum MapHeaderID mapHeaderID); +enum EvolutionMethod MapHeader_GetMapEvolutionMethod(enum MapHeaderID mapHeaderID); #endif // POKEPLATINUM_MAP_HEADER_H diff --git a/include/map_header_data.h b/include/map_header_data.h index b53314de41..40974f5578 100644 --- a/include/map_header_data.h +++ b/include/map_header_data.h @@ -2,6 +2,7 @@ #define POKEPLATINUM_MAP_HEADER_DATA_H #include "constants/heap.h" +#include "generated/map_headers.h" #include "field/field_system_decl.h" #include "overlay006/wild_encounters.h" @@ -67,7 +68,7 @@ typedef struct MapHeaderData { void MapHeaderData_Init(FieldSystem *fieldSystem, enum HeapID heapID); void MapHeaderData_Free(FieldSystem *fieldSystem); -void MapHeaderData_Load(FieldSystem *fieldSystem, int headerID); +void MapHeaderData_Load(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID); void sub_0203A418(FieldSystem *fieldSystem); const BgEvent *MapHeaderData_GetBgEvents(const FieldSystem *fieldSystem); int MapHeaderData_GetNumBgEvents(const FieldSystem *fieldSystem); @@ -84,7 +85,7 @@ BOOL MapHeaderData_SetWarpEventPos(FieldSystem *fieldSystem, u16 index, u16 x, u BOOL MapHeaderData_SetWarpEventDestHeaderID(FieldSystem *fieldSystem, u16 index, u16 destHeaderID); BOOL MapHeaderData_SetWarpEventDestWarpID(FieldSystem *fieldSystem, u16 index, u16 destWarpID); BOOL MapHeaderData_SetBgEventPos(FieldSystem *fieldSystem, u16 index, u16 x, u16 z); -void MapHeaderData_LoadWildEncounters(WildEncounters *encounterData, int headerID); +void MapHeaderData_LoadWildEncounters(WildEncounters *data, enum MapHeaderID mapHeaderID); const WildEncounters *MapHeaderData_GetWildEncounters(const FieldSystem *fieldSystem); const u8 *MapHeaderData_GetInitScriptBytes(const FieldSystem *fieldSystem); BOOL MapHeaderData_IsPosFreeOfObjectEvents(const FieldSystem *fieldSystem, u16 x, u16 z); diff --git a/include/map_object.h b/include/map_object.h index 895f95b1d0..2283330c7c 100644 --- a/include/map_object.h +++ b/include/map_object.h @@ -5,6 +5,7 @@ #include "constants/field/map.h" #include "constants/map_object.h" +#include "generated/map_headers.h" #include "generated/movement_actions.h" #include "struct_decls/map_object.h" @@ -60,10 +61,10 @@ typedef struct MapObjectSave { MapObjectManager *MapObjectMan_New(FieldSystem *fieldSystem, int maxObjs, int taskBasePriority); void MapObjectMan_Delete(MapObjectManager *mapObjMan); -void sub_0206184C(MapObjectManager *mapObjMan, int mapID, int param2, int objEventCount, const ObjectEvent *objectEvent); -MapObject *MapObjectMan_AddMapObjectFromHeader(const MapObjectManager *mapObjMan, const ObjectEvent *objectEvent, int mapID); -MapObject *MapObjectMan_AddMapObject(const MapObjectManager *mapObjMan, int x, int z, int initialDir, int graphicsID, int movementType, int mapID); -MapObject *MapObjectMan_AddMapObjectFromLocalID(const MapObjectManager *mapObjMan, int param1, int objEventCount, int mapID, const ObjectEvent *objectEvent); +void sub_0206184C(MapObjectManager *mapObjMan, enum MapHeaderID oldMapHeaderID, enum MapHeaderID newMapHeaderID, int objEventCount, const ObjectEvent *objectEvent); +MapObject *MapObjectMan_AddMapObjectFromHeader(const MapObjectManager *mapObjMan, const ObjectEvent *objectEvent, enum MapHeaderID mapHeaderID); +MapObject *MapObjectMan_AddMapObject(const MapObjectManager *mapObjMan, int x, int z, int initialDir, int graphicsID, int movementType, enum MapHeaderID mapHeaderID); +MapObject *MapObjectMan_AddMapObjectFromLocalID(const MapObjectManager *mapObjMan, int param1, int objEventCount, enum MapHeaderID mapHeaderID, const ObjectEvent *objectEvent); void sub_02061AB4(MapObject *mapObj, int graphicsID); void sub_02061AD4(MapObject *mapObj, int param1); void MapObject_Delete(MapObject *mapObj); @@ -74,14 +75,14 @@ void sub_02061BF0(MapObjectManager *mapObjMan); void sub_02061C48(MapObjectManager *mapObjMan); void MapObjectMan_SaveAll(FieldSystem *fieldSystem, const MapObjectManager *mapObjMan, MapObjectSave *mapObjSave, int param3); void MapObjectMan_LoadAllObjects(const MapObjectManager *mapObjMan, MapObjectSave *mapObjSave, int size); -void sub_02062068(const MapObjectManager *mapObjMan, int param1, int param2, const ObjectEvent *objectEvent); +void sub_02062068(const MapObjectManager *mapObjMan, enum MapHeaderID mapHeaderID, u32 numObjectEvents, const ObjectEvent *objectEvent); MapObject *MapObjMan_LocalMapObjByIndex(const MapObjectManager *mapObjMan, int index); MapObject *MapObjMan_GetLocalMapObjByMovementType(const MapObjectManager *mapObjMan, int movementType); BOOL MapObjectMan_FindObjectWithStatus(const MapObjectManager *mapObjMan, MapObject **mapObj, int *startIdx, u32 status); int MapObject_HasNoScript(const MapObject *mapObj); int MapObject_CalculateTaskPriority(const MapObject *mapObj, int priority); -int sub_02062764(const MapObject *mapObj, int param1, int param2); -int sub_020627B4(const MapObject *mapObj, int param1, int param2, int param3); +int sub_02062764(const MapObject *mapObj, int param1, enum MapHeaderID param2); +int sub_020627B4(const MapObject *mapObj, int param1, int param2, enum MapHeaderID param3); void MapObjectMan_SetMaxObjects(MapObjectManager *mapObjMan, int maxObjs); int MapObjectMan_GetMaxObjects(const MapObjectManager *mapObjMan); void MapObjectMan_SetStatusFlagOn(MapObjectManager *mapObjMan, u32 flag); @@ -111,8 +112,8 @@ void sub_020628F8(MapObject *mapObj, u32 param1); u32 sub_02062904(const MapObject *mapObj, u32 param1); void MapObject_SetLocalID(MapObject *mapObj, u32 localID); u32 MapObject_GetLocalID(const MapObject *mapObj); -void MapObject_SetMapID(MapObject *mapObj, int mapID); -int MapObject_GetMapID(const MapObject *mapObj); +void MapObject_SetMapHeaderID(MapObject *mapObj, enum MapHeaderID mapHeaderID); +enum MapHeaderID MapObject_GetMapHeaderID(const MapObject *mapObj); void MapObject_SetGraphicsID(MapObject *mapObj, u32 graphicsID); u32 MapObject_GetGraphicsID(const MapObject *mapObj); u32 MapObject_GetEffectiveGraphicsID(const MapObject *mapObj); diff --git a/include/overlay005/fieldmap.h b/include/overlay005/fieldmap.h index c968ebd668..871f8a24a9 100644 --- a/include/overlay005/fieldmap.h +++ b/include/overlay005/fieldmap.h @@ -1,6 +1,8 @@ #ifndef POKEPLATINUM_OV5_021D0D80_H #define POKEPLATINUM_OV5_021D0D80_H +#include "generated/map_headers.h" + #include "field/field_system_decl.h" #include "bg_window.h" @@ -8,7 +10,7 @@ extern const ApplicationManagerTemplate gFieldMapTemplate; -void FieldMap_ChangeZoneDistortionWorld(FieldSystem *fieldSystem, u32 mapId); +void FieldMap_ChangeZoneDistortionWorld(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID); void ov5_021D1434(BgConfig *param0); void ov5_021D143C(BgConfig *param0); void ov5_021D16F4(FieldSystem *fieldSystem, BOOL param1); diff --git a/include/overlay006/great_marsh_binoculars.h b/include/overlay006/great_marsh_binoculars.h index 98ba675e72..fbf68c1c04 100644 --- a/include/overlay006/great_marsh_binoculars.h +++ b/include/overlay006/great_marsh_binoculars.h @@ -1,6 +1,8 @@ #ifndef POKEPLATINUM_GREAT_MARSH_BINOCULARS_H #define POKEPLATINUM_GREAT_MARSH_BINOCULARS_H +#include "generated/map_headers.h" + #include "field/field_system_decl.h" #include "great_marsh_lookout.h" @@ -16,7 +18,7 @@ typedef struct GreatMarshBinoculars { BinocularCoords coordsList[BINOCULARS_CYCLE_COUNT + 1]; Location viewLocation; FieldSystem *fieldSystem; - int lookoutMapId; + enum MapHeaderID lookoutMapHeaderID; } GreatMarshBinoculars; int GreatMarshBinoculars_GetMonSpecies(FieldSystem *fieldSystem); diff --git a/include/overlay006/great_marsh_daily_encounters.h b/include/overlay006/great_marsh_daily_encounters.h index 9089e7104e..33d528a56f 100644 --- a/include/overlay006/great_marsh_daily_encounters.h +++ b/include/overlay006/great_marsh_daily_encounters.h @@ -1,6 +1,8 @@ #ifndef POKEPLATINUM_MARSH_DAILY_ENCOUNTERS_H #define POKEPLATINUM_MARSH_DAILY_ENCOUNTERS_H -void ReplaceGreatMarshDailyEncounters(const int dailyMon, const BOOL nationalDexObtained, const int mapId, int *encounterSlot1, int *encounterSlot2); +#include "generated/map_headers.h" + +void ReplaceGreatMarshDailyEncounters(const int dailyMon, const BOOL nationalDexObtained, const enum MapHeaderID mapHeaderID, int *encounterSlot1, int *encounterSlot2); #endif // POKEPLATINUM_MARSH_DAILY_ENCOUNTERS_H diff --git a/include/spawn_locations.h b/include/spawn_locations.h index 9c59b5330c..9c5433f240 100644 --- a/include/spawn_locations.h +++ b/include/spawn_locations.h @@ -1,6 +1,8 @@ #ifndef POKEPLATINUM_SPAWN_LOCATIONS_H #define POKEPLATINUM_SPAWN_LOCATIONS_H +#include "generated/map_headers.h" + #include "field/field_system_decl.h" #include "location.h" @@ -8,10 +10,10 @@ int FieldOverworldState_GetDefaultWarpID(void); void Location_InitFly(int flyDestination, Location *location); void Location_InitBlackOut(int blackOutDestination, Location *location); -int GetMapBlackOutWarpId(int mapId); -int GetMapFlyWarpId(int mapId); -int GetSpawnIdByMapAndCoords(int mapID, int param1, int param2); -void TryUnlockFlyLocationByMap(FieldSystem *fieldSystem, int param1); -BOOL CheckFlyLocationUnlocked(FieldSystem *fieldSystem, int param1); +int GetMapBlackOutWarpId(enum MapHeaderID mapHeaderID); +int GetMapFlyWarpId(enum MapHeaderID mapHeaderID); +int GetSpawnIdByMapAndCoords(enum MapHeaderID mapHeaderID, int param1, int param2); +void TryUnlockFlyLocationByMap(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID); +BOOL CheckFlyLocationUnlocked(FieldSystem *fieldSystem, int flyLocation); #endif // POKEPLATINUM_SPAWN_LOCATIONS_H diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index 00f99d0c31..020a65d8e4 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -276,7 +276,7 @@ Static main Object main.nef.p/src_cutscenes_boat_cutscene_boat_cutscene.c.o Object main.nef.p/src_tv_segment.c.o Object main.nef.p/src_rankings_machine.c.o - Object main.nef.p/src_unk_02070428.c.o + Object main.nef.p/src_field_map_change_flags.c.o Object main.nef.p/src_field_move_tasks.c.o Object main.nef.p/src_unk_020711C8.c.o Object main.nef.p/src_overworld_anim_manager.c.o diff --git a/src/applications/party_menu/callbacks.c b/src/applications/party_menu/callbacks.c index 9b7e4d46c8..81afc06387 100644 --- a/src/applications/party_menu/callbacks.c +++ b/src/applications/party_menu/callbacks.c @@ -815,7 +815,7 @@ static enum PartyMenuState PartyMenuCB_LevelUp(PartyMenuApplication *application case LEVELUP_STATE_CHECK_EVOLUTION: mon = Party_GetPokemonBySlotIndex(application->partyMenu->party, application->currPartySlot); - u32 mapEvoMethod = MapHeader_GetMapEvolutionMethod(application->partyMenu->fieldSystem->location->mapId); + u32 mapEvoMethod = MapHeader_GetMapEvolutionMethod(application->partyMenu->fieldSystem->location->mapHeaderID); application->partyMenu->evoTargetSpecies = Pokemon_GetEvolutionTargetSpecies( application->partyMenu->party, mon, @@ -1238,5 +1238,5 @@ void PartyMenu_GiveMail(PartyMenuApplication *application) static u16 GetCurrentMapLabel(PartyMenuApplication *application) { FieldSystem *fieldSystem = application->partyMenu->fieldSystem; - return MapHeader_GetMapLabelTextID(fieldSystem->location->mapId); + return MapHeader_GetMapLabelTextID(fieldSystem->location->mapHeaderID); } diff --git a/src/applications/party_menu/main.c b/src/applications/party_menu/main.c index a634a34715..98d88de6e1 100644 --- a/src/applications/party_menu/main.c +++ b/src/applications/party_menu/main.c @@ -2757,7 +2757,7 @@ static int ProcessItemApplication(PartyMenuApplication *application) StringTemplate_Format(application->template, application->tmpString, application->tmpFormat); v2 = PARTY_MENU_STATE_CONFIRM_ITEM_UPDATE; } else if (fieldSystem != NULL) { - if (fieldSystem->location->mapId == MAP_HEADER_UNION_ROOM) { + if (fieldSystem->location->mapHeaderID == MAP_HEADER_UNION_ROOM) { MessageLoader_GetString(application->messageLoader, PartyMenu_Text_ItemCannotBeGivenHere, application->tmpFormat); StringTemplate_SetItemName(application->template, 0, application->partyMenu->usedItemID); StringTemplate_Format(application->template, application->tmpString, application->tmpFormat); @@ -2812,8 +2812,8 @@ static int UpdatePokemonWithItem(PartyMenuApplication *application, Pokemon *mon Pokemon_SetArceusForm(mon); if (fieldSystem == NULL - || fieldSystem->location->mapId < MAP_HEADER_DISTORTION_WORLD_1F - || (fieldSystem->location->mapId > MAP_HEADER_DISTORTION_WORLD_TURNBACK_CAVE_ROOM)) { + || fieldSystem->location->mapHeaderID < MAP_HEADER_DISTORTION_WORLD_1F + || (fieldSystem->location->mapHeaderID > MAP_HEADER_DISTORTION_WORLD_TURNBACK_CAVE_ROOM)) { *param2 = Pokemon_SetGiratinaFormByHeldItem(mon); } else { *param2 = -1; diff --git a/src/applications/party_menu/unk_02083370.c b/src/applications/party_menu/unk_02083370.c index ae01ffecaf..0c36f23705 100644 --- a/src/applications/party_menu/unk_02083370.c +++ b/src/applications/party_menu/unk_02083370.c @@ -230,8 +230,8 @@ static void PartyMenu_SelectItemTake(PartyMenuApplication *application, int *par Pokemon_SetArceusForm(mon); if (fieldSystem == NULL - || fieldSystem->location->mapId < MAP_HEADER_DISTORTION_WORLD_1F - || fieldSystem->location->mapId > MAP_HEADER_DISTORTION_WORLD_TURNBACK_CAVE_ROOM) { + || fieldSystem->location->mapHeaderID < MAP_HEADER_DISTORTION_WORLD_1F + || fieldSystem->location->mapHeaderID > MAP_HEADER_DISTORTION_WORLD_TURNBACK_CAVE_ROOM) { v1 = Pokemon_SetGiratinaFormByHeldItem(mon); if ((application->partyMembers[application->currPartySlot].heldItem == ITEM_GRISEOUS_ORB) && (v1 == 0)) { diff --git a/src/applications/poketch/link_searcher/main.c b/src/applications/poketch/link_searcher/main.c index 1b03ed560c..99e8bb7b8b 100644 --- a/src/applications/poketch/link_searcher/main.c +++ b/src/applications/poketch/link_searcher/main.c @@ -186,7 +186,7 @@ static BOOL State_OnIntroScreen(PoketchLinkSearcher *appData) PoketchLinkSearcherGraphics_StartTask(appData->graphics, LINK_SEARCHER_GRAPHICS_SEARCHING); - if (MapHeader_IsPokemonCenter2(fieldSystem->location->mapId)) { + if (MapHeader_IsPokemonCenter2(fieldSystem->location->mapHeaderID)) { ChangeState(appData, STATE_UNUSABLE_ERROR); } else { ChangeState(appData, STATE_SHOW_RESULTS); diff --git a/src/applications/town_map/context.c b/src/applications/town_map/context.c index 0d430ade23..610b9e8b90 100644 --- a/src/applications/town_map/context.c +++ b/src/applications/town_map/context.c @@ -93,7 +93,7 @@ void TownMapContext_Init(FieldSystem *fieldSystem, TownMapContext *ctx, enum Tow int j = NELEMS(sDistWorldMapOffsets) - 1; Location *playerLocation = FieldOverworldState_GetPlayerLocation(fieldState); - currentMap = playerLocation->mapId; + currentMap = playerLocation->mapHeaderID; while (j >= 0) { if (currentMap == sDistWorldMapOffsets[j].mapHeader) { diff --git a/src/battle_frontier.c b/src/battle_frontier.c index 6e3f31ca49..27e6992b6a 100644 --- a/src/battle_frontier.c +++ b/src/battle_frontier.c @@ -313,7 +313,7 @@ FieldFrontierDTO *sub_0209BA18(FieldSystem *fieldSystem, void *param1) fieldData->subscreenCursorOn = fieldSystem->battleSubscreenCursorOn; fieldData->unk_14 = 0; fieldData->unk_18 = 0; - fieldData->mapHeaderID = fieldSystem->location->mapId; + fieldData->mapHeaderID = fieldSystem->location->mapHeaderID; fieldData->sceneID = FRONTIER_SCENE_14; fieldData->fieldSystem = fieldSystem; diff --git a/src/binoculars_vista_lighthouse.c b/src/binoculars_vista_lighthouse.c index fe268f38f1..76f934ef6e 100644 --- a/src/binoculars_vista_lighthouse.c +++ b/src/binoculars_vista_lighthouse.c @@ -10,6 +10,7 @@ #include "camera.h" #include "field_map_change.h" +#include "field_map_change_flags.h" #include "field_task.h" #include "field_transition.h" #include "heap.h" @@ -21,7 +22,6 @@ #include "system.h" #include "system_flags.h" #include "unk_02056B30.h" -#include "unk_02070428.h" #include "vars_flags.h" typedef struct VistaLighthouseBinoculars { @@ -54,7 +54,7 @@ static BOOL Task_UseVistaLighthouseBinoculars(FieldTask *taskMan) case 0: binoculars->xPos = PlayerAvatar_GetXPos(fieldSystem->playerAvatar); binoculars->zPos = PlayerAvatar_GetZPos(fieldSystem->playerAvatar); - sub_02070428(fieldSystem, 1); + FieldSystem_SetTemporaryMapChange(fieldSystem, TRUE); FieldTransition_FadeOut(taskMan); binoculars->state++; break; @@ -116,7 +116,7 @@ static BOOL Task_UseVistaLighthouseBinoculars(FieldTask *taskMan) break; case 11: Heap_Free(binoculars); - sub_02070428(fieldSystem, 0); + FieldSystem_SetTemporaryMapChange(fieldSystem, FALSE); return TRUE; } diff --git a/src/cutscenes/boat_cutscene/boat_cutscene.c b/src/cutscenes/boat_cutscene/boat_cutscene.c index e0db90d061..f49b380964 100644 --- a/src/cutscenes/boat_cutscene/boat_cutscene.c +++ b/src/cutscenes/boat_cutscene/boat_cutscene.c @@ -54,7 +54,7 @@ typedef struct BoatCutscene { int goalDistance; fx32 bridgeDistance; fx32 distanceTraveled; - int mapID; + enum MapHeaderID mapHeaderID; int x; int z; VecFx32 cameraPos; @@ -71,25 +71,22 @@ static BOOL BoatCutscene_CheckBridgeReached(const fx32 *distanceTraveled, const static void FieldSystem_LoadCanalaveBridgeAnimation(FieldSystem *fieldSystem); static void BoatCutscene_PanStartingCamera(BoatCutscene *boatCutscene); -void FieldSystem_PlayBoatCutscene(FieldSystem *fieldSystem, const u8 travelDir, const u8 exitDir, const int mapID, const int x, const int z) +void FieldSystem_PlayBoatCutscene(FieldSystem *fieldSystem, const u8 travelDir, const u8 exitDir, const enum MapHeaderID mapHeaderID, const int x, const int z) { - BoatCutscene *boatCutscene; - BOOL moveBeforeFadeOut; - BOOL boatFound; TerrainCollisionHitbox hitbox; int targetMapPropModelID; int goalDistance; - boatCutscene = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(BoatCutscene)); + BoatCutscene *boatCutscene = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(BoatCutscene)); boatCutscene->travelDir = travelDir; boatCutscene->exitDir = exitDir; - boatCutscene->mapID = mapID; + boatCutscene->mapHeaderID = mapHeaderID; boatCutscene->x = x; boatCutscene->z = z; boatCutscene->areaModelAttrs = *(fieldSystem->areaModelAttrs); - moveBeforeFadeOut = FALSE; + BOOL moveBeforeFadeOut = FALSE; boatCutscene->bridgeDistance = 0xffffffff; boatCutscene->dummy = 0; @@ -111,7 +108,7 @@ void FieldSystem_PlayBoatCutscene(FieldSystem *fieldSystem, const u8 travelDir, } if (moveBeforeFadeOut) { - boatFound = FieldSystem_FindCollidingLoadedMapPropByModelID(fieldSystem, targetMapPropModelID, &hitbox, &boatCutscene->boat); + BOOL boatFound = FieldSystem_FindCollidingLoadedMapPropByModelID(fieldSystem, targetMapPropModelID, &hitbox, &boatCutscene->boat); if (boatFound) { boatCutscene->goalDistance = goalDistance; @@ -236,11 +233,11 @@ static BOOL FieldSystem_PlayBoatCutsceneStep(FieldTask *taskMan) boatCutscene->state = BOAT_CUTSCENE_STATE_MAP_TRANSITION; break; case BOAT_CUTSCENE_STATE_MAP_TRANSITION: - FieldTask_ChangeMapToLocation(taskMan, boatCutscene->mapID, -1, boatCutscene->x, boatCutscene->z, boatCutscene->exitDir); + FieldTask_ChangeMapToLocation(taskMan, boatCutscene->mapHeaderID, -1, boatCutscene->x, boatCutscene->z, boatCutscene->exitDir); boatCutscene->state = BOAT_CUTSCENE_STATE_FADE_IN; break; case BOAT_CUTSCENE_STATE_FADE_IN: - FieldBGM_PlayForMapHeader(fieldSystem, boatCutscene->mapID); + FieldBGM_PlayForMapHeader(fieldSystem, boatCutscene->mapHeaderID); FieldTransition_StartMapAndFadeIn(taskMan); boatCutscene->state = BOAT_CUTSCENE_STATE_CLEAN_UP; break; diff --git a/src/dynamic_map_features.c b/src/dynamic_map_features.c index afbf42107f..ac2a877c7b 100644 --- a/src/dynamic_map_features.c +++ b/src/dynamic_map_features.c @@ -104,6 +104,6 @@ BOOL DynamicMapFeatures_CheckCollision(FieldSystem *fieldSystem, const int tileX BOOL DynamicMapFeatures_WillPlayerJumpEternaGymClock(FieldSystem *fieldSystem, const int tileX, const int tileZ, const fx32 unused3, int direction) { - return fieldSystem->location->mapId == MAP_HEADER_ETERNA_CITY_GYM + return fieldSystem->location->mapHeaderID == MAP_HEADER_ETERNA_CITY_GYM && EternaGym_IsHourHandJumpTile(fieldSystem, tileX, tileZ, direction); } diff --git a/src/egg_hatch.c b/src/egg_hatch.c index e555d0eaf2..9d2a5e2fa8 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -191,7 +191,7 @@ static BOOL FieldTask_HatchEgg(FieldTask *fieldTask) Pokemon *mon = app->args.mon; TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(fieldSystem)); - int location = MapHeader_GetMapLabelTextID(fieldSystem->location->mapId); + int location = MapHeader_GetMapLabelTextID(fieldSystem->location->mapHeaderID); int isEgg = FALSE; Pokemon_SetValue(mon, MON_DATA_IS_EGG, &isEgg); diff --git a/src/encounter.c b/src/encounter.c index 8e3bad56ad..3379c2f404 100644 --- a/src/encounter.c +++ b/src/encounter.c @@ -743,8 +743,8 @@ void Encounter_NewVsTrainer(FieldTask *taskMan, int enemyTrainer1ID, int enemyTr dto = FieldBattleDTO_New(HEAP_ID_FIELD2, battleType); FieldBattleDTO_Init(dto, fieldSystem); - if (fieldSystem->location->mapId >= MAP_HEADER_DISTORTION_WORLD_1F - && fieldSystem->location->mapId <= MAP_HEADER_DISTORTION_WORLD_TURNBACK_CAVE_ROOM) { + if (fieldSystem->location->mapHeaderID >= MAP_HEADER_DISTORTION_WORLD_1F + && fieldSystem->location->mapHeaderID <= MAP_HEADER_DISTORTION_WORLD_TURNBACK_CAVE_ROOM) { dto->battleStatusMask |= BATTLE_STATUS_DISTORTION; } @@ -962,7 +962,7 @@ static void UpdateJournal(FieldSystem *fieldSystem, FieldBattleDTO *dto) } } else if ((battleType & BATTLE_TYPE_TRAINER) || (battleType & BATTLE_TYPE_TAG)) { if (resultMask == BATTLE_RESULT_WIN) { - JournalEntry_CreateAndSaveEventTrainer(fieldSystem->journalEntry, fieldSystem->location->mapId, dto->trainerIDs[BATTLER_ENEMY_1], HEAP_ID_FIELD2); + JournalEntry_CreateAndSaveEventTrainer(fieldSystem->journalEntry, fieldSystem->location->mapHeaderID, dto->trainerIDs[BATTLER_ENEMY_1], HEAP_ID_FIELD2); } } } diff --git a/src/field_battle_data_transfer.c b/src/field_battle_data_transfer.c index c721ad14b8..16dc3f962e 100644 --- a/src/field_battle_data_transfer.c +++ b/src/field_battle_data_transfer.c @@ -175,7 +175,7 @@ FieldBattleDTO *FieldBattleDTO_NewCatchingTutorial(enum HeapID heapID, const Fie dto->subscreenCursorOn = NULL; dto->records = SaveData_GetGameRecords(fieldSystem->saveData); dto->journalEntry = fieldSystem->journalEntry; - dto->mapHeaderID = fieldSystem->location->mapId; + dto->mapHeaderID = fieldSystem->location->mapHeaderID; FieldBattleDTO_CopyPlayerInfoToTrainerData(dto); @@ -278,7 +278,7 @@ void FieldBattleDTO_InitFromGameState(FieldBattleDTO *dto, const FieldSystem *fi void FieldBattleDTO_Init(FieldBattleDTO *dto, const FieldSystem *fieldSystem) { - FieldBattleDTO_InitFromGameState(dto, fieldSystem, fieldSystem->saveData, fieldSystem->location->mapId, fieldSystem->journalEntry, fieldSystem->bagCursor, fieldSystem->battleSubscreenCursorOn); + FieldBattleDTO_InitFromGameState(dto, fieldSystem, fieldSystem->saveData, fieldSystem->location->mapHeaderID, fieldSystem->journalEntry, fieldSystem->bagCursor, fieldSystem->battleSubscreenCursorOn); FieldBattleDTO_CopyPlayerInfoToTrainerData(dto); } @@ -327,7 +327,7 @@ void FieldBattleDTO_InitWithNormalizedMonLevels(FieldBattleDTO *dto, const Field dto->records = SaveData_GetGameRecords(fieldSystem->saveData); dto->journalEntry = fieldSystem->journalEntry; dto->palPad = SaveData_GetPalPad(fieldSystem->saveData); - dto->mapHeaderID = fieldSystem->location->mapId; + dto->mapHeaderID = fieldSystem->location->mapHeaderID; dto->saveData = fieldSystem->saveData; FieldBattleDTO_CopyPlayerInfoToTrainerData(dto); @@ -391,7 +391,7 @@ void FieldBattleDTO_InitWithPartyOrder(FieldBattleDTO *dto, const FieldSystem *f dto->wiFiHistory = SaveData_WiFiHistory(fieldSystem->saveData); dto->records = SaveData_GetGameRecords(fieldSystem->saveData); dto->journalEntry = fieldSystem->journalEntry; - dto->mapHeaderID = fieldSystem->location->mapId; + dto->mapHeaderID = fieldSystem->location->mapHeaderID; dto->palPad = SaveData_GetPalPad(fieldSystem->saveData); dto->saveData = fieldSystem->saveData; @@ -496,7 +496,7 @@ static int CalcTerrain(const FieldSystem *fieldSystem, enum BattleBackground bac static void SetBackgroundAndTerrain(FieldBattleDTO *dto, const FieldSystem *fieldSystem) { PlayerData *player = FieldOverworldState_GetPlayerData(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - dto->background = MapHeader_GetBattleBG(fieldSystem->location->mapId); + dto->background = MapHeader_GetBattleBG(fieldSystem->location->mapHeaderID); if (player->playerState == PLAYER_AVATAR_SURFING) { dto->background = BACKGROUND_WATER; } diff --git a/src/field_bgm.c b/src/field_bgm.c index 6c5b6a37e7..4d55e0f6f3 100644 --- a/src/field_bgm.c +++ b/src/field_bgm.c @@ -3,6 +3,7 @@ #include #include +#include "generated/map_headers.h" #include "generated/trainer_classes.h" #include "field/field_system.h" @@ -104,7 +105,7 @@ const static u16 sTrainerEncounterBGMs[][2] = { }; // clang-format on -static u16 FieldBGM_GetAltMusicForCyclingRoad(FieldSystem *fieldSystem, int headerID); +static u16 FieldBGM_GetAltMusicForCyclingRoad(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID); static void FieldBGM_GetFadeOutAndWaitFrames(FieldSystem *fieldSystem, int mode, int *fadeOutFrames, int *waitFrames); void FieldBGM_Stop() @@ -134,13 +135,13 @@ void FieldBGM_ClearOverride(FieldSystem *fieldSystem) *bgm = SEQ_NONE; } -u16 FieldBGM_GetEffective(FieldSystem *fieldSystem, enum MapHeaderID mapID) +u16 FieldBGM_GetEffective(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID) { PlayerAvatar *playerAvatar = fieldSystem->playerAvatar; int playerState = PlayerAvatar_GetPlayerState(playerAvatar); if (playerState == PLAYER_AVATAR_SURFING) { - switch (mapID) { + switch (mapHeaderID) { case MAP_HEADER_DISTORTION_WORLD_1F: case MAP_HEADER_DISTORTION_WORLD_B1F: case MAP_HEADER_DISTORTION_WORLD_B2F: @@ -161,7 +162,7 @@ u16 FieldBGM_GetEffective(FieldSystem *fieldSystem, enum MapHeaderID mapID) return SEQ_POKERADAR; } - u16 bgmID = FieldBGM_GetForMapHeader(fieldSystem, mapID); + u16 bgmID = FieldBGM_GetForMapHeader(fieldSystem, mapHeaderID); if (FieldBGM_GetOverride(fieldSystem) != SEQ_NONE) { bgmID = FieldBGM_GetOverride(fieldSystem); @@ -170,23 +171,23 @@ u16 FieldBGM_GetEffective(FieldSystem *fieldSystem, enum MapHeaderID mapID) return bgmID; } -u16 FieldBGM_GetForMapHeader(FieldSystem *fieldSystem, int mapID) +u16 FieldBGM_GetForMapHeader(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID) { u16 sdatID; if (IsNight() == FALSE) { - sdatID = MapHeader_GetDayMusicID(mapID); + sdatID = MapHeader_GetDayMusicID(mapHeaderID); } else { - sdatID = MapHeader_GetNightMusicID(mapID); + sdatID = MapHeader_GetNightMusicID(mapHeaderID); } - u16 altSdatID = SystemFlag_GetAltMusicForHeader(SaveData_GetVarsFlags(fieldSystem->saveData), mapID); + u16 altSdatID = SystemFlag_GetAltMusicForHeader(SaveData_GetVarsFlags(fieldSystem->saveData), mapHeaderID); if (altSdatID != SEQ_NONE) { sdatID = altSdatID; } - altSdatID = FieldBGM_GetAltMusicForCyclingRoad(fieldSystem, mapID); + altSdatID = FieldBGM_GetAltMusicForCyclingRoad(fieldSystem, mapHeaderID); if (altSdatID != SEQ_NONE) { sdatID = altSdatID; @@ -195,20 +196,19 @@ u16 FieldBGM_GetForMapHeader(FieldSystem *fieldSystem, int mapID) return sdatID; } -static u16 FieldBGM_GetAltMusicForCyclingRoad(FieldSystem *fieldSystem, int headerID) +static u16 FieldBGM_GetAltMusicForCyclingRoad(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID) { - int x, y; FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); Location *location = FieldOverworldState_GetPrevLocation(fieldState); - x = PlayerAvatar_GetXPos(fieldSystem->playerAvatar); - y = PlayerAvatar_GetZPos(fieldSystem->playerAvatar); + int x = PlayerAvatar_GetXPos(fieldSystem->playerAvatar); + int y = PlayerAvatar_GetZPos(fieldSystem->playerAvatar); - if (headerID != MAP_HEADER_ROUTE_206) { + if (mapHeaderID != MAP_HEADER_ROUTE_206) { return SEQ_NONE; } - if ((location->mapId == MAP_HEADER_ROUTE_206_CYCLING_ROAD_NORTH_GATE) || (location->mapId == MAP_HEADER_ROUTE_206_CYCLING_ROAD_SOUTH_GATE)) { + if ((location->mapHeaderID == MAP_HEADER_ROUTE_206_CYCLING_ROAD_NORTH_GATE) || (location->mapHeaderID == MAP_HEADER_ROUTE_206_CYCLING_ROAD_SOUTH_GATE)) { if (x < 299) { return 0; } @@ -291,37 +291,35 @@ u16 FieldBGM_GetEyesMeetForTrainer(enum TrainerID trainerID) return bgmID; } -void FieldBGM_TryFadeIn(FieldSystem *fieldSystem, int mapID) +void FieldBGM_TryFadeIn(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID) { if (Sound_IsBGMFixed() == 1) { return; } - if (Sound_GetCurrentBGM() != FieldBGM_GetForMapHeader(fieldSystem, mapID)) { + if (Sound_GetCurrentBGM() != FieldBGM_GetForMapHeader(fieldSystem, mapHeaderID)) { Sound_FadeOutBGM(0, 40); } } -void FieldBGM_PlayForMapHeader(FieldSystem *fieldSystem, int mapID) +void FieldBGM_PlayForMapHeader(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID) { - u16 bgmID; - if (Sound_IsBGMFixed() == 1) { return; } Sound_SetScene(SOUND_SCENE_NONE); - bgmID = FieldBGM_GetForMapHeader(fieldSystem, mapID); + u16 bgmID = FieldBGM_GetForMapHeader(fieldSystem, mapHeaderID); Sound_SetFieldBGM(bgmID); Sound_SetSceneAndPlayBGM(SOUND_SCENE_FIELD, bgmID, 1); } -void FieldBGM_PlayEffectiveForMapHeader(FieldSystem *fieldSystem, int mapID) +void FieldBGM_PlayEffectiveForMapHeader(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID) { - u16 bgmID = FieldBGM_GetEffective(fieldSystem, mapID); + u16 bgmID = FieldBGM_GetEffective(fieldSystem, mapHeaderID); - Sound_SetFieldBGM(FieldBGM_GetForMapHeader(fieldSystem, mapID)); + Sound_SetFieldBGM(FieldBGM_GetForMapHeader(fieldSystem, mapHeaderID)); Sound_SetSceneAndPlayBGM(SOUND_SCENE_FIELD, bgmID, 1); } diff --git a/src/field_map_change.c b/src/field_map_change.c index 600362ba45..88eea51ba4 100644 --- a/src/field_map_change.c +++ b/src/field_map_change.c @@ -26,6 +26,7 @@ #include "brightness_controller.h" #include "communication_system.h" #include "field_bgm.h" +#include "field_map_change_flags.h" #include "field_message.h" #include "field_overworld_state.h" #include "field_overworld_weather.h" @@ -69,7 +70,6 @@ #include "unk_020559DC.h" #include "unk_0205B33C.h" #include "unk_0205C22C.h" -#include "unk_02070428.h" #include "vars_flags.h" #include "res/text/bank/pokemon_center_2f_common.h" @@ -188,7 +188,7 @@ static void sub_020530C8(FieldSystem *fieldSystem) { BOOL inBattleTower; - switch (fieldSystem->location->mapId) { + switch (fieldSystem->location->mapHeaderID) { case MAP_HEADER_BATTLE_TOWER: case MAP_HEADER_BATTLE_TOWER_ELEVATOR: case MAP_HEADER_BATTLE_TOWER_CORRIDOR: @@ -221,7 +221,7 @@ static void FieldMapChange_SetNewLocation(FieldSystem *fieldSystem, const Locati *(fieldSystem->location) = *nextLocation; } - MapHeaderData_Load(fieldSystem, fieldSystem->location->mapId); + MapHeaderData_Load(fieldSystem, fieldSystem->location->mapHeaderID); if (fieldSystem->location->warpId != WARP_ID_NONE) { const WarpEvent *warpEvent = MapHeaderData_GetWarpEventByIndex(fieldSystem, fieldSystem->location->warpId); @@ -247,7 +247,7 @@ void FieldMapChange_Set3DDisplay(FieldSystem *fieldSystem) void FieldMapChange_UpdateGameData(FieldSystem *fieldSystem, BOOL noWarp) { - int mapId = fieldSystem->location->mapId; + enum MapHeaderID mapHeaderID = fieldSystem->location->mapHeaderID; FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); FieldBGM_ClearOverride(fieldSystem); @@ -270,7 +270,7 @@ void FieldMapChange_UpdateGameData(FieldSystem *fieldSystem, BOOL noWarp) } VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); - u16 weather = FieldSystem_GetWeather(fieldSystem, mapId); + u16 weather = FieldSystem_GetWeather(fieldSystem, mapHeaderID); if ((weather == OVERWORLD_WEATHER_FOG && SystemFlag_CheckDefogActive(varsFlags) == TRUE) || (weather == OVERWORLD_WEATHER_DARK_FLASH && SystemFlag_CheckFlashActive(varsFlags) == TRUE)) { @@ -281,15 +281,15 @@ void FieldMapChange_UpdateGameData(FieldSystem *fieldSystem, BOOL noWarp) if (noWarp) { int cam1 = FieldOverworldState_GetCameraType(fieldState); - int cam2 = MapHeader_GetCameraType(mapId); + int cam2 = MapHeader_GetCameraType(mapHeaderID); GF_ASSERT(cam1 == cam2); } else { - FieldOverworldState_SetCameraType(fieldState, MapHeader_GetCameraType(mapId)); + FieldOverworldState_SetCameraType(fieldState, MapHeader_GetCameraType(mapHeaderID)); } if (!noWarp) { - u16 warpId = GetMapBlackOutWarpId(mapId); + u16 warpId = GetMapBlackOutWarpId(mapHeaderID); if (warpId != 0) { FieldOverworldState_SetBlackOutWarpId(fieldState, warpId); @@ -304,7 +304,7 @@ void FieldMapChange_UpdateGameData(FieldSystem *fieldSystem, BOOL noWarp) void FieldMapChange_UpdateGameDataDistortionWorld(FieldSystem *fieldSystem, BOOL param1) { - int mapId = fieldSystem->location->mapId; + enum MapHeaderID mapHeaderID = fieldSystem->location->mapHeaderID; FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); FieldBGM_ClearOverride(fieldSystem); @@ -327,7 +327,7 @@ void FieldMapChange_UpdateGameDataDistortionWorld(FieldSystem *fieldSystem, BOOL } if (!param1) { - u16 warpId = GetMapBlackOutWarpId(mapId); + u16 warpId = GetMapBlackOutWarpId(mapHeaderID); if (warpId != 0) { FieldOverworldState_SetBlackOutWarpId(fieldState, warpId); @@ -377,7 +377,7 @@ static void FieldMapChange_InitTerrainCollisionManager(FieldSystem *fieldSystem) { sub_020530C8(fieldSystem); GF_ASSERT(fieldSystem->terrainCollisionMan == NULL); - MapMatrix_Load(fieldSystem->location->mapId, fieldSystem->mapMatrix); + MapMatrix_Load(fieldSystem->location->mapHeaderID, fieldSystem->mapMatrix); if (SystemVars_CheckHiddenLocation(SaveData_GetVarsFlags(fieldSystem->saveData), HIDDEN_LOCATION_SEABREAK_PATH)) { MapMatrix_RevealSeabreakPath(fieldSystem->mapMatrix); // reveal Seabreak Path if Oak's Letter has been used @@ -417,7 +417,7 @@ static void FieldMapChange_RemoveTerrainCollisionManager(FieldSystem *fieldSyste void sub_02053494(FieldSystem *fieldSystem) { if (fieldSystem->journalEntry != NULL) { - void *v0 = JournalEntry_CreateTitle(fieldSystem->location->mapId, 11); + void *v0 = JournalEntry_CreateTitle(fieldSystem->location->mapHeaderID, 11); JournalEntry_SaveData(fieldSystem->journalEntry, v0, JOURNAL_TITLE); } } @@ -427,19 +427,19 @@ static void sub_020534BC(FieldSystem *fieldSystem) if (fieldSystem->journalEntry != NULL) { FieldOverworldState *owState = SaveData_GetFieldOverworldState(fieldSystem->saveData); Location *location = FieldOverworldState_GetSpecialLocation(owState); - void *v2 = JournalEntry_CreateTitle(location->mapId, 11); + void *v2 = JournalEntry_CreateTitle(location->mapHeaderID, 11); JournalEntry_SaveData(fieldSystem->journalEntry, v2, JOURNAL_TITLE); } } static void Location_SetToPlayerLocation(Location *location, const FieldSystem *fieldSystem) { - Location_Set(location, fieldSystem->location->mapId, WARP_ID_NONE, PlayerAvatar_GetXPos(fieldSystem->playerAvatar), PlayerAvatar_GetZPos(fieldSystem->playerAvatar), DIR_SOUTH); + Location_Set(location, fieldSystem->location->mapHeaderID, WARP_ID_NONE, PlayerAvatar_GetXPos(fieldSystem->playerAvatar), PlayerAvatar_GetZPos(fieldSystem->playerAvatar), DIR_SOUTH); } static BOOL FieldSystem_IsSaveInUnionRoom(const FieldSystem *fieldSystem) { - return MapHeader_IsPokemonCenter2F(fieldSystem->location->mapId) + return MapHeader_IsPokemonCenter2F(fieldSystem->location->mapHeaderID) && fieldSystem->location->x == 7 && fieldSystem->location->z == 6; } @@ -449,7 +449,7 @@ static void FieldSystem_SetLocationToUnionRoomExit(FieldSystem *fieldSystem) Location *exit = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); - Location_Set(exit, fieldSystem->location->mapId, -1, 8, 2, 1); + Location_Set(exit, fieldSystem->location->mapHeaderID, -1, 8, 2, 1); } static BOOL FieldTask_LoadNewGameSpawn(FieldTask *task) @@ -526,7 +526,7 @@ static BOOL FieldTask_LoadSavedGameMap(FieldTask *task) } sub_02053494(fieldSystem); - sub_020705CC(fieldSystem); + FieldSystem_RandomizeRoamingPokemonLocations(fieldSystem); *state = 2; break; case 2: @@ -600,9 +600,7 @@ static BOOL FieldTask_LoadMapFromError(FieldTask *task) void FieldSystem_StartLoadMapFromErrorTask(FieldSystem *fieldSystem) { - MapChangeFromErrorData *errorData; - - if (!MapHeader_IsUnionRoom(fieldSystem->location->mapId)) { + if (!MapHeader_IsUnionRoom(fieldSystem->location->mapHeaderID)) { if (FieldSystem_IsSaveInUnionRoom(fieldSystem)) { VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); @@ -614,10 +612,10 @@ void FieldSystem_StartLoadMapFromErrorTask(FieldSystem *fieldSystem) } } - errorData = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(MapChangeFromErrorData)); + MapChangeFromErrorData *errorData = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(MapChangeFromErrorData)); errorData->finishedFlag = FALSE; - Location_Set(&errorData->location, 466, -1, 8, 14, 0); + Location_Set(&errorData->location, MAP_HEADER_UNION_ROOM, -1, 8, 14, 0); fieldSystem->mapLoadType = MAP_LOAD_TYPE_UNION; FieldSystem_CreateTask(fieldSystem, FieldTask_LoadMapFromError, errorData); } @@ -631,7 +629,7 @@ static BOOL FieldTask_ChangeMap(FieldTask *task) switch (mapChangeData->state) { case 0: Sound_PlayEffect(SEQ_SE_DP_KAIDAN2); - FieldBGM_TryFadeIn(fieldSystem, location->mapId); + FieldBGM_TryFadeIn(fieldSystem, location->mapHeaderID); FieldTransition_FadeOutAndFinishMap(task); mapChangeData->state++; break; @@ -644,7 +642,7 @@ static BOOL FieldTask_ChangeMap(FieldTask *task) break; } - FieldBGM_PlayForMapHeader(fieldSystem, location->mapId); + FieldBGM_PlayForMapHeader(fieldSystem, location->mapHeaderID); FieldTransition_StartMapAndFadeIn(task); mapChangeData->state++; break; @@ -709,11 +707,11 @@ void FieldTask_ChangeMapByLocation(FieldTask *task, const Location *nextLocation FieldTask_InitCall(task, FieldTask_ChangeMapSub, mapChangeSub); } -void FieldTask_ChangeMapToLocation(FieldTask *task, int mapId, int warpId, int x, int z, int dir) +void FieldTask_ChangeMapToLocation(FieldTask *task, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int dir) { Location location; - Location_Set(&location, mapId, warpId, x, z, dir); + Location_Set(&location, mapHeaderID, warpId, x, z, dir); FieldTask_ChangeMapByLocation(task, &location); } @@ -725,7 +723,7 @@ static BOOL FieldTask_ChangeMapFull(FieldTask *task) switch (mapChangeSub->state) { case 0: - FieldBGM_TryFadeIn(fieldSystem, nextLocation->mapId); + FieldBGM_TryFadeIn(fieldSystem, nextLocation->mapHeaderID); FieldTransition_FinishMap(task); mapChangeSub->state++; break; @@ -738,7 +736,7 @@ static BOOL FieldTask_ChangeMapFull(FieldTask *task) break; } - FieldBGM_PlayForMapHeader(fieldSystem, nextLocation->mapId); + FieldBGM_PlayForMapHeader(fieldSystem, nextLocation->mapHeaderID); FieldTransition_StartMap(task); mapChangeSub->state++; break; @@ -750,21 +748,21 @@ static BOOL FieldTask_ChangeMapFull(FieldTask *task) return FALSE; } -void FieldTask_StartMapChangeFull(FieldTask *task, int mapId, int warpId, int x, int z, int dir) +void FieldTask_StartMapChangeFull(FieldTask *task, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int dir) { MapChangeSubData *mapChangeSub = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(MapChangeSubData)); mapChangeSub->state = 0; - Location_Set(&mapChangeSub->nextLocation, mapId, warpId, x, z, dir); + Location_Set(&mapChangeSub->nextLocation, mapHeaderID, warpId, x, z, dir); FieldTask_InitCall(task, FieldTask_ChangeMapFull, mapChangeSub); } -void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, int mapId, int warpId, int x, int z, int dir) +void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int dir) { Location location; - Location_Set(&location, mapId, warpId, x, z, dir); + Location_Set(&location, mapHeaderID, warpId, x, z, dir); MapChangeFlyData *mapChangeData = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(MapChangeFlyData)); @@ -775,11 +773,11 @@ void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, int mapId, int warpId FieldSystem_CreateTask(fieldSystem, FieldTask_MapChangeFly, mapChangeData); } -void FieldTask_ChangeMapChangeFly(FieldTask *task, int mapId, int warpId, int x, int z, int dir) +void FieldTask_ChangeMapChangeFly(FieldTask *task, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int dir) { Location location; - Location_Set(&location, mapId, warpId, x, z, dir); + Location_Set(&location, mapHeaderID, warpId, x, z, dir); MapChangeFlyData *mapChangeData = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(MapChangeFlyData)); @@ -798,7 +796,7 @@ static BOOL FieldTask_MapChangeFly(FieldTask *task) switch (mapChangeData->state) { case 0: - FieldBGM_TryFadeIn(fieldSystem, location->mapId); + FieldBGM_TryFadeIn(fieldSystem, location->mapHeaderID); FieldTask_FinishFly(task); mapChangeData->state++; break; @@ -812,7 +810,7 @@ static BOOL FieldTask_MapChangeFly(FieldTask *task) break; } - FieldBGM_PlayForMapHeader(fieldSystem, location->mapId); + FieldBGM_PlayForMapHeader(fieldSystem, location->mapHeaderID); FieldSystem_SetFlyFlags(fieldSystem); FieldTransition_StartMapAndFadeInFly(task); mapChangeData->state++; @@ -920,7 +918,7 @@ static BOOL FieldTask_MapChangeByFieldWarp(FieldTask *task) switch (mapChangeData->state) { case 0: - FieldBGM_TryFadeIn(fieldSystem, location->mapId); + FieldBGM_TryFadeIn(fieldSystem, location->mapHeaderID); FieldTask_StartFinishFieldMapFieldWarp(task); mapChangeData->state++; break; @@ -934,7 +932,7 @@ static BOOL FieldTask_MapChangeByFieldWarp(FieldTask *task) break; } - FieldBGM_PlayForMapHeader(fieldSystem, location->mapId); + FieldBGM_PlayForMapHeader(fieldSystem, location->mapHeaderID); if (mapChangeData->fieldWarpType == FIELD_WARP_TYPE_TELEPORT) { FieldSystem_SetTeleportFlags(fieldSystem); @@ -1032,7 +1030,7 @@ static BOOL FieldTask_MapChangeWarp(FieldTask *task) break; case 1: if (mapChangeWarpData->warpFinished) { - FieldBGM_TryFadeIn(fieldSystem, nextLocation->mapId); + FieldBGM_TryFadeIn(fieldSystem, nextLocation->mapHeaderID); FieldTransition_FinishMap(task); mapChangeWarpData->state++; } @@ -1046,7 +1044,7 @@ static BOOL FieldTask_MapChangeWarp(FieldTask *task) break; } - FieldBGM_PlayForMapHeader(fieldSystem, nextLocation->mapId); + FieldBGM_PlayForMapHeader(fieldSystem, nextLocation->mapHeaderID); FieldTransition_StartMap(task); mapChangeWarpData->state++; break; @@ -1090,13 +1088,13 @@ MapChangeUndergroundContext *MapChangeUndergroundContext_New(FieldSystem *fieldS ctx->transitionState = 0; if (fieldSystem->mapLoadType == MAP_LOAD_TYPE_UNDERGROUND) { - ctx->mapId = location->mapId; + ctx->mapHeaderID = location->mapHeaderID; ctx->dummy = -1; ctx->destX = location->x; ctx->destZ = location->z; } else { Location_SetToPlayerLocation(location, fieldSystem); - ctx->mapId = MAP_HEADER_UNDERGROUND; + ctx->mapHeaderID = MAP_HEADER_UNDERGROUND; ctx->dummy = -1; int matrixX = location->x / MAP_TILES_COUNT_X - 1; @@ -1214,7 +1212,7 @@ BOOL FieldTask_MapChangeToUnderground(FieldTask *task) fieldSystem->mapLoadType = MAP_LOAD_TYPE_UNDERGROUND; Overlay_LoadByID(FS_OVERLAY_ID(underground), OVERLAY_LOAD_ASYNC); CommManUnderground_InitUnderground(fieldSystem); - FieldTask_ChangeMapToLocation(task, ctx->mapId, WARP_ID_NONE, ctx->destX, ctx->destZ, DIR_SOUTH); + FieldTask_ChangeMapToLocation(task, ctx->mapHeaderID, WARP_ID_NONE, ctx->destX, ctx->destZ, DIR_SOUTH); ctx->state++; break; case ENTER_UNDERGROUND_START_MAP: @@ -1280,7 +1278,7 @@ BOOL FieldTask_MapChangeFromUnderground(FieldTask *task) case EXIT_UNDERGROUND_LOAD_OVERWORLD: fieldSystem->mapLoadType = MAP_LOAD_TYPE_OVERWORLD; Overlay_UnloadByID(FS_OVERLAY_ID(underground)); - FieldTask_ChangeMapToLocation(task, ctx->mapId, WARP_ID_NONE, ctx->destX, ctx->destZ, DIR_SOUTH); + FieldTask_ChangeMapToLocation(task, ctx->mapHeaderID, WARP_ID_NONE, ctx->destX, ctx->destZ, DIR_SOUTH); ctx->state++; break; case EXIT_UNDERGROUND_START_MAP: @@ -1390,7 +1388,7 @@ static BOOL sub_02054538(FieldTask *task) switch (*state) { case 0: - FieldBGM_TryFadeIn(fieldSystem, v3->mapId); + FieldBGM_TryFadeIn(fieldSystem, v3->mapHeaderID); FieldSystem_StartWarpAnimation(fieldSystem, 1, &mapChangeData->unk_04); (*state)++; break; @@ -1409,7 +1407,7 @@ static BOOL sub_02054538(FieldTask *task) break; } - FieldBGM_PlayForMapHeader(fieldSystem, v3->mapId); + FieldBGM_PlayForMapHeader(fieldSystem, v3->mapHeaderID); FieldTransition_StartMap(task); (*state)++; break; @@ -1450,7 +1448,7 @@ static BOOL sub_02054648(FieldTask *task) switch (*state) { case 0: - FieldBGM_TryFadeIn(fieldSystem, v3->mapId); + FieldBGM_TryFadeIn(fieldSystem, v3->mapHeaderID); FieldTransition_FadeOut(task); (*state)++; break; @@ -1467,7 +1465,7 @@ static BOOL sub_02054648(FieldTask *task) break; } - FieldBGM_PlayForMapHeader(fieldSystem, v3->mapId); + FieldBGM_PlayForMapHeader(fieldSystem, v3->mapHeaderID); FieldTransition_StartMap(task); (*state)++; break; @@ -1498,7 +1496,7 @@ void sub_02054708(FieldTask *task) MI_CpuClear8(mapChangeData, sizeof(MapChangeUnionData)); Location_SetToPlayerLocation(location, fieldSystem); - Location_Set(&mapChangeData->location, 466, -1, 8, 14, 0); + Location_Set(&mapChangeData->location, MAP_HEADER_UNION_ROOM, -1, 8, 14, 0); fieldSystem->unk_7C = FieldSystem_InitCommUnionRoom(fieldSystem); fieldSystem->unk_80 = sub_0205C22C(fieldSystem->unk_7C); @@ -1516,7 +1514,7 @@ static BOOL FieldTask_ChangeMapColosseum(FieldTask *task) switch (mapChangeData->state) { case 0: Sound_PlayEffect(SEQ_SE_DP_KAIDAN2); - FieldBGM_TryFadeIn(fieldSystem, location->mapId); + FieldBGM_TryFadeIn(fieldSystem, location->mapHeaderID); FieldTransition_FadeOutAndFinishMap(task); mapChangeData->state++; break; @@ -1529,7 +1527,7 @@ static BOOL FieldTask_ChangeMapColosseum(FieldTask *task) break; } - FieldBGM_PlayForMapHeader(fieldSystem, location->mapId); + FieldBGM_PlayForMapHeader(fieldSystem, location->mapHeaderID); FieldTransition_StartMap(task); mapChangeData->state++; break; @@ -1541,7 +1539,7 @@ static BOOL FieldTask_ChangeMapColosseum(FieldTask *task) return FALSE; } -void FieldTask_StartChangeMapColosseum(FieldTask *task, int mapId, int warpId, int x, int z, int dir) +void FieldTask_StartChangeMapColosseum(FieldTask *task, enum MapHeaderID mapHeaderID, int warpId, int x, int z, int dir) { Location nextLocation; FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); @@ -1553,7 +1551,7 @@ void FieldTask_StartChangeMapColosseum(FieldTask *task, int mapId, int warpId, i MapChangeData *mapChangeData = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(MapChangeData)); - Location_Set(&nextLocation, mapId, warpId, x, z, dir); + Location_Set(&nextLocation, mapHeaderID, warpId, x, z, dir); mapChangeData->state = 0; mapChangeData->nextLocation = nextLocation; diff --git a/src/unk_02070428.c b/src/field_map_change_flags.c similarity index 58% rename from src/unk_02070428.c rename to src/field_map_change_flags.c index e6286520f8..fc5977c8d6 100644 --- a/src/unk_02070428.c +++ b/src/field_map_change_flags.c @@ -1,8 +1,10 @@ -#include "unk_02070428.h" +#include "field_map_change_flags.h" #include #include +#include "generated/map_headers.h" + #include "struct_defs/player_data.h" #include "struct_defs/special_encounter.h" @@ -23,43 +25,41 @@ #include "system_vars.h" #include "vars_flags.h" -static BOOL sub_020705DC(FieldSystem *fieldSystem); -static BOOL sub_02070610(FieldSystem *fieldSystem); +static BOOL CreateFlyLocationJournalEvent(FieldSystem *fieldSystem); +static BOOL CreateMapTransitionJournalEvent(FieldSystem *fieldSystem); -void sub_02070428(FieldSystem *fieldSystem, BOOL param1) +void FieldSystem_SetTemporaryMapChange(FieldSystem *fieldSystem, BOOL temporaryMapChange) { - fieldSystem->unk_B8 = param1; + fieldSystem->temporaryMapChange = temporaryMapChange; } void FieldSystem_InitFlagsOnMapChange(FieldSystem *fieldSystem) { - sub_020705DC(fieldSystem); + CreateFlyLocationJournalEvent(fieldSystem); SystemFlag_HandleForceBikingInGate(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CLEAR); SystemFlag_HandleStrengthActive(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CLEAR); - TryUnlockFlyLocationByMap(fieldSystem, fieldSystem->location->mapId); + TryUnlockFlyLocationByMap(fieldSystem, fieldSystem->location->mapHeaderID); SpecialEncounter_SetFluteFactor(SaveData_GetSpecialEncounters(fieldSystem->saveData), FLUTE_FACTOR_NONE); fieldSystem->wildBattleMetadata.encounterAttempts = 0; if (SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)) == FALSE) { - SpecialEncounter *v0; - - v0 = SaveData_GetSpecialEncounters(fieldSystem->saveData); - RoamingPokemon_UpdatePlayerRecentRoutes(v0, fieldSystem->location->mapId); - RoamingPokemon_MoveAllLocations(v0); + SpecialEncounter *speEnc = SaveData_GetSpecialEncounters(fieldSystem->saveData); + RoamingPokemon_UpdatePlayerRecentRoutes(speEnc, fieldSystem->location->mapHeaderID); + RoamingPokemon_MoveAllLocations(speEnc); } } void FieldSystem_InitFlagsWarp(FieldSystem *fieldSystem) { - if (fieldSystem->unk_B8 == 1) { + if (fieldSystem->temporaryMapChange == TRUE) { return; } - if (sub_020705DC(fieldSystem) == 0) { - sub_02070610(fieldSystem); + if (CreateFlyLocationJournalEvent(fieldSystem) == FALSE) { + CreateMapTransitionJournalEvent(fieldSystem); } SystemFlag_HandleForceBikingInGate(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CLEAR); @@ -67,36 +67,34 @@ void FieldSystem_InitFlagsWarp(FieldSystem *fieldSystem) SystemFlag_HandleStrengthActive(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CLEAR); - TryUnlockFlyLocationByMap(fieldSystem, fieldSystem->location->mapId); + TryUnlockFlyLocationByMap(fieldSystem, fieldSystem->location->mapHeaderID); SpecialEncounter_SetFluteFactor(SaveData_GetSpecialEncounters(fieldSystem->saveData), FLUTE_FACTOR_NONE); fieldSystem->wildBattleMetadata.encounterAttempts = 0; { - SpecialEncounter *v0; - - v0 = SaveData_GetSpecialEncounters(fieldSystem->saveData); - RoamingPokemon_UpdatePlayerRecentRoutes(v0, fieldSystem->location->mapId); + SpecialEncounter *speEnc = SaveData_GetSpecialEncounters(fieldSystem->saveData); + RoamingPokemon_UpdatePlayerRecentRoutes(speEnc, fieldSystem->location->mapHeaderID); } - if (!MapHeader_IsCave(fieldSystem->location->mapId)) { - VarsFlags *v1 = SaveData_GetVarsFlags(fieldSystem->saveData); + if (!MapHeader_IsCave(fieldSystem->location->mapHeaderID)) { + VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); - SystemFlag_ClearFlashActive(v1); - SystemFlag_ClearDefogActive(v1); + SystemFlag_ClearFlashActive(varsFlags); + SystemFlag_ClearDefogActive(varsFlags); } { - PlayerData *v2 = FieldOverworldState_GetPlayerData(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + PlayerData *playerData = FieldOverworldState_GetPlayerData(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - if ((v2->playerState == PLAYER_AVATAR_CYCLING) && (MapHeader_IsBikeAllowed(fieldSystem->location->mapId) == 0)) { - v2->playerState = PLAYER_AVATAR_WALKING; - } else if (v2->playerState == PLAYER_AVATAR_SURFING) { - v2->playerState = PLAYER_AVATAR_WALKING; + if (playerData->playerState == PLAYER_AVATAR_CYCLING && MapHeader_IsBikeAllowed(fieldSystem->location->mapHeaderID) == FALSE) { + playerData->playerState = PLAYER_AVATAR_WALKING; + } else if (playerData->playerState == PLAYER_AVATAR_SURFING) { + playerData->playerState = PLAYER_AVATAR_WALKING; } } - if (MapHeader_IsOnMainMatrix(fieldSystem->location->mapId)) { + if (MapHeader_IsOnMainMatrix(fieldSystem->location->mapHeaderID)) { OverworldMapHistory *mapHistory = FieldOverworldState_GetMapHistory(SaveData_GetFieldOverworldState(fieldSystem->saveData)); OverworldMapHistory_PushViaWarp(mapHistory, fieldSystem->location->x, fieldSystem->location->z); } @@ -126,29 +124,29 @@ void FieldSystem_ClearPartnerTrainer(FieldSystem *fieldSystem) SystemVars_SetPartnerTrainerID(varsFlags, 0); } -void sub_020705CC(FieldSystem *fieldSystem) +void FieldSystem_RandomizeRoamingPokemonLocations(FieldSystem *fieldSystem) { RoamingPokemon_RandomizeAllLocations(SaveData_GetSpecialEncounters(fieldSystem->saveData)); } -static BOOL sub_020705DC(FieldSystem *fieldSystem) +static BOOL CreateFlyLocationJournalEvent(FieldSystem *fieldSystem) { - int v0 = GetMapFlyWarpId(fieldSystem->location->mapId); + int flyLocation = GetMapFlyWarpId(fieldSystem->location->mapHeaderID); - if (v0 != 0 && CheckFlyLocationUnlocked(fieldSystem, v0) == 0) { - JournalEntry_CreateAndSaveEventArrivedInLocation(fieldSystem->journalEntry, fieldSystem->location->mapId, HEAP_ID_FIELD3); + if (flyLocation != MAP_HEADER_EVERYWHERE && CheckFlyLocationUnlocked(fieldSystem, flyLocation) == FALSE) { + JournalEntry_CreateAndSaveEventArrivedInLocation(fieldSystem->journalEntry, fieldSystem->location->mapHeaderID, HEAP_ID_FIELD3); return TRUE; } return FALSE; } -static BOOL sub_02070610(FieldSystem *fieldSystem) +static BOOL CreateMapTransitionJournalEvent(FieldSystem *fieldSystem) { Location *location = FieldOverworldState_GetPrevLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - if (location->mapId != fieldSystem->location->mapId) { - JournalEntry_CreateAndSaveEventMapTransition(SaveData_GetTrainerInfo(fieldSystem->saveData), fieldSystem->journalEntry, fieldSystem->location->mapId, location->mapId, HEAP_ID_FIELD3); + if (location->mapHeaderID != fieldSystem->location->mapHeaderID) { + JournalEntry_CreateAndSaveEventMapTransition(SaveData_GetTrainerInfo(fieldSystem->saveData), fieldSystem->journalEntry, fieldSystem->location->mapHeaderID, location->mapHeaderID, HEAP_ID_FIELD3); return TRUE; } diff --git a/src/field_move_tasks.c b/src/field_move_tasks.c index e414dac72a..4395f689d9 100644 --- a/src/field_move_tasks.c +++ b/src/field_move_tasks.c @@ -17,7 +17,9 @@ #include "overlay005/ov5_021DFB54.h" #include "overlay005/ov5_021F101C.h" #include "overlay006/field_warp.h" +#include "overlay006/hm_cut_in.h" +#include "field_map_change.h" #include "field_overworld_state.h" #include "field_task.h" #include "heap.h" @@ -31,6 +33,7 @@ #include "player_move.h" #include "save_player.h" #include "script_manager.h" +#include "spawn_locations.h" #include "start_menu.h" #include "system_flags.h" #include "terrain_collision_manager.h" @@ -210,7 +213,7 @@ BOOL FieldMoves_FlyTask(FieldTask *task) Location location; Location_InitFly(destination, &location); - FieldTask_ChangeMapChangeFly(task, location.mapId, WARP_ID_NONE, location.x, location.z, DIR_SOUTH); + FieldTask_ChangeMapChangeFly(task, location.mapHeaderID, WARP_ID_NONE, location.x, location.z, DIR_SOUTH); Heap_Free(ctx); } @@ -235,7 +238,7 @@ void FieldMoves_SetUsableMoves(FieldSystem *fieldSystem, FieldMoveContext *field int currTileBehavior; fieldMoveContext->fieldSystem = fieldSystem; - fieldMoveContext->mapId = fieldSystem->location->mapId; + fieldMoveContext->mapHeaderID = fieldSystem->location->mapHeaderID; fieldMoveContext->usableMoves = 0; if (PlayerAvatar_DistortionGravityChanged(fieldSystem->playerAvatar) == TRUE) { @@ -371,7 +374,7 @@ static enum FieldMoveError FieldMoves_CheckFly(const FieldMoveContext *fieldMove return FIELD_MOVE_ERROR_BADGE; } - if (MapHeader_IsFlyAllowed(fieldMoveContext->mapId) == FALSE) { + if (MapHeader_IsFlyAllowed(fieldMoveContext->mapHeaderID) == FALSE) { return FIELD_MOVE_ERROR_LOCATION; } @@ -707,7 +710,7 @@ static enum FieldMoveError FieldMoves_CheckTeleport(const FieldMoveContext *fiel return FIELD_MOVE_ERROR_LOCATION; } - if (MapHeader_IsTeleportAllowed(fieldMoveContext->mapId) == FALSE) { + if (MapHeader_IsTeleportAllowed(fieldMoveContext->mapHeaderID) == FALSE) { return FIELD_MOVE_ERROR_LOCATION; } @@ -754,7 +757,7 @@ static enum FieldMoveError FieldMoves_CheckDig(const FieldMoveContext *fieldMove return FIELD_MOVE_ERROR_LOCATION; } - if (!((MapHeader_IsCave(fieldMoveContext->mapId) == TRUE) && (MapHeader_IsEscapeRopeAllowed(fieldMoveContext->mapId) == TRUE))) { + if (!((MapHeader_IsCave(fieldMoveContext->mapHeaderID) == TRUE) && (MapHeader_IsEscapeRopeAllowed(fieldMoveContext->mapHeaderID) == TRUE))) { return FIELD_MOVE_ERROR_LOCATION; } @@ -785,7 +788,7 @@ static BOOL FieldMoves_DigTask(FieldTask *task) UnkStruct_020711C8 *v1 = FieldTask_GetEnv(task); FieldWarp *fieldWarp = FieldWarp_InitDig(fieldSystem, v1->unk_00, HEAP_ID_FIELD2); - void *journalEntryLocationEvent = JournalEntry_CreateEventUsedMove(FIELD_MOVE_DIG, fieldSystem->location->mapId, HEAP_ID_FIELD1); + void *journalEntryLocationEvent = JournalEntry_CreateEventUsedMove(FIELD_MOVE_DIG, fieldSystem->location->mapHeaderID, HEAP_ID_FIELD1); JournalEntry_SaveData(fieldSystem->journalEntry, journalEntryLocationEvent, JOURNAL_LOCATION); Heap_Free(v1); @@ -821,7 +824,7 @@ static void FieldMoves_SetSweetScentTask(FieldMovePokemon *fieldMoveMon, const F startMenu->taskData = v2; startMenu->state = START_MENU_STATE_NEW_TASK; - v4 = JournalEntry_CreateEventUsedMove(FIELD_MOVE_SWEET_SCENT, fieldSystem->location->mapId, HEAP_ID_FIELD2); + v4 = JournalEntry_CreateEventUsedMove(FIELD_MOVE_SWEET_SCENT, fieldSystem->location->mapHeaderID, HEAP_ID_FIELD2); JournalEntry_SaveData(fieldSystem->journalEntry, v4, JOURNAL_LOCATION); } diff --git a/src/field_system.c b/src/field_system.c index 6fc0cb2ee1..3e39e2d308 100644 --- a/src/field_system.c +++ b/src/field_system.c @@ -244,7 +244,7 @@ static void HandleFieldInput(FieldSystem *fieldSystem) } enum MapLoadType loadType = fieldSystem->mapLoadType; - if (fieldSystem->location->mapId == MAP_HEADER_BATTLE_TOWER) { + if (fieldSystem->location->mapHeaderID == MAP_HEADER_BATTLE_TOWER) { loadType = MAP_LOAD_TYPE_OVERWORLD; } diff --git a/src/great_marsh_lookout.c b/src/great_marsh_lookout.c index 4830f4d9dc..c16c01973c 100644 --- a/src/great_marsh_lookout.c +++ b/src/great_marsh_lookout.c @@ -11,6 +11,7 @@ #include "overlay006/great_marsh_lookout_sprite.h" #include "field_map_change.h" +#include "field_map_change_flags.h" #include "field_task.h" #include "field_transition.h" #include "heap.h" @@ -21,7 +22,6 @@ #include "system.h" #include "system_flags.h" #include "unk_02056B30.h" -#include "unk_02070428.h" #include "vars_flags.h" // Data used for the Great Marsh lookout binoculars scene. @@ -55,7 +55,7 @@ static BOOL Task_GreatMarshLookout(FieldTask *taskMan) switch (lookout->state) { case 0: - sub_02070428(fieldSystem, 1); + FieldSystem_SetTemporaryMapChange(fieldSystem, TRUE); GreatMarshBinoculars_SetNextLocationWithCoords(lookout->numCycles, lookout->binocularsData); lookout->nextLocation = GreatMarshBinoculars_GetLocation(lookout->binocularsData); FieldTransition_FadeOut(taskMan); @@ -124,7 +124,7 @@ static BOOL Task_GreatMarshLookout(FieldTask *taskMan) } break; case 8: - sub_02070428(fieldSystem, 0); + FieldSystem_SetTemporaryMapChange(fieldSystem, FALSE); GreatMarshBinoculars_FreeData(lookout->binocularsData); GreatMarshLookout_FreeSpriteManager(lookout->spriteResources); Heap_Free(lookout); diff --git a/src/item_use_functions.c b/src/item_use_functions.c index 8254f6dc92..3c4bdf4dcd 100644 --- a/src/item_use_functions.c +++ b/src/item_use_functions.c @@ -184,7 +184,7 @@ void ItemUseContext_Init(FieldSystem *fieldSystem, ItemUseContext *ctxOut) } ctxOut->fieldSystem = fieldSystem; - ctxOut->mapHeaderID = fieldSystem->location->mapId; + ctxOut->mapHeaderID = fieldSystem->location->mapHeaderID; ctxOut->hasPartner = SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData)); ctxOut->playerState = PlayerAvatar_GetPlayerState(fieldSystem->playerAvatar); @@ -221,7 +221,7 @@ void ItemUseContext_Init(FieldSystem *fieldSystem, ItemUseContext *ctxOut) static void ItemUseContext_InitForDistortionWorld(FieldSystem *fieldSystem, ItemUseContext *ctxOut) { ctxOut->fieldSystem = fieldSystem; - ctxOut->mapHeaderID = fieldSystem->location->mapId; + ctxOut->mapHeaderID = fieldSystem->location->mapHeaderID; ctxOut->hasPartner = SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData)); ctxOut->playerState = PlayerAvatar_GetPlayerState(fieldSystem->playerAvatar); ctxOut->currTileBehavior = PlayerAvatar_GetDistortionCurrTileBehaviour(fieldSystem->playerAvatar); @@ -437,7 +437,7 @@ static BOOL MountOrUnmountBicycle(FieldTask *task) PlayerAvatar_RequestChangeState(fieldSystem->playerAvatar); FieldBGM_SetOverride(fieldSystem, SEQ_NONE); - FieldBGM_TryFadeOut(fieldSystem, FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapId), 1); + FieldBGM_TryFadeOut(fieldSystem, FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapHeaderID), 1); } else { FieldBGM_SetOverride(fieldSystem, SEQ_BICYCLE); FieldBGM_TryFadeOut(fieldSystem, SEQ_BICYCLE, 1); diff --git a/src/location.c b/src/location.c index 79e7ac56ba..84b8881e6e 100644 --- a/src/location.c +++ b/src/location.c @@ -6,7 +6,7 @@ #include "savedata.h" static const Location sPlayerStartLocation = { - .mapId = MAP_HEADER_TWINLEAF_TOWN_PLAYER_HOUSE_2F, + .mapHeaderID = MAP_HEADER_TWINLEAF_TOWN_PLAYER_HOUSE_2F, .warpId = WARP_ID_NONE, .x = 4, .z = 6, @@ -14,7 +14,7 @@ static const Location sPlayerStartLocation = { }; static const Location sPlayerFirstRespawnLocation = { - .mapId = MAP_HEADER_TWINLEAF_TOWN, + .mapHeaderID = MAP_HEADER_TWINLEAF_TOWN, .warpId = WARP_ID_NONE, .x = 116, .z = 886, diff --git a/src/map_header.c b/src/map_header.c index 6240f8cfd8..dfc794b19f 100644 --- a/src/map_header.c +++ b/src/map_header.c @@ -5,32 +5,32 @@ #include "data/map_headers.h" -u32 MapHeader_IDBoundsCheck(u32 headerID) +enum MapHeaderID MapHeader_IDBoundsCheck(enum MapHeaderID mapHeaderID) { - if (headerID >= NELEMS(sMapHeaders)) { + if (mapHeaderID >= NELEMS(sMapHeaders)) { GF_ASSERT(FALSE); - return 3; + return MAP_HEADER_JUBILIFE_CITY; } - return headerID; + return mapHeaderID; } -u16 MapHeader_GetAreaDataArchiveID(u32 headerID) +u16 MapHeader_GetAreaDataArchiveID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].areaDataArchiveID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].areaDataArchiveID; } -u16 MapHeader_GetPreloadedMapObjectsArchiveID(u32 headerID) +u16 MapHeader_GetPreloadedMapObjectsArchiveID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].preloadedMapObjectsArchiveID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].preloadedMapObjectsArchiveID; } -u16 MapHeader_GetMapMatrixID(u32 headerID) +u16 MapHeader_GetMapMatrixID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - u16 mapMatrixID = sMapHeaders[headerID].mapMatrixID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + u16 mapMatrixID = sMapHeaders[mapHeaderID].mapMatrixID; if (mapMatrixID == 22 && gGameVersion == VERSION_PEARL) { mapMatrixID = 23; @@ -39,183 +39,183 @@ u16 MapHeader_GetMapMatrixID(u32 headerID) return mapMatrixID; } -u32 MapHeader_GetMsgArchiveID(u32 headerID) +u32 MapHeader_GetMsgArchiveID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].msgArchiveID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].msgArchiveID; } -u32 MapHeader_GetScriptsArchiveID(u32 headerID) +u32 MapHeader_GetScriptsArchiveID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].scriptsArchiveID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].scriptsArchiveID; } -u32 MapHeader_GetInitScriptsArchiveID(u32 headerID) +u32 MapHeader_GetInitScriptsArchiveID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].initScriptsArchiveID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].initScriptsArchiveID; } -u16 MapHeader_GetDayMusicID(u32 headerID) +u16 MapHeader_GetDayMusicID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].dayMusicID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].dayMusicID; } -u16 MapHeader_GetNightMusicID(u32 headerID) +u16 MapHeader_GetNightMusicID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].nightMusicID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].nightMusicID; } -BOOL MapHeader_HasWildEncounters(u32 headerID) +BOOL MapHeader_HasWildEncounters(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].wildEncountersArchiveID != 65535; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].wildEncountersArchiveID != 65535; } -u32 MapHeader_GetWildEncountersArchiveID(u32 headerID) +u32 MapHeader_GetWildEncountersArchiveID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].wildEncountersArchiveID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].wildEncountersArchiveID; } -u32 MapHeader_GetEventsArchiveID(u32 headerID) +u32 MapHeader_GetEventsArchiveID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].eventsArchiveID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].eventsArchiveID; } -u32 MapHeader_GetMapLabelTextID(u32 headerID) +u32 MapHeader_GetMapLabelTextID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].mapLabelTextID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].mapLabelTextID; } -u8 MapHeader_GetMapLabelWindowID(u32 headerID) +u8 MapHeader_GetMapLabelWindowID(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].mapLabelWindowID; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].mapLabelWindowID; } -u32 MapHeader_GetWeatherType(u32 headerID) +u32 MapHeader_GetWeatherType(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].weather; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].weather; } -u32 MapHeader_GetCameraType(u32 headerID) +u32 MapHeader_GetCameraType(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].cameraType; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].cameraType; } -enum BattleBackground MapHeader_GetBattleBG(u32 headerID) +enum BattleBackground MapHeader_GetBattleBG(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].battleBG; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].battleBG; } -BOOL MapHeader_IsEscapeRopeAllowed(u32 headerID) +BOOL MapHeader_IsEscapeRopeAllowed(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].isEscapeRopeAllowed; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].isEscapeRopeAllowed; } -BOOL MapHeader_IsFlyAllowed(u32 headerID) +BOOL MapHeader_IsFlyAllowed(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].isFlyAllowed; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].isFlyAllowed; } -BOOL MapHeader_IsBikeAllowed(u32 headerID) +BOOL MapHeader_IsBikeAllowed(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].isBikeAllowed; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].isBikeAllowed; } -u32 MapHeader_GetMapType(u32 headerID) +u32 MapHeader_GetMapType(enum MapHeaderID mapHeaderID) { - headerID = MapHeader_IDBoundsCheck(headerID); - return sMapHeaders[headerID].mapType; + mapHeaderID = MapHeader_IDBoundsCheck(mapHeaderID); + return sMapHeaders[mapHeaderID].mapType; } -BOOL MapHeader_IsTeleportAllowed(u32 headerID) +BOOL MapHeader_IsTeleportAllowed(enum MapHeaderID mapHeaderID) { - if (MapHeader_IsFlyAllowed(headerID) == FALSE) { + if (MapHeader_IsFlyAllowed(mapHeaderID) == FALSE) { return FALSE; } - return MapHeader_GetMapType(headerID) != MAP_TYPE_TOWN_CITY; + return MapHeader_GetMapType(mapHeaderID) != MAP_TYPE_TOWN_CITY; } -BOOL MapHeader_IsOnMainMatrix(u32 headerID) +BOOL MapHeader_IsOnMainMatrix(enum MapHeaderID mapHeaderID) { - return MapHeader_GetMapMatrixID(headerID) == 0; + return MapHeader_GetMapMatrixID(mapHeaderID) == 0; } -BOOL MapHeader_IsPokemonCenter(u32 headerID) +BOOL MapHeader_IsPokemonCenter(enum MapHeaderID mapHeaderID) { - return MapHeader_GetMapType(headerID) == MAP_TYPE_POKECENTER; + return MapHeader_GetMapType(mapHeaderID) == MAP_TYPE_POKECENTER; } -BOOL MapHeader_IsCave(u32 headerID) +BOOL MapHeader_IsCave(enum MapHeaderID mapHeaderID) { - return MapHeader_GetMapType(headerID) == MAP_TYPE_CAVE; + return MapHeader_GetMapType(mapHeaderID) == MAP_TYPE_CAVE; } -BOOL MapHeader_IsBuilding(u32 headerID) +BOOL MapHeader_IsBuilding(enum MapHeaderID mapHeaderID) { - return MapHeader_GetMapType(headerID) == MAP_TYPE_INDOORS - || MapHeader_GetMapType(headerID) == MAP_TYPE_POKECENTER; + return MapHeader_GetMapType(mapHeaderID) == MAP_TYPE_INDOORS + || MapHeader_GetMapType(mapHeaderID) == MAP_TYPE_POKECENTER; } -BOOL MapHeader_IsOutdoors(u32 headerID) +BOOL MapHeader_IsOutdoors(enum MapHeaderID mapHeaderID) { - return MapHeader_GetMapType(headerID) == MAP_TYPE_TOWN_CITY - || MapHeader_GetMapType(headerID) == MAP_TYPE_OUTDOORS; + return MapHeader_GetMapType(mapHeaderID) == MAP_TYPE_TOWN_CITY + || MapHeader_GetMapType(mapHeaderID) == MAP_TYPE_OUTDOORS; } -BOOL MapHeader_IsPokemonCenter2(u32 headerID) +BOOL MapHeader_IsPokemonCenter2(enum MapHeaderID mapHeaderID) { - if (MapHeader_IsPokemonCenter(headerID)) { + if (MapHeader_IsPokemonCenter(mapHeaderID)) { return TRUE; } return FALSE; } -BOOL MapHeader_IsUnionRoom(const u32 headerID) +BOOL MapHeader_IsUnionRoom(const enum MapHeaderID mapHeaderID) { - return headerID == MAP_HEADER_UNION_ROOM; + return mapHeaderID == MAP_HEADER_UNION_ROOM; } -BOOL MapHeader_HasFeebasTiles(const u32 headerID) +BOOL MapHeader_HasFeebasTiles(const enum MapHeaderID mapHeaderID) { - return headerID == MAP_HEADER_MT_CORONET_B1F; + return mapHeaderID == MAP_HEADER_MT_CORONET_B1F; } -BOOL MapHeader_IsTrophyGarden(const u32 headerID) +BOOL MapHeader_IsTrophyGarden(const enum MapHeaderID mapHeaderID) { - return headerID == MAP_HEADER_TROPHY_GARDEN; + return mapHeaderID == MAP_HEADER_TROPHY_GARDEN; } -BOOL MapHeader_IsAmitySquare(const u32 headerID) +BOOL MapHeader_IsAmitySquare(const enum MapHeaderID mapHeaderID) { - return headerID == MAP_HEADER_AMITY_SQUARE; + return mapHeaderID == MAP_HEADER_AMITY_SQUARE; } -BOOL MapHeader_IsAzureFluteAllowed(const u32 headerID) +BOOL MapHeader_IsAzureFluteAllowed(const enum MapHeaderID mapHeaderID) { - if (headerID == MAP_HEADER_SPEAR_PILLAR || headerID == MAP_HEADER_SPEAR_PILLAR_DIALGA || headerID == MAP_HEADER_SPEAR_PILLAR_PALKIA) { + if (mapHeaderID == MAP_HEADER_SPEAR_PILLAR || mapHeaderID == MAP_HEADER_SPEAR_PILLAR_DIALGA || mapHeaderID == MAP_HEADER_SPEAR_PILLAR_PALKIA) { return TRUE; } return FALSE; } -BOOL MapHeader_IsPokemonCenter2F(const u32 headerID) +BOOL MapHeader_IsPokemonCenter2F(const enum MapHeaderID mapHeaderID) { static const u16 pokecenters2F[] = { MAP_HEADER_SANDGEM_TOWN_POKECENTER_2F, @@ -240,7 +240,7 @@ BOOL MapHeader_IsPokemonCenter2F(const u32 headerID) int i; for (i = 0; i < NELEMS(pokecenters2F); i++) { - if (headerID == pokecenters2F[i]) { + if (mapHeaderID == pokecenters2F[i]) { return TRUE; } } @@ -248,7 +248,7 @@ BOOL MapHeader_IsPokemonCenter2F(const u32 headerID) return FALSE; } -enum EvolutionMethod MapHeader_GetMapEvolutionMethod(u32 headerID) +enum EvolutionMethod MapHeader_GetMapEvolutionMethod(enum MapHeaderID mapHeaderID) { static const u16 mapEvolutionMethods[] = { MAP_HEADER_ROUTE_217, @@ -296,7 +296,7 @@ enum EvolutionMethod MapHeader_GetMapEvolutionMethod(u32 headerID) }; for (int i = 0; i < NELEMS(mapEvolutionMethods); i += 2) { - if (mapEvolutionMethods[i] == headerID) { + if (mapEvolutionMethods[i] == mapHeaderID) { return mapEvolutionMethods[i + 1]; } } diff --git a/src/map_header_data.c b/src/map_header_data.c index 3429886dc4..6e46858701 100644 --- a/src/map_header_data.c +++ b/src/map_header_data.c @@ -5,6 +5,7 @@ #include "constants/heap.h" #include "constants/versions.h" +#include "generated/map_headers.h" #include "field/field_system.h" #include "overlay006/wild_encounters.h" @@ -14,7 +15,7 @@ #include "map_object.h" #include "narc.h" -static void MapHeaderData_LoadEvents(MapHeaderData *data, int headerID); +static void MapHeaderData_LoadEvents(MapHeaderData *data, enum MapHeaderID mapHeaderID); static void MapHeaderData_ParseEvents(MapHeaderData *data); static void MapHeaderData_LoadInitScripts(MapHeaderData *data, int headerID); @@ -30,19 +31,19 @@ void MapHeaderData_Free(FieldSystem *fieldSystem) Heap_Free(fieldSystem->mapHeaderData); } -void MapHeaderData_Load(FieldSystem *fieldSystem, int headerID) +void MapHeaderData_Load(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID) { GF_ASSERT(fieldSystem->mapHeaderData != NULL); - MapHeaderData_LoadEvents(fieldSystem->mapHeaderData, headerID); + MapHeaderData_LoadEvents(fieldSystem->mapHeaderData, mapHeaderID); MapHeaderData_ParseEvents(fieldSystem->mapHeaderData); - MapHeaderData_LoadWildEncounters(&fieldSystem->mapHeaderData->wildEncounters, headerID); - MapHeaderData_LoadInitScripts(fieldSystem->mapHeaderData, headerID); + MapHeaderData_LoadWildEncounters(&fieldSystem->mapHeaderData->wildEncounters, mapHeaderID); + MapHeaderData_LoadInitScripts(fieldSystem->mapHeaderData, mapHeaderID); } -static void MapHeaderData_LoadEvents(MapHeaderData *data, int headerID) +static void MapHeaderData_LoadEvents(MapHeaderData *data, enum MapHeaderID mapHeaderID) { - int eventsID = MapHeader_GetEventsArchiveID(headerID); + int eventsID = MapHeader_GetEventsArchiveID(mapHeaderID); GF_ASSERT(NARC_GetMemberSizeByIndexPair(NARC_INDEX_FIELDDATA__EVENTDATA__ZONE_EVENT, eventsID) < sizeof(data->tmpEventsBuf)); NARC_ReadWholeMemberByIndexPair(data->tmpEventsBuf, NARC_INDEX_FIELDDATA__EVENTDATA__ZONE_EVENT, eventsID); } @@ -54,7 +55,7 @@ void sub_0203A418(FieldSystem *fieldSystem) GF_ASSERT(fieldSystem->mapHeaderData != NULL); if (numObjectEvents != 0) { - sub_02062068(fieldSystem->mapObjMan, fieldSystem->location->mapId, numObjectEvents, fieldSystem->mapHeaderData->objectEvents); + sub_02062068(fieldSystem->mapObjMan, fieldSystem->location->mapHeaderID, numObjectEvents, fieldSystem->mapHeaderData->objectEvents); } } @@ -214,14 +215,14 @@ static void MapHeaderData_ParseEvents(MapHeaderData *data) CONSUME_EVENTS(CoordEvent, data->coordEvents, data->numCoordEvents); } -void MapHeaderData_LoadWildEncounters(WildEncounters *data, int headerID) +void MapHeaderData_LoadWildEncounters(WildEncounters *data, enum MapHeaderID mapHeaderID) { memset(data, 0, sizeof(WildEncounters)); - if (MapHeader_HasWildEncounters(headerID)) { + if (MapHeader_HasWildEncounters(mapHeaderID)) { enum NarcID narcID = (GAME_VERSION == VERSION_DIAMOND || GAME_VERSION == VERSION_PLATINUM) ? NARC_INDEX_FIELDDATA__ENCOUNTDATA__PL_ENC_DATA : NARC_INDEX_FIELDDATA__ENCOUNTDATA__P_ENC_DATA; - NARC_ReadWholeMemberByIndexPair(data, narcID, MapHeader_GetWildEncountersArchiveID(headerID)); + NARC_ReadWholeMemberByIndexPair(data, narcID, MapHeader_GetWildEncountersArchiveID(mapHeaderID)); } } diff --git a/src/map_object.c b/src/map_object.c index eba057cfe4..ab6b913379 100644 --- a/src/map_object.c +++ b/src/map_object.c @@ -54,7 +54,7 @@ typedef struct MapObject { u32 status; u32 unk_04; u32 localID; - u32 mapID; + enum MapHeaderID mapHeaderID; u32 graphicsID; u32 movementType; u32 trainerType; @@ -135,8 +135,8 @@ static int MapObject_GetFieldSystemGraphicsID(FieldSystem *fieldSystem, int para static void sub_02062648(MapObject *mapObj); static void sub_02062660(MapObject *mapObj); static void sub_02062670(MapObject *mapObj); -static void sub_020626D0(MapObject *mapObj, const ObjectEvent *objectEvent, int mapID); -static void sub_02062714(MapObject *mapObj, int mapID, const ObjectEvent *objectEvent); +static void sub_020626D0(MapObject *mapObj, const ObjectEvent *objectEvent, enum MapHeaderID mapHeaderID); +static void sub_02062714(MapObject *mapObj, enum MapHeaderID mapHeaderID, const ObjectEvent *objectEvent); static void MapObjectTask_Move(SysTask *task, void *param1); static void MapObjectTask_Draw(MapObject *mapObj); static MapObjectManager *MapObjectMan_Deconst(const MapObjectManager *mapObjMan); @@ -176,18 +176,18 @@ void MapObjectMan_Delete(MapObjectManager *mapObjMan) Heap_FreeExplicit(HEAP_ID_FIELD2, mapObjMan); } -void sub_0206184C(MapObjectManager *mapObjMan, int mapID, int param2, int objEventCount, const ObjectEvent *objectEvent) +void sub_0206184C(MapObjectManager *mapObjMan, enum MapHeaderID oldMapHeaderID, enum MapHeaderID newMapHeaderID, int objEventCount, const ObjectEvent *objectEvent) { - int v0, maxObjects = MapObjectMan_GetMaxObjects(mapObjMan); + int maxObjects = MapObjectMan_GetMaxObjects(mapObjMan); MapObject *mapObj = MapObjectMan_GetMapObject(mapObjMan); while (maxObjects) { if (sub_02062CF8(mapObj) == TRUE) { - v0 = sub_0206244C(mapObj, param2, objEventCount, objectEvent); + int v0 = sub_0206244C(mapObj, newMapHeaderID, objEventCount, objectEvent); switch (v0) { case 0: - if (MapObject_GetMapID(mapObj) != param2 && !MapObject_CheckStatusFlag(mapObj, MAP_OBJ_STATUS_PERSISTENT)) { + if (MapObject_GetMapHeaderID(mapObj) != newMapHeaderID && !MapObject_CheckStatusFlag(mapObj, MAP_OBJ_STATUS_PERSISTENT)) { MapObject_Delete(mapObj); } break; @@ -225,7 +225,7 @@ static MapObjectManager *MapObjectMan_Alloc(int maxObjs) return mapObjMan; } -MapObject *MapObjectMan_AddMapObjectFromHeader(const MapObjectManager *mapObjMan, const ObjectEvent *objectEvent, int mapID) +MapObject *MapObjectMan_AddMapObjectFromHeader(const MapObjectManager *mapObjMan, const ObjectEvent *objectEvent, enum MapHeaderID mapHeaderID) { MapObject *mapObj; ObjectEvent v1 = *objectEvent; @@ -234,10 +234,10 @@ MapObject *MapObjectMan_AddMapObjectFromHeader(const MapObjectManager *mapObjMan int localID = ObjectEvent_GetLocalID(v2); if (ObjectEvent_HasNoScript(v2) == FALSE) { - mapObj = sub_02062154(mapObjMan, localID, mapID); + mapObj = sub_02062154(mapObjMan, localID, mapHeaderID); if (mapObj != NULL) { - sub_020626D0(mapObj, v2, mapID); + sub_020626D0(mapObj, v2, mapHeaderID); return mapObj; } @@ -245,7 +245,7 @@ MapObject *MapObjectMan_AddMapObjectFromHeader(const MapObjectManager *mapObjMan mapObj = sub_020624CC(mapObjMan, localID, ObjectEvent_GetHiddenFlagNoScript(v2)); if (mapObj != NULL) { - sub_02062714(mapObj, mapID, v2); + sub_02062714(mapObj, mapHeaderID, v2); return mapObj; } } @@ -258,7 +258,7 @@ MapObject *MapObjectMan_AddMapObjectFromHeader(const MapObjectManager *mapObjMan sub_020621E8(mapObj, v2, MapObjectMan_FieldSystem(mapObjMan)); sub_0206234C(mapObj, mapObjMan); - MapObject_SetMapID(mapObj, mapID); + MapObject_SetMapHeaderID(mapObj, mapHeaderID); sub_02062660(mapObj); sub_02062670(mapObj); MapObject_SetStatusFlagOn(mapObj, MAP_OBJ_STATUS_START_MOVEMENT); @@ -268,7 +268,7 @@ MapObject *MapObjectMan_AddMapObjectFromHeader(const MapObjectManager *mapObjMan return mapObj; } -MapObject *MapObjectMan_AddMapObject(const MapObjectManager *mapObjMan, int x, int z, int initialDir, int graphicsID, int movementType, int mapID) +MapObject *MapObjectMan_AddMapObject(const MapObjectManager *mapObjMan, int x, int z, int initialDir, int graphicsID, int movementType, enum MapHeaderID mapHeaderID) { ObjectEvent objectEvent; MapObject *mapObj; @@ -289,12 +289,12 @@ MapObject *MapObjectMan_AddMapObject(const MapObjectManager *mapObjMan, int x, i ObjectEvent_SetZ(&objectEvent, z); ObjectEvent_SetY(&objectEvent, 0); - mapObj = MapObjectMan_AddMapObjectFromHeader(mapObjMan, &objectEvent, mapID); + mapObj = MapObjectMan_AddMapObjectFromHeader(mapObjMan, &objectEvent, mapHeaderID); return mapObj; } -MapObject *MapObjectMan_AddMapObjectFromLocalID(const MapObjectManager *mapObjMan, int localID, int objEventCount, int mapID, const ObjectEvent *objectEvent) +MapObject *MapObjectMan_AddMapObjectFromLocalID(const MapObjectManager *mapObjMan, int localID, int objEventCount, enum MapHeaderID mapHeaderID, const ObjectEvent *objectEvent) { MapObject *mapObj = NULL; const ObjectEvent *v1 = sub_020631A4(localID, objEventCount, objectEvent); @@ -304,7 +304,7 @@ MapObject *MapObjectMan_AddMapObjectFromLocalID(const MapObjectManager *mapObjMa FieldSystem *fieldSystem = MapObjectMan_FieldSystem(mapObjMan); if (!FieldSystem_CheckFlag(fieldSystem, hiddenFlag)) { - mapObj = MapObjectMan_AddMapObjectFromHeader(mapObjMan, v1, mapID); + mapObj = MapObjectMan_AddMapObjectFromHeader(mapObjMan, v1, mapHeaderID); } } @@ -470,7 +470,7 @@ static void MapObject_Save(FieldSystem *fieldSystem, MapObject *mapObj, MapObjec mapObjSave->status = MapObject_GetStatus(mapObj); mapObjSave->unk_04 = sub_020628EC(mapObj); mapObjSave->localID = MapObject_GetLocalID(mapObj); - mapObjSave->mapID = MapObject_GetMapID(mapObj); + mapObjSave->mapID = MapObject_GetMapHeaderID(mapObj); mapObjSave->graphicsID = MapObject_GetGraphicsID(mapObj); mapObjSave->movementType = MapObject_GetMovementType(mapObj); mapObjSave->trainerType = MapObject_GetTrainerType(mapObj); @@ -519,7 +519,7 @@ static void MapObject_LoadSave(MapObject *mapObj, MapObjectSave *mapObjSave) MapObject_SetStatus(mapObj, mapObjSave->status); sub_020628E8(mapObj, mapObjSave->unk_04); MapObject_SetLocalID(mapObj, mapObjSave->localID); - MapObject_SetMapID(mapObj, mapObjSave->mapID); + MapObject_SetMapHeaderID(mapObj, mapObjSave->mapID); MapObject_SetGraphicsID(mapObj, mapObjSave->graphicsID); MapObject_SetMovementType(mapObj, mapObjSave->movementType); MapObject_SetTrainerType(mapObj, mapObjSave->trainerType); @@ -590,25 +590,21 @@ static void sub_02062010(MapObject *mapObj) MapObject_SetPos(mapObj, &v1); } -void sub_02062068(const MapObjectManager *mapObjMan, int param1, int param2, const ObjectEvent *objectEvent) +void sub_02062068(const MapObjectManager *mapObjMan, enum MapHeaderID mapHeaderID, u32 numObjectEvents, const ObjectEvent *objectEvent) { - int v0; - ObjectEvent *v1; - UnkStruct_020620C4 *v2; + GF_ASSERT(numObjectEvents); - GF_ASSERT(param2); - - v0 = sizeof(ObjectEvent) * param2; - v1 = Heap_AllocAtEnd(HEAP_ID_FIELD2, v0); + int v0 = sizeof(ObjectEvent) * numObjectEvents; + ObjectEvent *v1 = Heap_AllocAtEnd(HEAP_ID_FIELD2, v0); GF_ASSERT(v1 != NULL); memcpy(v1, objectEvent, v0); - v2 = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(UnkStruct_020620C4)); + UnkStruct_020620C4 *v2 = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(UnkStruct_020620C4)); GF_ASSERT(v2 != NULL); - v2->unk_00 = param1; - v2->unk_04 = param2; + v2->unk_00 = mapHeaderID; + v2->unk_04 = numObjectEvents; v2->unk_08 = 0; v2->mapObjMan = mapObjMan; v2->objectEvent = v1; @@ -797,7 +793,7 @@ static int sub_0206244C(const MapObject *mapObj, int param1, int objEventCount, if (sub_02062C18(mapObj) == flag) { return 1; } - } else if (MapObject_GetMapID(mapObj) == flag) { + } else if (MapObject_GetMapHeaderID(mapObj) == flag) { return 2; } } else if (sub_02062E94(mapObj) == TRUE && sub_02062C18(mapObj) == param1) { @@ -818,7 +814,7 @@ static MapObject *sub_020624CC(const MapObjectManager *mapObjMan, int localID, i MapObject *mapObj; while (MapObjectMan_FindObjectWithStatus(mapObjMan, &mapObj, &v0, MAP_OBJ_STATUS_0) == TRUE) { - if (MapObject_GetLocalID(mapObj) == localID && MapObject_GetMapID(mapObj) == flag) { + if (MapObject_GetLocalID(mapObj) == localID && MapObject_GetMapHeaderID(mapObj) == flag) { return mapObj; } } @@ -961,24 +957,24 @@ int MapObject_HasNoScript(const MapObject *mapObj) return FALSE; } -static void sub_020626D0(MapObject *mapObj, const ObjectEvent *objectEvent, int mapID) +static void sub_020626D0(MapObject *mapObj, const ObjectEvent *objectEvent, enum MapHeaderID mapHeaderID) { GF_ASSERT(sub_02062E94(mapObj) == TRUE); sub_02062E78(mapObj, 0); - MapObject_SetMapID(mapObj, mapID); + MapObject_SetMapHeaderID(mapObj, mapHeaderID); MapObject_SetScript(mapObj, ObjectEvent_GetScript(objectEvent)); MapObject_SetFlag(mapObj, ObjectEvent_GetHiddenFlag(objectEvent)); } -static void sub_02062714(MapObject *mapObj, int mapID, const ObjectEvent *objectEvent) +static void sub_02062714(MapObject *mapObj, enum MapHeaderID mapHeaderID, const ObjectEvent *objectEvent) { GF_ASSERT(ObjectEvent_HasNoScript(objectEvent) == TRUE); sub_02062E78(mapObj, 1); MapObject_SetScript(mapObj, ObjectEvent_GetScript(objectEvent)); MapObject_SetFlag(mapObj, ObjectEvent_GetHiddenFlagNoScript(objectEvent)); - MapObject_SetMapID(mapObj, mapID); + MapObject_SetMapHeaderID(mapObj, mapHeaderID); } int MapObject_CalculateTaskPriority(const MapObject *mapObj, int priority) @@ -989,7 +985,7 @@ int MapObject_CalculateTaskPriority(const MapObject *mapObj, int priority) return result; } -int sub_02062764(const MapObject *mapObj, int param1, int param2) +int sub_02062764(const MapObject *mapObj, int param1, enum MapHeaderID param2) { if (!MapObject_CheckStatusFlag(mapObj, MAP_OBJ_STATUS_0)) { return FALSE; @@ -999,7 +995,7 @@ int sub_02062764(const MapObject *mapObj, int param1, int param2) return FALSE; } - if (MapObject_GetMapID(mapObj) != param2) { + if (MapObject_GetMapHeaderID(mapObj) != param2) { if (sub_02062E94(mapObj) == FALSE) { return FALSE; } @@ -1012,7 +1008,7 @@ int sub_02062764(const MapObject *mapObj, int param1, int param2) return TRUE; } -int sub_020627B4(const MapObject *mapObj, int param1, int param2, int param3) +int sub_020627B4(const MapObject *mapObj, int param1, int param2, enum MapHeaderID param3) { if (!MapObject_CheckStatusFlag(mapObj, MAP_OBJ_STATUS_0)) { return 0; @@ -1217,14 +1213,14 @@ u32 MapObject_GetLocalID(const MapObject *mapObj) return mapObj->localID; } -void MapObject_SetMapID(MapObject *mapObj, int mapID) +void MapObject_SetMapHeaderID(MapObject *mapObj, enum MapHeaderID mapHeaderID) { - mapObj->mapID = mapID; + mapObj->mapHeaderID = mapHeaderID; } -int MapObject_GetMapID(const MapObject *mapObj) +enum MapHeaderID MapObject_GetMapHeaderID(const MapObject *mapObj) { - return mapObj->mapID; + return mapObj->mapHeaderID; } void MapObject_SetGraphicsID(MapObject *mapObj, u32 graphicsID) diff --git a/src/meson.build b/src/meson.build index 0c75ffea1d..75327e6295 100644 --- a/src/meson.build +++ b/src/meson.build @@ -262,7 +262,7 @@ pokeplatinum_c = files( 'cutscenes/boat_cutscene/boat_cutscene.c', 'tv_segment.c', 'rankings_machine.c', - 'unk_02070428.c', + 'field_map_change_flags.c', 'field_move_tasks.c', 'unk_020711C8.c', 'overworld_anim_manager.c', diff --git a/src/overlay005/berry_patch_effects.c b/src/overlay005/berry_patch_effects.c index 8a7e2eb465..a367ed61f5 100644 --- a/src/overlay005/berry_patch_effects.c +++ b/src/overlay005/berry_patch_effects.c @@ -35,7 +35,7 @@ typedef struct BerryPatchMoistureEffectContext { typedef struct BerryPatchMoistureEffect { int localID; - int mapID; + enum MapHeaderID mapHeaderID; BOOL isHidden; int moistureLevel; BerryPatchMoistureEffectContext context; @@ -139,7 +139,7 @@ static BOOL BerryPatchMoistureEffect_Init(OverworldAnimManager *effect, void *co moistureEffect->context = *effectContext; moistureEffect->localID = MapObject_GetLocalID(moistureEffect->context.mapObject); - moistureEffect->mapID = MapObject_GetMapID(moistureEffect->context.mapObject); + moistureEffect->mapHeaderID = MapObject_GetMapHeaderID(moistureEffect->context.mapObject); return TRUE; } @@ -154,7 +154,7 @@ static void BerryPatchMoistureEffect_Update(OverworldAnimManager *effectTask, vo BerryPatchMoistureEffect *berryPatchEffect = effectData; MapObject *mapObject = berryPatchEffect->context.mapObject; - if (!sub_02062764(mapObject, berryPatchEffect->localID, berryPatchEffect->mapID)) { + if (!sub_02062764(mapObject, berryPatchEffect->localID, berryPatchEffect->mapHeaderID)) { FieldEffectManager_FinishAnimManager(effectTask); return; } diff --git a/src/overlay005/field_control.c b/src/overlay005/field_control.c index 7d5a761e4f..54a9e7b753 100644 --- a/src/overlay005/field_control.c +++ b/src/overlay005/field_control.c @@ -555,7 +555,7 @@ static BOOL Field_CheckWildEncounter(FieldSystem *fieldSystem) } } - return MapHeader_HasWildEncounters(fieldSystem->location->mapId) && WildEncounters_TryWildEncounter(fieldSystem) == TRUE; + return MapHeader_HasWildEncounters(fieldSystem->location->mapHeaderID) && WildEncounters_TryWildEncounter(fieldSystem) == TRUE; } static BOOL Field_CheckMapTransition(FieldSystem *fieldSystem, const FieldInput *input) @@ -588,7 +588,7 @@ static BOOL Field_CheckMapTransition(FieldSystem *fieldSystem, const FieldInput HearthomeGym_CheckIfEnteredIncorrectDoor(fieldSystem, playerX, playerZ, &transitionDir); } - sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, transitionDir, 1); + sub_02056BDC(fieldSystem, nextMap.mapHeaderID, nextMap.warpId, 0, 0, transitionDir, 1); return TRUE; } @@ -635,14 +635,14 @@ static BOOL Field_CheckMapTransition(FieldSystem *fieldSystem, const FieldInput } else if (TileBehavior_IsWarpEntranceEast(tileBehavior) || TileBehavior_IsWarpEast(tileBehavior) || TileBehavior_IsWarpEntranceWest(tileBehavior) || TileBehavior_IsWarpWest(tileBehavior) || TileBehavior_IsWarpEntranceSouth(tileBehavior) || TileBehavior_IsWarpSouth(tileBehavior)) { - sub_02056C18(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, input->transitionDir); + sub_02056C18(fieldSystem, nextMap.mapHeaderID, nextMap.warpId, 0, 0, input->transitionDir); return TRUE; } else { return FALSE; } // these statements are unreachable, but required for matching - sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, input->transitionDir, transitionType); + sub_02056BDC(fieldSystem, nextMap.mapHeaderID, nextMap.warpId, 0, 0, input->transitionDir, transitionType); return TRUE; } @@ -796,7 +796,7 @@ static BOOL Field_CheckTransition(FieldSystem *fieldSystem, const int playerX, c return FALSE; } - sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, playerDir, 2); + sub_02056BDC(fieldSystem, nextMap.mapHeaderID, nextMap.warpId, 0, 0, playerDir, 2); return TRUE; } else if (TileBehavior_IsEscalator(curTileBehavior) == TRUE) { int playerDir = PlayerAvatar_GetFacingDir(fieldSystem->playerAvatar); @@ -806,17 +806,17 @@ static BOOL Field_CheckTransition(FieldSystem *fieldSystem, const int playerX, c return FALSE; } - sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, playerDir, 2); + sub_02056BDC(fieldSystem, nextMap.mapHeaderID, nextMap.warpId, 0, 0, playerDir, 2); return TRUE; } if (TileBehavior_IsWarpEntranceNorth(curTileBehavior) || TileBehavior_IsWarpNorth(curTileBehavior)) { - sub_02056C18(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, 0); + sub_02056C18(fieldSystem, nextMap.mapHeaderID, nextMap.warpId, 0, 0, 0); return TRUE; } if (TileBehavior_IsWarpPanel(curTileBehavior)) { - FieldSystem_StartMapChangeWarpTask(fieldSystem, nextMap.mapId, nextMap.warpId); + FieldSystem_StartMapChangeWarpTask(fieldSystem, nextMap.mapHeaderID, nextMap.warpId); return TRUE; } @@ -883,7 +883,7 @@ static void Field_CalculateFriendship(FieldSystem *fieldSystem) // C99-style declarations don't match int i, partyCount; Party *party = SaveData_GetParty(fieldSystem->saveData); - u16 mapID = MapHeader_GetMapLabelTextID(fieldSystem->location->mapId); + u16 mapID = MapHeader_GetMapLabelTextID(fieldSystem->location->mapHeaderID); partyCount = Party_GetCurrentCount(party); @@ -905,7 +905,7 @@ static BOOL Field_UpdatePoison(FieldSystem *fieldSystem) return FALSE; } - switch (Pokemon_DoPoisonDamage(party, MapHeader_GetMapLabelTextID(fieldSystem->location->mapId))) { + switch (Pokemon_DoPoisonDamage(party, MapHeader_GetMapLabelTextID(fieldSystem->location->mapHeaderID))) { case FLDPSN_NONE: return FALSE; case FLDPSN_POISONED: @@ -994,28 +994,27 @@ static u8 Field_NextTileBehavior(const FieldSystem *fieldSystem) static BOOL Field_MapConnection(const FieldSystem *fieldSystem, int playerX, int playerZ, Location *nextMap) { - const WarpEvent *v0; - int v1 = MapHeaderData_GetIndexOfWarpEventAtPos(fieldSystem, playerX, playerZ); + int eventIndex = MapHeaderData_GetIndexOfWarpEventAtPos(fieldSystem, playerX, playerZ); - if (v1 == -1) { + if (eventIndex == -1) { return FALSE; } - v0 = MapHeaderData_GetWarpEventByIndex(fieldSystem, v1); + const WarpEvent *warpEvent = MapHeaderData_GetWarpEventByIndex(fieldSystem, eventIndex); - if (v0 == NULL) { + if (warpEvent == NULL) { return FALSE; } - if (v0->destWarpID == 0x100) { - GF_ASSERT(v0->destHeaderID == 0xfff); + if (warpEvent->destWarpID == 0x100) { + GF_ASSERT(warpEvent->destHeaderID == 0xfff); *nextMap = *(FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData))); } else { - Location_Set(nextMap, v0->destHeaderID, v0->destWarpID, v0->x, v0->z, 1); + Location_Set(nextMap, warpEvent->destHeaderID, warpEvent->destWarpID, warpEvent->x, warpEvent->z, 1); } - Location *v2 = FieldOverworldState_GetEntranceLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - Location_Set(v2, fieldSystem->location->mapId, v1, playerX, playerZ, PlayerAvatar_GetFacingDir(fieldSystem->playerAvatar)); + Location *entrance = FieldOverworldState_GetEntranceLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + Location_Set(entrance, fieldSystem->location->mapHeaderID, eventIndex, playerX, playerZ, PlayerAvatar_GetFacingDir(fieldSystem->playerAvatar)); return TRUE; } @@ -1034,7 +1033,7 @@ static void Field_SetMapConnection(FieldSystem *fieldSystem, const int playerX, (nextMap->z)++; } - nextMap->mapId = fieldSystem->location->mapId; + nextMap->mapHeaderID = fieldSystem->location->mapHeaderID; nextMap->warpId = WARP_ID_NONE; } @@ -1046,15 +1045,15 @@ static void Field_TrySetMapConnection(FieldSystem *fieldSystem) Location nextMap; if (Field_MapConnection(fieldSystem, playerX, playerZ, &nextMap)) { - if (MapHeader_IsOnMainMatrix(fieldSystem->location->mapId) == TRUE && MapHeader_IsOnMainMatrix(nextMap.mapId) == FALSE) { + if (MapHeader_IsOnMainMatrix(fieldSystem->location->mapHeaderID) == TRUE && MapHeader_IsOnMainMatrix(nextMap.mapHeaderID) == FALSE) { Field_SetMapConnection(fieldSystem, playerX, playerZ, PlayerAvatar_GetFacingDir(fieldSystem->playerAvatar)); } } else { Field_Step(fieldSystem, &playerX, &playerZ); if (Field_MapConnection(fieldSystem, playerX, playerZ, &nextMap) - && MapHeader_IsOnMainMatrix(fieldSystem->location->mapId) == TRUE - && MapHeader_IsOnMainMatrix(nextMap.mapId) == FALSE) { + && MapHeader_IsOnMainMatrix(fieldSystem->location->mapHeaderID) == TRUE + && MapHeader_IsOnMainMatrix(nextMap.mapHeaderID) == FALSE) { Field_SetMapConnection(fieldSystem, playerX, playerZ, PlayerAvatar_GetFacingDir(fieldSystem->playerAvatar)); } diff --git a/src/overlay005/fieldmap.c b/src/overlay005/fieldmap.c index 40fbf445d6..874cadf83a 100644 --- a/src/overlay005/fieldmap.c +++ b/src/overlay005/fieldmap.c @@ -220,7 +220,7 @@ static BOOL FieldMap_Init(ApplicationManager *appMan, int *state) ov5_021D5F24(fieldSystem->unk_04->unk_0C, weather); } - FieldBGM_PlayEffectiveForMapHeader(fieldSystem, fieldSystem->location->mapId); + FieldBGM_PlayEffectiveForMapHeader(fieldSystem, fieldSystem->location->mapHeaderID); FieldSystem_RunInitScript(fieldSystem, INIT_SCRIPT_ON_RESUME); fieldSystem->unk_04->hBlankSystem = HBlankSystem_New(HEAP_ID_FIELD1); @@ -403,26 +403,26 @@ static BOOL FieldMap_ChangeZone(FieldSystem *fieldSystem) int x = (PlayerAvatar_GetXPos(fieldSystem->playerAvatar) - LandDataManager_GetOffsetTileX(fieldSystem->landDataMan)) / MAP_TILES_COUNT_X; int y = (PlayerAvatar_GetZPos(fieldSystem->playerAvatar) - LandDataManager_GetOffsetTileZ(fieldSystem->landDataMan)) / MAP_TILES_COUNT_Z; - u32 newMapID = MapMatrix_GetMapHeaderIDAtCoords(fieldSystem->mapMatrix, x, y); - u32 oldMapID = fieldSystem->location->mapId; - if (newMapID == oldMapID) { + enum MapHeaderID newMapHeaderID = MapMatrix_GetMapHeaderIDAtCoords(fieldSystem->mapMatrix, x, y); + enum MapHeaderID oldMapHeaderID = fieldSystem->location->mapHeaderID; + if (newMapHeaderID == oldMapHeaderID) { return FALSE; } FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); - fieldSystem->location->mapId = newMapID; + fieldSystem->location->mapHeaderID = newMapHeaderID; - MapHeaderData_Load(fieldSystem, newMapID); + MapHeaderData_Load(fieldSystem, newMapHeaderID); FieldMapChange_UpdateGameData(fieldSystem, 1); int objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem); const ObjectEvent *objEventList = MapHeaderData_GetObjectEvents(fieldSystem); - sub_0206184C(fieldSystem->mapObjMan, oldMapID, newMapID, objEventCount, objEventList); + sub_0206184C(fieldSystem->mapObjMan, oldMapHeaderID, newMapHeaderID, objEventCount, objEventList); RadarChain_Clear(fieldSystem->chain); - FieldBGM_TryFadeOut(fieldSystem, FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapId), 1); + FieldBGM_TryFadeOut(fieldSystem, FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapHeaderID), 1); sub_0203A418(fieldSystem); if (fieldSystem->unk_04->unk_0C != NULL) { @@ -430,9 +430,9 @@ static BOOL FieldMap_ChangeZone(FieldSystem *fieldSystem) fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(fieldState)); } - int oldMapLabelTextID = MapHeader_GetMapLabelTextID(oldMapID); - int newMapLabelTextID = MapHeader_GetMapLabelTextID(newMapID); - int mapLabelWindowID = MapHeader_GetMapLabelWindowID(newMapID); + int oldMapLabelTextID = MapHeader_GetMapLabelTextID(oldMapHeaderID); + int newMapLabelTextID = MapHeader_GetMapLabelTextID(newMapHeaderID); + int mapLabelWindowID = MapHeader_GetMapLabelWindowID(newMapHeaderID); if (oldMapLabelTextID != newMapLabelTextID) { if (mapLabelWindowID != 0) { @@ -445,22 +445,22 @@ static BOOL FieldMap_ChangeZone(FieldSystem *fieldSystem) return TRUE; } -void FieldMap_ChangeZoneDistortionWorld(FieldSystem *fieldSystem, u32 mapId) +void FieldMap_ChangeZoneDistortionWorld(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID) { - u32 oldMapId = fieldSystem->location->mapId; + enum MapHeaderID oldMapHeaderID = fieldSystem->location->mapHeaderID; FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); - fieldSystem->location->mapId = mapId; + fieldSystem->location->mapHeaderID = mapHeaderID; - MapHeaderData_Load(fieldSystem, mapId); + MapHeaderData_Load(fieldSystem, mapHeaderID); FieldMapChange_UpdateGameDataDistortionWorld(fieldSystem, 1); - int objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem); + u32 objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem); const ObjectEvent *objEventList = MapHeaderData_GetObjectEvents(fieldSystem); - sub_0206184C(fieldSystem->mapObjMan, oldMapId, mapId, objEventCount, objEventList); + sub_0206184C(fieldSystem->mapObjMan, oldMapHeaderID, mapHeaderID, objEventCount, objEventList); - FieldBGM_TryFadeOut(fieldSystem, FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapId), 1); + FieldBGM_TryFadeOut(fieldSystem, FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapHeaderID), 1); sub_0203A418(fieldSystem); if (fieldSystem->unk_04->unk_0C != NULL) { @@ -500,7 +500,7 @@ static void ov5_021D134C(FieldSystem *fieldSystem, u8 param1) static void ov5_021D13B4(FieldSystem *fieldSystem) { - if (MapHeader_IsOnMainMatrix(fieldSystem->location->mapId) == 0) { + if (MapHeader_IsOnMainMatrix(fieldSystem->location->mapHeaderID) == 0) { return; } @@ -767,9 +767,9 @@ static void InitGraphicsAndManagers(FieldSystem *fieldSystem) fieldSystem->mapPropAnimMan = MapPropAnimationManager_New(); fieldSystem->mapPropOneShotAnimMan = MapPropOneShotAnimationManager_New(); - u16 areaDataArchiveID = MapHeader_GetAreaDataArchiveID(fieldSystem->location->mapId); + u16 areaDataArchiveID = MapHeader_GetAreaDataArchiveID(fieldSystem->location->mapHeaderID); fieldSystem->areaDataManager = AreaDataManager_Alloc(areaDataArchiveID, fieldSystem->mapPropAnimMan); - u16 preloadedMapObjectsArchiveID = MapHeader_GetPreloadedMapObjectsArchiveID(fieldSystem->location->mapId); + u16 preloadedMapObjectsArchiveID = MapHeader_GetPreloadedMapObjectsArchiveID(fieldSystem->location->mapHeaderID); GF_ASSERT(fieldSystem->mapObjectsToPreload == NULL); fieldSystem->mapObjectsToPreload = FetchMapObjectsToPreload(HEAP_ID_FIELD1, preloadedMapObjectsArchiveID); @@ -782,7 +782,7 @@ static void FieldSystem_InitLandManager(FieldSystem *fieldSystem) if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) { int v0 = 0, v1 = 0, v2 = 0; - DistWorld_LoadFloorOffsets(fieldSystem->location->mapId, &v0, &v1, &v2); + DistWorld_LoadFloorOffsets(fieldSystem->location->mapHeaderID, &v0, &v1, &v2); LandDataManager_DistortionWorldSetOffsets(fieldSystem->landDataMan, v0, v1, v2); LandDataManager_SetInDistortionWorld(fieldSystem->landDataMan, TRUE); LandDataManager_SetSkipMapProps(fieldSystem->landDataMan, TRUE); diff --git a/src/overlay005/honey_tree.c b/src/overlay005/honey_tree.c index f8625a6cfd..f0d9815f73 100644 --- a/src/overlay005/honey_tree.c +++ b/src/overlay005/honey_tree.c @@ -31,14 +31,14 @@ static void GetTreeEncounterGroup(const BOOL isMunchlaxTree, u8 *param1); static void GetTreeEncounterSlot(u8 *slot); static void DoTreeShakingAnimation(FieldSystem *fieldSystem, MapPropManager *param1, const int param2); -static u8 GetTreeIdFromMapId(const int param0); +static u8 GetTreeIDFromMapHeaderID(const enum MapHeaderID mapHeaderID); static const int GetEncounterTableFromGroup(const u8 param0); static const int GetShakesFromGroup(const u8 param0); static const BOOL GetShakingValue(const int numShakes, u8 *value); static const BOOL SixHoursSinceSlathered(const int param0); static BOOL IsMunchlaxTree(const u32 param0, const u8 param1); -static const int sHoneyTreeMapIds[NUM_HONEY_TREES] = { +static const int sHoneyTreeMapHeaderIDs[NUM_HONEY_TREES] = { MAP_HEADER_ROUTE_205_SOUTH, MAP_HEADER_ROUTE_205_NORTH, MAP_HEADER_ROUTE_206, @@ -117,15 +117,11 @@ BOOL HoneyTree_TryInteract(FieldSystem *fieldSystem, int *eventId) u16 HoneyTree_GetTreeSlatherStatus(FieldSystem *fieldSystem) { - u8 treeId; - PlayerHoneyTreeStates *treeDat; - HoneyTree *tree; - - treeId = GetTreeIdFromMapId(fieldSystem->location->mapId); + u8 treeId = GetTreeIDFromMapHeaderID(fieldSystem->location->mapHeaderID); GF_ASSERT(treeId != NUM_HONEY_TREES); - treeDat = SpecialEncounter_GetPlayerHoneyTreeStates(SaveData_GetSpecialEncounters(fieldSystem->saveData)); - tree = SpecialEncounter_GetHoneyTree(treeId, treeDat); + PlayerHoneyTreeStates *treeDat = SpecialEncounter_GetPlayerHoneyTreeStates(SaveData_GetSpecialEncounters(fieldSystem->saveData)); + HoneyTree *tree = SpecialEncounter_GetHoneyTree(treeId, treeDat); if (SixHoursSinceSlathered(tree->minutesRemaining)) { return TREE_STATUS_ENCOUNTER; // tree can have Pokemon @@ -138,21 +134,16 @@ u16 HoneyTree_GetTreeSlatherStatus(FieldSystem *fieldSystem) void HoneyTree_SlatherTree(FieldSystem *fieldSystem) { - u8 treeId; - PlayerHoneyTreeStates *treeDat; - HoneyTree *tree; - BOOL munchlaxTree; - - treeId = GetTreeIdFromMapId(fieldSystem->location->mapId); + u8 treeId = GetTreeIDFromMapHeaderID(fieldSystem->location->mapHeaderID); GF_ASSERT(treeId != NUM_HONEY_TREES); - treeDat = SpecialEncounter_GetPlayerHoneyTreeStates(SaveData_GetSpecialEncounters(fieldSystem->saveData)); - tree = SpecialEncounter_GetHoneyTree(treeId, treeDat); + PlayerHoneyTreeStates *treeDat = SpecialEncounter_GetPlayerHoneyTreeStates(SaveData_GetSpecialEncounters(fieldSystem->saveData)); + HoneyTree *tree = SpecialEncounter_GetHoneyTree(treeId, treeDat); tree->minutesRemaining = (24 * 60); // slathering lasts for one day TrainerInfo *trainer = SaveData_GetTrainerInfo(fieldSystem->saveData); - munchlaxTree = IsMunchlaxTree(TrainerInfo_ID(trainer), treeId); + BOOL munchlaxTree = IsMunchlaxTree(TrainerInfo_ID(trainer), treeId); // Slathering the same tree twice in succession has a 90% chance to give the same group again. if (SpecialEncounter_GetLastSlatheredTreeId(treeDat) == treeId) { @@ -182,21 +173,18 @@ void HoneyTree_SlatherTree(FieldSystem *fieldSystem) void HoneyTree_StopShaking(FieldSystem *fieldSystem) { - u8 treeId = GetTreeIdFromMapId(fieldSystem->location->mapId); + u8 treeId = GetTreeIDFromMapHeaderID(fieldSystem->location->mapHeaderID); GF_ASSERT(treeId != NUM_HONEY_TREES); if (fieldSystem->unk_A8->trees[treeId].isShaking) { - u8 v1; - MapProp *v2; MapPropManager *v3; - NNSG3dRenderObj *v4; - v1 = LandDataManager_GetTrackedTargetLoadedMapsQuadrant(fieldSystem->landDataMan); + u8 v1 = LandDataManager_GetTrackedTargetLoadedMapsQuadrant(fieldSystem->landDataMan); LandDataManager_GetLoadedMapPropManager(v1, fieldSystem->landDataMan, &v3); - v2 = MapPropManager_FindLoadedPropByModelID(v3, honey_tree_nsbmd); - v4 = MapProp_GetRenderObj(v2); + MapProp *v2 = MapPropManager_FindLoadedPropByModelID(v3, honey_tree_nsbmd); + NNSG3dRenderObj *v4 = MapProp_GetRenderObj(v2); if (v2 != NULL) { MapPropAnimationManager_RemoveAnimationFromRenderObj(fieldSystem->mapPropAnimMan, v4, honey_tree_nsbmd, fieldSystem->unk_A8->trees[treeId].shakeValue); @@ -341,36 +329,24 @@ static const BOOL GetShakingValue(const int numShakes, u8 *value) static void DoTreeShakingAnimation(FieldSystem *fieldSystem, MapPropManager *param1, const int param2) { - u16 mapId; - u8 treeId; - - mapId = MapMatrix_GetMapHeaderIDAtIndex(fieldSystem->mapMatrix, param2); - treeId = GetTreeIdFromMapId(mapId); + u16 mapId = MapMatrix_GetMapHeaderIDAtIndex(fieldSystem->mapMatrix, param2); + u8 treeId = GetTreeIDFromMapHeaderID(mapId); if (treeId != NUM_HONEY_TREES) { - PlayerHoneyTreeStates *treeDat; - HoneyTree *tree; - MapProp *v4; - - treeDat = SpecialEncounter_GetPlayerHoneyTreeStates(SaveData_GetSpecialEncounters(fieldSystem->saveData)); - tree = SpecialEncounter_GetHoneyTree(treeId, treeDat); + PlayerHoneyTreeStates *treeDat = SpecialEncounter_GetPlayerHoneyTreeStates(SaveData_GetSpecialEncounters(fieldSystem->saveData)); + HoneyTree *tree = SpecialEncounter_GetHoneyTree(treeId, treeDat); if (SixHoursSinceSlathered(tree->minutesRemaining)) { - BOOL isShaking; u8 shakeValue; - - isShaking = GetShakingValue(tree->numShakes, &shakeValue); - + BOOL isShaking = GetShakingValue(tree->numShakes, &shakeValue); if (!isShaking) { return; } - v4 = MapPropManager_FindLoadedPropByModelID(param1, honey_tree_nsbmd); + MapProp *v4 = MapPropManager_FindLoadedPropByModelID(param1, honey_tree_nsbmd); if (v4 != NULL) { - NNSG3dRenderObj *v7; - - v7 = MapProp_GetRenderObj(v4); + NNSG3dRenderObj *v7 = MapProp_GetRenderObj(v4); MapPropAnimationManager_RemoveAnimationFromRenderObj(fieldSystem->mapPropAnimMan, v7, honey_tree_nsbmd, fieldSystem->unk_A8->trees[treeId].shakeValue); @@ -384,11 +360,11 @@ static void DoTreeShakingAnimation(FieldSystem *fieldSystem, MapPropManager *par } // Returns NUM_HONEY_TREES if map does not have a Honey Tree. -static u8 GetTreeIdFromMapId(const int mapId) +static u8 GetTreeIDFromMapHeaderID(const enum MapHeaderID mapHeaderID) { u8 i; for (i = 0; i < NUM_HONEY_TREES; i++) { - if (mapId == sHoneyTreeMapIds[i]) { + if (mapHeaderID == sHoneyTreeMapHeaderIDs[i]) { return i; } } @@ -444,11 +420,10 @@ static BOOL IsMunchlaxTree(const u32 trainerId, const u8 treeId) int HoneyTree_GetSpecies(FieldSystem *fieldSystem) { - u8 treeId = GetTreeIdFromMapId(fieldSystem->location->mapId); + u8 treeId = GetTreeIDFromMapHeaderID(fieldSystem->location->mapHeaderID); GF_ASSERT(treeId != NUM_HONEY_TREES); int *narcData; - int species; PlayerHoneyTreeStates *treeDat = SpecialEncounter_GetPlayerHoneyTreeStates(SaveData_GetSpecialEncounters(fieldSystem->saveData)); HoneyTree *tree = SpecialEncounter_GetHoneyTree(treeId, treeDat); @@ -458,7 +433,7 @@ int HoneyTree_GetSpecies(FieldSystem *fieldSystem) narcData = NARC_AllocAtEndAndReadWholeMemberByIndexPair(NARC_INDEX_ARC__ENCDATA_EX, sEncounterTableIndexes_P_Unused[tree->encounterTableIndex], HEAP_ID_FIELD1); } - species = narcData[tree->encounterSlot]; + int species = narcData[tree->encounterSlot]; Heap_Free(narcData); return species; @@ -466,27 +441,23 @@ int HoneyTree_GetSpecies(FieldSystem *fieldSystem) void ov5_021F0030(void *param0, const int param1, MapPropManager *const mapPropManager) { - FieldSystem *fieldSystem; - if (param1 < 0) { return; } - fieldSystem = (FieldSystem *)param0; + FieldSystem *fieldSystem = (FieldSystem *)param0; DoTreeShakingAnimation(fieldSystem, mapPropManager, param1); } void HoneyTree_Unslather(FieldSystem *fieldSystem) { - PlayerHoneyTreeStates *treeDat; - HoneyTree *tree; - u8 treeId = GetTreeIdFromMapId(fieldSystem->location->mapId); + u8 treeId = GetTreeIDFromMapHeaderID(fieldSystem->location->mapHeaderID); GF_ASSERT(treeId != NUM_HONEY_TREES); fieldSystem->unk_A8->trees[treeId].isShaking = FALSE; - treeDat = SpecialEncounter_GetPlayerHoneyTreeStates(SaveData_GetSpecialEncounters(fieldSystem->saveData)); - tree = SpecialEncounter_GetHoneyTree(treeId, treeDat); + PlayerHoneyTreeStates *treeDat = SpecialEncounter_GetPlayerHoneyTreeStates(SaveData_GetSpecialEncounters(fieldSystem->saveData)); + HoneyTree *tree = SpecialEncounter_GetHoneyTree(treeId, treeDat); tree->minutesRemaining = 0; } diff --git a/src/overlay005/map_name_popup.c b/src/overlay005/map_name_popup.c index a32d6edb82..079404c29d 100644 --- a/src/overlay005/map_name_popup.c +++ b/src/overlay005/map_name_popup.c @@ -267,13 +267,13 @@ void MapNamePopUp_Hide(MapNamePopUp *mapPopUp) void FieldSystem_RequestLocationName(FieldSystem *fieldSystem) { - if (MapHeader_GetMapLabelWindowID(fieldSystem->location->mapId) == 0) { + if (MapHeader_GetMapLabelWindowID(fieldSystem->location->mapHeaderID) == 0) { return; } - if (!MapHeader_IsBuilding(fieldSystem->location->mapId)) { - u32 mapLabelTextID = MapHeader_GetMapLabelTextID(fieldSystem->location->mapId); - u32 mapLabelWindowID = MapHeader_GetMapLabelWindowID(fieldSystem->location->mapId); + if (!MapHeader_IsBuilding(fieldSystem->location->mapHeaderID)) { + u32 mapLabelTextID = MapHeader_GetMapLabelTextID(fieldSystem->location->mapHeaderID); + u32 mapLabelWindowID = MapHeader_GetMapLabelWindowID(fieldSystem->location->mapHeaderID); if (mapLabelWindowID != 0) { mapLabelWindowID--; diff --git a/src/overlay005/ov5_021DFB54.c b/src/overlay005/ov5_021DFB54.c index 61334c1a9d..40f1c0def9 100644 --- a/src/overlay005/ov5_021DFB54.c +++ b/src/overlay005/ov5_021DFB54.c @@ -832,7 +832,7 @@ static BOOL ov5_021E03C8(FieldTask *param0) PlayerAvatar_SetSurfMountAnimManager(v0->playerAvatar, NULL); PlayerAvatar_SetPlayerState(v0->playerAvatar, 0x0); - FieldBGM_TryFadeOut(v0->fieldSystem, FieldBGM_GetForMapHeader(v0->fieldSystem, v0->fieldSystem->location->mapId), 1); + FieldBGM_TryFadeOut(v0->fieldSystem, FieldBGM_GetForMapHeader(v0->fieldSystem, v0->fieldSystem->location->mapHeaderID), 1); MonRideTaskEnv_Free(v0); return 1; } diff --git a/src/overlay005/ov5_021F007C.c b/src/overlay005/ov5_021F007C.c index e98e591572..2f9fb26206 100644 --- a/src/overlay005/ov5_021F007C.c +++ b/src/overlay005/ov5_021F007C.c @@ -467,7 +467,7 @@ BOOL ov5_021F0488(FieldTask *param0) case 3: v1->unk_0E--; - if (MapHeader_HasWildEncounters(fieldSystem->location->mapId)) { + if (MapHeader_HasWildEncounters(fieldSystem->location->mapHeaderID)) { if (v1->unk_0E < 0) { { u8 v3; diff --git a/src/overlay005/ov5_021F10E8.c b/src/overlay005/ov5_021F10E8.c index db14ea25ae..c1a990aee4 100644 --- a/src/overlay005/ov5_021F10E8.c +++ b/src/overlay005/ov5_021F10E8.c @@ -206,7 +206,7 @@ static int ov5_021F1258(OverworldAnimManager *param0, void *param1) if (sub_02062E94(v0->unk_1C.unk_08) == 1) { v0->unk_08 = sub_02062C18(v0->unk_1C.unk_08); } else { - v0->unk_08 = MapObject_GetMapID(v0->unk_1C.unk_08); + v0->unk_08 = MapObject_GetMapHeaderID(v0->unk_1C.unk_08); } OverworldAnimManager_GetPosition(param0, &v0->unk_0C); diff --git a/src/overlay005/ov5_021F134C.c b/src/overlay005/ov5_021F134C.c index e1b28bca9a..50ee204de0 100644 --- a/src/overlay005/ov5_021F134C.c +++ b/src/overlay005/ov5_021F134C.c @@ -227,7 +227,7 @@ static int ov5_021F15B4(OverworldAnimManager *param0, void *param1) if (sub_02062E94(v0->unk_14.unk_08) == 1) { v0->unk_08 = sub_02062C18(v0->unk_14.unk_08); } else { - v0->unk_08 = MapObject_GetMapID(v0->unk_14.unk_08); + v0->unk_08 = MapObject_GetMapHeaderID(v0->unk_14.unk_08); } return 1; diff --git a/src/overlay005/ov5_021F17B8.c b/src/overlay005/ov5_021F17B8.c index 801d6d6610..54888cd547 100644 --- a/src/overlay005/ov5_021F17B8.c +++ b/src/overlay005/ov5_021F17B8.c @@ -121,7 +121,7 @@ static int ov5_021F184C(OverworldAnimManager *param0, void *param1) v1->unk_14 = *v2; v1->unk_10 = OverworldAnimManager_GetUserInt(param0); v1->unk_00 = MapObject_GetLocalID(v1->unk_14.unk_0C); - v1->unk_04 = MapObject_GetMapID(v1->unk_14.unk_0C); + v1->unk_04 = MapObject_GetMapHeaderID(v1->unk_14.unk_0C); v1->unk_08 = MapObject_GetGraphicsID(v1->unk_14.unk_0C); if (BerryPatchGraphics_IsBerryPatch(v1->unk_08) == 1) { diff --git a/src/overlay005/ov5_021F23D0.c b/src/overlay005/ov5_021F23D0.c index 0426010f14..42ecc8cbd4 100644 --- a/src/overlay005/ov5_021F23D0.c +++ b/src/overlay005/ov5_021F23D0.c @@ -112,7 +112,7 @@ static int ov5_021F2488(OverworldAnimManager *param0, void *param1) Simple3D_CreateRenderObjectWithAnim(&v0->unk_40, &v0->unk_10.unk_04->unk_04, &v0->unk_1C); v0->unk_04 = MapObject_GetLocalID(v0->unk_10.unk_08); - v0->unk_08 = MapObject_GetMapID(v0->unk_10.unk_08); + v0->unk_08 = MapObject_GetMapHeaderID(v0->unk_10.unk_08); { VecFx32 v2, v3; diff --git a/src/overlay005/ov5_021F2D20.c b/src/overlay005/ov5_021F2D20.c index ab61e3b989..2c159433ed 100644 --- a/src/overlay005/ov5_021F2D20.c +++ b/src/overlay005/ov5_021F2D20.c @@ -178,7 +178,7 @@ static int ov5_021F2F0C(OverworldAnimManager *param0, void *param1) v3->unk_18 = *v4; v3->unk_04 = MapObject_GetEffectiveGraphicsID(v3->unk_18.unk_18); v3->unk_08 = MapObject_GetLocalID(v3->unk_18.unk_18); - v3->unk_0C = MapObject_GetMapID(v3->unk_18.unk_18); + v3->unk_0C = MapObject_GetMapHeaderID(v3->unk_18.unk_18); v2.x = (((v3->unk_18.unk_00) << 4) * FX32_ONE); v2.z = (((v3->unk_18.unk_08) << 4) * FX32_ONE); diff --git a/src/overlay005/ov5_021F3284.c b/src/overlay005/ov5_021F3284.c index ef030c491a..8fb520ab41 100644 --- a/src/overlay005/ov5_021F3284.c +++ b/src/overlay005/ov5_021F3284.c @@ -105,7 +105,7 @@ static int ov5_021F336C(OverworldAnimManager *param0, void *param1) v1->unk_14 = *v2; v1->unk_04 = MapObject_GetEffectiveGraphicsID(v1->unk_14.unk_0C); v1->unk_08 = MapObject_GetLocalID(v1->unk_14.unk_0C); - v1->unk_0C = MapObject_GetMapID(v1->unk_14.unk_0C); + v1->unk_0C = MapObject_GetMapHeaderID(v1->unk_14.unk_0C); OverworldAnimManager_SetPosition(param0, &v0); v1->unk_24 = ov5_021DF84C(v1->unk_14.unk_04, 3, &v0); diff --git a/src/overlay005/ov5_021F348C.c b/src/overlay005/ov5_021F348C.c index 8b5aec9085..c7a656e3b8 100644 --- a/src/overlay005/ov5_021F348C.c +++ b/src/overlay005/ov5_021F348C.c @@ -185,7 +185,7 @@ static int ov5_021F36F4(OverworldAnimManager *param0, void *param1) v2->unk_10 = *v3; v2->unk_04 = MapObject_GetLocalID(v2->unk_10.unk_0C); - v2->unk_08 = MapObject_GetMapID(v2->unk_10.unk_0C); + v2->unk_08 = MapObject_GetMapHeaderID(v2->unk_10.unk_0C); OverworldAnimManager_GetPosition(param0, &v1); diff --git a/src/overlay005/ov5_021F37A8.c b/src/overlay005/ov5_021F37A8.c index b9a3d7788a..70e0f349f2 100644 --- a/src/overlay005/ov5_021F37A8.c +++ b/src/overlay005/ov5_021F37A8.c @@ -114,7 +114,7 @@ static int ov5_021F38AC(OverworldAnimManager *param0, void *param1) v3->unk_18 = *v4; v3->unk_04 = MapObject_GetEffectiveGraphicsID(v3->unk_18.unk_18); v3->unk_08 = MapObject_GetLocalID(v3->unk_18.unk_18); - v3->unk_0C = MapObject_GetMapID(v3->unk_18.unk_18); + v3->unk_0C = MapObject_GetMapHeaderID(v3->unk_18.unk_18); v2.x = (((v3->unk_18.unk_00) << 4) * FX32_ONE); v2.z = (((v3->unk_18.unk_08) << 4) * FX32_ONE); diff --git a/src/overlay005/ov5_021F3A50.c b/src/overlay005/ov5_021F3A50.c index b4c2b64013..ef3a3814d8 100644 --- a/src/overlay005/ov5_021F3A50.c +++ b/src/overlay005/ov5_021F3A50.c @@ -114,7 +114,7 @@ static int ov5_021F3B54(OverworldAnimManager *param0, void *param1) v3->unk_18 = *v4; v3->unk_04 = MapObject_GetEffectiveGraphicsID(v3->unk_18.unk_18); v3->unk_08 = MapObject_GetLocalID(v3->unk_18.unk_18); - v3->unk_0C = MapObject_GetMapID(v3->unk_18.unk_18); + v3->unk_0C = MapObject_GetMapHeaderID(v3->unk_18.unk_18); v2.x = (((v3->unk_18.unk_00) << 4) * FX32_ONE); v2.z = (((v3->unk_18.unk_08) << 4) * FX32_ONE); diff --git a/src/overlay005/ov5_021F3D00.c b/src/overlay005/ov5_021F3D00.c index fb984b540d..8595e2b582 100644 --- a/src/overlay005/ov5_021F3D00.c +++ b/src/overlay005/ov5_021F3D00.c @@ -124,7 +124,7 @@ static int ov5_021F3E00(OverworldAnimManager *param0, void *param1) v0->unk_10 = *v1; v0->unk_08 = MapObject_GetLocalID(v2); - v0->unk_0C = MapObject_GetMapID(v2); + v0->unk_0C = MapObject_GetMapHeaderID(v2); return 1; } diff --git a/src/overlay005/ov5_021F3E74.c b/src/overlay005/ov5_021F3E74.c index a0b0d10dd0..3f861cc2c1 100644 --- a/src/overlay005/ov5_021F3E74.c +++ b/src/overlay005/ov5_021F3E74.c @@ -106,7 +106,7 @@ static int ov5_021F3F74(OverworldAnimManager *param0, void *param1) v1->unk_10 = *v2; v1->unk_04 = MapObject_GetLocalID(v1->unk_10.unk_0C); - v1->unk_08 = MapObject_GetMapID(v1->unk_10.unk_0C); + v1->unk_08 = MapObject_GetMapHeaderID(v1->unk_10.unk_0C); OverworldAnimManager_GetPosition(param0, &v0); diff --git a/src/overlay005/ov5_021F50BC.c b/src/overlay005/ov5_021F50BC.c index bdda9bc1a6..392a4af784 100644 --- a/src/overlay005/ov5_021F50BC.c +++ b/src/overlay005/ov5_021F50BC.c @@ -31,7 +31,7 @@ typedef struct { int unk_00; int unk_04; int unk_08; - int unk_0C; + enum MapHeaderID unk_0C; int unk_10; int unk_14; VecFx32 unk_18; @@ -96,16 +96,14 @@ OverworldAnimManager *ov5_021F511C(MapObject *param0) static int ov5_021F5158(OverworldAnimManager *param0, void *param1) { - UnkStruct_ov5_021F5158 *v0; - const UnkStruct_ov5_021F511C *v1; VecFx32 v2; - v0 = param1; - v1 = OverworldAnimManager_GetUserData(param0); + UnkStruct_ov5_021F5158 *v0 = param1; + const UnkStruct_ov5_021F511C *v1 = OverworldAnimManager_GetUserData(param0); v0->unk_30 = *v1; v0->unk_08 = MapObject_GetLocalID(v0->unk_30.unk_08); - v0->unk_0C = MapObject_GetMapID(v0->unk_30.unk_08); + v0->unk_0C = MapObject_GetMapHeaderID(v0->unk_30.unk_08); v0->unk_24.y = (FX32_ONE * 6); MapObject_GetPosPtr(v0->unk_30.unk_08, &v2); diff --git a/src/overlay005/ov5_021F5284.c b/src/overlay005/ov5_021F5284.c index 7a13f8f8a4..d89dd17625 100644 --- a/src/overlay005/ov5_021F5284.c +++ b/src/overlay005/ov5_021F5284.c @@ -107,7 +107,7 @@ static int ov5_021F5320(OverworldAnimManager *param0, void *param1) v0->unk_30 = *v1; v0->unk_08 = MapObject_GetLocalID(v0->unk_30.unk_08); - v0->unk_0C = MapObject_GetMapID(v0->unk_30.unk_08); + v0->unk_0C = MapObject_GetMapHeaderID(v0->unk_30.unk_08); v0->unk_24.y = (FX32_ONE * 6); MapObject_GetPosPtr(v0->unk_30.unk_08, &v2); diff --git a/src/overlay005/ov5_021F5428.c b/src/overlay005/ov5_021F5428.c index 2e65b43b0b..0d6d82af6f 100644 --- a/src/overlay005/ov5_021F5428.c +++ b/src/overlay005/ov5_021F5428.c @@ -107,7 +107,7 @@ static int ov5_021F54C4(OverworldAnimManager *param0, void *param1) v0->unk_34 = *v1; v0->unk_08 = MapObject_GetLocalID(v0->unk_34.unk_08); - v0->unk_0C = MapObject_GetMapID(v0->unk_34.unk_08); + v0->unk_0C = MapObject_GetMapHeaderID(v0->unk_34.unk_08); v0->unk_24.y = (FX32_ONE * 6); MapObject_GetPosPtr(v0->unk_34.unk_08, &v2); diff --git a/src/overlay005/ov5_021F5A10.c b/src/overlay005/ov5_021F5A10.c index 9332c49008..ff682a65f7 100644 --- a/src/overlay005/ov5_021F5A10.c +++ b/src/overlay005/ov5_021F5A10.c @@ -381,7 +381,7 @@ static int ov5_021F5DE4(OverworldAnimManager *param0, void *param1) v1->unk_30 = *v2; v1->unk_08 = MapObject_GetLocalID(v1->unk_30.unk_0C); - v1->unk_0C = MapObject_GetMapID(v1->unk_30.unk_0C); + v1->unk_0C = MapObject_GetMapHeaderID(v1->unk_30.unk_0C); v1->unk_24.y = (FX32_ONE * 6); ov5_021F5BF0(v1->unk_30.unk_08, v1->unk_30.unk_00); @@ -450,7 +450,7 @@ static int ov5_021F5EE0(OverworldAnimManager *param0, void *param1) v1->unk_30 = *v2; v1->unk_08 = MapObject_GetLocalID(v1->unk_30.unk_0C); - v1->unk_0C = MapObject_GetMapID(v1->unk_30.unk_0C); + v1->unk_0C = MapObject_GetMapHeaderID(v1->unk_30.unk_0C); v1->unk_24.y = (FX32_ONE * 6); v1->unk_10 = 1; diff --git a/src/overlay005/ov5_021F600C.c b/src/overlay005/ov5_021F600C.c index e21d98cc85..9e7281c687 100644 --- a/src/overlay005/ov5_021F600C.c +++ b/src/overlay005/ov5_021F600C.c @@ -103,7 +103,7 @@ static int ov5_021F60E4(OverworldAnimManager *param0, void *param1) v1->unk_10 = *v2; v1->unk_04 = MapObject_GetLocalID(v1->unk_10.unk_0C); - v1->unk_08 = MapObject_GetMapID(v1->unk_10.unk_0C); + v1->unk_08 = MapObject_GetMapHeaderID(v1->unk_10.unk_0C); OverworldAnimManager_SetPosition(param0, &v0); v1->unk_20 = ov5_021DF84C(v1->unk_10.unk_04, 4, &v0); diff --git a/src/overlay005/ov5_021F61BC.c b/src/overlay005/ov5_021F61BC.c index 900256fa42..364ac88db1 100644 --- a/src/overlay005/ov5_021F61BC.c +++ b/src/overlay005/ov5_021F61BC.c @@ -108,7 +108,7 @@ static int ov5_021F6264(OverworldAnimManager *param0, void *param1) v0->unk_04 = -1; v0->unk_14 = MapObject_GetLocalID(v1); - v0->unk_18 = MapObject_GetMapID(v1); + v0->unk_18 = MapObject_GetMapHeaderID(v1); return 1; } diff --git a/src/overlay005/save_info_window.c b/src/overlay005/save_info_window.c index 652c8bda45..ef0ed63613 100644 --- a/src/overlay005/save_info_window.c +++ b/src/overlay005/save_info_window.c @@ -50,7 +50,7 @@ static void SaveInfo_SetValues(SaveInfo *saveInfo, const FieldSystem *fieldSyste Location *curLocation = FieldOverworldState_GetPlayerLocation(SaveData_GetFieldOverworldState(saveData)); Pokedex *pokedex = SaveData_GetPokedex(saveData); - saveInfo->mapLabelTextID = MapHeader_GetMapLabelTextID(curLocation->mapId); + saveInfo->mapLabelTextID = MapHeader_GetMapLabelTextID(curLocation->mapHeaderID); if (Pokedex_IsObtained(pokedex)) { saveInfo->pokedexCount = Pokedex_CountSeen(pokedex); @@ -209,7 +209,7 @@ void FieldSystem_SaveStateIfCommunicationOff(FieldSystem *fieldSystem) return; } - switch (fieldSystem->location->mapId) { + switch (fieldSystem->location->mapHeaderID) { case MAP_HEADER_UNION_ROOM: case MAP_HEADER_COMMUNICATION_CLUB_COLOSSEUM_2P: case MAP_HEADER_COMMUNICATION_CLUB_COLOSSEUM_4P: diff --git a/src/overlay005/surf_mount_renderer.c b/src/overlay005/surf_mount_renderer.c index ea36f001d2..3d6fb87881 100644 --- a/src/overlay005/surf_mount_renderer.c +++ b/src/overlay005/surf_mount_renderer.c @@ -120,7 +120,7 @@ static BOOL SurfMountRenderer_AnimInit(OverworldAnimManager *animMan, void *cont renderer->userData = *userData; renderer->mapObjLocalID = MapObject_GetLocalID(playerMapObj); - renderer->mapHeaderID = MapObject_GetMapID(playerMapObj); + renderer->mapHeaderID = MapObject_GetMapHeaderID(playerMapObj); renderer->dir = userData->dir; renderer->syncPos = OverworldAnimManager_GetUserInt(animMan); renderer->yOffset = RENDERER_INITIAL_Y_OFFSET; diff --git a/src/overlay006/field_warp.c b/src/overlay006/field_warp.c index 86c45c5d02..a6e1c3af68 100644 --- a/src/overlay006/field_warp.c +++ b/src/overlay006/field_warp.c @@ -280,7 +280,7 @@ static void CreateJournalEntryForTeleport(FieldSystem *fieldSystem, FieldWarp *f return; } - void *journalEntryLocationEvent = JournalEntry_CreateEventUsedMove(FIELD_MOVE_TELEPORT, fieldSystem->location->mapId, HEAP_ID_FIELD1); + void *journalEntryLocationEvent = JournalEntry_CreateEventUsedMove(FIELD_MOVE_TELEPORT, fieldSystem->location->mapHeaderID, HEAP_ID_FIELD1); JournalEntry_SaveData(fieldSystem->journalEntry, journalEntryLocationEvent, JOURNAL_LOCATION); } diff --git a/src/overlay006/great_marsh_binoculars.c b/src/overlay006/great_marsh_binoculars.c index a0e01cce36..7fd81ef86e 100644 --- a/src/overlay006/great_marsh_binoculars.c +++ b/src/overlay006/great_marsh_binoculars.c @@ -3,6 +3,8 @@ #include #include +#include "generated/map_headers.h" + #include "field/field_system.h" #include "overlay006/dual_slot_encounters.h" #include "overlay006/great_marsh_daily_encounters.h" @@ -32,7 +34,7 @@ int GreatMarshBinoculars_GetMonSpecies(FieldSystem *fieldSystem) BOOL natDexObtained = Pokedex_IsNationalDexObtained(SaveData_GetPokedex(FieldSystem_GetSaveData(fieldSystem))); - ReplaceGreatMarshDailyEncounters(SpecialEncounter_GetDailyMon(SaveData_GetSpecialEncounters(fieldSystem->saveData), DAILY_MARSH), natDexObtained, fieldSystem->location->mapId, &encounterTable[6], &encounterTable[7]); + ReplaceGreatMarshDailyEncounters(SpecialEncounter_GetDailyMon(SaveData_GetSpecialEncounters(fieldSystem->saveData), DAILY_MARSH), natDexObtained, fieldSystem->location->mapHeaderID, &encounterTable[6], &encounterTable[7]); WildEncounters_ReplaceTimedEncounters(encounterData, &encounterTable[2], &encounterTable[3]); WildEncounters_ReplaceDualSlotEncounters(encounterData, natDexObtained, &encounterTable[8], &encounterTable[9]); @@ -56,7 +58,7 @@ GreatMarshBinoculars *GreatMarshBinoculars_InitData(const enum HeapID heapID, Fi binocularsData->coordsList[BINOCULARS_CYCLE_COUNT].x = PlayerAvatar_GetXPos(fieldSystem->playerAvatar); binocularsData->coordsList[BINOCULARS_CYCLE_COUNT].z = PlayerAvatar_GetZPos(fieldSystem->playerAvatar); - binocularsData->lookoutMapId = fieldSystem->location->mapId; + binocularsData->lookoutMapHeaderID = fieldSystem->location->mapHeaderID; Heap_Free(coordData); return binocularsData; @@ -69,23 +71,23 @@ void GreatMarshBinoculars_FreeData(GreatMarshBinoculars *data) void GreatMarshBinoculars_SetNextLocationWithCoords(const u8 cycleNum, GreatMarshBinoculars *binocularsData) { - int nextMapId; + enum MapHeaderID nextMapHeaderID; int nextX, nextZ; if (cycleNum == 0) { int v3 = 240; // member number for NARC_INDEX_FIELDDATA__MAPMATRIX__MAP_MATRIX. Not sure what it represents exactly. nextX = binocularsData->coordsList[cycleNum].x / 32; nextZ = binocularsData->coordsList[cycleNum].z / 32; - nextMapId = MapMatrixData_GetMapHeaderIDAtCoords(v3, nextX, nextZ); + nextMapHeaderID = MapMatrixData_GetMapHeaderIDAtCoords(v3, nextX, nextZ); } else if (cycleNum == BINOCULARS_CYCLE_COUNT) { - nextMapId = binocularsData->lookoutMapId; + nextMapHeaderID = binocularsData->lookoutMapHeaderID; } else { nextX = binocularsData->coordsList[cycleNum].x / 32; nextZ = binocularsData->coordsList[cycleNum].z / 32; - nextMapId = MapMatrix_GetMapHeaderIDAtCoords(binocularsData->fieldSystem->mapMatrix, nextX, nextZ); + nextMapHeaderID = MapMatrix_GetMapHeaderIDAtCoords(binocularsData->fieldSystem->mapMatrix, nextX, nextZ); } - Location_Set(&binocularsData->viewLocation, nextMapId, -1, binocularsData->coordsList[cycleNum].x, binocularsData->coordsList[cycleNum].z, 0); + Location_Set(&binocularsData->viewLocation, nextMapHeaderID, -1, binocularsData->coordsList[cycleNum].x, binocularsData->coordsList[cycleNum].z, 0); } Location *GreatMarshBinoculars_GetLocation(GreatMarshBinoculars *binocData) diff --git a/src/overlay006/great_marsh_daily_encounters.c b/src/overlay006/great_marsh_daily_encounters.c index 68f4e4a95e..74c58cabf0 100644 --- a/src/overlay006/great_marsh_daily_encounters.c +++ b/src/overlay006/great_marsh_daily_encounters.c @@ -6,14 +6,12 @@ #include "heap.h" #include "narc.h" -static u8 GreatMarsh_GetAreaNumFromMapId(const int mapId); +static u8 GreatMarsh_GetAreaNumFromMapId(const enum MapHeaderID mapHeaderID); -void ReplaceGreatMarshDailyEncounters(const int dailyMon, const BOOL nationalDexObtained, const int mapId, int *encounterSlot1, int *encounterSlot2) +void ReplaceGreatMarshDailyEncounters(const int dailyMon, const BOOL nationalDexObtained, const enum MapHeaderID mapHeaderID, int *encounterSlot1, int *encounterSlot2) { - int *narc; int encDataGroup; - u8 encounterIndex; - u8 areaNum = GreatMarsh_GetAreaNumFromMapId(mapId); + u8 areaNum = GreatMarsh_GetAreaNumFromMapId(mapHeaderID); if (nationalDexObtained) { encDataGroup = 9; @@ -21,8 +19,8 @@ void ReplaceGreatMarshDailyEncounters(const int dailyMon, const BOOL nationalDex encDataGroup = 10; } - narc = NARC_AllocAtEndAndReadWholeMemberByIndexPair(NARC_INDEX_ARC__ENCDATA_EX, encDataGroup, HEAP_ID_FIELD1); - encounterIndex = ((dailyMon >> (5 * areaNum)) & 0x1f); + int *narc = NARC_AllocAtEndAndReadWholeMemberByIndexPair(NARC_INDEX_ARC__ENCDATA_EX, encDataGroup, HEAP_ID_FIELD1); + u8 encounterIndex = ((dailyMon >> (5 * areaNum)) & 0x1f); encounterIndex %= 32; (*encounterSlot1) = narc[encounterIndex]; @@ -31,11 +29,11 @@ void ReplaceGreatMarshDailyEncounters(const int dailyMon, const BOOL nationalDex Heap_Free(narc); } -static u8 GreatMarsh_GetAreaNumFromMapId(const int mapId) +static u8 GreatMarsh_GetAreaNumFromMapId(const enum MapHeaderID mapHeaderID) { u8 areaNum = 0; - switch (mapId) { + switch (mapHeaderID) { case MAP_HEADER_GREAT_MARSH_1: areaNum = 0; break; diff --git a/src/overlay006/npc_trade.c b/src/overlay006/npc_trade.c index f82b61da88..af6c8384c5 100644 --- a/src/overlay006/npc_trade.c +++ b/src/overlay006/npc_trade.c @@ -80,7 +80,7 @@ void NPCTrade_FillAnimationTemplate(FieldSystem *fieldSystem, NPCTradeData *data Pokemon *partyMon = Party_GetPokemonBySlotIndex(party, slot); u32 level = Pokemon_GetValue(partyMon, MON_DATA_LEVEL, NULL); - NPCTrade_CreateMon(data->mon, data->npcTradeMon, level, data->npcTradeID, data->heapID, fieldSystem->location->mapId); + NPCTrade_CreateMon(data->mon, data->npcTradeMon, level, data->npcTradeID, data->heapID, fieldSystem->location->mapHeaderID); Pokemon_Copy(partyMon, givingMon); Pokemon_Copy(data->mon, receivingMon); diff --git a/src/overlay006/roamer_after_battle.c b/src/overlay006/roamer_after_battle.c index c1ac745f89..b8bfd69034 100644 --- a/src/overlay006/roamer_after_battle.c +++ b/src/overlay006/roamer_after_battle.c @@ -50,10 +50,10 @@ void RoamerAfterBattle_UpdateRoamers(FieldSystem *fieldSystem, FieldBattleDTO *b Roamer_SetData(roamer, ROAMER_DATA_STATUS, roamerStatus); } - MoveRoamersOffMap(specialEncounter, fieldSystem->location->mapId); // all roamers leave if you encounter one + MoveRoamersOffMap(specialEncounter, fieldSystem->location->mapHeaderID); // all roamers leave if you encounter one } else { if (LCRNG_RandMod(100) < 30) { // 30% chance for roamers to leave even if you don't encounter one - MoveRoamersOffMap(specialEncounter, fieldSystem->location->mapId); + MoveRoamersOffMap(specialEncounter, fieldSystem->location->mapHeaderID); } } } diff --git a/src/overlay006/wild_encounters.c b/src/overlay006/wild_encounters.c index 1f7f4d36cf..ebfbabce6a 100644 --- a/src/overlay006/wild_encounters.c +++ b/src/overlay006/wild_encounters.c @@ -199,7 +199,7 @@ static void WildEncounters_ReplaceSwarmEncounters(FieldSystem *fieldSystem, cons if (SpecialEncounter_IsSwarmEnabled(specialEncounter)) { u32 swarmId = SpecialEncounter_GetDailyMon(specialEncounter, DAILY_SWARM); - if (fieldSystem->location->mapId == Swarm_GetMapId(swarmId)) { + if (fieldSystem->location->mapHeaderID == Swarm_GetMapId(swarmId)) { *radarSlot1 = encounterData->swarmEncounters[0]; *radarSlot2 = encounterData->swarmEncounters[1]; } @@ -208,7 +208,7 @@ static void WildEncounters_ReplaceSwarmEncounters(FieldSystem *fieldSystem, cons static void WildEncounters_ReplaceTrophyGardenEncounters(FieldSystem *fieldSystem, const BOOL nationalDexObtained, int *trophySlot1, int *trophySlot2) { - if (MapHeader_IsTrophyGarden(fieldSystem->location->mapId)) { + if (MapHeader_IsTrophyGarden(fieldSystem->location->mapHeaderID)) { u16 index1, index2; SpecialEncounter_GetTrophyGardenMons(fieldSystem->saveData, &index1, &index2); @@ -404,7 +404,7 @@ BOOL WildEncounters_TryFishingEncounter(FieldSystem *fieldSystem, enum Encounter FieldBattleDTO_Init(*battleParams, fieldSystem); FieldBattleDTO_SetWaterTerrain(*battleParams); - if (MapHeader_HasFeebasTiles(fieldSystem->location->mapId) && PlayerAvatar_IsFacingFeebasTile(fieldSystem)) { + if (MapHeader_HasFeebasTiles(fieldSystem->location->mapHeaderID) && PlayerAvatar_IsFacingFeebasTile(fieldSystem)) { int species; u8 maxLevel, minLevel; @@ -1390,7 +1390,7 @@ static void CreateWildSingleBattle(FieldSystem *fieldSystem, const BOOL safariGa static void WildEncounters_ReplaceGreatMarshDailyEncounters(FieldSystem *fieldSystem, const BOOL safariGameActive, const BOOL nationalDexObtained, EncounterSlot *encTable) { if (safariGameActive) { - ReplaceGreatMarshDailyEncounters(SpecialEncounter_GetDailyMon(SaveData_GetSpecialEncounters(fieldSystem->saveData), DAILY_MARSH), nationalDexObtained, fieldSystem->location->mapId, &encTable[6].species, &encTable[7].species); + ReplaceGreatMarshDailyEncounters(SpecialEncounter_GetDailyMon(SaveData_GetSpecialEncounters(fieldSystem->saveData), DAILY_MARSH), nationalDexObtained, fieldSystem->location->mapHeaderID, &encTable[6].species, &encTable[7].species); } } @@ -1430,7 +1430,7 @@ static BOOL TryEncounterRoamer(FieldSystem *fieldSystem, Roamer **encounteredRoa for (u8 slot = 0; slot < ROAMING_SLOT_MAX; slot++) { int roamerMapId = RoamingPokemon_GetRouteFromId(SpecialEncounter_GetRoamerRouteIndex(speEnc, slot)); - if (SpecialEncounter_IsRoamerActive(speEnc, slot) && roamerMapId == fieldSystem->location->mapId) { + if (SpecialEncounter_IsRoamerActive(speEnc, slot) && roamerMapId == fieldSystem->location->mapHeaderID) { roamers[numRoamersOnMap] = SpecialEncounter_GetRoamer(speEnc, slot); numRoamersOnMap++; } diff --git a/src/overlay007/shop_menu.c b/src/overlay007/shop_menu.c index 293c5c29c8..66a19bdb54 100644 --- a/src/overlay007/shop_menu.c +++ b/src/overlay007/shop_menu.c @@ -456,9 +456,9 @@ static u8 Shop_Exit(FieldSystem *fieldSystem, ShopMenu *shopMenu) StringTemplate_Free(shopMenu->strTemplate); String_Free(shopMenu->string); - if (shopMenu->martType == MART_TYPE_NORMAL && MapHeader_GetMapLabelTextID(fieldSystem->location->mapId) != LocationNames_Text_VeilstoneStore - && fieldSystem->location->mapId != MAP_HEADER_ETERNA_CITY_HERB_SHOP - && fieldSystem->location->mapId != MAP_HEADER_CELESTIC_TOWN_NORTHWEST_HOUSE) { + if (shopMenu->martType == MART_TYPE_NORMAL && MapHeader_GetMapLabelTextID(fieldSystem->location->mapHeaderID) != LocationNames_Text_VeilstoneStore + && fieldSystem->location->mapHeaderID != MAP_HEADER_ETERNA_CITY_HERB_SHOP + && fieldSystem->location->mapHeaderID != MAP_HEADER_CELESTIC_TOWN_NORTHWEST_HOUSE) { if (shopMenu->itemPurchaseCount != 0 && shopMenu->itemSoldCount != 0) { journalEntryLocationEvent = JournalEntry_CreateEventBusinessAtMart(HEAP_ID_FIELD2); JournalEntry_SaveData(shopMenu->journalEntry, journalEntryLocationEvent, JOURNAL_LOCATION); diff --git a/src/overlay008/gym_features.c b/src/overlay008/gym_features.c index 2fa83459c8..64e3063b83 100644 --- a/src/overlay008/gym_features.c +++ b/src/overlay008/gym_features.c @@ -80,7 +80,10 @@ #define ETERNA_GYM_FOUNTAIN_Z 19 #define ETERNA_GYM_WIDTH 21 -#define ETERNA_CLOCK_NO_HOUR_HAND_JUMP { -1, -1, 2 } +#define ETERNA_CLOCK_NO_HOUR_HAND_JUMP \ + { \ + -1, -1, 2 \ + } // 0x1559 is close to, but not the closest integer to 1/12 of 0x10000. It is // used for the hour-positions of the clock hand expect for 3, 6, 9 and 12 @@ -332,7 +335,7 @@ typedef struct VeilstoneGym_BagAnimation { typedef int (*VeilstoneGymAnimationStateFunc)(VeilstoneGym_BagAnimation *); typedef struct HearthomeGymTrainerRoomLayout { - int mapID; + enum MapHeaderID mapHeaderID; int firstDoorID; int numExitDoors; int offsetX; @@ -2593,7 +2596,7 @@ static void EternaGym_SetupCameraMoveAwayFromPlayer(FieldSystem *fieldSystem, Et cameraMan->moveXFirst = TRUE; } - cameraMan->cameraObj = MapObjectMan_AddMapObject(fieldSystem->mapObjMan, playerX, playerZ, 0, OBJ_EVENT_GFX_INVISIBLE, 0x0, fieldSystem->location->mapId); + cameraMan->cameraObj = MapObjectMan_AddMapObject(fieldSystem->mapObjMan, playerX, playerZ, 0, OBJ_EVENT_GFX_INVISIBLE, 0x0, fieldSystem->location->mapHeaderID); MapObject_RecalculateObjectHeight(cameraMan->cameraObj); MapObject_SetHidden(cameraMan->cameraObj, TRUE); @@ -3061,7 +3064,7 @@ BOOL VeilstoneGym_DynamicMapFeaturesCheckCollision(FieldSystem *fieldSystem, con static MapObject *VeilstoneGym_CreateObject(FieldSystem *fieldSystem, int x, int z, BOOL isPunchingBag) { - MapObject *mapObj = MapObjectMan_AddMapObject(fieldSystem->mapObjMan, x, z, 0, OBJ_EVENT_GFX_INVISIBLE, MOVEMENT_TYPE_NONE, fieldSystem->location->mapId); + MapObject *mapObj = MapObjectMan_AddMapObject(fieldSystem->mapObjMan, x, z, 0, OBJ_EVENT_GFX_INVISIBLE, MOVEMENT_TYPE_NONE, fieldSystem->location->mapHeaderID); MapObject_SetLocalID(mapObj, VEILSTONE_GYM_OBJECT_LOCALID); MapObject_SetDataAt(mapObj, isPunchingBag, 0); @@ -3593,7 +3596,7 @@ static void VeilstoneGym_InitCameraManager(FieldSystem *fieldSystem, VeilstoneGy cameraMan->playerX = x; cameraMan->playerZ = z; - cameraMan->cameraObj = MapObjectMan_AddMapObject(fieldSystem->mapObjMan, x, z, 0, OBJ_EVENT_GFX_INVISIBLE, MOVEMENT_TYPE_NONE, fieldSystem->location->mapId); + cameraMan->cameraObj = MapObjectMan_AddMapObject(fieldSystem->mapObjMan, x, z, 0, OBJ_EVENT_GFX_INVISIBLE, MOVEMENT_TYPE_NONE, fieldSystem->location->mapHeaderID); MapObject_RecalculateObjectHeight(cameraMan->cameraObj); MapObject_SetHidden(cameraMan->cameraObj, TRUE); @@ -3688,7 +3691,7 @@ static void VeilstoneGym_UpdateCamera(VeilstoneGym_BagAnimation *bagAnim, fx32 s static const HearthomeGymTrainerRoomLayout sTrainerRoomLayouts[HEARTHOME_NUM_TRAINER_ROOMS] = { { - .mapID = MAP_HEADER_HEARTHOME_CITY_GYM_TRAINER_ROOM_1, + .mapHeaderID = MAP_HEADER_HEARTHOME_CITY_GYM_TRAINER_ROOM_1, .firstDoorID = HEARTHOME_DOOR_ID_CIRCLE, .numExitDoors = 3, .offsetX = 1, @@ -3697,7 +3700,7 @@ static const HearthomeGymTrainerRoomLayout sTrainerRoomLayouts[HEARTHOME_NUM_TRA .sizeZ = HEARTHOME_ROOM_1_SIZE_Z, }, { - .mapID = MAP_HEADER_HEARTHOME_CITY_GYM_TRAINER_ROOM_2, + .mapHeaderID = MAP_HEADER_HEARTHOME_CITY_GYM_TRAINER_ROOM_2, .firstDoorID = HEARTHOME_DOOR_ID_SUN, .numExitDoors = 5, .offsetX = 1, @@ -3799,11 +3802,11 @@ void HearthomeGym_DynamicMapFeaturesInit(FieldSystem *fieldSystem) HearthomeGym_InitTrainers(gymSystem); int i = 0; - int mapID = fieldSystem->location->mapId; + enum MapHeaderID mapHeaderID = fieldSystem->location->mapHeaderID; const HearthomeGymTrainerRoomLayout *room = sTrainerRoomLayouts; do { - if (room->mapID == mapID) { + if (room->mapHeaderID == mapHeaderID) { break; } @@ -3887,7 +3890,7 @@ static void HearthomeGym_InitFog(HearthomeGymSystem *gymSystem) char fogDensity = 109; if (TrainerInfo_HasBadge(SaveData_GetTrainerInfo(gymSystem->fieldSystem->saveData), BADGE_ID_RELIC) == TRUE) { fogDensity = 91; - } else if (gymSystem->fieldSystem->location->mapId == MAP_HEADER_HEARTHOME_CITY_GYM_TRAINER_ROOM_2) { + } else if (gymSystem->fieldSystem->location->mapHeaderID == MAP_HEADER_HEARTHOME_CITY_GYM_TRAINER_ROOM_2) { fogDensity = 119; } @@ -4018,11 +4021,11 @@ BOOL HearthomeGym_CheckIfEnteredIncorrectDoor(FieldSystem *fieldSystem, int play } int i = 0; - int mapID = fieldSystem->location->mapId; + enum MapHeaderID mapHeaderID = fieldSystem->location->mapHeaderID; const HearthomeGymTrainerRoomLayout *room = sTrainerRoomLayouts; do { - if (room->mapID == mapID) { + if (room->mapHeaderID == mapHeaderID) { break; } diff --git a/src/overlay009/ov9_02249960.c b/src/overlay009/ov9_02249960.c index 81a2f62bab..fdbf78a11e 100644 --- a/src/overlay009/ov9_02249960.c +++ b/src/overlay009/ov9_02249960.c @@ -5492,7 +5492,7 @@ static int DistWorldElevatorPlatform_ChangeMaps(DistWorldSystem *system, DistWor MapObject_SetScript(elevatorPlatform->passengerMapObj, 6); } - MapObject_SetMapID(elevatorPlatform->passengerMapObj, elevatorPlatform->destMapHeaderID); + MapObject_SetMapHeaderID(elevatorPlatform->passengerMapObj, elevatorPlatform->destMapHeaderID); } if (elevatorPlatform->dir == MOVING_PLATFORM_ELEVATOR_DIR_DOWN) { @@ -7288,7 +7288,7 @@ static MapObject *FindExistingMapObjectByEvent(DistWorldSystem *system, const Ob const MapObjectManager *mapObjMan = system->fieldSystem->mapObjMan; while (MapObjectMan_FindObjectWithStatus(mapObjMan, &mapObj, &startIdx, MAP_OBJ_STATUS_0)) { - if (MapObject_GetMapID(mapObj) == mapHeaderID && MapObject_GetLocalID(mapObj) == objEvent->localID) { + if (MapObject_GetMapHeaderID(mapObj) == mapHeaderID && MapObject_GetLocalID(mapObj) == objEvent->localID) { GF_ASSERT(objEvent->graphicsID == MapObject_GetGraphicsID(mapObj)); return mapObj; } @@ -7390,7 +7390,7 @@ static void DeleteMapObjectsForMap(DistWorldSystem *system, u32 mapHeaderID) for (i = 0; i < MAP_OBJECT_MANAGER_OBJECT_COUNT; i++, iter++) { if (*iter != NULL) { - if (MapObject_GetMapID(*iter) == mapHeaderID) { + if (MapObject_GetMapHeaderID(*iter) == mapHeaderID) { MapObject_Delete(*iter); *iter = NULL; } @@ -7434,7 +7434,7 @@ static MapObject *AddMapObjectWithLocalID(DistWorldSystem *system, u32 mapHeader void DistWorld_AddMapObjectWithLocalID(FieldSystem *fieldSystem, u16 mapObjLocalID) { - u32 mapHeaderID = fieldSystem->location->mapId; + u32 mapHeaderID = fieldSystem->location->mapHeaderID; DistWorldSystem *dwSystem = fieldSystem->unk_04->dynamicMapFeaturesData; AddMapObjectWithLocalID(dwSystem, mapHeaderID, mapObjLocalID); @@ -7444,12 +7444,12 @@ void DistWorld_DeleteMapObjectWithLocalID(FieldSystem *fieldSystem, u16 mapObjLo { int startIdx = 0; MapObject *mapObj; - u32 mapHeaderID = fieldSystem->location->mapId; + u32 mapHeaderID = fieldSystem->location->mapHeaderID; MapObjectManager *mapObjMan = fieldSystem->mapObjMan; DistWorldSystem *dwSystem = fieldSystem->unk_04->dynamicMapFeaturesData; while (MapObjectMan_FindObjectWithStatus(mapObjMan, &mapObj, &startIdx, MAP_OBJ_STATUS_0) == TRUE) { - if (MapObject_GetLocalID(mapObj) == mapObjLocalID && MapObject_GetMapID(mapObj) == mapHeaderID) { + if (MapObject_GetLocalID(mapObj) == mapObjLocalID && MapObject_GetMapHeaderID(mapObj) == mapHeaderID) { DeleteMapObject(dwSystem, mapObj); return; } @@ -7590,7 +7590,7 @@ static BOOL FindBoulderFallLocationFlag(u32 mapHeaderID, int boulderTileX, int b BOOL DistWorld_WillBoulderBeAtFallLocation(const MapObject *boulderMapObj, enum FaceDirection boulderDir) { FieldSystem *fieldSystem = MapObject_FieldSystem(boulderMapObj); - u32 mapHeaderID = fieldSystem->location->mapId; + u32 mapHeaderID = fieldSystem->location->mapHeaderID; int boulderTileX = MapObject_GetX(boulderMapObj); int boulderTileZ = MapObject_GetZ(boulderMapObj); @@ -7604,7 +7604,7 @@ BOOL DistWorld_WillBoulderBeAtFallLocation(const MapObject *boulderMapObj, enum static BOOL FindMapObjectBoulderFallLocationFlag(const MapObject *boulderMapObj, u32 *flagIndex) { FieldSystem *fieldSystem = MapObject_FieldSystem(boulderMapObj); - u32 mapHeaderID = fieldSystem->location->mapId; + u32 mapHeaderID = fieldSystem->location->mapHeaderID; int boulderTileX = MapObject_GetX(boulderMapObj); int boulderTileZ = MapObject_GetZ(boulderMapObj); @@ -7667,7 +7667,7 @@ static BOOL DistWorldFallingBoulder_TickToB6F(DistWorldFallingBoulder *boulder) Sound_PlayEffect(SEQ_SE_DP_UG_008); boulderPos.y = MAP_OBJECT_COORD_EDGE_TO_FX32(115); MapObject_SetPosDirFromVec(boulderMapObj, &boulderPos, MapObject_GetFacingDir(boulderMapObj)); - MapObject_SetMapID(boulderMapObj, MAP_HEADER_DISTORTION_WORLD_B6F); + MapObject_SetMapHeaderID(boulderMapObj, MAP_HEADER_DISTORTION_WORLD_B6F); u32 flagIndexToSet; u32 flagIndexToClear; @@ -9727,7 +9727,7 @@ void DistWorld_LoadFloorOffsets(int mapHeaderID, int *offsetTileX, int *offsetAl static u32 DistWorldSystem_GetMapHeaderID(DistWorldSystem *system) { - return system->fieldSystem->location->mapId; + return system->fieldSystem->location->mapHeaderID; } static enum AvatarDistortionState GetAvatarDistortionStateForFloatingPlatformKind(u32 platformKind) diff --git a/src/platform_lift.c b/src/platform_lift.c index 83756ff6b3..2811956b57 100644 --- a/src/platform_lift.c +++ b/src/platform_lift.c @@ -209,7 +209,7 @@ void PersistedMapFeatures_InitForPlatformLift(FieldSystem *fieldSystem) data->notUsedWhenEnteredMap = TRUE; data->kind = PLATFORM_LIFT_KIND_IRON_ISLAND; - switch (fieldSystem->location->mapId) { + switch (fieldSystem->location->mapHeaderID) { case MAP_HEADER_IRON_ISLAND_B1F_RIGHT_ROOM: if (fieldSystem->location->z == IRON_ISLAND_B1F_RIGHT_ROOM_BOTTOM_FLOOR_WARP_Z) { data->floorID = PLATFORM_LIFT_BOTTOM_FLOOR; diff --git a/src/pokeradar.c b/src/pokeradar.c index 3f23eb7656..6b76a79fec 100644 --- a/src/pokeradar.c +++ b/src/pokeradar.c @@ -136,7 +136,7 @@ BOOL RadarSpawnPatches(FieldSystem *fieldSystem, const int param1, const int par if (v7 == 0) { RadarChain_Clear(chain); - FieldBGM_TryFadeOut(fieldSystem, FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapId), 1); + FieldBGM_TryFadeOut(fieldSystem, FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapHeaderID), 1); } else { chain->active = TRUE; } @@ -289,7 +289,7 @@ void PokeRadar_ClearIfAllOutOfView(FieldSystem *fieldSystem) if (inactiveRadarRings == 4) { RadarChain_Clear(fieldSystem->chain); - FieldBGM_TryFadeOut(fieldSystem, FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapId), 1); + FieldBGM_TryFadeOut(fieldSystem, FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapHeaderID), 1); } } @@ -320,7 +320,7 @@ static BOOL CheckTileIsGrass(FieldSystem *fieldSystem, const fx32 param1, const int v5 = v0 / 32; int v6 = v1 / 32; int v4 = MapMatrix_GetMapHeaderIDAtCoords(fieldSystem->mapMatrix, v5, v6); - if (fieldSystem->location->mapId != v4) { + if (fieldSystem->location->mapHeaderID != v4) { patch->active = FALSE; return FALSE; } diff --git a/src/scrcmd.c b/src/scrcmd.c index 57e09a8411..d53f0336ab 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -107,6 +107,7 @@ #include "field_bgm.h" #include "field_comm_manager.h" #include "field_map_change.h" +#include "field_map_change_flags.h" #include "field_message.h" #include "field_overworld_state.h" #include "field_script_context.h" @@ -209,7 +210,6 @@ #include "unk_0205DFC4.h" #include "unk_020655F4.h" #include "unk_02069BE0.h" -#include "unk_02070428.h" #include "unk_020722AC.h" #include "unk_0207DA28.h" #include "unk_02097B18.h" @@ -2348,7 +2348,7 @@ static BOOL ScrCmd_AddObject(ScriptContext *ctx) FieldSystem *fieldSystem = ctx->fieldSystem; u16 localID = ScriptContext_GetVar(ctx); - MapObject *mapObj = MapObjectMan_AddMapObjectFromLocalID(fieldSystem->mapObjMan, localID, MapHeaderData_GetNumObjectEvents(fieldSystem), fieldSystem->location->mapId, MapHeaderData_GetObjectEvents(fieldSystem)); + MapObject *mapObj = MapObjectMan_AddMapObjectFromLocalID(fieldSystem->mapObjMan, localID, MapHeaderData_GetNumObjectEvents(fieldSystem), fieldSystem->location->mapHeaderID, MapHeaderData_GetObjectEvents(fieldSystem)); if (mapObj == NULL) { GF_ASSERT(FALSE); @@ -2378,7 +2378,7 @@ static BOOL ScrCmd_AddFreeCamera(ScriptContext *ctx) u16 zPos = ScriptContext_GetVar(ctx); MapObject **cameraObject = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, SCRIPT_MANAGER_CAMERA_OBJECT); - *cameraObject = MapObjectMan_AddMapObject(ctx->fieldSystem->mapObjMan, xPos, zPos, 0, OBJ_EVENT_GFX_INVISIBLE, 0x0, ctx->fieldSystem->location->mapId); + *cameraObject = MapObjectMan_AddMapObject(ctx->fieldSystem->mapObjMan, xPos, zPos, 0, OBJ_EVENT_GFX_INVISIBLE, 0x0, ctx->fieldSystem->location->mapHeaderID); MapObject_RecalculateObjectHeight(*cameraObject); MapObject_SetHidden(*cameraObject, TRUE); @@ -2414,7 +2414,7 @@ static BOOL ScrCmd_AddCameraOverrideObject(ScriptContext *ctx) u16 zPos = ScriptContext_GetVar(ctx); MapObject **cameraObject = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, SCRIPT_MANAGER_CAMERA_OBJECT); - *cameraObject = MapObjectMan_AddMapObject(ctx->fieldSystem->mapObjMan, xPos, zPos, 0, OBJ_EVENT_GFX_INVISIBLE, 0x0, ctx->fieldSystem->location->mapId); + *cameraObject = MapObjectMan_AddMapObject(ctx->fieldSystem->mapObjMan, xPos, zPos, 0, OBJ_EVENT_GFX_INVISIBLE, 0x0, ctx->fieldSystem->location->mapHeaderID); MapObject_RecalculateObjectHeight(*cameraObject); MapObject_SetHidden(*cameraObject, TRUE); @@ -3568,13 +3568,13 @@ static BOOL ScriptContext_ScreenWipeDone(ScriptContext *ctx) static BOOL ScrCmd_Warp(ScriptContext *ctx) { - u16 mapID = ScriptContext_GetVar(ctx); + enum MapHeaderID mapHeaderID = ScriptContext_GetVar(ctx); s16 unused = ScriptContext_ReadHalfWord(ctx); u16 x = ScriptContext_GetVar(ctx); u16 z = ScriptContext_GetVar(ctx); u16 direction = ScriptContext_GetVar(ctx); - FieldTask_StartMapChangeFull(ctx->task, mapID, -1, x, z, direction); + FieldTask_StartMapChangeFull(ctx->task, mapHeaderID, -1, x, z, direction); return TRUE; } @@ -3606,7 +3606,7 @@ static BOOL ScrCmd_GetPreviousMapID(ScriptContext *ctx) Location *location = FieldOverworldState_GetPrevLocation(fieldState); u16 *mapId = ScriptContext_GetVarPointer(ctx); - *mapId = location->mapId; + *mapId = location->mapHeaderID; return FALSE; } @@ -3614,7 +3614,7 @@ static BOOL ScrCmd_GetCurrentMapID(ScriptContext *ctx) { u16 *mapID = ScriptContext_GetVarPointer(ctx); - *mapID = ctx->fieldSystem->location->mapId; + *mapID = ctx->fieldSystem->location->mapHeaderID; return FALSE; } @@ -3727,7 +3727,7 @@ static BOOL ScrCmd_SetPlayerBike(ScriptContext *ctx) PlayerAvatar_SetTransitionState(ctx->fieldSystem->playerAvatar, PLAYER_TRANSITION_WALKING); PlayerAvatar_RequestChangeState(ctx->fieldSystem->playerAvatar); FieldBGM_SetOverride(ctx->fieldSystem, SEQ_NONE); - FieldBGM_TryFadeOut(ctx->fieldSystem, FieldBGM_GetEffective(ctx->fieldSystem, ctx->fieldSystem->location->mapId), 1); + FieldBGM_TryFadeOut(ctx->fieldSystem, FieldBGM_GetEffective(ctx->fieldSystem, ctx->fieldSystem->location->mapHeaderID), 1); } return FALSE; @@ -3902,7 +3902,7 @@ static BOOL ScrCmd_SetSpecialLocation(ScriptContext *ctx) { Location location; - location.mapId = ScriptContext_GetVar(ctx); + location.mapHeaderID = ScriptContext_GetVar(ctx); location.warpId = ScriptContext_GetVar(ctx); location.x = ScriptContext_GetVar(ctx); location.z = ScriptContext_GetVar(ctx); @@ -3918,7 +3918,7 @@ static BOOL ScrCmd_GetFloorsAbove(ScriptContext *ctx) u16 *destVar = ScriptContext_GetVarPointer(ctx); location = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData)); - *destVar = FieldMenu_GetFloorsAbove(location->mapId); + *destVar = FieldMenu_GetFloorsAbove(location->mapHeaderID); return FALSE; } @@ -5559,11 +5559,11 @@ static BOOL ScrCmd_PlayBoatCutscene(ScriptContext *ctx) { u8 travelDir = ScriptContext_ReadByte(ctx); u8 exitDir = ScriptContext_ReadByte(ctx); - int mapID = ScriptContext_ReadHalfWord(ctx); + enum MapHeaderID mapHeaderID = ScriptContext_ReadHalfWord(ctx); int x = ScriptContext_ReadHalfWord(ctx); int z = ScriptContext_ReadHalfWord(ctx); - FieldSystem_PlayBoatCutscene(ctx->fieldSystem, travelDir, exitDir, mapID, x, z); + FieldSystem_PlayBoatCutscene(ctx->fieldSystem, travelDir, exitDir, mapHeaderID, x, z); return TRUE; } @@ -6504,7 +6504,7 @@ static BOOL ScrCmd_2B5(ScriptContext *ctx) FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); Location *location = FieldOverworldState_GetExitLocation(fieldState); - location->mapId = mapId; + location->mapHeaderID = mapId; location->x = x; location->z = z; location->warpId = WARP_ID_NONE; @@ -6565,7 +6565,7 @@ static BOOL ScrCmd_CloseSaveInfo(ScriptContext *ctx) static BOOL ScrCmd_Unused_2C3(ScriptContext *ctx) { - sub_02070428(ctx->fieldSystem, ScriptContext_ReadByte(ctx)); + FieldSystem_SetTemporaryMapChange(ctx->fieldSystem, ScriptContext_ReadByte(ctx)); return FALSE; } @@ -6588,7 +6588,7 @@ static BOOL ScrCmd_LaunchBattleFrontierScene(ScriptContext *ctx) fieldData->options = SaveData_GetOptions(ctx->fieldSystem->saveData); fieldData->sceneID = sceneID; fieldData->saveData = ctx->fieldSystem->saveData; - fieldData->mapHeaderID = ctx->fieldSystem->location->mapId; + fieldData->mapHeaderID = ctx->fieldSystem->location->mapHeaderID; fieldData->journalEntry = ctx->fieldSystem->journalEntry; fieldData->bagCursor = ctx->fieldSystem->bagCursor; fieldData->subscreenCursorOn = ctx->fieldSystem->battleSubscreenCursorOn; diff --git a/src/scrcmd_contests.c b/src/scrcmd_contests.c index b953686439..eac8b56341 100644 --- a/src/scrcmd_contests.c +++ b/src/scrcmd_contests.c @@ -96,7 +96,7 @@ BOOL ScrCmd_EndContest(ScriptContext *ctx) { void **contest = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, SCRIPT_MANAGER_DATA_PTR); u16 unused = ScriptContext_GetVar(ctx); - u32 mapID = MapHeader_GetMapLabelTextID(ctx->fieldSystem->location->mapId); + u32 mapID = MapHeader_GetMapLabelTextID(ctx->fieldSystem->location->mapHeaderID); Contest_EndContest(*contest, ctx->fieldSystem->saveData, mapID, ctx->fieldSystem->journalEntry); Contest_Free(*contest); diff --git a/src/scrcmd_party.c b/src/scrcmd_party.c index 0913f451cd..49d000e7c6 100644 --- a/src/scrcmd_party.c +++ b/src/scrcmd_party.c @@ -28,7 +28,7 @@ BOOL ScrCmd_GivePokemon(ScriptContext *ctx) { - int metLocation = MapHeader_GetMapLabelTextID(ctx->fieldSystem->location->mapId); + int metLocation = MapHeader_GetMapLabelTextID(ctx->fieldSystem->location->mapHeaderID); int metTerrain = TERRAIN_MAX; FieldSystem *fieldSystem = ctx->fieldSystem; u16 species = ScriptContext_GetVar(ctx); @@ -280,7 +280,7 @@ BOOL ScrCmd_IncreasePartyMonFriendship(ScriptContext *ctx) FieldSystem *fieldSystem = ctx->fieldSystem; u16 value = ScriptContext_GetVar(ctx); u16 slot = ScriptContext_GetVar(ctx); - u32 location = MapHeader_GetMapLabelTextID(ctx->fieldSystem->location->mapId); + u32 location = MapHeader_GetMapLabelTextID(ctx->fieldSystem->location->mapHeaderID); Pokemon *mon = Party_GetPokemonBySlotIndex(SaveData_GetParty(fieldSystem->saveData), slot); u16 friendship = Pokemon_GetValue(mon, MON_DATA_FRIENDSHIP, NULL); diff --git a/src/scrcmd_sound.c b/src/scrcmd_sound.c index 37c7283752..93c1aecaed 100644 --- a/src/scrcmd_sound.c +++ b/src/scrcmd_sound.c @@ -42,7 +42,7 @@ BOOL ScrCmd_StopMusic(ScriptContext *ctx) BOOL ScrCmd_PlayDefaultMusic(ScriptContext *ctx) { - Sound_PlayBGM(FieldBGM_GetForMapHeader(ctx->fieldSystem, ctx->fieldSystem->location->mapId)); + Sound_PlayBGM(FieldBGM_GetForMapHeader(ctx->fieldSystem, ctx->fieldSystem->location->mapHeaderID)); return FALSE; } diff --git a/src/script_manager.c b/src/script_manager.c index 5a96a35b95..3a12f178d4 100644 --- a/src/script_manager.c +++ b/src/script_manager.c @@ -263,9 +263,9 @@ static void ScriptContext_Load(FieldSystem *fieldSystem, ScriptContext *ctx, int static void ScriptContext_LoadFromCurrentMap(FieldSystem *fieldSystem, ScriptContext *ctx) { - u8 *scripts = ScriptContext_LoadScripts(fieldSystem->location->mapId); + u8 *scripts = ScriptContext_LoadScripts(fieldSystem->location->mapHeaderID); ctx->scripts = scripts; - ctx->loader = MessageLoader_Init(MSG_LOADER_LOAD_ON_DEMAND, NARC_INDEX_MSGDATA__PL_MSG, MapHeaderToMsgArchive(fieldSystem->location->mapId), HEAP_ID_FIELD2); + ctx->loader = MessageLoader_Init(MSG_LOADER_LOAD_ON_DEMAND, NARC_INDEX_MSGDATA__PL_MSG, MapHeaderToMsgArchive(fieldSystem->location->mapHeaderID), HEAP_ID_FIELD2); } void *ScriptManager_GetMemberPtr(ScriptManager *scriptManager, u32 member) @@ -559,17 +559,17 @@ void FieldSystem_ClearDailyHiddenItemFlags(FieldSystem *fieldSystem) { u8 rand = LCRNG_Next() % NELEMS(sIronIslandHiddenItemFlags); - if (fieldSystem->location->mapId != sIronIslandHiddenItemFlags[rand][0]) { + if (fieldSystem->location->mapHeaderID != sIronIslandHiddenItemFlags[rand][0]) { FieldSystem_ClearFlag(fieldSystem, HIDDEN_ITEM_FLAGS_START + sIronIslandHiddenItemFlags[rand][1]); } rand = LCRNG_Next() % NELEMS(sIronIslandHiddenItemFlags); - if (fieldSystem->location->mapId != sIronIslandHiddenItemFlags[rand][0]) { + if (fieldSystem->location->mapHeaderID != sIronIslandHiddenItemFlags[rand][0]) { FieldSystem_ClearFlag(fieldSystem, HIDDEN_ITEM_FLAGS_START + sIronIslandHiddenItemFlags[rand][1]); } - if (fieldSystem->location->mapId != MAP_HEADER_FLOAROMA_MEADOW) { + if (fieldSystem->location->mapHeaderID != MAP_HEADER_FLOAROMA_MEADOW) { rand = LCRNG_Next() % NELEMS(sFloaromaMeadowHiddenItemFlags); FieldSystem_ClearFlag(fieldSystem, HIDDEN_ITEM_FLAGS_START + sFloaromaMeadowHiddenItemFlags[rand]); diff --git a/src/spawn_locations.c b/src/spawn_locations.c index 232c62430a..1c5a368e1f 100644 --- a/src/spawn_locations.c +++ b/src/spawn_locations.c @@ -4,6 +4,7 @@ #include #include "generated/first_arrival_to_zones.h" +#include "generated/map_headers.h" #include "field/field_system.h" @@ -13,10 +14,10 @@ #include "vars_flags.h" typedef struct SpawnLocation { - u16 blackOutMapId; + u16 blackOutMapHeaderID; u16 blackOutX; u16 blackOutZ; - u16 flyMapId; + u16 flyMapHeaderID; u16 flyX; u16 flyZ; u8 isWarpPos; @@ -67,7 +68,7 @@ void Location_InitFly(int flyDestination, Location *location) { flyDestination = MapSpawnIdToIndex(flyDestination); - location->mapId = sSpawnLocations[flyDestination].flyMapId; + location->mapHeaderID = sSpawnLocations[flyDestination].flyMapHeaderID; location->warpId = WARP_ID_NONE; location->x = sSpawnLocations[flyDestination].flyX; location->z = sSpawnLocations[flyDestination].flyZ; @@ -78,17 +79,17 @@ void Location_InitBlackOut(int blackOutDestination, Location *location) { blackOutDestination = MapSpawnIdToIndex(blackOutDestination); - location->mapId = sSpawnLocations[blackOutDestination].blackOutMapId; + location->mapHeaderID = sSpawnLocations[blackOutDestination].blackOutMapHeaderID; location->warpId = WARP_ID_NONE; location->x = sSpawnLocations[blackOutDestination].blackOutX; location->z = sSpawnLocations[blackOutDestination].blackOutZ; location->faceDirection = FACE_UP; } -int GetMapBlackOutWarpId(int mapId) +int GetMapBlackOutWarpId(enum MapHeaderID mapHeaderID) { for (int i = 0; i < NELEMS(sSpawnLocations); i++) { - if (sSpawnLocations[i].blackOutMapId == mapId && sSpawnLocations[i].isWarpPos) { + if (sSpawnLocations[i].blackOutMapHeaderID == mapHeaderID && sSpawnLocations[i].isWarpPos) { return i + 1; } } @@ -96,10 +97,10 @@ int GetMapBlackOutWarpId(int mapId) return 0; } -int GetMapFlyWarpId(int mapId) +int GetMapFlyWarpId(enum MapHeaderID mapHeaderID) { for (int i = 0; i < NELEMS(sSpawnLocations); i++) { - if (sSpawnLocations[i].flyMapId == mapId && sSpawnLocations[i].isWarpPos) { + if (sSpawnLocations[i].flyMapHeaderID == mapHeaderID && sSpawnLocations[i].isWarpPos) { return i + 1; } } @@ -107,7 +108,7 @@ int GetMapFlyWarpId(int mapId) return 0; } -int GetSpawnIdByMapAndCoords(int mapID, int param1, int param2) +int GetSpawnIdByMapAndCoords(enum MapHeaderID mapHeaderID, int param1, int param2) { int i; int v1 = param1 / 32; @@ -115,7 +116,7 @@ int GetSpawnIdByMapAndCoords(int mapID, int param1, int param2) int destinationId = 0; for (i = 0; i < NELEMS(sSpawnLocations); i++) { - if (sSpawnLocations[i].flyMapId == mapID) { + if (sSpawnLocations[i].flyMapHeaderID == mapHeaderID) { destinationId = i + 1; if ((v1 == sSpawnLocations[i].flyX / 32) && (v2 == sSpawnLocations[i].flyZ / 32)) { @@ -127,20 +128,18 @@ int GetSpawnIdByMapAndCoords(int mapID, int param1, int param2) return destinationId; } -void TryUnlockFlyLocationByMap(FieldSystem *fieldSystem, int param1) +void TryUnlockFlyLocationByMap(FieldSystem *fieldSystem, enum MapHeaderID mapHeaderID) { - int v0; - - for (v0 = 0; v0 < NELEMS(sSpawnLocations); v0++) { - if ((sSpawnLocations[v0].flyMapId == param1) && sSpawnLocations[v0].unlockOnMapEntry) { + for (int v0 = 0; v0 < NELEMS(sSpawnLocations); v0++) { + if ((sSpawnLocations[v0].flyMapHeaderID == mapHeaderID) && sSpawnLocations[v0].unlockOnMapEntry) { SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_SET, sSpawnLocations[v0].firstArrival); return; } } } -BOOL CheckFlyLocationUnlocked(FieldSystem *fieldSystem, int param1) +BOOL CheckFlyLocationUnlocked(FieldSystem *fieldSystem, int flyLocation) { - int v0 = MapSpawnIdToIndex(param1); - return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, sSpawnLocations[v0].firstArrival); + int flyDestination = MapSpawnIdToIndex(flyLocation); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, sSpawnLocations[flyDestination].firstArrival); } diff --git a/src/start_menu.c b/src/start_menu.c index 12201fd774..f8a17774f6 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -260,7 +260,7 @@ static const u8 sOnlyMovePages[] = { BOOL FieldSystem_IsInValidLocation(FieldSystem *fieldSystem) { - return MapHeader_GetMapLabelTextID(fieldSystem->location->mapId) != LocationNames_Text_MysteryZone; + return MapHeader_GetMapLabelTextID(fieldSystem->location->mapHeaderID) != LocationNames_Text_MysteryZone; } #define HIDE_OPTION_POKEDEX (1 << 0) @@ -376,7 +376,7 @@ static u32 StartMenu_GetNormalHiddenOptions(FieldSystem *fieldSystem) hideFlags |= HIDE_OPTION_BAG; } - if (MapHeader_IsAmitySquare(fieldSystem->location->mapId) == TRUE) { + if (MapHeader_IsAmitySquare(fieldSystem->location->mapHeaderID) == TRUE) { hideFlags |= HIDE_OPTION_POKEMON; hideFlags |= HIDE_OPTION_BAG; } @@ -1081,7 +1081,7 @@ BOOL StartMenu_ExitPartyMenu(FieldTask *fieldTask) case PARTY_MENU_EXIT_CODE_EVOLVE_BY_LEVEL: evoData = Heap_Alloc(HEAP_ID_FIELD2, sizeof(MenuEvolutionData)); - evoData->dummy = MapHeader_GetMapEvolutionMethod(fieldSystem->location->mapId); + evoData->dummy = MapHeader_GetMapEvolutionMethod(fieldSystem->location->mapHeaderID); evoData->class = EVO_CLASS_BY_LEVEL; evoData->slot = partyMenu->selectedMonSlot; evoData->targetSpecies = partyMenu->evoTargetSpecies; @@ -1763,7 +1763,7 @@ static void StartMenu_Evolve(FieldTask *fieldTask) Heap_Destroy(HEAP_ID_EVOLUTION); Sound_StopBGM(SEQ_SHINKA, 0); Sound_SetScene(SOUND_SCENE_NONE); - FieldBGM_PlayEffectiveForMapHeader(fieldSystem, fieldSystem->location->mapId); + FieldBGM_PlayEffectiveForMapHeader(fieldSystem, fieldSystem->location->mapHeaderID); menu->taskData = FieldSystem_OpenBag(fieldSystem, &menu->itemUseCtx); diff --git a/src/system_vars.c b/src/system_vars.c index 927c54539c..e6ea14aff4 100644 --- a/src/system_vars.c +++ b/src/system_vars.c @@ -420,7 +420,7 @@ void SystemVars_UpdateVillaVisitor(SaveData *saveData) FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(saveData); Location *location = FieldOverworldState_GetPlayerLocation(fieldState); - if (location->mapId != MAP_HEADER_RESORT_AREA && location->mapId != MAP_HEADER_VILLA) { + if (location->mapHeaderID != MAP_HEADER_RESORT_AREA && location->mapHeaderID != MAP_HEADER_VILLA) { SystemFlag_ClearVillaVisitorInside(varsFlags); SystemFlag_ClearVillaVisitorOutside(varsFlags); InitVillaVisitor(varsFlags, CalcVillaVisitorIndex(varsFlags)); diff --git a/src/tv_segment.c b/src/tv_segment.c index 8e9b870543..5731b8d88d 100644 --- a/src/tv_segment.c +++ b/src/tv_segment.c @@ -7,6 +7,7 @@ #include "constants/overworld_weather.h" #include "constants/tv_broadcast.h" #include "generated/first_arrival_to_zones.h" +#include "generated/map_headers.h" #include "generated/natures.h" #include "generated/pokemon_stats.h" @@ -341,7 +342,10 @@ typedef struct TVProgramType { const TVSegment *segments; } TVProgramType; -#define TV_PROGRAM_SEGMENT_NULL { NULL, NULL } +#define TV_PROGRAM_SEGMENT_NULL \ + { \ + NULL, NULL \ + } static const TVSegment sTrainerSightingsSegments[TV_PROGRAM_TYPE_TRAINER_SIGHTINGS_NUM_SEGMENTS]; static const TVSegment sRecordsSegments[TV_PROGRAM_TYPE_RECORDS_NUM_SEGMENTS]; @@ -872,7 +876,7 @@ void FieldSystem_SaveTVSegment_HiddenItemBreakingNews(FieldSystem *fieldSystem, TVSegment_HiddenItemBreakingNews *hiddenItemBreakingNews = &segments.hiddenItemBreakingNews; hiddenItemBreakingNews->item = item; - hiddenItemBreakingNews->location = MapHeader_GetMapLabelTextID(fieldSystem->location->mapId); + hiddenItemBreakingNews->location = MapHeader_GetMapLabelTextID(fieldSystem->location->mapHeaderID); FieldSystem_SaveTVSegment(fieldSystem, TV_PROGRAM_TYPE_TRAINER_SIGHTINGS, TV_PROGRAM_SEGMENT_HIDDEN_ITEM_BREAKING_NEWS, hiddenItemBreakingNews); } @@ -923,7 +927,7 @@ void FieldSystem_SaveTVSegment_HappyHappyEggClub(FieldSystem *fieldSystem, Pokem TVSegment_HappyHappyEggClub *happyHappyEggClub = &segments.happyHappyEggClub; TVSegment_CopyPokemonValues(mon, &happyHappyEggClub->species, &happyHappyEggClub->gender, &happyHappyEggClub->language, &happyHappyEggClub->metGame); - happyHappyEggClub->location = MapHeader_GetMapLabelTextID(fieldSystem->location->mapId); + happyHappyEggClub->location = MapHeader_GetMapLabelTextID(fieldSystem->location->mapHeaderID); FieldSystem_SaveTVSegment(fieldSystem, TV_PROGRAM_TYPE_TRAINER_SIGHTINGS, TV_PROGRAM_SEGMENT_HAPPY_HAPPY_EGG_CLUB, happyHappyEggClub); } @@ -2166,64 +2170,64 @@ static BOOL FieldSystem_AlwaysTrue(FieldSystem *fieldSystem, TVEpisode *episode) static int TVSegment_LoadMessage_YourTownsBestThree(FieldSystem *fieldSystem, StringTemplate *template, TVEpisode *episode) { TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(fieldSystem)); - int mapID = fieldSystem->location->mapId; + enum MapHeaderID mapHeaderID = fieldSystem->location->mapHeaderID; - if (mapID == MAP_HEADER_TWINLEAF_TOWN || (mapID >= MAP_HEADER_TWINLEAF_TOWN_RIVAL_HOUSE_1F && mapID <= MAP_HEADER_TWINLEAF_TOWN_SOUTHWEST_HOUSE)) { + if (mapHeaderID == MAP_HEADER_TWINLEAF_TOWN || (mapHeaderID >= MAP_HEADER_TWINLEAF_TOWN_RIVAL_HOUSE_1F && mapHeaderID <= MAP_HEADER_TWINLEAF_TOWN_SOUTHWEST_HOUSE)) { StringTemplate_SetPlayerName(template, 0, trainerInfo); StringTemplate_SetRivalName(template, 1, fieldSystem->saveData); return TVProgramSinnohNow_Text_YourTownsBestThree_TwinleafTown; } - if (mapID == MAP_HEADER_SANDGEM_TOWN || (mapID >= MAP_HEADER_SANDGEM_TOWN_POKEMON_RESEARCH_LAB && mapID <= MAP_HEADER_SANDGEM_TOWN_HOUSE)) { + if (mapHeaderID == MAP_HEADER_SANDGEM_TOWN || (mapHeaderID >= MAP_HEADER_SANDGEM_TOWN_POKEMON_RESEARCH_LAB && mapHeaderID <= MAP_HEADER_SANDGEM_TOWN_HOUSE)) { StringTemplate_SetCounterpartName(template, 1, fieldSystem->saveData); return TVProgramSinnohNow_Text_YourTownsBestThree_SandgemTown; } - if (mapID == MAP_HEADER_FLOAROMA_TOWN || (mapID >= MAP_HEADER_FLOWER_SHOP && mapID <= MAP_HEADER_FLOAROMA_TOWN_MIDDLE_HOUSE) || mapID == MAP_HEADER_FLOAROMA_MEADOW_HOUSE) { + if (mapHeaderID == MAP_HEADER_FLOAROMA_TOWN || (mapHeaderID >= MAP_HEADER_FLOWER_SHOP && mapHeaderID <= MAP_HEADER_FLOAROMA_TOWN_MIDDLE_HOUSE) || mapHeaderID == MAP_HEADER_FLOAROMA_MEADOW_HOUSE) { return TVProgramSinnohNow_Text_YourTownsBestThree_FloaromaTown; } - if (mapID == MAP_HEADER_SOLACEON_TOWN || (mapID >= MAP_HEADER_POKEMON_DAY_CARE && mapID <= MAP_HEADER_SOLACEON_TOWN_EAST_HOUSE)) { + if (mapHeaderID == MAP_HEADER_SOLACEON_TOWN || (mapHeaderID >= MAP_HEADER_POKEMON_DAY_CARE && mapHeaderID <= MAP_HEADER_SOLACEON_TOWN_EAST_HOUSE)) { return TVProgramSinnohNow_Text_YourTownsBestThree_SolaceonTown; } - if (mapID == MAP_HEADER_CELESTIC_TOWN || (mapID >= MAP_HEADER_CELESTIC_TOWN_NORTH_HOUSE && mapID <= MAP_HEADER_CELESTIC_TOWN_CAVE)) { + if (mapHeaderID == MAP_HEADER_CELESTIC_TOWN || (mapHeaderID >= MAP_HEADER_CELESTIC_TOWN_NORTH_HOUSE && mapHeaderID <= MAP_HEADER_CELESTIC_TOWN_CAVE)) { return TVProgramSinnohNow_Text_YourTownsBestThree_CelesticTown; } - if (mapID == MAP_HEADER_JUBILIFE_CITY || (mapID >= MAP_HEADER_POKETCH_CO_1F && mapID <= MAP_HEADER_UNUSED_JUBILIFE_CITY_HOUSE_4)) { + if (mapHeaderID == MAP_HEADER_JUBILIFE_CITY || (mapHeaderID >= MAP_HEADER_POKETCH_CO_1F && mapHeaderID <= MAP_HEADER_UNUSED_JUBILIFE_CITY_HOUSE_4)) { return TVProgramSinnohNow_Text_YourTownsBestThree_JubilifeCity; } - if (mapID == MAP_HEADER_CANALAVE_CITY || (mapID >= MAP_HEADER_CANALAVE_LIBRARY_1F && mapID <= MAP_HEADER_CANALAVE_CITY_SAILOR_ELDRITCH_HOUSE) || mapID == MAP_HEADER_CANALAVE_CITY_WEST_HOUSE) { + if (mapHeaderID == MAP_HEADER_CANALAVE_CITY || (mapHeaderID >= MAP_HEADER_CANALAVE_LIBRARY_1F && mapHeaderID <= MAP_HEADER_CANALAVE_CITY_SAILOR_ELDRITCH_HOUSE) || mapHeaderID == MAP_HEADER_CANALAVE_CITY_WEST_HOUSE) { return TVProgramSinnohNow_Text_YourTownsBestThree_CanalaveCity; } - if (mapID == MAP_HEADER_OREBURGH_CITY || (mapID >= MAP_HEADER_OREBURGH_CITY_NORTHWEST_HOUSE_1F && mapID <= MAP_HEADER_OREBURGH_CITY_SOUTH_HOUSE)) { + if (mapHeaderID == MAP_HEADER_OREBURGH_CITY || (mapHeaderID >= MAP_HEADER_OREBURGH_CITY_NORTHWEST_HOUSE_1F && mapHeaderID <= MAP_HEADER_OREBURGH_CITY_SOUTH_HOUSE)) { return TVProgramSinnohNow_Text_YourTownsBestThree_OreburghCity; } - if (mapID == MAP_HEADER_ETERNA_CITY || (mapID >= MAP_HEADER_CYCLE_SHOP && mapID <= MAP_HEADER_UNUSED_ETERNA_CITY_HOUSE)) { + if (mapHeaderID == MAP_HEADER_ETERNA_CITY || (mapHeaderID >= MAP_HEADER_CYCLE_SHOP && mapHeaderID <= MAP_HEADER_UNUSED_ETERNA_CITY_HOUSE)) { return TVProgramSinnohNow_Text_YourTownsBestThree_EternaCity; } - if (mapID == MAP_HEADER_HEARTHOME_CITY || (mapID >= MAP_HEADER_HEARTHOME_CITY_SOUTHEAST_HOUSE_1F && mapID <= MAP_HEADER_FOREIGN_BUILDING)) { + if (mapHeaderID == MAP_HEADER_HEARTHOME_CITY || (mapHeaderID >= MAP_HEADER_HEARTHOME_CITY_SOUTHEAST_HOUSE_1F && mapHeaderID <= MAP_HEADER_FOREIGN_BUILDING)) { return TVProgramSinnohNow_Text_YourTownsBestThree_HearthomeCity; } - if (mapID == MAP_HEADER_PASTORIA_CITY || (mapID >= MAP_HEADER_PASTORIA_CITY_OBSERVATORY_GATE_1F && mapID <= MAP_HEADER_PASTORIA_CITY_NORTHEAST_HOUSE)) { + if (mapHeaderID == MAP_HEADER_PASTORIA_CITY || (mapHeaderID >= MAP_HEADER_PASTORIA_CITY_OBSERVATORY_GATE_1F && mapHeaderID <= MAP_HEADER_PASTORIA_CITY_NORTHEAST_HOUSE)) { return TVProgramSinnohNow_Text_YourTownsBestThree_PastoriaCity; } - if (mapID == MAP_HEADER_VEILSTONE_CITY || (mapID >= MAP_HEADER_GAME_CORNER && mapID <= MAP_HEADER_ROUTE_215_GATE_TO_VEILSTONE_CITY) || (mapID >= MAP_HEADER_GALACTIC_HQ_1F && mapID <= MAP_HEADER_GALACTIC_HQ_B2F)) { + if (mapHeaderID == MAP_HEADER_VEILSTONE_CITY || (mapHeaderID >= MAP_HEADER_GAME_CORNER && mapHeaderID <= MAP_HEADER_ROUTE_215_GATE_TO_VEILSTONE_CITY) || (mapHeaderID >= MAP_HEADER_GALACTIC_HQ_1F && mapHeaderID <= MAP_HEADER_GALACTIC_HQ_B2F)) { return TVProgramSinnohNow_Text_YourTownsBestThree_VeilstoneCity; } - if (mapID == MAP_HEADER_SUNYSHORE_CITY || (mapID >= MAP_HEADER_SUNYSHORE_MARKET && mapID <= MAP_HEADER_VISTA_LIGHTHOUSE) || mapID == MAP_HEADER_VISTA_LIGHTHOUSE_ELEVATOR) { + if (mapHeaderID == MAP_HEADER_SUNYSHORE_CITY || (mapHeaderID >= MAP_HEADER_SUNYSHORE_MARKET && mapHeaderID <= MAP_HEADER_VISTA_LIGHTHOUSE) || mapHeaderID == MAP_HEADER_VISTA_LIGHTHOUSE_ELEVATOR) { return TVProgramSinnohNow_Text_YourTownsBestThree_SunyshoreCity; } - if (mapID == MAP_HEADER_SNOWPOINT_CITY || (mapID >= MAP_HEADER_SNOWPOINT_CITY_WEST_HOUSE && mapID <= MAP_HEADER_SNOWPOINT_CITY_EAST_HOUSE)) { + if (mapHeaderID == MAP_HEADER_SNOWPOINT_CITY || (mapHeaderID >= MAP_HEADER_SNOWPOINT_CITY_WEST_HOUSE && mapHeaderID <= MAP_HEADER_SNOWPOINT_CITY_EAST_HOUSE)) { return TVProgramSinnohNow_Text_YourTownsBestThree_SnowpointCity; } diff --git a/src/underground/secret_bases.c b/src/underground/secret_bases.c index c7863541ae..b0e47b1967 100644 --- a/src/underground/secret_bases.c +++ b/src/underground/secret_bases.c @@ -229,7 +229,7 @@ typedef struct BaseTransitionContext { SysTask *sysTask; int state; int subState; - int mapID; + enum MapHeaderID mapHeaderID; int warpID; int x; int z; @@ -1019,7 +1019,7 @@ static void SecretBases_StartExitBasePromptTask(FieldSystem *fieldSystem, int x, ctx->z = z; ctx->netID = netID; ctx->baseOwnerNetID = baseOwnerNetID; - ctx->mapID = MAP_HEADER_UNDERGROUND; + ctx->mapHeaderID = MAP_HEADER_UNDERGROUND; ctx->dir = dir; ctx->fieldSystem = fieldSystem; ctx->sysTask = SysTask_Start(SecretBases_ExitBasePromptTask, ctx, 100); @@ -1042,9 +1042,9 @@ static BaseTransitionContext *BaseTransitionContext_New(FieldSystem *fieldSystem ctx->netID = netID; ctx->baseOwnerNetID = baseOwnerNetID; - GF_ASSERT(fieldSystem->location->mapId == MAP_HEADER_UNDERGROUND); + GF_ASSERT(fieldSystem->location->mapHeaderID == MAP_HEADER_UNDERGROUND); - ctx->mapID = MAP_HEADER_UNDERGROUND; + ctx->mapHeaderID = MAP_HEADER_UNDERGROUND; ctx->dir = dir; } @@ -1248,7 +1248,7 @@ static void SecretBases_StartEnterBasePromptTask(FieldSystem *fieldSystem, int x ctx->z = z; ctx->netID = netID; ctx->baseOwnerNetID = baseOwnerNetID; - ctx->mapID = MAP_HEADER_UNDERGROUND; + ctx->mapHeaderID = MAP_HEADER_UNDERGROUND; ctx->dir = dir; ctx->fieldSystem = fieldSystem; ctx->timer = 0; @@ -1651,7 +1651,7 @@ static BOOL SecretBases_MoveToFromSecretBaseTask(FieldTask *task) break; case MOVE_STATE_UPDATE_LOCATION: Location nextLocation; - nextLocation.mapId = ctx->mapID; + nextLocation.mapHeaderID = ctx->mapHeaderID; nextLocation.warpId = ctx->warpID; nextLocation.x = ctx->x; nextLocation.z = ctx->z; diff --git a/src/unk_0203D1B8.c b/src/unk_0203D1B8.c index a6d37fc6ee..93a7133f6e 100644 --- a/src/unk_0203D1B8.c +++ b/src/unk_0203D1B8.c @@ -1478,7 +1478,7 @@ void FieldSystem_HatchEgg(FieldSystem *fieldSystem) args.mon = eggMon; args.options = SaveData_GetOptions(fieldSystem->saveData); args.trainerInfo = SaveData_GetTrainerInfo(fieldSystem->saveData); - args.bgmID = FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapId); + args.bgmID = FieldBGM_GetEffective(fieldSystem, fieldSystem->location->mapHeaderID); EggHatch_HatchEgg(fieldSystem->task, &args); } diff --git a/src/unk_02049D08.c b/src/unk_02049D08.c index 6866757e14..8c2843ea4f 100644 --- a/src/unk_02049D08.c +++ b/src/unk_02049D08.c @@ -227,7 +227,7 @@ void BattleTower_SetCommunicationClubAccessible(FieldSystem *fieldSystem) { Location *v0 = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - Location_Set(v0, fieldSystem->location->mapId, -1, PlayerAvatar_GetXPos(fieldSystem->playerAvatar), PlayerAvatar_GetZPos(fieldSystem->playerAvatar), 0); + Location_Set(v0, fieldSystem->location->mapHeaderID, -1, PlayerAvatar_GetXPos(fieldSystem->playerAvatar), PlayerAvatar_GetZPos(fieldSystem->playerAvatar), 0); SystemFlag_SetCommunicationClubAccessible(SaveData_GetVarsFlags(fieldSystem->saveData)); return; diff --git a/src/unk_020528D0.c b/src/unk_020528D0.c index effb5e817a..c47dea1d54 100644 --- a/src/unk_020528D0.c +++ b/src/unk_020528D0.c @@ -11,6 +11,7 @@ #include "brightness_controller.h" #include "field_bgm.h" #include "field_map_change.h" +#include "field_map_change_flags.h" #include "field_overworld_state.h" #include "field_system.h" #include "field_task.h" @@ -33,7 +34,6 @@ #include "string_template.h" #include "system.h" #include "text.h" -#include "unk_02070428.h" typedef struct { int unk_00; @@ -121,7 +121,7 @@ static void sub_02052914(FieldSystem *fieldSystem, FieldTask *task) Window_AddFromTemplate(v0->unk_08, &v0->unk_0C, &Unk_020EC2F0); StringTemplate_SetPlayerName(v0->unk_20, 0, SaveData_GetTrainerInfo(FieldSystem_GetSaveData(fieldSystem))); - if (fieldSystem->location->mapId == MAP_HEADER_TWINLEAF_TOWN_PLAYER_HOUSE_1F) { + if (fieldSystem->location->mapHeaderID == MAP_HEADER_TWINLEAF_TOWN_PLAYER_HOUSE_1F) { sub_02052AA4(v0, 4, 0, 0); } else { sub_02052AA4(v0, 3, 0, 0); diff --git a/src/unk_02056B30.c b/src/unk_02056B30.c index 9d38f75f76..d402a8cef0 100644 --- a/src/unk_02056B30.c +++ b/src/unk_02056B30.c @@ -154,8 +154,6 @@ void sub_02056BDC(FieldSystem *fieldSystem, const int param1, const int param2, void sub_02056C18(FieldSystem *fieldSystem, const int param1, const int param2, const int param3, const int param4, const int param5) { - int v0; - int v1; UnkStruct_02056BDC *v2 = Heap_AllocAtEnd(HEAP_ID_FIELD2, sizeof(UnkStruct_02056BDC)); v2->unk_00 = 0; @@ -163,10 +161,10 @@ void sub_02056C18(FieldSystem *fieldSystem, const int param1, const int param2, Location_Set(&v2->unk_08, param1, param2, param3, param4, param5); - v0 = fieldSystem->location->mapId; - v1 = 0; + enum MapHeaderID mapHeaderID = fieldSystem->location->mapHeaderID; + int v1 = 0; - if (MapHeader_IsCave(v0)) { + if (MapHeader_IsCave(mapHeaderID)) { if (MapHeader_IsCave(param1)) { v1 = 6; } else if (MapHeader_IsOutdoors(param1)) { @@ -176,7 +174,7 @@ void sub_02056C18(FieldSystem *fieldSystem, const int param1, const int param2, } else { GF_ASSERT(FALSE); } - } else if (MapHeader_IsOutdoors(v0)) { + } else if (MapHeader_IsOutdoors(mapHeaderID)) { if (MapHeader_IsCave(param1)) { v1 = 4; } else if (MapHeader_IsBuilding(param1)) { @@ -184,7 +182,7 @@ void sub_02056C18(FieldSystem *fieldSystem, const int param1, const int param2, } else { GF_ASSERT(FALSE); } - } else if (MapHeader_IsBuilding(v0)) { + } else if (MapHeader_IsBuilding(mapHeaderID)) { if (MapHeader_IsOutdoors(param1)) { v1 = 0; } else if (MapHeader_IsBuilding(param1)) { @@ -212,7 +210,7 @@ static BOOL sub_02056CFC(FieldTask *taskMan) switch (v1->unk_00) { case 0: v1->unk_04 = 0; - FieldBGM_TryFadeIn(fieldSystem, v2->mapId); + FieldBGM_TryFadeIn(fieldSystem, v2->mapHeaderID); FieldTask_InitCall(taskMan, Unk_020EC560[v1->unk_20], v1); (v1->unk_00)++; break; @@ -240,7 +238,7 @@ static BOOL sub_02056CFC(FieldTask *taskMan) break; } - FieldBGM_PlayForMapHeader(fieldSystem, v2->mapId); + FieldBGM_PlayForMapHeader(fieldSystem, v2->mapHeaderID); FieldSystem_RequestLocationName(fieldSystem); v1->unk_04 = 0; diff --git a/src/unk_02069BE0.c b/src/unk_02069BE0.c index ba7b2b8b0c..d6f7547317 100644 --- a/src/unk_02069BE0.c +++ b/src/unk_02069BE0.c @@ -311,7 +311,7 @@ MapObject *sub_02069EB8(MapObject *mapObj) { int v0 = 0; int v1 = MapObject_GetTrainerType(mapObj); - int v2 = MapObject_GetMapID(mapObj); + enum MapHeaderID mapHeaderID = MapObject_GetMapHeaderID(mapObj); u32 v3 = MapObject_GetTrainerID(mapObj); const MapObjectManager *mapObjMan = MapObject_MapObjectManager(mapObj); MapObject *v5; @@ -326,7 +326,7 @@ MapObject *sub_02069EB8(MapObject *mapObj) case 0x7: case 0x8: while (MapObjectMan_FindObjectWithStatus(mapObjMan, &v5, &v0, (1 << 0)) == 1) { - if ((mapObj != v5) && (MapObject_GetMapID(v5) == v2)) { + if ((mapObj != v5) && (MapObject_GetMapHeaderID(v5) == mapHeaderID)) { if (MapObject_GetTrainerID(v5) == v3) { return v5; } @@ -339,17 +339,18 @@ MapObject *sub_02069EB8(MapObject *mapObj) static int sub_02069F48(MapObject *mapObj, UnkStruct_02069F48 *param1) { - int v0, v1; + int v0; + enum MapHeaderID v1; u32 v2; MapObject *v3; const MapObjectManager *mapObjMan = MapObject_MapObjectManager(mapObj); v0 = 0; - v1 = MapObject_GetMapID(mapObj); + v1 = MapObject_GetMapHeaderID(mapObj); v2 = MapObject_GetTrainerID(mapObj); while (MapObjectMan_FindObjectWithStatus(mapObjMan, &v3, &v0, (1 << 0)) == 1) { - if ((mapObj != v3) && (MapObject_GetMapID(v3) == v1) && (MapObject_GetTrainerID(v3) == v2)) { + if ((mapObj != v3) && (MapObject_GetMapHeaderID(v3) == v1) && (MapObject_GetTrainerID(v3) == v2)) { if (param1->unk_01 == 0) { sub_02069FC4(mapObj, param1, v3); } diff --git a/src/unk_0206B9D8.c b/src/unk_0206B9D8.c index 9946721f0f..6548d2034c 100644 --- a/src/unk_0206B9D8.c +++ b/src/unk_0206B9D8.c @@ -499,7 +499,7 @@ u32 sub_0206C068(SaveData *saveData) BOOL FieldSystem_IsInBattleTowerSalon(FieldSystem *fieldSystem) { - if (fieldSystem->location->mapId == MAP_HEADER_BATTLE_TOWER_BATTLE_SALON) { + if (fieldSystem->location->mapHeaderID == MAP_HEADER_BATTLE_TOWER_BATTLE_SALON) { return TRUE; } diff --git a/src/unk_0208BA78.c b/src/unk_0208BA78.c index dc0919c98a..cf3e0290bd 100644 --- a/src/unk_0208BA78.c +++ b/src/unk_0208BA78.c @@ -320,9 +320,9 @@ static BOOL sub_0208BC8C(UnkStruct_0208BC3C *param0, enum HeapID heapID) sub_02005464(0); Sound_SetScene(SOUND_SCENE_NONE); - bgmID = FieldBGM_GetEffective(param0->fieldSystem, param0->fieldSystem->location->mapId); + bgmID = FieldBGM_GetEffective(param0->fieldSystem, param0->fieldSystem->location->mapHeaderID); - Sound_SetFieldBGM(FieldBGM_GetForMapHeader(param0->fieldSystem, param0->fieldSystem->location->mapId)); + Sound_SetFieldBGM(FieldBGM_GetForMapHeader(param0->fieldSystem, param0->fieldSystem->location->mapHeaderID)); Sound_SetSceneAndPlayBGM(SOUND_SCENE_FIELD, bgmID, 1); }