diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-06-06 13:53:20 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-06-06 13:53:20 -0400 |
commit | 67a2efe7be6f4872adca8d944ebf403046472a98 (patch) | |
tree | 63f30a28c2c32ab03f9dfccc1c50567a0f03d3cc /src/game_data.cpp | |
parent | 78ac9905e222c26758e95b098d2e3a3e74a48839 (diff) | |
download | lingo-ap-tracker-67a2efe7be6f4872adca8d944ebf403046472a98.tar.gz lingo-ap-tracker-67a2efe7be6f4872adca8d944ebf403046472a98.tar.bz2 lingo-ap-tracker-67a2efe7be6f4872adca8d944ebf403046472a98.zip |
Proper painting reachability detection
Diffstat (limited to 'src/game_data.cpp')
-rw-r--r-- | src/game_data.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/game_data.cpp b/src/game_data.cpp index 4dd69e2..71b8629 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp | |||
@@ -48,11 +48,13 @@ struct GameData { | |||
48 | std::vector<Panel> panels_; | 48 | std::vector<Panel> panels_; |
49 | std::vector<MapArea> map_areas_; | 49 | std::vector<MapArea> map_areas_; |
50 | std::vector<SubwayItem> subway_items_; | 50 | std::vector<SubwayItem> subway_items_; |
51 | std::vector<PaintingExit> paintings_; | ||
51 | 52 | ||
52 | std::map<std::string, int> room_by_id_; | 53 | std::map<std::string, int> room_by_id_; |
53 | std::map<std::string, int> door_by_id_; | 54 | std::map<std::string, int> door_by_id_; |
54 | std::map<std::string, int> panel_by_id_; | 55 | std::map<std::string, int> panel_by_id_; |
55 | std::map<std::string, int> area_by_id_; | 56 | std::map<std::string, int> area_by_id_; |
57 | std::map<std::string, int> painting_by_id_; | ||
56 | 58 | ||
57 | std::vector<int> door_definition_order_; | 59 | std::vector<int> door_definition_order_; |
58 | 60 | ||
@@ -419,13 +421,13 @@ struct GameData { | |||
419 | 421 | ||
420 | if (room_it.second["paintings"]) { | 422 | if (room_it.second["paintings"]) { |
421 | for (const auto &painting : room_it.second["paintings"]) { | 423 | for (const auto &painting : room_it.second["paintings"]) { |
422 | std::string painting_id = painting["id"].as<std::string>(); | 424 | std::string internal_id = painting["id"].as<std::string>(); |
423 | room_by_painting_[painting_id] = room_id; | ||
424 | 425 | ||
425 | if ((!painting["exit_only"] || !painting["exit_only"].as<bool>()) && | 426 | if ((!painting["exit_only"] || !painting["exit_only"].as<bool>()) && |
426 | (!painting["disable"] || !painting["disable"].as<bool>())) { | 427 | (!painting["disable"] || !painting["disable"].as<bool>())) { |
427 | PaintingExit painting_exit; | 428 | int painting_id = AddOrGetPainting(internal_id); |
428 | painting_exit.id = painting_id; | 429 | PaintingExit &painting_exit = paintings_[painting_id]; |
430 | painting_exit.room = room_id; | ||
429 | 431 | ||
430 | if (painting["required_door"]) { | 432 | if (painting["required_door"]) { |
431 | std::string rd_room = rooms_[room_id].name; | 433 | std::string rd_room = rooms_[room_id].name; |
@@ -437,7 +439,7 @@ struct GameData { | |||
437 | rd_room, painting["required_door"]["door"].as<std::string>()); | 439 | rd_room, painting["required_door"]["door"].as<std::string>()); |
438 | } | 440 | } |
439 | 441 | ||
440 | rooms_[room_id].paintings.push_back(painting_exit); | 442 | rooms_[room_id].paintings.push_back(painting_exit.id); |
441 | } | 443 | } |
442 | } | 444 | } |
443 | } | 445 | } |
@@ -606,8 +608,8 @@ struct GameData { | |||
606 | int area_id = AddOrGetArea(area_name); | 608 | int area_id = AddOrGetArea(area_name); |
607 | MapArea &map_area = map_areas_[area_id]; | 609 | MapArea &map_area = map_areas_[area_id]; |
608 | 610 | ||
609 | for (const PaintingExit &painting : room.paintings) { | 611 | for (int painting_id : room.paintings) { |
610 | map_area.paintings.push_back(painting); | 612 | map_area.paintings.push_back(painting_id); |
611 | } | 613 | } |
612 | } | 614 | } |
613 | } | 615 | } |
@@ -738,6 +740,16 @@ struct GameData { | |||
738 | 740 | ||
739 | return area_by_id_[area]; | 741 | return area_by_id_[area]; |
740 | } | 742 | } |
743 | |||
744 | int AddOrGetPainting(std::string internal_id) { | ||
745 | if (!painting_by_id_.count(internal_id)) { | ||
746 | int painting_id = paintings_.size(); | ||
747 | painting_by_id_[internal_id] = painting_id; | ||
748 | paintings_.push_back({.id = painting_id, .internal_id = internal_id}); | ||
749 | } | ||
750 | |||
751 | return painting_by_id_[internal_id]; | ||
752 | } | ||
741 | }; | 753 | }; |
742 | 754 | ||
743 | GameData &GetState() { | 755 | GameData &GetState() { |
@@ -773,8 +785,12 @@ const Panel &GD_GetPanel(int panel_id) { | |||
773 | return GetState().panels_.at(panel_id); | 785 | return GetState().panels_.at(panel_id); |
774 | } | 786 | } |
775 | 787 | ||
776 | int GD_GetRoomForPainting(const std::string &painting_id) { | 788 | const PaintingExit &GD_GetPaintingExit(int painting_id) { |
777 | return GetState().room_by_painting_.at(painting_id); | 789 | return GetState().paintings_.at(painting_id); |
790 | } | ||
791 | |||
792 | int GD_GetPaintingByName(const std::string &name) { | ||
793 | return GetState().painting_by_id_.at(name); | ||
778 | } | 794 | } |
779 | 795 | ||
780 | const std::vector<int> &GD_GetAchievementPanels() { | 796 | const std::vector<int> &GD_GetAchievementPanels() { |