diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-06-10 19:13:22 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-06-10 19:13:22 -0400 |
commit | 33bf1f9653ed608de5554940dc8a0c3f5dc7e4ea (patch) | |
tree | b1db5d3e83ccd8c5219d5db12b01bc3d152b79d1 /src/game_data.cpp | |
parent | 3b3c3ca4ed98c8d1e884f6c9f8f63d7b7c76e37b (diff) | |
download | lingo-ap-tracker-33bf1f9653ed608de5554940dc8a0c3f5dc7e4ea.tar.gz lingo-ap-tracker-33bf1f9653ed608de5554940dc8a0c3f5dc7e4ea.tar.bz2 lingo-ap-tracker-33bf1f9653ed608de5554940dc8a0c3f5dc7e4ea.zip |
Go back to old logging system
Brought in libfmt to handle string formatting and replace a bunch of ostringstream uses.
Diffstat (limited to 'src/game_data.cpp')
-rw-r--r-- | src/game_data.cpp | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/src/game_data.cpp b/src/game_data.cpp index 85f7f51..77e435a 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 | } |
@@ -88,7 +84,7 @@ struct GameData { | |||
88 | ap_id_by_color_[GetColorForString(input_name)] = | 84 | ap_id_by_color_[GetColorForString(input_name)] = |
89 | ids_config["special_items"][color_name].as<int>(); | 85 | ids_config["special_items"][color_name].as<int>(); |
90 | } else { | 86 | } else { |
91 | wxLogError("Missing AP item ID for color %s", color_name); | 87 | TrackerLog(fmt::format("Missing AP item ID for color {}", color_name)); |
92 | } | 88 | } |
93 | }; | 89 | }; |
94 | 90 | ||
@@ -165,7 +161,8 @@ struct GameData { | |||
165 | // This shouldn't happen. | 161 | // This shouldn't happen. |
166 | std::ostringstream formatted; | 162 | std::ostringstream formatted; |
167 | formatted << entrance_it; | 163 | formatted << entrance_it; |
168 | wxLogError("Error reading game data: %s", formatted.str()); | 164 | TrackerLog( |
165 | fmt::format("Error reading game data: {}", formatted.str())); | ||
169 | break; | 166 | break; |
170 | } | 167 | } |
171 | } | 168 | } |
@@ -290,8 +287,9 @@ struct GameData { | |||
290 | [panels_[panel_id].name] | 287 | [panels_[panel_id].name] |
291 | .as<int>(); | 288 | .as<int>(); |
292 | } else { | 289 | } else { |
293 | wxLogError("Missing AP location ID for panel %s - %s", | 290 | TrackerLog(fmt::format("Missing AP location ID for panel {} - {}", |
294 | rooms_[room_id].name, panels_[panel_id].name); | 291 | rooms_[room_id].name, |
292 | panels_[panel_id].name)); | ||
295 | } | 293 | } |
296 | } | 294 | } |
297 | } | 295 | } |
@@ -354,8 +352,9 @@ struct GameData { | |||
354 | [doors_[door_id].name]["item"] | 352 | [doors_[door_id].name]["item"] |
355 | .as<int>(); | 353 | .as<int>(); |
356 | } else { | 354 | } else { |
357 | wxLogError("Missing AP item ID for door %s - %s", | 355 | TrackerLog(fmt::format("Missing AP item ID for door {} - {}", |
358 | rooms_[room_id].name, doors_[door_id].name); | 356 | rooms_[room_id].name, |
357 | doors_[door_id].name)); | ||
359 | } | 358 | } |
360 | } | 359 | } |
361 | 360 | ||
@@ -369,8 +368,8 @@ struct GameData { | |||
369 | ids_config["door_groups"][doors_[door_id].group_name] | 368 | ids_config["door_groups"][doors_[door_id].group_name] |
370 | .as<int>(); | 369 | .as<int>(); |
371 | } else { | 370 | } else { |
372 | wxLogError("Missing AP item ID for door group %s", | 371 | TrackerLog(fmt::format("Missing AP item ID for door group {}", |
373 | doors_[door_id].group_name); | 372 | doors_[door_id].group_name)); |
374 | } | 373 | } |
375 | } | 374 | } |
376 | 375 | ||
@@ -380,11 +379,11 @@ struct GameData { | |||
380 | } else if (!door_it.second["skip_location"] && | 379 | } else if (!door_it.second["skip_location"] && |
381 | !door_it.second["event"]) { | 380 | !door_it.second["event"]) { |
382 | if (has_external_panels) { | 381 | if (has_external_panels) { |
383 | wxLogError( | 382 | TrackerLog(fmt::format( |
384 | "%s - %s has panels from other rooms but does not have an " | 383 | "{} - {} has panels from other rooms but does not have an " |
385 | "explicit location name and is not marked skip_location or " | 384 | "explicit location name and is not marked skip_location or " |
386 | "event", | 385 | "event", |
387 | rooms_[room_id].name, doors_[door_id].name); | 386 | rooms_[room_id].name, doors_[door_id].name)); |
388 | } | 387 | } |
389 | 388 | ||
390 | doors_[door_id].location_name = | 389 | doors_[door_id].location_name = |
@@ -404,8 +403,9 @@ struct GameData { | |||
404 | [doors_[door_id].name]["location"] | 403 | [doors_[door_id].name]["location"] |
405 | .as<int>(); | 404 | .as<int>(); |
406 | } else { | 405 | } else { |
407 | wxLogError("Missing AP location ID for door %s - %s", | 406 | TrackerLog(fmt::format("Missing AP location ID for door {} - {}", |
408 | rooms_[room_id].name, doors_[door_id].name); | 407 | rooms_[room_id].name, |
408 | doors_[door_id].name)); | ||
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
@@ -473,8 +473,8 @@ struct GameData { | |||
473 | progressive_item_id = | 473 | progressive_item_id = |
474 | ids_config["progression"][progressive_item_name].as<int>(); | 474 | ids_config["progression"][progressive_item_name].as<int>(); |
475 | } else { | 475 | } else { |
476 | wxLogError("Missing AP item ID for progressive item %s", | 476 | TrackerLog(fmt::format("Missing AP item ID for progressive item {}", |
477 | progressive_item_name); | 477 | progressive_item_name)); |
478 | } | 478 | } |
479 | 479 | ||
480 | int index = 1; | 480 | int index = 1; |
@@ -553,14 +553,13 @@ struct GameData { | |||
553 | int area_id = AddOrGetArea(area_name); | 553 | int area_id = AddOrGetArea(area_name); |
554 | MapArea &map_area = map_areas_[area_id]; | 554 | MapArea &map_area = map_areas_[area_id]; |
555 | // room field should be the original room ID | 555 | // room field should be the original room ID |
556 | map_area.locations.push_back( | 556 | map_area.locations.push_back({.name = section_name, |
557 | {.name = section_name, | 557 | .ap_location_name = location_name, |
558 | .ap_location_name = location_name, | 558 | .ap_location_id = panel.ap_location_id, |
559 | .ap_location_id = panel.ap_location_id, | 559 | .room = panel.room, |
560 | .room = panel.room, | 560 | .panels = {panel.id}, |
561 | .panels = {panel.id}, | 561 | .classification = classification, |
562 | .classification = classification, | 562 | .hunt = panel.hunt}); |
563 | .hunt = panel.hunt}); | ||
564 | locations_by_name[location_name] = {area_id, | 563 | locations_by_name[location_name] = {area_id, |
565 | map_area.locations.size() - 1}; | 564 | map_area.locations.size() - 1}; |
566 | } | 565 | } |
@@ -638,7 +637,7 @@ struct GameData { | |||
638 | 637 | ||
639 | // Report errors. | 638 | // Report errors. |
640 | for (const std::string &area : malconfigured_areas_) { | 639 | for (const std::string &area : malconfigured_areas_) { |
641 | wxLogError("Area data not found for: %s", area); | 640 | TrackerLog(fmt::format("Area data not found for: {}", area)); |
642 | } | 641 | } |
643 | 642 | ||
644 | // Read in subway items. | 643 | // Read in subway items. |
@@ -709,7 +708,7 @@ struct GameData { | |||
709 | 708 | ||
710 | for (const auto &[tag, items] : subway_tags) { | 709 | for (const auto &[tag, items] : subway_tags) { |
711 | if (items.size() == 1) { | 710 | if (items.size() == 1) { |
712 | wxLogWarning("Singleton subway item tag: %s", tag); | 711 | TrackerLog(fmt::format("Singleton subway item tag: {}", tag)); |
713 | } | 712 | } |
714 | } | 713 | } |
715 | } | 714 | } |