From 085531b53449dc28bc18739b06772641c5c82192 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 17 May 2024 18:07:16 -0400 Subject: Handle panel location name config field --- src/game_data.cpp | 30 ++++++++++++++++++++++++------ src/game_data.h | 1 + 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/game_data.cpp b/src/game_data.cpp index c98f532..be31b8f 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -254,6 +254,11 @@ struct GameData { achievement_panels_.push_back(panel_id); } + if (panel_it.second["location_name"]) { + panels_[panel_id].location_name = + panel_it.second["location_name"].as(); + } + if (panel_it.second["hunt"]) { panels_[panel_id].hunt = panel_it.second["hunt"].as(); } @@ -521,8 +526,21 @@ struct GameData { std::string room_name = rooms_[room_id].name; std::string area_name = room_name; - if (fold_areas.count(room_name)) { - int fold_area_id = fold_areas[room_name]; + std::string section_name = panel.name; + std::string location_name = room_name + " - " + panel.name; + + if (!panel.location_name.empty()) { + location_name = panel.location_name; + + size_t divider_pos = location_name.find(" - "); + if (divider_pos != std::string::npos) { + area_name = location_name.substr(0, divider_pos); + section_name = location_name.substr(divider_pos + 3); + } + } + + if (fold_areas.count(area_name)) { + int fold_area_id = fold_areas[area_name]; area_name = map_areas_[fold_area_id].name; } @@ -538,15 +556,15 @@ struct GameData { MapArea &map_area = map_areas_[area_id]; // room field should be the original room ID map_area.locations.push_back( - {.name = panel.name, - .ap_location_name = room_name + " - " + panel.name, + {.name = section_name, + .ap_location_name = location_name, .ap_location_id = panel.ap_location_id, .room = panel.room, .panels = {panel.id}, .classification = classification, .hunt = panel.hunt}); - locations_by_name[map_area.locations.back().ap_location_name] = { - area_id, map_area.locations.size() - 1}; + locations_by_name[location_name] = {area_id, + map_area.locations.size() - 1}; } for (int door_id : door_definition_order_) { diff --git a/src/game_data.h b/src/game_data.h index cd09627..f3edaa2 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -50,6 +50,7 @@ struct Panel { bool exclude_reduce = false; bool achievement = false; std::string achievement_name; + std::string location_name; bool non_counting = false; int ap_location_id = -1; bool hunt = false; -- cgit 1.4.1