diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-09-08 08:51:43 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-09-08 08:51:43 -0400 |
commit | 0e6be5bbe8c506882e8100ccaaf13a5f58079f97 (patch) | |
tree | 4fee4d578e7936cb4052a74b93064c5ea845521f /src/tracker_state.cpp | |
parent | c443acfd0b25b3e4f3446f795777b8dd18b00e2b (diff) | |
parent | 86b4b06e78c5c71588c1b55273969a1327a6710a (diff) | |
download | lingo-ap-tracker-0e6be5bbe8c506882e8100ccaaf13a5f58079f97.tar.gz lingo-ap-tracker-0e6be5bbe8c506882e8100ccaaf13a5f58079f97.tar.bz2 lingo-ap-tracker-0e6be5bbe8c506882e8100ccaaf13a5f58079f97.zip |
Merge branch 'main' into panels panels
Diffstat (limited to 'src/tracker_state.cpp')
-rw-r--r-- | src/tracker_state.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index 18bb499..4a49fac 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp | |||
@@ -166,6 +166,7 @@ struct TrackerState { | |||
166 | std::mutex reachability_mutex; | 166 | std::mutex reachability_mutex; |
167 | RequirementCalculator requirements; | 167 | RequirementCalculator requirements; |
168 | std::map<int, std::map<std::string, bool>> door_reports; | 168 | std::map<int, std::map<std::string, bool>> door_reports; |
169 | bool pilgrimage_doable = false; | ||
169 | }; | 170 | }; |
170 | 171 | ||
171 | enum Decision { kYes, kNo, kMaybe }; | 172 | enum Decision { kYes, kNo, kMaybe }; |
@@ -375,6 +376,8 @@ class StateCalculator { | |||
375 | return door_report_; | 376 | return door_report_; |
376 | } | 377 | } |
377 | 378 | ||
379 | bool IsPilgrimageDoable() const { return pilgrimage_doable_; } | ||
380 | |||
378 | std::string GetPathToRoom(int room_id) const { | 381 | std::string GetPathToRoom(int room_id) const { |
379 | if (!paths_.count(room_id)) { | 382 | if (!paths_.count(room_id)) { |
380 | return ""; | 383 | return ""; |
@@ -601,6 +604,8 @@ class StateCalculator { | |||
601 | } | 604 | } |
602 | } | 605 | } |
603 | 606 | ||
607 | pilgrimage_doable_ = true; | ||
608 | |||
604 | return kYes; | 609 | return kYes; |
605 | } | 610 | } |
606 | 611 | ||
@@ -641,6 +646,7 @@ class StateCalculator { | |||
641 | std::set<int> solveable_panels_; | 646 | std::set<int> solveable_panels_; |
642 | std::set<int> reachable_paintings_; | 647 | std::set<int> reachable_paintings_; |
643 | std::map<int, std::map<std::string, bool>> door_report_; | 648 | std::map<int, std::map<std::string, bool>> door_report_; |
649 | bool pilgrimage_doable_ = false; | ||
644 | 650 | ||
645 | std::map<int, std::list<int>> paths_; | 651 | std::map<int, std::list<int>> paths_; |
646 | }; | 652 | }; |
@@ -692,6 +698,7 @@ void RecalculateReachability() { | |||
692 | std::swap(GetState().reachable_doors, new_reachable_doors); | 698 | std::swap(GetState().reachable_doors, new_reachable_doors); |
693 | std::swap(GetState().reachable_paintings, reachable_paintings); | 699 | std::swap(GetState().reachable_paintings, reachable_paintings); |
694 | std::swap(GetState().door_reports, door_reports); | 700 | std::swap(GetState().door_reports, door_reports); |
701 | GetState().pilgrimage_doable = state_calculator.IsPilgrimageDoable(); | ||
695 | } | 702 | } |
696 | 703 | ||
697 | bool IsLocationReachable(int location_id) { | 704 | bool IsLocationReachable(int location_id) { |
@@ -721,3 +728,9 @@ const std::map<std::string, bool>& GetDoorRequirements(int door_id) { | |||
721 | 728 | ||
722 | return GetState().door_reports[door_id]; | 729 | return GetState().door_reports[door_id]; |
723 | } | 730 | } |
731 | |||
732 | bool IsPilgrimageDoable() { | ||
733 | std::lock_guard reachability_guard(GetState().reachability_mutex); | ||
734 | |||
735 | return GetState().pilgrimage_doable; | ||
736 | } | ||