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.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index 66e7751..a4134f9 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp
@@ -584,6 +584,8 @@ void ResetReachabilityRequirements() {
584} 584}
585 585
586void RecalculateReachability() { 586void RecalculateReachability() {
587 std::lock_guard reachability_guard(GetState().reachability_mutex);
588
587 StateCalculator state_calculator({.start = GD_GetRoomByName("Menu")}); 589 StateCalculator state_calculator({.start = GD_GetRoomByName("Menu")});
588 state_calculator.Calculate(); 590 state_calculator.Calculate();
589 591
@@ -616,14 +618,11 @@ void RecalculateReachability() {
616 std::set<int> reachable_paintings = state_calculator.GetReachablePaintings(); 618 std::set<int> reachable_paintings = state_calculator.GetReachablePaintings();
617 std::map<int, std::map<std::string, bool>> door_reports = 619 std::map<int, std::map<std::string, bool>> door_reports =
618 state_calculator.GetDoorReports(); 620 state_calculator.GetDoorReports();
619 621
620 { 622 std::swap(GetState().reachability, new_reachability);
621 std::lock_guard reachability_guard(GetState().reachability_mutex); 623 std::swap(GetState().reachable_doors, new_reachable_doors);
622 std::swap(GetState().reachability, new_reachability); 624 std::swap(GetState().reachable_paintings, reachable_paintings);
623 std::swap(GetState().reachable_doors, new_reachable_doors); 625 std::swap(GetState().door_reports, door_reports);
624 std::swap(GetState().reachable_paintings, reachable_paintings);
625 std::swap(GetState().door_reports, door_reports);
626 }
627} 626}
628 627
629bool IsLocationReachable(int location_id) { 628bool IsLocationReachable(int location_id) {
@@ -651,5 +650,5 @@ bool IsPaintingReachable(int painting_id) {
651const std::map<std::string, bool>& GetDoorRequirements(int door_id) { 650const std::map<std::string, bool>& GetDoorRequirements(int door_id) {
652 std::lock_guard reachability_guard(GetState().reachability_mutex); 651 std::lock_guard reachability_guard(GetState().reachability_mutex);
653 652
654 return GetState().door_reports[door_id]; 653 return GetState().door_reports.at(door_id);
655} 654}