about summary refs log tree commit diff stats
path: root/src/game_data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game_data.cpp')
-rw-r--r--src/game_data.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/game_data.cpp b/src/game_data.cpp index 7c221e9..a5af66b 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp
@@ -33,6 +33,7 @@ struct GameData {
33 33
34 std::map<std::string, int> room_by_painting_; 34 std::map<std::string, int> room_by_painting_;
35 std::map<int, int> room_by_sunwarp_; 35 std::map<int, int> room_by_sunwarp_;
36 std::map<int, int> panel_by_solve_index_;
36 37
37 std::vector<int> achievement_panels_; 38 std::vector<int> achievement_panels_;
38 39
@@ -77,6 +78,8 @@ struct GameData {
77 78
78 rooms_.reserve(lingo_config.size() * 2); 79 rooms_.reserve(lingo_config.size() * 2);
79 80
81 std::vector<int> panel_location_ids;
82
80 for (const auto &room_it : lingo_config) { 83 for (const auto &room_it : lingo_config) {
81 int room_id = AddOrGetRoom(room_it.first.as<std::string>()); 84 int room_id = AddOrGetRoom(room_it.first.as<std::string>());
82 room_definition_order_.push_back(room_id); 85 room_definition_order_.push_back(room_id);
@@ -266,10 +269,11 @@ struct GameData {
266 ids_config["panels"][rooms_[room_id].name] && 269 ids_config["panels"][rooms_[room_id].name] &&
267 ids_config["panels"][rooms_[room_id].name] 270 ids_config["panels"][rooms_[room_id].name]
268 [panels_[panel_id].name]) { 271 [panels_[panel_id].name]) {
269 panels_[panel_id].ap_location_id = 272 int location_id = ids_config["panels"][rooms_[room_id].name]
270 ids_config["panels"][rooms_[room_id].name] 273 [panels_[panel_id].name]
271 [panels_[panel_id].name] 274 .as<int>();
272 .as<int>(); 275 panels_[panel_id].ap_location_id = location_id;
276 panel_location_ids.push_back(location_id);
273 } else { 277 } else {
274 TrackerLog(fmt::format("Missing AP location ID for panel {} - {}", 278 TrackerLog(fmt::format("Missing AP location ID for panel {} - {}",
275 rooms_[room_id].name, 279 rooms_[room_id].name,
@@ -563,6 +567,21 @@ struct GameData {
563 } 567 }
564 } 568 }
565 569
570 // Determine the panel solve indices from the sorted location IDs.
571 std::sort(panel_location_ids.begin(), panel_location_ids.end());
572
573 std::map<int, int> solve_index_by_location_id;
574 for (int i = 0; i < panel_location_ids.size(); i++) {
575 solve_index_by_location_id[panel_location_ids[i]] = i;
576 }
577
578 for (Panel &panel : panels_) {
579 if (panel.ap_location_id != -1) {
580 panel.solve_index = solve_index_by_location_id[panel.ap_location_id];
581 panel_by_solve_index_[panel.solve_index] = panel.id;
582 }
583 }
584
566 map_areas_.reserve(areas_config.size()); 585 map_areas_.reserve(areas_config.size());
567 586
568 std::map<std::string, int> fold_areas; 587 std::map<std::string, int> fold_areas;
@@ -938,6 +957,10 @@ const Panel &GD_GetPanel(int panel_id) {
938 return GetState().panels_.at(panel_id); 957 return GetState().panels_.at(panel_id);
939} 958}
940 959
960int GD_GetPanelBySolveIndex(int solve_index) {
961 return GetState().panel_by_solve_index_.at(solve_index);
962}
963
941const std::vector<PaintingExit> &GD_GetPaintings() { 964const std::vector<PaintingExit> &GD_GetPaintings() {
942 return GetState().paintings_; 965 return GetState().paintings_;
943} 966}