diff --git a/data/event_scripts.s b/data/event_scripts.s index f6937b3fc..dc398d9e5 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -1090,3 +1090,11 @@ EventScript_VsSeekerChargingDone:: .include "data/maps/PowerPlantTemplates_Connections/scripts.inc" .include "data/maps/PowerPlantTemplates_BossRoom/scripts.inc" + + .include "data/maps/PowerPlantTemplates_ShopRoom/scripts.inc" + + .include "data/maps/PowerPlantTemplates_TreasureRoom/scripts.inc" + + .include "data/maps/PowerPlantTemplates_ChallengeRoom/scripts.inc" + + .include "data/maps/PowerPlantTemplates_Room1/scripts.inc" diff --git a/data/layouts/PowerPlantTemplates_BossRoom/map.bin b/data/layouts/PowerPlantTemplates_BossRoom/map.bin index 53d65cd79..643b5acde 100644 Binary files a/data/layouts/PowerPlantTemplates_BossRoom/map.bin and b/data/layouts/PowerPlantTemplates_BossRoom/map.bin differ diff --git a/data/layouts/PowerPlantTemplates_ChallengeRoom/border.bin b/data/layouts/PowerPlantTemplates_ChallengeRoom/border.bin new file mode 100644 index 000000000..03bcafef1 --- /dev/null +++ b/data/layouts/PowerPlantTemplates_ChallengeRoom/border.bin @@ -0,0 +1 @@ +ÔÕÜÝ \ No newline at end of file diff --git a/data/layouts/PowerPlantTemplates_ChallengeRoom/map.bin b/data/layouts/PowerPlantTemplates_ChallengeRoom/map.bin new file mode 100644 index 000000000..643b5acde Binary files /dev/null and b/data/layouts/PowerPlantTemplates_ChallengeRoom/map.bin differ diff --git a/data/layouts/PowerPlantTemplates_Connections/map.bin b/data/layouts/PowerPlantTemplates_Connections/map.bin index 9f9a5ce2c..83e4f4995 100644 Binary files a/data/layouts/PowerPlantTemplates_Connections/map.bin and b/data/layouts/PowerPlantTemplates_Connections/map.bin differ diff --git a/data/layouts/PowerPlantTemplates_Room1/border.bin b/data/layouts/PowerPlantTemplates_Room1/border.bin new file mode 100644 index 000000000..12819766e --- /dev/null +++ b/data/layouts/PowerPlantTemplates_Room1/border.bin @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/data/layouts/PowerPlantTemplates_Room1/map.bin b/data/layouts/PowerPlantTemplates_Room1/map.bin new file mode 100644 index 000000000..643b5acde Binary files /dev/null and b/data/layouts/PowerPlantTemplates_Room1/map.bin differ diff --git a/data/layouts/PowerPlantTemplates_ShopRoom/border.bin b/data/layouts/PowerPlantTemplates_ShopRoom/border.bin new file mode 100644 index 000000000..03bcafef1 --- /dev/null +++ b/data/layouts/PowerPlantTemplates_ShopRoom/border.bin @@ -0,0 +1 @@ +ÔÕÜÝ \ No newline at end of file diff --git a/data/layouts/PowerPlantTemplates_ShopRoom/map.bin b/data/layouts/PowerPlantTemplates_ShopRoom/map.bin new file mode 100644 index 000000000..643b5acde Binary files /dev/null and b/data/layouts/PowerPlantTemplates_ShopRoom/map.bin differ diff --git a/data/layouts/PowerPlantTemplates_TreasureRoom/border.bin b/data/layouts/PowerPlantTemplates_TreasureRoom/border.bin new file mode 100644 index 000000000..03bcafef1 --- /dev/null +++ b/data/layouts/PowerPlantTemplates_TreasureRoom/border.bin @@ -0,0 +1 @@ +ÔÕÜÝ \ No newline at end of file diff --git a/data/layouts/PowerPlantTemplates_TreasureRoom/map.bin b/data/layouts/PowerPlantTemplates_TreasureRoom/map.bin new file mode 100644 index 000000000..643b5acde Binary files /dev/null and b/data/layouts/PowerPlantTemplates_TreasureRoom/map.bin differ diff --git a/data/layouts/layouts.json b/data/layouts/layouts.json index d1eba7c17..7e168184e 100644 --- a/data/layouts/layouts.json +++ b/data/layouts/layouts.json @@ -4475,7 +4475,7 @@ "id": "LAYOUT_POWER_PLANT_TEMPLATES_CONNECTIONS", "name": "PowerPlantTemplates_Connections_Layout", "width": 5, - "height": 20, + "height": 28, "primary_tileset": "gTileset_General", "secondary_tileset": "gTileset_PowerPlant", "border_filepath": "data/layouts/PowerPlantTemplates_Connections/border.bin", @@ -4484,12 +4484,52 @@ { "id": "LAYOUT_POWER_PLANT_TEMPLATES_BOSS_ROOM", "name": "PowerPlantTemplates_BossRoom_Layout", - "width": 16, - "height": 14, + "width": 17, + "height": 21, "primary_tileset": "gTileset_General", "secondary_tileset": "gTileset_PowerPlant", "border_filepath": "data/layouts/PowerPlantTemplates_BossRoom/border.bin", "blockdata_filepath": "data/layouts/PowerPlantTemplates_BossRoom/map.bin" + }, + { + "id": "LAYOUT_POWER_PLANT_TEMPLATES_SHOP_ROOM", + "name": "PowerPlantTemplates_ShopRoom_Layout", + "width": 17, + "height": 21, + "primary_tileset": "gTileset_General", + "secondary_tileset": "gTileset_PowerPlant", + "border_filepath": "data/layouts/PowerPlantTemplates_ShopRoom/border.bin", + "blockdata_filepath": "data/layouts/PowerPlantTemplates_ShopRoom/map.bin" + }, + { + "id": "LAYOUT_POWER_PLANT_TEMPLATES_TREASURE_ROOM", + "name": "PowerPlantTemplates_TreasureRoom_Layout", + "width": 17, + "height": 21, + "primary_tileset": "gTileset_General", + "secondary_tileset": "gTileset_PowerPlant", + "border_filepath": "data/layouts/PowerPlantTemplates_TreasureRoom/border.bin", + "blockdata_filepath": "data/layouts/PowerPlantTemplates_TreasureRoom/map.bin" + }, + { + "id": "LAYOUT_POWER_PLANT_TEMPLATES_CHALLENGE_ROOM", + "name": "PowerPlantTemplates_ChallengeRoom_Layout", + "width": 17, + "height": 21, + "primary_tileset": "gTileset_General", + "secondary_tileset": "gTileset_PowerPlant", + "border_filepath": "data/layouts/PowerPlantTemplates_ChallengeRoom/border.bin", + "blockdata_filepath": "data/layouts/PowerPlantTemplates_ChallengeRoom/map.bin" + }, + { + "id": "LAYOUT_POWER_PLANT_TEMPLATES_ROOM1", + "name": "PowerPlantTemplates_Room1_Layout", + "width": 17, + "height": 21, + "primary_tileset": "gTileset_General", + "secondary_tileset": "gTileset_PowerPlant", + "border_filepath": "data/layouts/PowerPlantTemplates_Room1/border.bin", + "blockdata_filepath": "data/layouts/PowerPlantTemplates_Room1/map.bin" } ] } diff --git a/data/maps/PowerPlantTemplates_BossRoom/map.json b/data/maps/PowerPlantTemplates_BossRoom/map.json index 4edb04533..c6a4baefd 100644 --- a/data/maps/PowerPlantTemplates_BossRoom/map.json +++ b/data/maps/PowerPlantTemplates_BossRoom/map.json @@ -18,36 +18,36 @@ ], "warp_events": [ { - "x": 7, - "y": 7, + "x": 8, + "y": 11, "elevation": 0, "dest_map": "MAP_POWER_PLANT_TEMPLATES_BOSS_ROOM", "dest_warp_id": "0" }, { - "x": 7, + "x": 8, "y": 1, "elevation": 0, "dest_map": "MAP_POWER_PLANT_TEMPLATES_BOSS_ROOM", "dest_warp_id": "0" }, { - "x": 7, - "y": 12, + "x": 8, + "y": 19, "elevation": 0, "dest_map": "MAP_POWER_PLANT_TEMPLATES_BOSS_ROOM", "dest_warp_id": "0" }, { - "x": 13, - "y": 7, + "x": 15, + "y": 11, "elevation": 0, "dest_map": "MAP_POWER_PLANT_TEMPLATES_BOSS_ROOM", "dest_warp_id": "0" }, { - "x": 2, - "y": 7, + "x": 1, + "y": 11, "elevation": 0, "dest_map": "MAP_POWER_PLANT_TEMPLATES_BOSS_ROOM", "dest_warp_id": "0" diff --git a/data/maps/PowerPlantTemplates_ChallengeRoom/map.json b/data/maps/PowerPlantTemplates_ChallengeRoom/map.json new file mode 100644 index 000000000..738c5cdd2 --- /dev/null +++ b/data/maps/PowerPlantTemplates_ChallengeRoom/map.json @@ -0,0 +1,28 @@ +{ + "id": "MAP_POWER_PLANT_TEMPLATES_CHALLENGE_ROOM", + "name": "PowerPlantTemplates_ChallengeRoom", + "layout": "LAYOUT_POWER_PLANT_TEMPLATES_CHALLENGE_ROOM", + "music": "MUS_DUMMY", + "region_map_section": "MAPSEC_ABANDONED_SHIP", + "requires_flash": false, + "weather": "WEATHER_NONE", + "map_type": "MAP_TYPE_NONE", + "allow_cycling": false, + "allow_escaping": false, + "allow_running": true, + "show_map_name": false, + "battle_scene": "MAP_BATTLE_SCENE_NORMAL", + "connections": 0, + "object_events": [ + + ], + "warp_events": [ + + ], + "coord_events": [ + + ], + "bg_events": [ + + ] +} diff --git a/data/maps/PowerPlantTemplates_ChallengeRoom/scripts.inc b/data/maps/PowerPlantTemplates_ChallengeRoom/scripts.inc new file mode 100644 index 000000000..669758f7a --- /dev/null +++ b/data/maps/PowerPlantTemplates_ChallengeRoom/scripts.inc @@ -0,0 +1,2 @@ +PowerPlantTemplates_ChallengeRoom_MapScripts:: + .byte 0 diff --git a/data/maps/PowerPlantTemplates_Room1/map.json b/data/maps/PowerPlantTemplates_Room1/map.json new file mode 100644 index 000000000..3086c8908 --- /dev/null +++ b/data/maps/PowerPlantTemplates_Room1/map.json @@ -0,0 +1,87 @@ +{ + "id": "MAP_POWER_PLANT_TEMPLATES_ROOM1", + "name": "PowerPlantTemplates_Room1", + "layout": "LAYOUT_POWER_PLANT_TEMPLATES_ROOM1", + "music": "MUS_DUMMY", + "region_map_section": "MAPSEC_ABANDONED_SHIP", + "requires_flash": false, + "weather": "WEATHER_NONE", + "map_type": "MAP_TYPE_NONE", + "allow_cycling": false, + "allow_escaping": false, + "allow_running": true, + "show_map_name": false, + "battle_scene": "MAP_BATTLE_SCENE_NORMAL", + "connections": 0, + "object_events": [ + { + "graphics_id": "OBJ_EVENT_GFX_MON_BASE", + "x": 11, + "y": 6, + "elevation": 0, + "movement_type": "MOVEMENT_TYPE_ENCOUNTER_TRACK_PLAYER", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "4", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_MON_BASE", + "x": 4, + "y": 16, + "elevation": 0, + "movement_type": "MOVEMENT_TYPE_ENCOUNTER_TRACK_PLAYER", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "4", + "script": "NULL", + "flag": "0" + } + ], + "warp_events": [ + { + "x": 8, + "y": 11, + "elevation": 0, + "dest_map": "MAP_POWER_PLANT_TEMPLATES_ROOM1", + "dest_warp_id": "0" + }, + { + "x": 8, + "y": 1, + "elevation": 0, + "dest_map": "MAP_POWER_PLANT_TEMPLATES_ROOM1", + "dest_warp_id": "0" + }, + { + "x": 8, + "y": 19, + "elevation": 0, + "dest_map": "MAP_POWER_PLANT_TEMPLATES_ROOM1", + "dest_warp_id": "0" + }, + { + "x": 15, + "y": 11, + "elevation": 0, + "dest_map": "MAP_POWER_PLANT_TEMPLATES_ROOM1", + "dest_warp_id": "0" + }, + { + "x": 1, + "y": 11, + "elevation": 0, + "dest_map": "MAP_POWER_PLANT_TEMPLATES_ROOM1", + "dest_warp_id": "0" + } + ], + "coord_events": [ + + ], + "bg_events": [ + + ] +} diff --git a/data/maps/PowerPlantTemplates_Room1/scripts.inc b/data/maps/PowerPlantTemplates_Room1/scripts.inc new file mode 100644 index 000000000..d00f1d42a --- /dev/null +++ b/data/maps/PowerPlantTemplates_Room1/scripts.inc @@ -0,0 +1,2 @@ +PowerPlantTemplates_Room1_MapScripts:: + .byte 0 diff --git a/data/maps/PowerPlantTemplates_ShopRoom/map.json b/data/maps/PowerPlantTemplates_ShopRoom/map.json new file mode 100644 index 000000000..1e9c126cf --- /dev/null +++ b/data/maps/PowerPlantTemplates_ShopRoom/map.json @@ -0,0 +1,28 @@ +{ + "id": "MAP_POWER_PLANT_TEMPLATES_SHOP_ROOM", + "name": "PowerPlantTemplates_ShopRoom", + "layout": "LAYOUT_POWER_PLANT_TEMPLATES_SHOP_ROOM", + "music": "MUS_DUMMY", + "region_map_section": "MAPSEC_ABANDONED_SHIP", + "requires_flash": false, + "weather": "WEATHER_NONE", + "map_type": "MAP_TYPE_NONE", + "allow_cycling": false, + "allow_escaping": false, + "allow_running": true, + "show_map_name": false, + "battle_scene": "MAP_BATTLE_SCENE_NORMAL", + "connections": 0, + "object_events": [ + + ], + "warp_events": [ + + ], + "coord_events": [ + + ], + "bg_events": [ + + ] +} diff --git a/data/maps/PowerPlantTemplates_ShopRoom/scripts.inc b/data/maps/PowerPlantTemplates_ShopRoom/scripts.inc new file mode 100644 index 000000000..11ff170dd --- /dev/null +++ b/data/maps/PowerPlantTemplates_ShopRoom/scripts.inc @@ -0,0 +1,2 @@ +PowerPlantTemplates_ShopRoom_MapScripts:: + .byte 0 diff --git a/data/maps/PowerPlantTemplates_TreasureRoom/map.json b/data/maps/PowerPlantTemplates_TreasureRoom/map.json new file mode 100644 index 000000000..df2f076b6 --- /dev/null +++ b/data/maps/PowerPlantTemplates_TreasureRoom/map.json @@ -0,0 +1,28 @@ +{ + "id": "MAP_POWER_PLANT_TEMPLATES_TREASURE_ROOM", + "name": "PowerPlantTemplates_TreasureRoom", + "layout": "LAYOUT_POWER_PLANT_TEMPLATES_TREASURE_ROOM", + "music": "MUS_DUMMY", + "region_map_section": "MAPSEC_ABANDONED_SHIP", + "requires_flash": false, + "weather": "WEATHER_NONE", + "map_type": "MAP_TYPE_NONE", + "allow_cycling": false, + "allow_escaping": false, + "allow_running": true, + "show_map_name": false, + "battle_scene": "MAP_BATTLE_SCENE_NORMAL", + "connections": 0, + "object_events": [ + + ], + "warp_events": [ + + ], + "coord_events": [ + + ], + "bg_events": [ + + ] +} diff --git a/data/maps/PowerPlantTemplates_TreasureRoom/scripts.inc b/data/maps/PowerPlantTemplates_TreasureRoom/scripts.inc new file mode 100644 index 000000000..981977784 --- /dev/null +++ b/data/maps/PowerPlantTemplates_TreasureRoom/scripts.inc @@ -0,0 +1,2 @@ +PowerPlantTemplates_TreasureRoom_MapScripts:: + .byte 0 diff --git a/data/maps/map_groups.json b/data/maps/map_groups.json index 7e881547a..1cc6b7e1a 100644 --- a/data/maps/map_groups.json +++ b/data/maps/map_groups.json @@ -633,6 +633,10 @@ ], "gMapGroup_PowerPlantTemplates": [ "PowerPlantTemplates_Connections", - "PowerPlantTemplates_BossRoom" + "PowerPlantTemplates_BossRoom", + "PowerPlantTemplates_ShopRoom", + "PowerPlantTemplates_TreasureRoom", + "PowerPlantTemplates_ChallengeRoom", + "PowerPlantTemplates_Room1" ] } diff --git a/data/tilesets/secondary/power_plant/metatiles.bin b/data/tilesets/secondary/power_plant/metatiles.bin index 6e4ec8ca0..93ec48757 100644 Binary files a/data/tilesets/secondary/power_plant/metatiles.bin and b/data/tilesets/secondary/power_plant/metatiles.bin differ diff --git a/include/constants/layouts.h b/include/constants/layouts.h index fa3326522..230468828 100755 --- a/include/constants/layouts.h +++ b/include/constants/layouts.h @@ -454,5 +454,9 @@ #define LAYOUT_CAVE_TEMPLATES_ROOM1 447 #define LAYOUT_POWER_PLANT_TEMPLATES_CONNECTIONS 448 #define LAYOUT_POWER_PLANT_TEMPLATES_BOSS_ROOM 449 +#define LAYOUT_POWER_PLANT_TEMPLATES_SHOP_ROOM 450 +#define LAYOUT_POWER_PLANT_TEMPLATES_TREASURE_ROOM 451 +#define LAYOUT_POWER_PLANT_TEMPLATES_CHALLENGE_ROOM 452 +#define LAYOUT_POWER_PLANT_TEMPLATES_ROOM1 453 #endif // GUARD_CONSTANTS_LAYOUTS_H diff --git a/include/constants/map_groups.h b/include/constants/map_groups.h index 020f44450..0911aa410 100755 --- a/include/constants/map_groups.h +++ b/include/constants/map_groups.h @@ -600,8 +600,12 @@ #define MAP_CAVE_TEMPLATES_ROOM1 (5 | (34 << 8)) // gMapGroup_PowerPlantTemplates -#define MAP_POWER_PLANT_TEMPLATES_CONNECTIONS (0 | (35 << 8)) -#define MAP_POWER_PLANT_TEMPLATES_BOSS_ROOM (1 | (35 << 8)) +#define MAP_POWER_PLANT_TEMPLATES_CONNECTIONS (0 | (35 << 8)) +#define MAP_POWER_PLANT_TEMPLATES_BOSS_ROOM (1 | (35 << 8)) +#define MAP_POWER_PLANT_TEMPLATES_SHOP_ROOM (2 | (35 << 8)) +#define MAP_POWER_PLANT_TEMPLATES_TREASURE_ROOM (3 | (35 << 8)) +#define MAP_POWER_PLANT_TEMPLATES_CHALLENGE_ROOM (4 | (35 << 8)) +#define MAP_POWER_PLANT_TEMPLATES_ROOM1 (5 | (35 << 8)) #define MAP_GROUPS_COUNT 36 diff --git a/include/fieldmap.h b/include/fieldmap.h index ecb1e49c4..70959bdfe 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -49,8 +49,8 @@ void LoadSecondaryTilesetPalette(struct MapLayout const *mapLayout); void CopySecondaryTilesetToVramUsingHeap(struct MapLayout const *mapLayout); void CopyPrimaryTilesetToVram(const struct MapLayout *); void CopySecondaryTilesetToVram(const struct MapLayout *); -const struct MapHeader *const GetMapHeaderFromConnection(const struct MapConnection *connection); -const struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y); +const struct MapHeader *const GetMapHeaderFromConnection(struct MapConnection connection); +struct MapConnection GetMapConnectionAtPos(s16 x, s16 y); void MapGridSetMetatileImpassabilityAt(int x, int y, bool32 impassable); // field_region_map.c diff --git a/include/map_gen.h b/include/map_gen.h index 0691b5f63..97767f080 100644 --- a/include/map_gen.h +++ b/include/map_gen.h @@ -13,7 +13,9 @@ #define MIN_ROOMS 7 #define MAX_ROOMS 20 #define STARTING_ROOM 45 -#define TEMPLATE_MAP_GROUP_START 1 + +// Template Constants +#define TEMPLATE_MAP_GROUP_START 34 // Room Constants #define ROOM_COORD(x, y) ((x+1) + (y+1)*10) // gFloorplan.layout is not zero-indexed @@ -38,6 +40,11 @@ enum TemplateTypes { TEMPLATE_TYPES_COUNT, }; +enum ConnectionTypes { + CONNECTION_TYPE_WARP, + CONNECTION_TYPE_SEAMLESS, +}; + struct Floorplan { u8 numRooms; u8 maxRooms; @@ -54,7 +61,7 @@ struct TemplateRules { u16 bgm; u8 previewId; u8 battleTerrain; - u8 lighting; // stored as hours + u8 connectionType; s8 offsets[5][2]; // (x, y) entrance cover offsets for each direction u8 numNormalRooms; const u8* normalRoomIds; @@ -83,17 +90,17 @@ extern struct Floorplan gFloorplan; extern const struct TemplateRules gTemplateRules[TEMPLATE_TYPES_COUNT]; extern const struct CharacterInfo gCharacterInfos[CHARACTERS_COUNT]; -void DebugPrintFloorplan(struct Floorplan* floorplan); -void SetRoomAsVisited(u8 i); -bool32 IsRoomVisited(u8 i); -bool32 DoesRoomExist(u8 i); -bool32 IsRoomAdjacentToVisited(u8 i); +void SetRoomAsVisited(u32 i); +bool32 IsRoomVisited(u32 i); +bool32 DoesRoomExist(u32 i); +bool32 IsRoomAdjacentToVisited(u32 i); u32 GetRoomInDirection(u32 dir); bool32 IsPlayerInFloorMap(void); void SetWarpDestinationToRoom(u32 index, u32 warpId); bool32 TryWarpToRoom(u32 target, u32 warpId); u32 GetRoomType(u32 index); -const struct TemplateRules* GetTemplateRules(enum TemplateTypes templateType); +const struct TemplateRules* GetCurrentTemplateRules(void); +const struct MapHeader * const GetRoomMapHeader(u32 i); u16 GetRoomSeed(u32 index); void SetRNGToRoomSeed(void); void GenerateFloorplan(void); diff --git a/src/battle_setup.c b/src/battle_setup.c index 1079f6378..26337fb87 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -738,7 +738,7 @@ u8 BattleSetup_GetTerrainId(void) tileBehavior = MapGridGetMetatileBehaviorAt(x, y); if (IsPlayerInFloorMap()) - return GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->battleTerrain; + return GetCurrentTemplateRules()->battleTerrain; if (MetatileBehavior_IsTallGrass(tileBehavior)) return BATTLE_TERRAIN_GRASS; diff --git a/src/continue_screen.c b/src/continue_screen.c index 285e52b35..9826dfb1c 100644 --- a/src/continue_screen.c +++ b/src/continue_screen.c @@ -341,7 +341,7 @@ static void LoadContinueScreenGfx(void) static void LoadMapPreviewGfx(void) { - struct MapPreview data = gMapPreviewData[GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->previewId]; + struct MapPreview data = gMapPreviewData[GetCurrentTemplateRules()->previewId]; DecompressAndCopyTileDataToVram(2, data.tiles, 0, 0, 0); LZDecompressWram(data.map, sMapPreviewTilemapPtr); LoadPalette(data.palette, BG_PLTT_ID(13), PLTT_SIZE_4BPP); diff --git a/src/data/map_group_count.h b/src/data/map_group_count.h index 102f24c8c..f9462553c 100644 --- a/src/data/map_group_count.h +++ b/src/data/map_group_count.h @@ -1 +1 @@ -static const u8 MAP_GROUP_COUNT[] = {57, 5, 5, 6, 7, 8, 9, 7, 7, 14, 8, 17, 10, 23, 13, 15, 15, 2, 2, 2, 3, 1, 1, 1, 108, 61, 89, 2, 1, 13, 1, 1, 3, 1, 6, 2, 0}; +static const u8 MAP_GROUP_COUNT[] = {57, 5, 5, 6, 7, 8, 9, 7, 7, 14, 8, 17, 10, 23, 13, 15, 15, 2, 2, 2, 3, 1, 1, 1, 108, 61, 89, 2, 1, 13, 1, 1, 3, 1, 6, 6, 0}; diff --git a/src/data/template_rules.h b/src/data/template_rules.h index 08f92089d..59bf8c5d1 100644 --- a/src/data/template_rules.h +++ b/src/data/template_rules.h @@ -183,7 +183,7 @@ static const u8 sCaveNormalRooms[] = // Power Plant Template Pools static const u8 sPowerPlantNormalRooms[] = { - MAP_NUM(POWER_PLANT_TEMPLATES_BOSS_ROOM), + MAP_NUM(POWER_PLANT_TEMPLATES_ROOM1), }; const struct TemplateRules gTemplateRules[TEMPLATE_TYPES_COUNT] = @@ -194,7 +194,7 @@ const struct TemplateRules gTemplateRules[TEMPLATE_TYPES_COUNT] = .bgm = MUS_RG_SEVII_CAVE, .previewId = PREVIEW_MT_MOON, .battleTerrain = BATTLE_TERRAIN_CAVE, - .lighting = 12, + .connectionType = CONNECTION_TYPE_WARP, .offsets = { [DIR_NORTH] = {-1, -1}, [DIR_SOUTH] = {-1, 1}, @@ -227,12 +227,12 @@ const struct TemplateRules gTemplateRules[TEMPLATE_TYPES_COUNT] = .bgm = MUS_RG_POKE_MANSION, .previewId = PREVIEW_POWER_PLANT, .battleTerrain = BATTLE_TERRAIN_CAVE, - .lighting = 12, + .connectionType = CONNECTION_TYPE_SEAMLESS, .offsets = { [DIR_NORTH] = {-2, -1}, - [DIR_SOUTH] = {-2, -3}, - [DIR_EAST] = {-2, -2}, - [DIR_WEST] = {-2, -2}, + [DIR_SOUTH] = {-2, -5}, + [DIR_EAST] = {-3, -4}, + [DIR_WEST] = {-1, -4}, }, .numNormalRooms = ARRAY_COUNT(sPowerPlantNormalRooms), .normalRoomIds = sPowerPlantNormalRooms, @@ -244,6 +244,12 @@ const struct TemplateRules gTemplateRules[TEMPLATE_TYPES_COUNT] = .itemPools = gDefaultItemPools, .encounterPool = { {SPECIES_MAGNEMITE, 100}, + {SPECIES_MAGNETON, 100}, + {SPECIES_VOLTORB, 100}, + {SPECIES_PLUSLE, 100}, + {SPECIES_MINUN, 100}, + {SPECIES_ZIGZAGOON, 100}, + {SPECIES_GRIMER, 100}, } }, }; diff --git a/src/field_weather_effect.c b/src/field_weather_effect.c index 9494226d3..6387b0e39 100644 --- a/src/field_weather_effect.c +++ b/src/field_weather_effect.c @@ -1402,7 +1402,7 @@ void FogHorizontal_Main(void) case 0: CreateFogHorizontalSprites(); if (gWeatherPtr->currWeather == WEATHER_FOG_HORIZONTAL) { - u8 paletteNum = IndexOfSpritePaletteTag(TAG_WEATHER_START); + // u8 paletteNum = IndexOfSpritePaletteTag(TAG_WEATHER_START); Weather_SetTargetBlendCoeffs(12, 8, 3); UpdateShadowColor(0x3DEF); // Gray } else diff --git a/src/fieldmap.c b/src/fieldmap.c index a231afe51..6191a526a 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -46,8 +46,8 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader); static void LoadSavedMapView(void); static bool8 SkipCopyingMetatileFromSavedMap(u16 *mapBlock, u16 mapWidth, u8 yMode); -static const struct MapConnection *GetIncomingConnection(u8 direction, int x, int y); -static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, const struct MapConnection *connection); +static struct MapConnection GetIncomingConnection(u8 direction, int x, int y); +static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, struct MapConnection connection); static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, int offset); static inline u16 GetBorderBlockAt(int x, int y) @@ -61,9 +61,9 @@ static inline u16 GetBorderBlockAt(int x, int y) #define GetMapGridBlockAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? gBackupMapLayout.map[x + gBackupMapLayout.width * y] : GetBorderBlockAt(x, y)) -const struct MapHeader *const GetMapHeaderFromConnection(const struct MapConnection *connection) +const struct MapHeader *const GetMapHeaderFromConnection(struct MapConnection connection) { - return Overworld_GetMapHeaderByGroupAndId(connection->mapGroup, connection->mapNum); + return Overworld_GetMapHeaderByGroupAndId(connection.mapGroup, connection.mapNum); } void InitMap(void) @@ -139,19 +139,19 @@ static void InitBackupMapLayoutData(const u16 *map, u16 width, u16 height) static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader) { int count; - const struct MapConnection *connection; + struct MapConnection connection; int i; if (mapHeader->connections) { count = mapHeader->connections->count; - connection = mapHeader->connections->connections; sMapConnectionFlags = sDummyConnectionFlags; - for (i = 0; i < count; i++, connection++) + for (i = 0; i < count; ++i) { + connection = mapHeader->connections->connections[i]; struct MapHeader const *cMap = GetMapHeaderFromConnection(connection); - u32 offset = connection->offset; - switch (connection->direction) + u32 offset = connection.offset; + switch (connection.direction) { case CONNECTION_SOUTH: FillSouthConnection(mapHeader, cMap, offset); @@ -172,6 +172,37 @@ static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader) } } } + // Fill dynamic connections for floors with seamless connections. + else if (IsPlayerInFloorMap() && GetCurrentTemplateRules()->connectionType == CONNECTION_TYPE_SEAMLESS) + { + for (i = DIR_SOUTH; i <= DIR_EAST; ++i) + { + if (DoesRoomExist(GetRoomInDirection(i))) + { + struct MapHeader const *cMap = GetRoomMapHeader(GetRoomInDirection(i)); + switch (i) + { + case DIR_SOUTH: + FillSouthConnection(mapHeader, cMap, 0); + sMapConnectionFlags.south = TRUE; + break; + case DIR_NORTH: + FillNorthConnection(mapHeader, cMap, 0); + sMapConnectionFlags.north = TRUE; + break; + case DIR_WEST: + FillWestConnection(mapHeader, cMap, 0); + sMapConnectionFlags.west = TRUE; + break; + case DIR_EAST: + FillEastConnection(mapHeader, cMap, 0); + sMapConnectionFlags.east = TRUE; + break; + } + + } + } + } } static void FillConnection(int x, int y, struct MapHeader const *connectedMapHeader, int x2, int y2, int width, int height) @@ -625,7 +656,7 @@ bool32 CanCameraMoveInDirection(int direction) return TRUE; } -static void SetPositionFromConnection(const struct MapConnection *connection, int direction, int x, int y) +static void SetPositionFromConnection(struct MapConnection connection, int direction, int x, int y) { struct MapHeader const *mapHeader = GetMapHeaderFromConnection(connection); @@ -633,18 +664,18 @@ static void SetPositionFromConnection(const struct MapConnection *connection, in { case CONNECTION_EAST: gSaveBlock1Ptr->pos.x = -x; - gSaveBlock1Ptr->pos.y -= connection->offset; + gSaveBlock1Ptr->pos.y -= connection.offset; break; case CONNECTION_WEST: gSaveBlock1Ptr->pos.x = mapHeader->mapLayout->width; - gSaveBlock1Ptr->pos.y -= connection->offset; + gSaveBlock1Ptr->pos.y -= connection.offset; break; case CONNECTION_SOUTH: - gSaveBlock1Ptr->pos.x -= connection->offset; + gSaveBlock1Ptr->pos.x -= connection.offset; gSaveBlock1Ptr->pos.y = -y; break; case CONNECTION_NORTH: - gSaveBlock1Ptr->pos.x -= connection->offset; + gSaveBlock1Ptr->pos.x -= connection.offset; gSaveBlock1Ptr->pos.y = mapHeader->mapLayout->height; break; default: @@ -656,7 +687,7 @@ static void SetPositionFromConnection(const struct MapConnection *connection, in bool8 CameraMove(int x, int y) { int direction; - const struct MapConnection *connection; + struct MapConnection connection; int old_x, old_y; gCamera.active = FALSE; direction = GetPostCameraMoveMapBorderId(x, y); @@ -672,10 +703,12 @@ bool8 CameraMove(int x, int y) old_x = gSaveBlock1Ptr->pos.x; old_y = gSaveBlock1Ptr->pos.y; connection = GetIncomingConnection(direction, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y); - if (connection) + if (connection.direction != 0xFF) { SetPositionFromConnection(connection, direction, x, y); - LoadMapFromCameraTransition(connection->mapGroup, connection->mapNum); + gSaveBlock1Ptr->currentRoom = GetRoomInDirection(direction); + SetRoomAsVisited(GetRoomInDirection(direction)); + LoadMapFromCameraTransition(connection.mapGroup, connection.mapNum); gCamera.active = TRUE; gCamera.x = old_x - gSaveBlock1Ptr->pos.x; gCamera.y = old_y - gSaveBlock1Ptr->pos.y; @@ -692,28 +725,39 @@ bool8 CameraMove(int x, int y) return gCamera.active; } -static const struct MapConnection *GetIncomingConnection(u8 direction, int x, int y) +static struct MapConnection GetIncomingConnection(u8 direction, int x, int y) { int count; int i; - const struct MapConnection *connection; + struct MapConnection connection = {0}, empty = {0xFF}; const struct MapConnections *connections = gMapHeader.connections; + if (IsPlayerInFloorMap() && DoesRoomExist(GetRoomInDirection(direction))) + { + connection.direction = direction; + connection.mapGroup = GetCurrentTemplateRules()->mapGroup; + connection.mapNum = gFloorplan.layout[GetRoomInDirection(direction)].mapNum; + connection.offset = 0; + return connection; + } #ifdef UBFIX // UB: Multiple possible null dereferences - if (connections == NULL || connections->connections == NULL) - return NULL; + else if (connections == NULL || connections->connections == NULL) + return empty; #endif - count = connections->count; - connection = connections->connections; - for (i = 0; i < count; i++, connection++) + else { - if (connection->direction == direction && IsPosInIncomingConnectingMap(direction, x, y, connection) == TRUE) - return connection; + count = connections->count; + for (i = 0; i < count; ++i) + { + connection = connections->connections[i]; + if (connection.direction == direction && IsPosInIncomingConnectingMap(direction, x, y, connection) == TRUE) + return connection; + } } - return NULL; + return empty; } -static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, const struct MapConnection *connection) +static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, struct MapConnection connection) { struct MapHeader const *mapHeader; mapHeader = GetMapHeaderFromConnection(connection); @@ -721,10 +765,10 @@ static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, const stru { case CONNECTION_SOUTH: case CONNECTION_NORTH: - return IsCoordInIncomingConnectingMap(x, gMapHeader.mapLayout->width, mapHeader->mapLayout->width, connection->offset); + return IsCoordInIncomingConnectingMap(x, gMapHeader.mapLayout->width, mapHeader->mapLayout->width, connection.offset); case CONNECTION_WEST: case CONNECTION_EAST: - return IsCoordInIncomingConnectingMap(y, gMapHeader.mapLayout->height, mapHeader->mapLayout->height, connection->offset); + return IsCoordInIncomingConnectingMap(y, gMapHeader.mapLayout->height, mapHeader->mapLayout->height, connection.offset); } return FALSE; } @@ -754,39 +798,39 @@ static int IsCoordInConnectingMap(int coord, int max) return FALSE; } -static int IsPosInConnectingMap(const struct MapConnection *connection, int x, int y) +static int IsPosInConnectingMap(struct MapConnection connection, int x, int y) { struct MapHeader const *mapHeader; mapHeader = GetMapHeaderFromConnection(connection); - switch (connection->direction) + switch (connection.direction) { case CONNECTION_SOUTH: case CONNECTION_NORTH: - return IsCoordInConnectingMap(x - connection->offset, mapHeader->mapLayout->width); + return IsCoordInConnectingMap(x - connection.offset, mapHeader->mapLayout->width); case CONNECTION_WEST: case CONNECTION_EAST: - return IsCoordInConnectingMap(y - connection->offset, mapHeader->mapLayout->height); + return IsCoordInConnectingMap(y - connection.offset, mapHeader->mapLayout->height); } return FALSE; } -const struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y) +struct MapConnection GetMapConnectionAtPos(s16 x, s16 y) { int count; - const struct MapConnection *connection; + struct MapConnection connection, empty = {0xFF}; int i; u8 direction; if (!gMapHeader.connections) { - return NULL; + return empty; } else { count = gMapHeader.connections->count; - connection = gMapHeader.connections->connections; - for (i = 0; i < count; i++, connection++) + for (i = 0; i < count; i++) { - direction = connection->direction; + connection = gMapHeader.connections->connections[i]; + direction = connection.direction; if ((direction == CONNECTION_DIVE || direction == CONNECTION_EMERGE) || (direction == CONNECTION_NORTH && y > MAP_OFFSET - 1) || (direction == CONNECTION_SOUTH && y < gMapHeader.mapLayout->height + MAP_OFFSET) @@ -801,7 +845,7 @@ const struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y) } } } - return NULL; + return empty; } void SetCameraFocusCoords(u16 x, u16 y) diff --git a/src/floor_preview.c b/src/floor_preview.c index eb20d0a4a..705bb6ca1 100644 --- a/src/floor_preview.c +++ b/src/floor_preview.c @@ -220,7 +220,7 @@ static void Task_FloorPreviewFadeIn(u8 taskId) static void LoadMapPreviewGfx(void) { - struct MapPreview data = gMapPreviewData[GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->previewId]; + struct MapPreview data = gMapPreviewData[GetCurrentTemplateRules()->previewId]; DecompressAndCopyTileDataToVram(2, data.tiles, 0, 0, 0); LZDecompressWram(data.map, sMapPreviewTilemapPtr); @@ -321,7 +321,7 @@ static void DrawText(void) ptr = StringCopy(gStringVar4, sText_Floor); ptr = ConvertIntToDecimalStringN(ptr, gSaveBlock1Ptr->currentFloor, STR_CONV_MODE_LEFT_ALIGN, 1+(gSaveBlock1Ptr->currentFloor/10)); ptr = StringAppend(ptr, sText_Continue); - ptr = StringAppend(ptr, gMapPreviewData[GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->previewId].name); + ptr = StringAppend(ptr, gMapPreviewData[GetCurrentTemplateRules()->previewId].name); *ptr = CHAR_ELLIPSIS; *(++ptr) = EOS; AddTextPrinterParameterized3(WIN_CONTINUE, FONT_NORMAL, 2, 2, sTextColor_Instructions, TEXT_SKIP_DRAW, gStringVar4); @@ -367,8 +367,7 @@ static void PopulateSpeciesList(void) { for (y = 0; y < MAX_LAYOUT_HEIGHT; ++y) { - header = Overworld_GetMapHeaderByGroupAndId(GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->mapGroup, - gFloorplan.layout[ROOM_COORD(x, y)].mapNum); + header = GetRoomMapHeader(ROOM_COORD(x, y)); for (i = 0; i < header->events->objectEventCount; ++i) { if (header->events->objectEvents[i].graphicsId == OBJ_EVENT_GFX_MON_BASE) @@ -404,7 +403,7 @@ static void Task_FloorPreviewSaveAndExit(u8 taskId) break; case 1: SetContinueGameWarpStatus(); - SetWarpData(&gSaveBlock1Ptr->continueGameWarp, GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->mapGroup, + SetWarpData(&gSaveBlock1Ptr->continueGameWarp, GetCurrentTemplateRules()->mapGroup, gFloorplan.layout[STARTING_ROOM].mapNum, 0, -1, -1); TrySavingData(SAVE_NORMAL); ++(*state); diff --git a/src/item_gen.c b/src/item_gen.c index c0f232251..8b1345ae7 100644 --- a/src/item_gen.c +++ b/src/item_gen.c @@ -11,7 +11,7 @@ // Returns the pool of items for a given tier and item type. const struct WeightedElement* GetItemPool(enum ItemType type, enum ItemTier tier) { - const struct TemplateRules* rules = GetTemplateRules(gSaveBlock1Ptr->currentTemplateType); + const struct TemplateRules* rules = GetCurrentTemplateRules(); const struct ItemPoolTable* tablePtr; const struct WeightedElement* pool; diff --git a/src/item_use.c b/src/item_use.c index e711f8cd2..b1538587b 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -428,7 +428,7 @@ static bool8 IsHiddenItemPresentAtCoords(const struct MapEvents *events, s16 x, return FALSE; } -static bool8 IsHiddenItemPresentInConnection(const struct MapConnection *connection, int x, int y) +static bool8 IsHiddenItemPresentInConnection(struct MapConnection connection, int x, int y) { u16 localX, localY; @@ -437,17 +437,17 @@ static bool8 IsHiddenItemPresentInConnection(const struct MapConnection *connect struct MapHeader const *const mapHeader = GetMapHeaderFromConnection(connection); - switch (connection->direction) + switch (connection.direction) { // same weird temp variable behavior seen in IsHiddenItemPresentAtCoords case CONNECTION_NORTH: - localOffset = connection->offset + MAP_OFFSET; + localOffset = connection.offset + MAP_OFFSET; localX = x - localOffset; localLength = mapHeader->mapLayout->height - MAP_OFFSET; localY = localLength + y; // additions are reversed for some reason break; case CONNECTION_SOUTH: - localOffset = connection->offset + MAP_OFFSET; + localOffset = connection.offset + MAP_OFFSET; localX = x - localOffset; localLength = gMapHeader.mapLayout->height + MAP_OFFSET; localY = y - localLength; @@ -455,13 +455,13 @@ static bool8 IsHiddenItemPresentInConnection(const struct MapConnection *connect case CONNECTION_WEST: localLength = mapHeader->mapLayout->width - MAP_OFFSET; localX = localLength + x; // additions are reversed for some reason - localOffset = connection->offset + MAP_OFFSET; + localOffset = connection.offset + MAP_OFFSET; localY = y - localOffset; break; case CONNECTION_EAST: localLength = gMapHeader.mapLayout->width + MAP_OFFSET; localX = x - localLength; - localOffset = connection->offset + MAP_OFFSET; + localOffset = connection.offset + MAP_OFFSET; localY = y - localOffset; break; default: @@ -493,8 +493,8 @@ static void CheckForHiddenItemsInMapConnection(u8 taskId) || var2 > y || y >= height) { - const struct MapConnection *conn = GetMapConnectionAtPos(x, y); - if (conn && IsHiddenItemPresentInConnection(conn, x, y) == TRUE) + struct MapConnection conn = GetMapConnectionAtPos(x, y); + if (conn.direction != 0xFF && IsHiddenItemPresentInConnection(conn, x, y)) SetDistanceOfClosestHiddenItem(taskId, x - playerX, y - playerY); } } diff --git a/src/map_gen.c b/src/map_gen.c index 1658f680c..891f2e554 100644 --- a/src/map_gen.c +++ b/src/map_gen.c @@ -25,13 +25,14 @@ // global floorplan EWRAM_DATA struct Floorplan gFloorplan = {0}; +EWRAM_DATA struct MapConnections gRoomMapConnections = {0}; #include "data/template_rules.h" #include "data/character_infos.h" // forward declarations -static u32 CountNeighbors(struct Floorplan* floorplan, u8 i); -static bool32 Visit(struct Floorplan* floorplan, u8 i); +static u32 CountNeighbors(struct Floorplan* floorplan, u32 i); +static bool32 Visit(struct Floorplan* floorplan, u32 i); static void ZeroFloorplan(struct Floorplan* floorplan); static u8 GetMaxRooms(void); static void PopulateFloorplan(struct Floorplan* floorplan); @@ -40,25 +41,25 @@ static void AssignRoomMapIds(struct Floorplan* floorplan); static void ClearFloorEventFlags(void); // Returns the number of occupied neighbors for a room index. -static u32 CountNeighbors(struct Floorplan* floorplan, u8 i) +static u32 CountNeighbors(struct Floorplan* floorplan, u32 i) { return (floorplan->layout[i-10].type >= NORMAL_ROOM) + (floorplan->layout[i-1].type >= NORMAL_ROOM) \ + (floorplan->layout[i+1].type >= NORMAL_ROOM) + (floorplan->layout[i+10].type >= NORMAL_ROOM); } // The visited flags for a room are set in a saveblock bitfield. -void SetRoomAsVisited(u8 i) +void SetRoomAsVisited(u32 i) { gSaveBlock1Ptr->visitedRooms[i / 32] |= (1 << i % 32); } -bool32 IsRoomVisited(u8 i) +bool32 IsRoomVisited(u32 i) { return gSaveBlock1Ptr->visitedRooms[i / 32] & (1 << i % 32); } // "Visits" a room during generation and marks it as occupied or ignores it. -static bool32 Visit(struct Floorplan* floorplan, u8 i) +static bool32 Visit(struct Floorplan* floorplan, u32 i) { if (floorplan->numRooms >= floorplan->maxRooms) return FALSE; @@ -172,9 +173,9 @@ static void AssignSpecialRoomTypes(struct Floorplan* floorplan) floorplan->layout[Pop(&floorplan->endrooms)].type = CHALLENGE_ROOM; } -const struct TemplateRules* GetTemplateRules(enum TemplateTypes templateType) +const struct TemplateRules* GetCurrentTemplateRules(void) { - return &gTemplateRules[templateType]; + return &gTemplateRules[gSaveBlock1Ptr->currentTemplateType]; } // Assigns each room a map ID. @@ -182,7 +183,7 @@ static void AssignRoomMapIds(struct Floorplan* floorplan) { u32 i; struct Room* room; - const struct TemplateRules * const rules = GetTemplateRules(gSaveBlock1Ptr->currentTemplateType); + const struct TemplateRules * const rules = GetCurrentTemplateRules(); const u8 *normalPool = rules->normalRoomIds; u32 poolSize = rules->numNormalRooms; u8 *shuffled = AllocZeroed(sizeof(u8) * poolSize); @@ -215,24 +216,6 @@ static void AssignRoomMapIds(struct Floorplan* floorplan) Free(shuffled); } - -// This prints the floor layout backwards. (it is janky) -void DebugPrintFloorplan(struct Floorplan* floorplan) -{ - u32 x, y, row, exponent; - for (y = 0; y < MAX_LAYOUT_HEIGHT; ++y) - { - row = 2000000000; - exponent = 1; - for(x = 0; x < MAX_LAYOUT_WIDTH; ++x) - { - row += floorplan->layout[ROOM_COORD(x, y)].type * exponent; - exponent *= 10; - } - DebugPrintf("%d", row); - } -} - // Clears all loot and encounter flags between floors. static void ClearFloorEventFlags(void) { @@ -242,13 +225,13 @@ static void ClearFloorEventFlags(void) } // Returns whether a room in the layout exists. -bool32 DoesRoomExist(u8 i) +bool32 DoesRoomExist(u32 i) { return gFloorplan.layout[i].type >= NORMAL_ROOM; } // Returns whether a room in the layout is adjacent to a visited room. -bool32 IsRoomAdjacentToVisited(u8 i) +bool32 IsRoomAdjacentToVisited(u32 i) { if (IsRoomVisited(i - 10)) return TRUE; @@ -293,7 +276,7 @@ bool32 IsPlayerInFloorMap(void) // Sets the warp destination to the room's map ID (given by room index). void SetWarpDestinationToRoom(u32 index, u32 warpId) { - SetWarpDestination(GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->mapGroup, gFloorplan.layout[index].mapNum, warpId, -1, -1); + SetWarpDestination(GetCurrentTemplateRules()->mapGroup, gFloorplan.layout[index].mapNum, warpId, -1, -1); } // Executes a warp to a given room. @@ -375,6 +358,12 @@ void GoToNextFloor(void) SetMainCallback2(CB2_FloorPreview); } +const struct MapHeader * const GetRoomMapHeader(u32 i) +{ + return Overworld_GetMapHeaderByGroupAndId(GetCurrentTemplateRules()->mapGroup, + gFloorplan.layout[i].mapNum); +} + // Debugging function called by menu scripts. void FloorDebugFunc(void) { diff --git a/src/map_stitch.c b/src/map_stitch.c index 61581a336..36953ba92 100644 --- a/src/map_stitch.c +++ b/src/map_stitch.c @@ -64,12 +64,12 @@ static void PasteMapChunk(u16 x, u16 y, struct MapChunk *chunk) static s32 GetCoverXOffset(u32 dir) { - return GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->offsets[dir][0]; + return GetCurrentTemplateRules()->offsets[dir][0]; } static s32 GetCoverYOffset(u32 dir) { - return GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->offsets[dir][1]; + return GetCurrentTemplateRules()->offsets[dir][1]; } static void CoverExitInDirection(u32 dir) diff --git a/src/overworld.c b/src/overworld.c index f89b05737..4ad6515ac 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -853,8 +853,10 @@ if (I_VS_SEEKER_CHARGING != 0) ResetFieldTasksArgs(); RunOnResumeMapScript(); - if (gMapHeader.regionMapSectionId != MAPSEC_BATTLE_FRONTIER + if ((gMapHeader.regionMapSectionId != MAPSEC_BATTLE_FRONTIER || gMapHeader.regionMapSectionId != sLastMapSectionId) + && !IsPlayerInFloorMap()) + ShowMapNamePopup(); } @@ -1123,7 +1125,7 @@ u16 GetLocationMusic(struct WarpData *warp) { // Allow for custom music inside a floor. if (IsPlayerInFloorMap() && GetRoomType(gSaveBlock1Ptr->currentRoom) != SHOP_ROOM) - return GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->bgm; + return GetCurrentTemplateRules()->bgm; else if (NoMusicInSotopolisWithLegendaries(warp) == TRUE) return MUS_NONE; else if (ShouldLegendaryMusicPlayAtLocation(warp) == TRUE) diff --git a/src/pokemon_gen.c b/src/pokemon_gen.c index f802ad811..c20724581 100644 --- a/src/pokemon_gen.c +++ b/src/pokemon_gen.c @@ -14,5 +14,5 @@ u16 GetOverworldSpeciesInRoom(u32 index, u32 localId) for (i = 0; i < localId; ++i) RandomF(); - return ChooseElementFromPool(GetTemplateRules(gSaveBlock1Ptr->currentTemplateType)->encounterPool); + return ChooseElementFromPool(GetCurrentTemplateRules()->encounterPool); }