diff options
Diffstat (limited to 'src/game_data.cpp')
-rw-r--r-- | src/game_data.cpp | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/src/game_data.cpp b/src/game_data.cpp index 759eb0c..39ea360 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp | |||
@@ -1,11 +1,6 @@ | |||
1 | #include "game_data.h" | 1 | #include "game_data.h" |
2 | 2 | ||
3 | #include <wx/wxprec.h> | 3 | #include <fmt/core.h> |
4 | |||
5 | #ifndef WX_PRECOMP | ||
6 | #include <wx/wx.h> | ||
7 | #endif | ||
8 | |||
9 | #include <hkutil/string.h> | 4 | #include <hkutil/string.h> |
10 | #include <yaml-cpp/yaml.h> | 5 | #include <yaml-cpp/yaml.h> |
11 | 6 | ||
@@ -13,6 +8,7 @@ | |||
13 | #include <sstream> | 8 | #include <sstream> |
14 | 9 | ||
15 | #include "global.h" | 10 | #include "global.h" |
11 | #include "logger.h" | ||
16 | 12 | ||
17 | namespace { | 13 | namespace { |
18 | 14 | ||
@@ -36,7 +32,7 @@ LingoColor GetColorForString(const std::string &str) { | |||
36 | } else if (str == "purple") { | 32 | } else if (str == "purple") { |
37 | return LingoColor::kPurple; | 33 | return LingoColor::kPurple; |
38 | } else { | 34 | } else { |
39 | wxLogError("Invalid color: %s", str); | 35 | TrackerLog(fmt::format("Invalid color: {}", str)); |
40 | 36 | ||
41 | return LingoColor::kNone; | 37 | return LingoColor::kNone; |
42 | } | 38 | } |
@@ -90,7 +86,7 @@ struct GameData { | |||
90 | ap_id_by_color_[GetColorForString(input_name)] = | 86 | ap_id_by_color_[GetColorForString(input_name)] = |
91 | ids_config["special_items"][color_name].as<int>(); | 87 | ids_config["special_items"][color_name].as<int>(); |
92 | } else { | 88 | } else { |
93 | wxLogError("Missing AP item ID for color %s", color_name); | 89 | TrackerLog(fmt::format("Missing AP item ID for color {}", color_name)); |
94 | } | 90 | } |
95 | }; | 91 | }; |
96 | 92 | ||
@@ -115,6 +111,7 @@ struct GameData { | |||
115 | auto process_single_entrance = | 111 | auto process_single_entrance = |
116 | [this, room_id, from_room_id](const YAML::Node &option) { | 112 | [this, room_id, from_room_id](const YAML::Node &option) { |
117 | Exit exit_obj; | 113 | Exit exit_obj; |
114 | exit_obj.source_room = from_room_id; | ||
118 | exit_obj.destination_room = room_id; | 115 | exit_obj.destination_room = room_id; |
119 | 116 | ||
120 | if (option["door"]) { | 117 | if (option["door"]) { |
@@ -149,7 +146,7 @@ struct GameData { | |||
149 | switch (entrance_it.second.Type()) { | 146 | switch (entrance_it.second.Type()) { |
150 | case YAML::NodeType::Scalar: { | 147 | case YAML::NodeType::Scalar: { |
151 | // This is just "true". | 148 | // This is just "true". |
152 | rooms_[from_room_id].exits.push_back({.destination_room = room_id}); | 149 | rooms_[from_room_id].exits.push_back({.source_room = from_room_id, .destination_room = room_id}); |
153 | break; | 150 | break; |
154 | } | 151 | } |
155 | case YAML::NodeType::Map: { | 152 | case YAML::NodeType::Map: { |
@@ -167,7 +164,8 @@ struct GameData { | |||
167 | // This shouldn't happen. | 164 | // This shouldn't happen. |
168 | std::ostringstream formatted; | 165 | std::ostringstream formatted; |
169 | formatted << entrance_it; | 166 | formatted << entrance_it; |
170 | wxLogError("Error reading game data: %s", formatted.str()); | 167 | TrackerLog( |
168 | fmt::format("Error reading game data: {}", formatted.str())); | ||
171 | break; | 169 | break; |
172 | } | 170 | } |
173 | } | 171 | } |
@@ -292,8 +290,9 @@ struct GameData { | |||
292 | [panels_[panel_id].name] | 290 | [panels_[panel_id].name] |
293 | .as<int>(); | 291 | .as<int>(); |
294 | } else { | 292 | } else { |
295 | wxLogError("Missing AP location ID for panel %s - %s", | 293 | TrackerLog(fmt::format("Missing AP location ID for panel {} - {}", |
296 | rooms_[room_id].name, panels_[panel_id].name); | 294 | rooms_[room_id].name, |
295 | panels_[panel_id].name)); | ||
297 | } | 296 | } |
298 | } | 297 | } |
299 | } | 298 | } |
@@ -356,8 +355,9 @@ struct GameData { | |||
356 | [doors_[door_id].name]["item"] | 355 | [doors_[door_id].name]["item"] |
357 | .as<int>(); | 356 | .as<int>(); |
358 | } else { | 357 | } else { |
359 | wxLogError("Missing AP item ID for door %s - %s", | 358 | TrackerLog(fmt::format("Missing AP item ID for door {} - {}", |
360 | rooms_[room_id].name, doors_[door_id].name); | 359 | rooms_[room_id].name, |
360 | doors_[door_id].name)); | ||
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
@@ -371,8 +371,8 @@ struct GameData { | |||
371 | ids_config["door_groups"][doors_[door_id].group_name] | 371 | ids_config["door_groups"][doors_[door_id].group_name] |
372 | .as<int>(); | 372 | .as<int>(); |
373 | } else { | 373 | } else { |
374 | wxLogError("Missing AP item ID for door group %s", | 374 | TrackerLog(fmt::format("Missing AP item ID for door group {}", |
375 | doors_[door_id].group_name); | 375 | doors_[door_id].group_name)); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
@@ -382,11 +382,11 @@ struct GameData { | |||
382 | } else if (!door_it.second["skip_location"] && | 382 | } else if (!door_it.second["skip_location"] && |
383 | !door_it.second["event"]) { | 383 | !door_it.second["event"]) { |
384 | if (has_external_panels) { | 384 | if (has_external_panels) { |
385 | wxLogError( | 385 | TrackerLog(fmt::format( |
386 | "%s - %s has panels from other rooms but does not have an " | 386 | "{} - {} has panels from other rooms but does not have an " |
387 | "explicit location name and is not marked skip_location or " | 387 | "explicit location name and is not marked skip_location or " |
388 | "event", | 388 | "event", |
389 | rooms_[room_id].name, doors_[door_id].name); | 389 | rooms_[room_id].name, doors_[door_id].name)); |
390 | } | 390 | } |
391 | 391 | ||
392 | doors_[door_id].location_name = | 392 | doors_[door_id].location_name = |
@@ -406,8 +406,9 @@ struct GameData { | |||
406 | [doors_[door_id].name]["location"] | 406 | [doors_[door_id].name]["location"] |
407 | .as<int>(); | 407 | .as<int>(); |
408 | } else { | 408 | } else { |
409 | wxLogError("Missing AP location ID for door %s - %s", | 409 | TrackerLog(fmt::format("Missing AP location ID for door {} - {}", |
410 | rooms_[room_id].name, doors_[door_id].name); | 410 | rooms_[room_id].name, |
411 | doors_[door_id].name)); | ||
411 | } | 412 | } |
412 | } | 413 | } |
413 | 414 | ||
@@ -524,8 +525,8 @@ struct GameData { | |||
524 | progressive_item_id = | 525 | progressive_item_id = |
525 | ids_config["progression"][progressive_item_name].as<int>(); | 526 | ids_config["progression"][progressive_item_name].as<int>(); |
526 | } else { | 527 | } else { |
527 | wxLogError("Missing AP item ID for progressive item %s", | 528 | TrackerLog(fmt::format("Missing AP item ID for progressive item {}", |
528 | progressive_item_name); | 529 | progressive_item_name)); |
529 | } | 530 | } |
530 | 531 | ||
531 | if (progression_it.second["doors"]) { | 532 | if (progression_it.second["doors"]) { |
@@ -625,17 +626,20 @@ struct GameData { | |||
625 | } | 626 | } |
626 | } | 627 | } |
627 | 628 | ||
629 | if (room_name == "Starting Room") { | ||
630 | classification |= kLOCATION_SMALL_SPHERE_ONE; | ||
631 | } | ||
632 | |||
628 | int area_id = AddOrGetArea(area_name); | 633 | int area_id = AddOrGetArea(area_name); |
629 | MapArea &map_area = map_areas_[area_id]; | 634 | MapArea &map_area = map_areas_[area_id]; |
630 | // room field should be the original room ID | 635 | // room field should be the original room ID |
631 | map_area.locations.push_back( | 636 | map_area.locations.push_back({.name = section_name, |
632 | {.name = section_name, | 637 | .ap_location_name = location_name, |
633 | .ap_location_name = location_name, | 638 | .ap_location_id = panel.ap_location_id, |
634 | .ap_location_id = panel.ap_location_id, | 639 | .room = panel.room, |
635 | .room = panel.room, | 640 | .panels = {panel.id}, |
636 | .panels = {panel.id}, | 641 | .classification = classification, |
637 | .classification = classification, | 642 | .hunt = panel.hunt}); |
638 | .hunt = panel.hunt}); | ||
639 | locations_by_name[location_name] = {area_id, | 643 | locations_by_name[location_name] = {area_id, |
640 | map_area.locations.size() - 1}; | 644 | map_area.locations.size() - 1}; |
641 | } | 645 | } |
@@ -713,7 +717,7 @@ struct GameData { | |||
713 | 717 | ||
714 | // Report errors. | 718 | // Report errors. |
715 | for (const std::string &area : malconfigured_areas_) { | 719 | for (const std::string &area : malconfigured_areas_) { |
716 | wxLogError("Area data not found for: %s", area); | 720 | TrackerLog(fmt::format("Area data not found for: {}", area)); |
717 | } | 721 | } |
718 | 722 | ||
719 | // Read in subway items. | 723 | // Read in subway items. |
@@ -784,7 +788,7 @@ struct GameData { | |||
784 | 788 | ||
785 | for (const auto &[tag, items] : subway_tags) { | 789 | for (const auto &[tag, items] : subway_tags) { |
786 | if (items.size() == 1) { | 790 | if (items.size() == 1) { |
787 | wxLogWarning("Singleton subway item tag: %s", tag); | 791 | TrackerLog(fmt::format("Singleton subway item tag: {}", tag)); |
788 | } | 792 | } |
789 | } | 793 | } |
790 | } | 794 | } |
@@ -930,13 +934,11 @@ const SubwayItem &GD_GetSubwayItem(int id) { | |||
930 | return GetState().subway_items_.at(id); | 934 | return GetState().subway_items_.at(id); |
931 | } | 935 | } |
932 | 936 | ||
933 | int GD_GetSubwayItemForPainting(const std::string &painting_id) { | 937 | std::optional<int> GD_GetSubwayItemForPainting(const std::string &painting_id) { |
934 | #ifndef NDEBUG | 938 | if (GetState().subway_item_by_painting_.count(painting_id)) { |
935 | if (!GetState().subway_item_by_painting_.count(painting_id)) { | 939 | return GetState().subway_item_by_painting_.at(painting_id); |
936 | wxLogError("No subway item for painting %s", painting_id); | ||
937 | } | 940 | } |
938 | #endif | 941 | return std::nullopt; |
939 | return GetState().subway_item_by_painting_.at(painting_id); | ||
940 | } | 942 | } |
941 | 943 | ||
942 | int GD_GetSubwayItemForSunwarp(const SubwaySunwarp &sunwarp) { | 944 | int GD_GetSubwayItemForSunwarp(const SubwaySunwarp &sunwarp) { |