Merge commit '07c897a' into pret-merge

Conflicts:
	include/constants/heal_locations.h
	map_data_rules.mk
This commit is contained in:
Hedara
2025-05-27 19:46:13 +02:00
30 changed files with 208 additions and 223 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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,6 +1,11 @@
#ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H
#define GUARD_CONSTANTS_HEAL_LOCATIONS_H
//
// DO NOT MODIFY THIS FILE! It is auto-generated from src/data/heal_locations.json and Inja template src/data/heal_locations.constants.json.txt
//
enum {
HEAL_LOCATION_NONE,
HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F,
@@ -25,7 +30,7 @@ enum {
HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE,
HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR,
HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST,
HEAL_LOCATION_COUNT
NUM_HEAL_LOCATIONS
};
#endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H

View File

@@ -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) $^ $@

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
AUTO_GEN_TARGETS += $(DATA_SRC_SUBDIR)/map_group_count.h
MAP_DIRS := $(dir $(wildcard $(MAPS_DIR)/*/map.json))
@@ -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 <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 emerald $^ $(INCLUDECONSTS_OUTDIR)/map_event_ids.h
@echo "$(MAPJSON) event_constants emerald <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,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
}
]
}

View File

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

View File

@@ -1,6 +1,6 @@
#define DEFAULT_POKEMON_CENTER_COORDS .x = 7, .y = 4
static const struct HealLocation sHealLocationsPokemonCenter[HEAL_LOCATION_COUNT - 1] =
static const struct HealLocation sHealLocationsPokemonCenter[NUM_HEAL_LOCATIONS - 1] =
{
[HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] =
{
@@ -148,7 +148,7 @@ static const struct HealLocation sHealLocationsPokemonCenter[HEAL_LOCATION_COUNT
// e.g. for OldaleTown_PokemonCenter1F/events.inc the following entry gets generated:
// object_event 1, OBJ_EVENT_GFX_NURSE, 7, 2, 3, MOVEMENT_TYPE_FACE_DOWN, 0, 0, TRAINER_TYPE_NONE, 0, OldaleTown_PokemonCenter_1F_EventScript_Nurse, 0
// In this case the localId is 1.
static const u8 sHealNpcLocalId[HEAL_LOCATION_COUNT - 1] =
static const u8 sHealNpcLocalId[NUM_HEAL_LOCATIONS - 1] =
{
[HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = 1,
[HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = 1,

View File

@@ -78,7 +78,7 @@ bool32 IsLastHealLocationPlayerHouse()
u32 GetHealNpcLocalId(u32 healLocationId)
{
if (healLocationId == HEAL_LOCATION_NONE || healLocationId >= HEAL_LOCATION_COUNT)
if (healLocationId == HEAL_LOCATION_NONE || healLocationId >= NUM_HEAL_LOCATIONS)
return 0;
return sHealNpcLocalId[healLocationId - 1];

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) {
@@ -788,21 +734,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");