diff options
Diffstat (limited to 'src/tracker_state.cpp')
| -rw-r--r-- | src/tracker_state.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
| diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index 640a159..5588c7f 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp | |||
| @@ -14,6 +14,7 @@ namespace { | |||
| 14 | 14 | ||
| 15 | struct TrackerState { | 15 | struct TrackerState { |
| 16 | std::map<int, bool> reachability; | 16 | std::map<int, bool> reachability; |
| 17 | std::set<int> reachable_doors; | ||
| 17 | std::mutex reachability_mutex; | 18 | std::mutex reachability_mutex; |
| 18 | }; | 19 | }; |
| 19 | 20 | ||
| @@ -156,6 +157,11 @@ class StateCalculator { | |||
| 156 | flood_boundary = new_boundary; | 157 | flood_boundary = new_boundary; |
| 157 | panel_boundary = new_panel_boundary; | 158 | panel_boundary = new_panel_boundary; |
| 158 | } | 159 | } |
| 160 | |||
| 161 | // Now that we know the full reachable area, let's make sure all doors are evaluated. | ||
| 162 | for (const Door& door : GD_GetDoors()) { | ||
| 163 | int discard = IsDoorReachable(door.id); | ||
| 164 | } | ||
| 159 | } | 165 | } |
| 160 | 166 | ||
| 161 | const std::set<int>& GetReachableRooms() const { return reachable_rooms_; } | 167 | const std::set<int>& GetReachableRooms() const { return reachable_rooms_; } |
| @@ -422,9 +428,17 @@ void RecalculateReachability() { | |||
| 422 | } | 428 | } |
| 423 | } | 429 | } |
| 424 | 430 | ||
| 431 | std::set<int> new_reachable_doors; | ||
| 432 | for (const auto& [door_id, decision] : state_calculator.GetDoorDecisions()) { | ||
| 433 | if (decision == kYes) { | ||
| 434 | new_reachable_doors.insert(door_id); | ||
| 435 | } | ||
| 436 | } | ||
| 437 | |||
| 425 | { | 438 | { |
| 426 | std::lock_guard reachability_guard(GetState().reachability_mutex); | 439 | std::lock_guard reachability_guard(GetState().reachability_mutex); |
| 427 | std::swap(GetState().reachability, new_reachability); | 440 | std::swap(GetState().reachability, new_reachability); |
| 441 | std::swap(GetState().reachable_doors, new_reachable_doors); | ||
| 428 | } | 442 | } |
| 429 | } | 443 | } |
| 430 | 444 | ||
| @@ -437,3 +451,9 @@ bool IsLocationReachable(int location_id) { | |||
| 437 | return false; | 451 | return false; |
| 438 | } | 452 | } |
| 439 | } | 453 | } |
| 454 | |||
| 455 | bool IsDoorOpen(int door_id) { | ||
| 456 | std::lock_guard reachability_guard(GetState().reachability_mutex); | ||
| 457 | |||
| 458 | return GetState().reachable_doors.count(door_id); | ||
| 459 | } | ||
