Generate heal location constants automatically, move data back to a single file.

This commit is contained in:
GriffinR 2025-02-03 15:57:28 -05:00
parent 65be523af2
commit 5f9f173b6a
28 changed files with 224 additions and 278 deletions

View File

@ -403,14 +403,5 @@
"quantity": 1,
"underfoot": false
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_CELADON_CITY",
"x": 48,
"y": 12,
"respawn_map": "MAP_CELADON_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_CELADON_NURSE"
}
]
}

View File

@ -420,14 +420,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "CeruleanCity_BikeShop_EventScript_Bicycle"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_CERULEAN_CITY",
"x": 22,
"y": 20,
"respawn_map": "MAP_CERULEAN_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_CERULEAN_NURSE"
}
]
}

View File

@ -166,14 +166,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "CinnabarIsland_EventScript_PokemonLabSign"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_CINNABAR_ISLAND",
"x": 14,
"y": 12,
"respawn_map": "MAP_CINNABAR_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_CINNABAR_NURSE"
}
]
}

View File

@ -103,14 +103,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "FiveIsland_EventScript_IslandSign"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_FIVE_ISLAND",
"x": 18,
"y": 7,
"respawn_map": "MAP_FIVE_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_FIVE_ISLAND_NURSE"
}
]
}

View File

@ -282,14 +282,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "FourIsland_EventScript_LoreleisHouseSign"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_FOUR_ISLAND",
"x": 18,
"y": 21,
"respawn_map": "MAP_FOUR_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_FOUR_ISLAND_NURSE"
}
]
}

View File

@ -435,14 +435,5 @@
"quantity": 1,
"underfoot": false
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_FUCHSIA_CITY",
"x": 25,
"y": 32,
"respawn_map": "MAP_FUCHSIA_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_FUCHSIA_NURSE"
}
]
}

View File

@ -62,14 +62,5 @@
}
],
"coord_events": [],
"bg_events": [],
"heal_locations": [
{
"id": "HEAL_LOCATION_INDIGO_PLATEAU",
"x": 11,
"y": 7,
"respawn_map": "MAP_INDIGO_PLATEAU_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_LEAGUE_NURSE"
}
]
"bg_events": []
}

View File

@ -152,14 +152,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "LavenderTown_EventScript_VolunteerHouseSign"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_LAVENDER_TOWN",
"x": 6,
"y": 6,
"respawn_map": "MAP_LAVENDER_TOWN_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_LAVENDER_NURSE"
}
]
}

View File

@ -118,14 +118,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "OneIsland_EventScript_PokemonNetCenterSign"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_ONE_ISLAND",
"x": 14,
"y": 6,
"respawn_map": "MAP_ONE_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_ONE_ISLAND_NURSE"
}
]
}

View File

@ -165,14 +165,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "PalletTown_EventScript_TrainerTips"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_PALLET_TOWN",
"x": 6,
"y": 8,
"respawn_map": "MAP_PALLET_TOWN_PLAYERS_HOUSE_1F",
"respawn_npc": "LOCALID_MOM"
}
]
}

View File

@ -295,14 +295,5 @@
"quantity": 1,
"underfoot": false
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_PEWTER_CITY",
"x": 17,
"y": 26,
"respawn_map": "MAP_PEWTER_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_PEWTER_NURSE"
}
]
}

View File

@ -280,14 +280,5 @@
"quantity": 1,
"underfoot": false
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_ROUTE10",
"x": 13,
"y": 21,
"respawn_map": "MAP_ROUTE10_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_ROUTE10_NURSE"
}
]
}

View File

@ -190,14 +190,5 @@
"quantity": 1,
"underfoot": false
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_ROUTE4",
"x": 12,
"y": 6,
"respawn_map": "MAP_ROUTE4_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_ROUTE4_NURSE"
}
]
}

View File

@ -430,14 +430,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "SaffronCity_EventScript_TrainerFanClubSign"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_SAFFRON_CITY",
"x": 24,
"y": 39,
"respawn_map": "MAP_SAFFRON_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_SAFFRON_NURSE"
}
]
}

View File

@ -110,14 +110,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "SevenIsland_EventScript_IslandSign"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_SEVEN_ISLAND",
"x": 12,
"y": 4,
"respawn_map": "MAP_SEVEN_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_SEVEN_ISLAND_NURSE"
}
]
}

View File

@ -100,14 +100,5 @@
"quantity": 1,
"underfoot": false
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_SIX_ISLAND",
"x": 11,
"y": 12,
"respawn_map": "MAP_SIX_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_SIX_ISLAND_NURSE"
}
]
}

View File

@ -394,14 +394,5 @@
"quantity": 1,
"underfoot": false
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_THREE_ISLAND",
"x": 14,
"y": 28,
"respawn_map": "MAP_THREE_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_THREE_ISLAND_NURSE"
}
]
}

View File

@ -204,14 +204,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "TwoIsland_EventScript_FastCurrentSign"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_TWO_ISLAND",
"x": 21,
"y": 8,
"respawn_map": "MAP_TWO_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_TWO_ISLAND_NURSE"
}
]
}

View File

@ -301,14 +301,5 @@
"quantity": 1,
"underfoot": false
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_VERMILION_CITY",
"x": 15,
"y": 7,
"respawn_map": "MAP_VERMILION_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_VERMILION_NURSE"
}
]
}

View File

@ -278,14 +278,5 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "ViridianCity_EventScript_GymDoor"
}
],
"heal_locations": [
{
"id": "HEAL_LOCATION_VIRIDIAN_CITY",
"x": 26,
"y": 27,
"respawn_map": "MAP_VIRIDIAN_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_VIRIDIAN_NURSE"
}
]
}

View File

@ -3,3 +3,4 @@ map_groups.h
layouts.h
region_map_sections.h
map_event_ids.h
heal_locations.h

View File

@ -1,28 +0,0 @@
#ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H
#define GUARD_CONSTANTS_HEAL_LOCATIONS_H
enum {
HEAL_LOCATION_NONE,
HEAL_LOCATION_PALLET_TOWN,
HEAL_LOCATION_VIRIDIAN_CITY,
HEAL_LOCATION_PEWTER_CITY,
HEAL_LOCATION_CERULEAN_CITY,
HEAL_LOCATION_LAVENDER_TOWN,
HEAL_LOCATION_VERMILION_CITY,
HEAL_LOCATION_CELADON_CITY,
HEAL_LOCATION_FUCHSIA_CITY,
HEAL_LOCATION_CINNABAR_ISLAND,
HEAL_LOCATION_INDIGO_PLATEAU,
HEAL_LOCATION_SAFFRON_CITY,
HEAL_LOCATION_ROUTE4,
HEAL_LOCATION_ROUTE10,
HEAL_LOCATION_ONE_ISLAND,
HEAL_LOCATION_TWO_ISLAND,
HEAL_LOCATION_THREE_ISLAND,
HEAL_LOCATION_FOUR_ISLAND,
HEAL_LOCATION_FIVE_ISLAND,
HEAL_LOCATION_SEVEN_ISLAND,
HEAL_LOCATION_SIX_ISLAND,
};
#endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H

View File

@ -28,3 +28,13 @@ $(DATA_SRC_SUBDIR)/items.h: $(DATA_SRC_SUBDIR)/items.json $(DATA_SRC_SUBDIR)/ite
$(JSONPROC) $^ $@
$(C_BUILDDIR)/item.o: c_dep += $(DATA_SRC_SUBDIR)/items.h
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) $^ $@

View File

@ -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))
@ -34,11 +33,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 firered $< $(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 firered $^ $(INCLUDECONSTS_OUTDIR)/map_event_ids.h $(DATA_SRC_SUBDIR)/heal_locations.h
@echo "$(MAPJSON) event_constants firered <MAP_JSONS> $(INCLUDECONSTS_OUTDIR)/map_event_ids.h $(DATA_SRC_SUBDIR)/heal_locations.h"
$(INCLUDECONSTS_OUTDIR)/map_event_ids.h: $(MAP_JSONS)
@$(MAPJSON) event_constants firered $^ $(INCLUDECONSTS_OUTDIR)/map_event_ids.h
@echo "$(MAPJSON) event_constants firered <MAP_JSONS> $(INCLUDECONSTS_OUTDIR)/map_event_ids.h"

View File

@ -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

View File

@ -0,0 +1,164 @@
{
"heal_locations": [
{
"id": "HEAL_LOCATION_PALLET_TOWN",
"map": "MAP_PALLET_TOWN",
"x": 6,
"y": 8,
"respawn_map": "MAP_PALLET_TOWN_PLAYERS_HOUSE_1F",
"respawn_npc": "LOCALID_MOM"
},
{
"id": "HEAL_LOCATION_VIRIDIAN_CITY",
"map": "MAP_VIRIDIAN_CITY",
"x": 26,
"y": 27,
"respawn_map": "MAP_VIRIDIAN_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_VIRIDIAN_NURSE"
},
{
"id": "HEAL_LOCATION_PEWTER_CITY",
"map": "MAP_PEWTER_CITY",
"x": 17,
"y": 26,
"respawn_map": "MAP_PEWTER_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_PEWTER_NURSE"
},
{
"id": "HEAL_LOCATION_CERULEAN_CITY",
"map": "MAP_CERULEAN_CITY",
"x": 22,
"y": 20,
"respawn_map": "MAP_CERULEAN_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_CERULEAN_NURSE"
},
{
"id": "HEAL_LOCATION_LAVENDER_TOWN",
"map": "MAP_LAVENDER_TOWN",
"x": 6,
"y": 6,
"respawn_map": "MAP_LAVENDER_TOWN_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_LAVENDER_NURSE"
},
{
"id": "HEAL_LOCATION_VERMILION_CITY",
"map": "MAP_VERMILION_CITY",
"x": 15,
"y": 7,
"respawn_map": "MAP_VERMILION_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_VERMILION_NURSE"
},
{
"id": "HEAL_LOCATION_CELADON_CITY",
"map": "MAP_CELADON_CITY",
"x": 48,
"y": 12,
"respawn_map": "MAP_CELADON_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_CELADON_NURSE"
},
{
"id": "HEAL_LOCATION_FUCHSIA_CITY",
"map": "MAP_FUCHSIA_CITY",
"x": 25,
"y": 32,
"respawn_map": "MAP_FUCHSIA_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_FUCHSIA_NURSE"
},
{
"id": "HEAL_LOCATION_CINNABAR_ISLAND",
"map": "MAP_CINNABAR_ISLAND",
"x": 14,
"y": 12,
"respawn_map": "MAP_CINNABAR_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_CINNABAR_NURSE"
},
{
"id": "HEAL_LOCATION_INDIGO_PLATEAU",
"map": "MAP_INDIGO_PLATEAU_EXTERIOR",
"x": 11,
"y": 7,
"respawn_map": "MAP_INDIGO_PLATEAU_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_LEAGUE_NURSE"
},
{
"id": "HEAL_LOCATION_SAFFRON_CITY",
"map": "MAP_SAFFRON_CITY",
"x": 24,
"y": 39,
"respawn_map": "MAP_SAFFRON_CITY_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_SAFFRON_NURSE"
},
{
"id": "HEAL_LOCATION_ROUTE4",
"map": "MAP_ROUTE4",
"x": 12,
"y": 6,
"respawn_map": "MAP_ROUTE4_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_ROUTE4_NURSE"
},
{
"id": "HEAL_LOCATION_ROUTE10",
"map": "MAP_ROUTE10",
"x": 13,
"y": 21,
"respawn_map": "MAP_ROUTE10_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_ROUTE10_NURSE"
},
{
"id": "HEAL_LOCATION_ONE_ISLAND",
"map": "MAP_ONE_ISLAND",
"x": 14,
"y": 6,
"respawn_map": "MAP_ONE_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_ONE_ISLAND_NURSE"
},
{
"id": "HEAL_LOCATION_TWO_ISLAND",
"map": "MAP_TWO_ISLAND",
"x": 21,
"y": 8,
"respawn_map": "MAP_TWO_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_TWO_ISLAND_NURSE"
},
{
"id": "HEAL_LOCATION_THREE_ISLAND",
"map": "MAP_THREE_ISLAND",
"x": 14,
"y": 28,
"respawn_map": "MAP_THREE_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_THREE_ISLAND_NURSE"
},
{
"id": "HEAL_LOCATION_FOUR_ISLAND",
"map": "MAP_FOUR_ISLAND",
"x": 18,
"y": 21,
"respawn_map": "MAP_FOUR_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_FOUR_ISLAND_NURSE"
},
{
"id": "HEAL_LOCATION_FIVE_ISLAND",
"map": "MAP_FIVE_ISLAND",
"x": 18,
"y": 7,
"respawn_map": "MAP_FIVE_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_FIVE_ISLAND_NURSE"
},
{
"id": "HEAL_LOCATION_SEVEN_ISLAND",
"map": "MAP_SEVEN_ISLAND",
"x": 12,
"y": 4,
"respawn_map": "MAP_SEVEN_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_SEVEN_ISLAND_NURSE"
},
{
"id": "HEAL_LOCATION_SIX_ISLAND",
"map": "MAP_SIX_ISLAND",
"x": 11,
"y": 12,
"respawn_map": "MAP_SIX_ISLAND_POKEMON_CENTER_1F",
"respawn_npc": "LOCALID_SIX_ISLAND_NURSE"
}
]
}

View File

@ -0,0 +1,24 @@
{{ 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[NUM_HEAL_LOCATIONS - 1][2] = {
## for heal_location in heal_locations
[{{ heal_location.id }} - 1] = { MAP_GROUP({{ heal_location.respawn_map }}), MAP_NUM({{ heal_location.respawn_map }})},
## endfor
};
static const u8 sWhiteoutRespawnHealerNpcIds[NUM_HEAL_LOCATIONS - 1] = {
## for heal_location in heal_locations
[{{ heal_location.id }} - 1] = {{ heal_location.respawn_npc }},
## endfor
};

View File

@ -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<string> &map_filepaths, string output_ids_file, string output_heal_locations_file) {
void process_event_constants(const vector<string> &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<string> &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 <game-version> <map_file> [additional_map_files] <output_ids_file> <output_heal_locations_file>");
if (argc < 5)
FATAL_ERROR("USAGE: mapjson event_constants <game-version> <map_file> [additional_map_files] <output_ids_file>");
infer_separator(argv[3]);
vector<string> 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: <mode> must be 'layouts', 'map', 'event_constants', or 'groups'.\n");