diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-09 12:00:40 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-09 12:00:40 -0400 |
commit | 233a0b98a04e6a39cd37cbfc9a6db39a3fcf3e33 (patch) | |
tree | fe6795f131444c3ed0c73c3698bbf803a212c0b5 /src | |
parent | 163897c7933a8970bc919b8153e9871aebda4afc (diff) | |
download | lingo-ap-tracker-233a0b98a04e6a39cd37cbfc9a6db39a3fcf3e33.tar.gz lingo-ap-tracker-233a0b98a04e6a39cd37cbfc9a6db39a3fcf3e33.tar.bz2 lingo-ap-tracker-233a0b98a04e6a39cd37cbfc9a6db39a3fcf3e33.zip |
Keep reachable doors/panels between reachability calcs
Receiving items/paintings shouldn't ever reduce access, so we can keep Yes decisions from prior runs (as long as we clear out everything when connecting to a new slot).
Diffstat (limited to 'src')
-rw-r--r-- | src/tracker_state.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index bcee1d6..9acf312 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp | |||
@@ -167,6 +167,7 @@ class RequirementCalculator { | |||
167 | struct TrackerState { | 167 | struct TrackerState { |
168 | std::map<int, bool> reachability; | 168 | std::map<int, bool> reachability; |
169 | std::set<int> reachable_doors; | 169 | std::set<int> reachable_doors; |
170 | std::set<int> solveable_panels; | ||
170 | std::set<int> reachable_paintings; | 171 | std::set<int> reachable_paintings; |
171 | std::mutex reachability_mutex; | 172 | std::mutex reachability_mutex; |
172 | RequirementCalculator requirements; | 173 | RequirementCalculator requirements; |
@@ -206,6 +207,16 @@ class StateCalculator { | |||
206 | explicit StateCalculator(StateCalculatorOptions options) | 207 | explicit StateCalculator(StateCalculatorOptions options) |
207 | : options_(options) {} | 208 | : options_(options) {} |
208 | 209 | ||
210 | void PreloadPanels(const std::set<int>& panels) { | ||
211 | solveable_panels_ = panels; | ||
212 | } | ||
213 | |||
214 | void PreloadDoors(const std::set<int>& doors) { | ||
215 | for (int door_id : doors) { | ||
216 | door_decisions_[door_id] = kYes; | ||
217 | } | ||
218 | } | ||
219 | |||
209 | void Calculate() { | 220 | void Calculate() { |
210 | painting_mapping_ = AP_GetPaintingMapping(); | 221 | painting_mapping_ = AP_GetPaintingMapping(); |
211 | checked_paintings_ = AP_GetCheckedPaintings(); | 222 | checked_paintings_ = AP_GetCheckedPaintings(); |
@@ -682,6 +693,8 @@ class StateCalculator { | |||
682 | void ResetReachabilityRequirements() { | 693 | void ResetReachabilityRequirements() { |
683 | std::lock_guard reachability_guard(GetState().reachability_mutex); | 694 | std::lock_guard reachability_guard(GetState().reachability_mutex); |
684 | GetState().requirements.Reset(); | 695 | GetState().requirements.Reset(); |
696 | GetState().reachable_doors.clear(); | ||
697 | GetState().solveable_panels.clear(); | ||
685 | 698 | ||
686 | if (AP_IsPostgameShuffle()) { | 699 | if (AP_IsPostgameShuffle()) { |
687 | GetState().non_postgame_areas.clear(); | 700 | GetState().non_postgame_areas.clear(); |
@@ -743,11 +756,16 @@ void ResetReachabilityRequirements() { | |||
743 | void RecalculateReachability() { | 756 | void RecalculateReachability() { |
744 | std::lock_guard reachability_guard(GetState().reachability_mutex); | 757 | std::lock_guard reachability_guard(GetState().reachability_mutex); |
745 | 758 | ||
759 | // Receiving items and checking paintings should never remove access to doors | ||
760 | // or panels, so we can preload any doors and panels we already know are | ||
761 | // accessible from previous runs, in order to reduce the work. | ||
746 | StateCalculator state_calculator({.start = GD_GetRoomByName("Menu")}); | 762 | StateCalculator state_calculator({.start = GD_GetRoomByName("Menu")}); |
763 | state_calculator.PreloadDoors(GetState().reachable_doors); | ||
764 | state_calculator.PreloadPanels(GetState().solveable_panels); | ||
747 | state_calculator.Calculate(); | 765 | state_calculator.Calculate(); |
748 | 766 | ||
749 | const std::set<int>& reachable_rooms = state_calculator.GetReachableRooms(); | 767 | const std::set<int>& reachable_rooms = state_calculator.GetReachableRooms(); |
750 | const std::set<int>& solveable_panels = state_calculator.GetSolveablePanels(); | 768 | std::set<int> solveable_panels = state_calculator.GetSolveablePanels(); |
751 | 769 | ||
752 | std::map<int, bool> new_reachability; | 770 | std::map<int, bool> new_reachability; |
753 | for (const MapArea& map_area : GD_GetMapAreas()) { | 771 | for (const MapArea& map_area : GD_GetMapAreas()) { |
@@ -778,6 +796,7 @@ void RecalculateReachability() { | |||
778 | 796 | ||
779 | std::swap(GetState().reachability, new_reachability); | 797 | std::swap(GetState().reachability, new_reachability); |
780 | std::swap(GetState().reachable_doors, new_reachable_doors); | 798 | std::swap(GetState().reachable_doors, new_reachable_doors); |
799 | std::swap(GetState().solveable_panels, solveable_panels); | ||
781 | std::swap(GetState().reachable_paintings, reachable_paintings); | 800 | std::swap(GetState().reachable_paintings, reachable_paintings); |
782 | std::swap(GetState().door_reports, door_reports); | 801 | std::swap(GetState().door_reports, door_reports); |
783 | GetState().pilgrimage_doable = state_calculator.IsPilgrimageDoable(); | 802 | GetState().pilgrimage_doable = state_calculator.IsPilgrimageDoable(); |