diff --git a/data/maps/BattleFrontier_OutsideEast/map.json b/data/maps/BattleFrontier_OutsideEast/map.json index 06cbfe2d36..ab871be653 100644 --- a/data/maps/BattleFrontier_OutsideEast/map.json +++ b/data/maps/BattleFrontier_OutsideEast/map.json @@ -526,12 +526,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "Common_EventScript_ShowPokemonCenterSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST", - "x": 3, - "y": 52 - } ] } diff --git a/data/maps/DewfordTown/map.json b/data/maps/DewfordTown/map.json index ec2e879561..ac958202a8 100644 --- a/data/maps/DewfordTown/map.json +++ b/data/maps/DewfordTown/map.json @@ -172,12 +172,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "DewfordTown_EventScript_HallSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_DEWFORD_TOWN", - "x": 2, - "y": 11 - } ] } diff --git a/data/maps/EverGrandeCity/map.json b/data/maps/EverGrandeCity/map.json index ed2d9bb9ce..58978b7ff8 100644 --- a/data/maps/EverGrandeCity/map.json +++ b/data/maps/EverGrandeCity/map.json @@ -192,17 +192,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "script": "Common_EventScript_ShowPokemonCenterSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_EVER_GRANDE_CITY", - "x": 27, - "y": 49 - }, - { - "id": "HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE", - "x": 18, - "y": 6 - } ] } diff --git a/data/maps/FallarborTown/map.json b/data/maps/FallarborTown/map.json index 41e55a3ce4..4888640a59 100644 --- a/data/maps/FallarborTown/map.json +++ b/data/maps/FallarborTown/map.json @@ -181,12 +181,5 @@ "item": "ITEM_NUGGET", "flag": "FLAG_HIDDEN_ITEM_FALLARBOR_TOWN_NUGGET" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_FALLARBOR_TOWN", - "x": 14, - "y": 8 - } ] } diff --git a/data/maps/FortreeCity/map.json b/data/maps/FortreeCity/map.json index 39483a94b5..007d8b22d7 100644 --- a/data/maps/FortreeCity/map.json +++ b/data/maps/FortreeCity/map.json @@ -232,12 +232,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "script": "Common_EventScript_ShowPokemartSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_FORTREE_CITY", - "x": 5, - "y": 7 - } ] } diff --git a/data/maps/LavaridgeTown/map.json b/data/maps/LavaridgeTown/map.json index f039af170c..1009c8c9d9 100644 --- a/data/maps/LavaridgeTown/map.json +++ b/data/maps/LavaridgeTown/map.json @@ -260,12 +260,5 @@ "item": "ITEM_ICE_HEAL", "flag": "FLAG_HIDDEN_ITEM_LAVARIDGE_TOWN_ICE_HEAL" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_LAVARIDGE_TOWN", - "x": 9, - "y": 7 - } ] } diff --git a/data/maps/LilycoveCity/map.json b/data/maps/LilycoveCity/map.json index 4115e31fe3..2eff099ab9 100644 --- a/data/maps/LilycoveCity/map.json +++ b/data/maps/LilycoveCity/map.json @@ -520,12 +520,5 @@ "item": "ITEM_POKE_BALL", "flag": "FLAG_HIDDEN_ITEM_LILYCOVE_CITY_POKE_BALL" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_LILYCOVE_CITY", - "x": 24, - "y": 15 - } ] } diff --git a/data/maps/LittlerootTown/map.json b/data/maps/LittlerootTown/map.json index e897b714a4..f5c8c7846d 100644 --- a/data/maps/LittlerootTown/map.json +++ b/data/maps/LittlerootTown/map.json @@ -268,17 +268,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "LittlerootTown_EventScript_MaysHouseSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE", - "x": 5, - "y": 9 - }, - { - "id": "HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE", - "x": 14, - "y": 9 - } ] } diff --git a/data/maps/LittlerootTown_BrendansHouse_2F/map.json b/data/maps/LittlerootTown_BrendansHouse_2F/map.json index 5bd46deeb9..9b3852767a 100644 --- a/data/maps/LittlerootTown_BrendansHouse_2F/map.json +++ b/data/maps/LittlerootTown_BrendansHouse_2F/map.json @@ -268,12 +268,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "PlayersHouse_2F_EventScript_GameCube" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F", - "x": 4, - "y": 2 - } ] } diff --git a/data/maps/LittlerootTown_MaysHouse_2F/map.json b/data/maps/LittlerootTown_MaysHouse_2F/map.json index 02d5ab06db..3cec7006c1 100644 --- a/data/maps/LittlerootTown_MaysHouse_2F/map.json +++ b/data/maps/LittlerootTown_MaysHouse_2F/map.json @@ -268,12 +268,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "LittlerootTown_MaysHouse_2F_EventScript_PC" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F", - "x": 4, - "y": 2 - } ] } diff --git a/data/maps/MauvilleCity/map.json b/data/maps/MauvilleCity/map.json index b6340a2715..cac4bf8067 100644 --- a/data/maps/MauvilleCity/map.json +++ b/data/maps/MauvilleCity/map.json @@ -299,12 +299,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "MauvilleCity_EventScript_GameCornerSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_MAUVILLE_CITY", - "x": 22, - "y": 6 - } ] } diff --git a/data/maps/MossdeepCity/map.json b/data/maps/MossdeepCity/map.json index 993f0c5520..446d2b9966 100644 --- a/data/maps/MossdeepCity/map.json +++ b/data/maps/MossdeepCity/map.json @@ -487,12 +487,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "MossdeepCity_EventScript_WhiteRock" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_MOSSDEEP_CITY", - "x": 28, - "y": 17 - } ] } diff --git a/data/maps/OldaleTown/map.json b/data/maps/OldaleTown/map.json index 991d2e50ca..d368e0bcbf 100644 --- a/data/maps/OldaleTown/map.json +++ b/data/maps/OldaleTown/map.json @@ -195,12 +195,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "script": "Common_EventScript_ShowPokemartSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_OLDALE_TOWN", - "x": 6, - "y": 17 - } ] } diff --git a/data/maps/PacifidlogTown/map.json b/data/maps/PacifidlogTown/map.json index e1f5700f17..37cfe8ad08 100644 --- a/data/maps/PacifidlogTown/map.json +++ b/data/maps/PacifidlogTown/map.json @@ -135,12 +135,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "script": "Common_EventScript_ShowPokemonCenterSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_PACIFIDLOG_TOWN", - "x": 8, - "y": 16 - } ] } diff --git a/data/maps/PetalburgCity/map.json b/data/maps/PetalburgCity/map.json index 57238192dc..3d9f2cc361 100644 --- a/data/maps/PetalburgCity/map.json +++ b/data/maps/PetalburgCity/map.json @@ -331,12 +331,5 @@ "item": "ITEM_RARE_CANDY", "flag": "FLAG_HIDDEN_ITEM_PETALBURG_CITY_RARE_CANDY" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_PETALBURG_CITY", - "x": 20, - "y": 17 - } ] } diff --git a/data/maps/RustboroCity/map.json b/data/maps/RustboroCity/map.json index 49f8a7d601..b4eadc2a77 100644 --- a/data/maps/RustboroCity/map.json +++ b/data/maps/RustboroCity/map.json @@ -603,12 +603,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "RustboroCity_EventScript_CuttersHouseSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_RUSTBORO_CITY", - "x": 16, - "y": 39 - } ] } diff --git a/data/maps/SlateportCity/map.json b/data/maps/SlateportCity/map.json index 90835cef3b..aa281c6bb8 100644 --- a/data/maps/SlateportCity/map.json +++ b/data/maps/SlateportCity/map.json @@ -702,12 +702,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "script": "SlateportCity_EventScript_BerryCrushRankingsSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_SLATEPORT_CITY", - "x": 19, - "y": 20 - } ] } diff --git a/data/maps/SootopolisCity/map.json b/data/maps/SootopolisCity/map.json index d1d9242a57..35bd4d51eb 100644 --- a/data/maps/SootopolisCity/map.json +++ b/data/maps/SootopolisCity/map.json @@ -409,12 +409,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "SootopolisCity_EventScript_CitySign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_SOOTOPOLIS_CITY", - "x": 43, - "y": 32 - } ] } diff --git a/data/maps/SouthernIsland_Exterior/map.json b/data/maps/SouthernIsland_Exterior/map.json index d7cdb1238a..f6775f2483 100644 --- a/data/maps/SouthernIsland_Exterior/map.json +++ b/data/maps/SouthernIsland_Exterior/map.json @@ -69,12 +69,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "SouthernIsland_Exterior_EventScript_Sign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR", - "x": 15, - "y": 20 - } ] } diff --git a/data/maps/VerdanturfTown/map.json b/data/maps/VerdanturfTown/map.json index 60e9d1b9be..1b29ea7153 100644 --- a/data/maps/VerdanturfTown/map.json +++ b/data/maps/VerdanturfTown/map.json @@ -196,12 +196,5 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "VerdanturfTown_EventScript_RusturfTunnelSign" } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_VERDANTURF_TOWN", - "x": 16, - "y": 4 - } ] } diff --git a/include/constants/.gitignore b/include/constants/.gitignore index ff77d833c7..5923892b4f 100644 --- a/include/constants/.gitignore +++ b/include/constants/.gitignore @@ -3,3 +3,4 @@ map_groups.h layouts.h region_map_sections.h map_event_ids.h +heal_locations.h diff --git a/include/constants/heal_locations.h b/include/constants/heal_locations.h deleted file mode 100644 index 4a9771d810..0000000000 --- a/include/constants/heal_locations.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H -#define GUARD_CONSTANTS_HEAL_LOCATIONS_H - -enum { - HEAL_LOCATION_NONE, - HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F, - HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F, - HEAL_LOCATION_PETALBURG_CITY, - HEAL_LOCATION_SLATEPORT_CITY, - HEAL_LOCATION_MAUVILLE_CITY, - HEAL_LOCATION_RUSTBORO_CITY, - HEAL_LOCATION_FORTREE_CITY, - HEAL_LOCATION_LILYCOVE_CITY, - HEAL_LOCATION_MOSSDEEP_CITY, - HEAL_LOCATION_SOOTOPOLIS_CITY, - HEAL_LOCATION_EVER_GRANDE_CITY, - HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE, - HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE, - HEAL_LOCATION_OLDALE_TOWN, - HEAL_LOCATION_DEWFORD_TOWN, - HEAL_LOCATION_LAVARIDGE_TOWN, - HEAL_LOCATION_FALLARBOR_TOWN, - HEAL_LOCATION_VERDANTURF_TOWN, - HEAL_LOCATION_PACIFIDLOG_TOWN, - HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE, - HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR, - HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST, -}; - -#endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H diff --git a/json_data_rules.mk b/json_data_rules.mk index 5847914c7c..08a2d00210 100755 --- a/json_data_rules.mk +++ b/json_data_rules.mk @@ -16,3 +16,13 @@ $(C_BUILDDIR)/region_map.o: c_dep += $(DATA_SRC_SUBDIR)/region_map/region_map_en AUTO_GEN_TARGETS += include/constants/region_map_sections.h include/constants/region_map_sections.h: $(DATA_SRC_SUBDIR)/region_map/region_map_sections.json $(DATA_SRC_SUBDIR)/region_map/region_map_sections.constants.json.txt $(JSONPROC) $^ $@ + +AUTO_GEN_TARGETS += $(DATA_SRC_SUBDIR)/heal_locations.h +$(DATA_SRC_SUBDIR)/heal_locations.h: $(DATA_SRC_SUBDIR)/heal_locations.json $(DATA_SRC_SUBDIR)/heal_locations.json.txt + $(JSONPROC) $^ $@ + +$(C_BUILDDIR)/heal_location.o: c_dep += $(DATA_SRC_SUBDIR)/heal_locations.h + +AUTO_GEN_TARGETS += include/constants/heal_locations.h +include/constants/heal_locations.h: $(DATA_SRC_SUBDIR)/heal_locations.json $(DATA_SRC_SUBDIR)/heal_locations.constants.json.txt + $(JSONPROC) $^ $@ diff --git a/map_data_rules.mk b/map_data_rules.mk index 4c255c098b..cad0531689 100755 --- a/map_data_rules.mk +++ b/map_data_rules.mk @@ -12,7 +12,6 @@ INCLUDECONSTS_OUTDIR := include/constants AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/map_groups.h AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/layouts.h AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/map_event_ids.h -AUTO_GEN_TARGETS += $(DATA_SRC_SUBDIR)/heal_locations.h MAP_DIRS := $(dir $(wildcard $(MAPS_DIR)/*/map.json)) MAP_CONNECTIONS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/connections.inc,$(MAP_DIRS)) @@ -35,11 +34,8 @@ $(MAPS_OUTDIR)/connections.inc $(MAPS_OUTDIR)/groups.inc $(MAPS_OUTDIR)/events.i $(LAYOUTS_OUTDIR)/layouts.inc $(LAYOUTS_OUTDIR)/layouts_table.inc $(INCLUDECONSTS_OUTDIR)/layouts.h: $(LAYOUTS_DIR)/layouts.json $(MAPJSON) layouts emerald $< $(LAYOUTS_OUTDIR) $(INCLUDECONSTS_OUTDIR) -# Generate files that depends on data that's distributed across the map.json files. +# Generate constants for map events, which depend on data that's distributed across the map.json files. # There's a lot of map.json files, so we print an abbreviated output with echo. -# We're also not using a pattern rule, and we only want this to run once for both targets, -# so we use a separate target 'event_constants'. -$(INCLUDECONSTS_OUTDIR)/map_event_ids.h $(DATA_SRC_SUBDIR)/heal_locations.h: .event_constants ; -.event_constants: $(MAP_JSONS) - @$(MAPJSON) event_constants emerald $^ $(INCLUDECONSTS_OUTDIR)/map_event_ids.h $(DATA_SRC_SUBDIR)/heal_locations.h - @echo "$(MAPJSON) event_constants emerald $(INCLUDECONSTS_OUTDIR)/map_event_ids.h $(DATA_SRC_SUBDIR)/heal_locations.h" +$(INCLUDECONSTS_OUTDIR)/map_event_ids.h: $(MAP_JSONS) + @$(MAPJSON) event_constants emerald $^ $(INCLUDECONSTS_OUTDIR)/map_event_ids.h + @echo "$(MAPJSON) event_constants emerald $(INCLUDECONSTS_OUTDIR)/map_event_ids.h" diff --git a/src/data/heal_locations.constants.json.txt b/src/data/heal_locations.constants.json.txt new file mode 100644 index 0000000000..e9ca860b35 --- /dev/null +++ b/src/data/heal_locations.constants.json.txt @@ -0,0 +1,14 @@ +#ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H +#define GUARD_CONSTANTS_HEAL_LOCATIONS_H + +{{ doNotModifyHeader }} + +enum { + HEAL_LOCATION_NONE, +## for heal_location in heal_locations + {{ heal_location.id }}, +## endfor + NUM_HEAL_LOCATIONS +}; + +#endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H diff --git a/src/data/heal_locations.json b/src/data/heal_locations.json new file mode 100644 index 0000000000..c465ff65c3 --- /dev/null +++ b/src/data/heal_locations.json @@ -0,0 +1,136 @@ +{ + "heal_locations": [ + { + "id": "HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F", + "map": "MAP_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F", + "x": 4, + "y": 2 + }, + { + "id": "HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F", + "map": "MAP_LITTLEROOT_TOWN_MAYS_HOUSE_2F", + "x": 4, + "y": 2 + }, + { + "id": "HEAL_LOCATION_PETALBURG_CITY", + "map": "MAP_PETALBURG_CITY", + "x": 20, + "y": 17 + }, + { + "id": "HEAL_LOCATION_SLATEPORT_CITY", + "map": "MAP_SLATEPORT_CITY", + "x": 19, + "y": 20 + }, + { + "id": "HEAL_LOCATION_MAUVILLE_CITY", + "map": "MAP_MAUVILLE_CITY", + "x": 22, + "y": 6 + }, + { + "id": "HEAL_LOCATION_RUSTBORO_CITY", + "map": "MAP_RUSTBORO_CITY", + "x": 16, + "y": 39 + }, + { + "id": "HEAL_LOCATION_FORTREE_CITY", + "map": "MAP_FORTREE_CITY", + "x": 5, + "y": 7 + }, + { + "id": "HEAL_LOCATION_LILYCOVE_CITY", + "map": "MAP_LILYCOVE_CITY", + "x": 24, + "y": 15 + }, + { + "id": "HEAL_LOCATION_MOSSDEEP_CITY", + "map": "MAP_MOSSDEEP_CITY", + "x": 28, + "y": 17 + }, + { + "id": "HEAL_LOCATION_SOOTOPOLIS_CITY", + "map": "MAP_SOOTOPOLIS_CITY", + "x": 43, + "y": 32 + }, + { + "id": "HEAL_LOCATION_EVER_GRANDE_CITY", + "map": "MAP_EVER_GRANDE_CITY", + "x": 27, + "y": 49 + }, + { + "id": "HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE", + "map": "MAP_LITTLEROOT_TOWN", + "x": 5, + "y": 9 + }, + { + "id": "HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE", + "map": "MAP_LITTLEROOT_TOWN", + "x": 14, + "y": 9 + }, + { + "id": "HEAL_LOCATION_OLDALE_TOWN", + "map": "MAP_OLDALE_TOWN", + "x": 6, + "y": 17 + }, + { + "id": "HEAL_LOCATION_DEWFORD_TOWN", + "map": "MAP_DEWFORD_TOWN", + "x": 2, + "y": 11 + }, + { + "id": "HEAL_LOCATION_LAVARIDGE_TOWN", + "map": "MAP_LAVARIDGE_TOWN", + "x": 9, + "y": 7 + }, + { + "id": "HEAL_LOCATION_FALLARBOR_TOWN", + "map": "MAP_FALLARBOR_TOWN", + "x": 14, + "y": 8 + }, + { + "id": "HEAL_LOCATION_VERDANTURF_TOWN", + "map": "MAP_VERDANTURF_TOWN", + "x": 16, + "y": 4 + }, + { + "id": "HEAL_LOCATION_PACIFIDLOG_TOWN", + "map": "MAP_PACIFIDLOG_TOWN", + "x": 8, + "y": 16 + }, + { + "id": "HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE", + "map": "MAP_EVER_GRANDE_CITY", + "x": 18, + "y": 6 + }, + { + "id": "HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR", + "map": "MAP_SOUTHERN_ISLAND_EXTERIOR", + "x": 15, + "y": 20 + }, + { + "id": "HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST", + "map": "MAP_BATTLE_FRONTIER_OUTSIDE_EAST", + "x": 3, + "y": 52 + } + ] +} diff --git a/src/data/heal_locations.json.txt b/src/data/heal_locations.json.txt new file mode 100644 index 0000000000..fd63228e33 --- /dev/null +++ b/src/data/heal_locations.json.txt @@ -0,0 +1,28 @@ +{{ doNotModifyHeader }} + +static const struct HealLocation sHealLocations[NUM_HEAL_LOCATIONS - 1] = { +## for heal_location in heal_locations + [{{ heal_location.id }} - 1] = { + .mapGroup = MAP_GROUP({{ heal_location.map }}), + .mapNum = MAP_NUM({{ heal_location.map }}), + .x = {{ heal_location.x }}, + .y = {{ heal_location.y }}, + }, +## endfor +}; + +static const u16 sWhiteoutRespawnHealCenterMapIdxs[][2] = { +## for heal_location in heal_locations +{% if existsIn(heal_location, "respawn_map") %} + [{{ heal_location.id }} - 1] = { MAP_GROUP({{ heal_location.respawn_map }}), MAP_NUM({{ heal_location.respawn_map }})}, +{% endif %} +## endfor +}; + +static const u8 sWhiteoutRespawnHealerNpcIds[] = { +## for heal_location in heal_locations +{% if existsIn(heal_location, "respawn_npc") %} + [{{ heal_location.id }} - 1] = {{ heal_location.respawn_npc }}, +{% endif %} +## endfor +}; diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index 99b67d82ea..8d8ec4e4e6 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -391,18 +391,13 @@ void process_map(string map_filepath, string layouts_filepath, string output_dir write_text_file(out_dir + "connections.inc", connections_text); } -void process_event_constants(const vector &map_filepaths, string output_ids_file, string output_heal_locations_file) { +void process_event_constants(const vector &map_filepaths, string output_ids_file) { string warning = get_generated_warning("data/maps/*/map.json", false); - ostringstream heal_locations_arr_text; - ostringstream respawn_maps_arr_text; - ostringstream respawn_npcs_arr_text; - string guard_name = "CONSTANTS_MAP_EVENT_IDS"; ostringstream ids_file_text; ids_file_text << get_include_guard_start(guard_name) << warning; - // Get heal location data from each map for (const string &filepath : map_filepaths) { string err; string map_json_text = read_text_file(filepath); @@ -432,59 +427,10 @@ void process_event_constants(const vector &map_filepaths, string output_ if (!temp.empty()) { ids_file_text << "// " << map_id << "\n" << temp << "\n"; } - - // Process heal locations. Maps are not required to have a heal locations array, so we check if it exists first. - if (map_data.object_items().find("heal_locations") != map_data.object_items().end()) { - for (auto &heal_location : map_data["heal_locations"].array_items()) { - // Each array is indexed with the heal location's ID, e.g. '[HEAL_LOCATION_NAME - 1] = ' - string index_text = "\t[" + json_to_string(heal_location, "id") + " - 1] ="; - - // Add element to main heal locations array - heal_locations_arr_text << index_text << "\n\t{\n" - << "\t\t.mapGroup = MAP_GROUP(" << map_id << "),\n" - << "\t\t.mapNum = MAP_NUM(" << map_id << "),\n" - << "\t\t.x = " << json_to_string(heal_location, "x") << ",\n" - << "\t\t.y = " << json_to_string(heal_location, "y") << ",\n" - << "\t},\n"; - - // Add element to respawn map array (if field is present) - if (heal_location.object_items().find("respawn_map") != heal_location.object_items().end()) { - string respawn_map_id = json_to_string(heal_location, "respawn_map"); - respawn_maps_arr_text << index_text << " {" - << "MAP_GROUP(" << respawn_map_id << "), " - << "MAP_NUM(" << respawn_map_id << ")" - << "},\n"; - } - - // Add element to respawn NPC array (if field is present) - if (heal_location.object_items().find("respawn_npc") != heal_location.object_items().end()) { - respawn_npcs_arr_text << index_text << " " << json_to_string(heal_location, "respawn_npc") << ",\n"; - } - } - } } - // Write event ids file ids_file_text << get_include_guard_end(guard_name); write_text_file(output_ids_file, ids_file_text.str()); - - - // Write heal locations data file - ostringstream heal_locations_file_text; - heal_locations_file_text << warning; - - string arr_body = heal_locations_arr_text.str(); - heal_locations_file_text << "static const struct HealLocation sHealLocations[] =\n{\n" << arr_body << "};\n\n"; - - arr_body = respawn_maps_arr_text.str(); - if (!arr_body.empty()) - heal_locations_file_text << "static const u16 sWhiteoutRespawnHealCenterMapIdxs[][2] =\n{\n" << arr_body << "};\n\n"; - - arr_body = respawn_npcs_arr_text.str(); - if (!arr_body.empty()) - heal_locations_file_text << "static const u8 sWhiteoutRespawnHealerNpcIds[] =\n{\n" << arr_body << "};\n\n"; - - write_text_file(output_heal_locations_file, heal_locations_file_text.str()); } string generate_groups_text(Json groups_data) { @@ -771,21 +717,20 @@ int main(int argc, char *argv[]) { process_layouts(filepath, output_asm, output_c); } else if (mode == "event_constants") { - if (argc < 6) - FATAL_ERROR("USAGE: mapjson event_constants [additional_map_files] "); + if (argc < 5) + FATAL_ERROR("USAGE: mapjson event_constants [additional_map_files] "); infer_separator(argv[3]); vector filepaths; const int firstMapFileArg = 3; - const int lastMapFileArg = argc - 3; + const int lastMapFileArg = argc - 2; for (int i = firstMapFileArg; i <= lastMapFileArg; i++) { filepaths.push_back(argv[i]); } - string output_ids_file(argv[argc - 2]); - string output_heal_locations_file(argv[argc - 1]); + string output_ids_file(argv[argc - 1]); - process_event_constants(filepaths, output_ids_file, output_heal_locations_file); + process_event_constants(filepaths, output_ids_file); } else { FATAL_ERROR("ERROR: must be 'layouts', 'map', 'event_constants', or 'groups'.\n");