about summary refs log tree commit diff stats
path: root/src/tracker_state.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tracker_state.cpp')
-rw-r--r--src/tracker_state.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index bd63076..2ee705c 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp
@@ -152,6 +152,7 @@ struct TrackerState {
152 std::mutex reachability_mutex; 152 std::mutex reachability_mutex;
153 RequirementCalculator requirements; 153 RequirementCalculator requirements;
154 std::map<int, std::map<std::string, bool>> door_reports; 154 std::map<int, std::map<std::string, bool>> door_reports;
155 bool pilgrimage_doable = false;
155}; 156};
156 157
157enum Decision { kYes, kNo, kMaybe }; 158enum Decision { kYes, kNo, kMaybe };
@@ -361,6 +362,8 @@ class StateCalculator {
361 return door_report_; 362 return door_report_;
362 } 363 }
363 364
365 bool IsPilgrimageDoable() const { return pilgrimage_doable_; }
366
364 std::string GetPathToRoom(int room_id) const { 367 std::string GetPathToRoom(int room_id) const {
365 if (!paths_.count(room_id)) { 368 if (!paths_.count(room_id)) {
366 return ""; 369 return "";
@@ -572,6 +575,8 @@ class StateCalculator {
572 } 575 }
573 } 576 }
574 577
578 pilgrimage_doable_ = true;
579
575 return kYes; 580 return kYes;
576 } 581 }
577 582
@@ -612,6 +617,7 @@ class StateCalculator {
612 std::set<int> solveable_panels_; 617 std::set<int> solveable_panels_;
613 std::set<int> reachable_paintings_; 618 std::set<int> reachable_paintings_;
614 std::map<int, std::map<std::string, bool>> door_report_; 619 std::map<int, std::map<std::string, bool>> door_report_;
620 bool pilgrimage_doable_ = false;
615 621
616 std::map<int, std::list<int>> paths_; 622 std::map<int, std::list<int>> paths_;
617}; 623};
@@ -663,6 +669,7 @@ void RecalculateReachability() {
663 std::swap(GetState().reachable_doors, new_reachable_doors); 669 std::swap(GetState().reachable_doors, new_reachable_doors);
664 std::swap(GetState().reachable_paintings, reachable_paintings); 670 std::swap(GetState().reachable_paintings, reachable_paintings);
665 std::swap(GetState().door_reports, door_reports); 671 std::swap(GetState().door_reports, door_reports);
672 GetState().pilgrimage_doable = state_calculator.IsPilgrimageDoable();
666} 673}
667 674
668bool IsLocationReachable(int location_id) { 675bool IsLocationReachable(int location_id) {
@@ -692,3 +699,9 @@ const std::map<std::string, bool>& GetDoorRequirements(int door_id) {
692 699
693 return GetState().door_reports[door_id]; 700 return GetState().door_reports[door_id];
694} 701}
702
703bool IsPilgrimageDoable() {
704 std::lock_guard reachability_guard(GetState().reachability_mutex);
705
706 return GetState().pilgrimage_doable;
707}