about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-07-24 13:36:07 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-07-24 13:36:07 -0400
commit4ffb5871e4bc54ab6765fcd738835c295d1e2924 (patch)
tree47d9521046ae6b628ec3b64d5a2890e6a26bcbbf
parent1a935f45c98905a20a13265ae0d00f9674ec4ea6 (diff)
downloadlingo-ap-tracker-4ffb5871e4bc54ab6765fcd738835c295d1e2924.tar.gz
lingo-ap-tracker-4ffb5871e4bc54ab6765fcd738835c295d1e2924.tar.bz2
lingo-ap-tracker-4ffb5871e4bc54ab6765fcd738835c295d1e2924.zip
Pilgrim Antechamber sunwarp now shows if pilgrimage is doable
-rw-r--r--src/network_set.cpp13
-rw-r--r--src/network_set.h2
-rw-r--r--src/subway_map.cpp20
-rw-r--r--src/tracker_state.cpp13
-rw-r--r--src/tracker_state.h2
5 files changed, 49 insertions, 1 deletions
diff --git a/src/network_set.cpp b/src/network_set.cpp index 6d2a098..2a9e12c 100644 --- a/src/network_set.cpp +++ b/src/network_set.cpp
@@ -21,6 +21,19 @@ void NetworkSet::AddLink(int id1, int id2) {
21 network_by_item_[id2].insert({id1, id2}); 21 network_by_item_[id2].insert({id1, id2});
22} 22}
23 23
24void NetworkSet::AddLinkToNetwork(int network_id, int id1, int id2) {
25 if (id2 > id1) {
26 // Make sure id1 < id2
27 std::swap(id1, id2);
28 }
29
30 if (!network_by_item_.count(network_id)) {
31 network_by_item_[network_id] = {};
32 }
33
34 network_by_item_[network_id].insert({id1, id2});
35}
36
24bool NetworkSet::IsItemInNetwork(int id) const { 37bool NetworkSet::IsItemInNetwork(int id) const {
25 return network_by_item_.count(id); 38 return network_by_item_.count(id);
26} 39}
diff --git a/src/network_set.h b/src/network_set.h index e6f0c07..cec3f39 100644 --- a/src/network_set.h +++ b/src/network_set.h
@@ -13,6 +13,8 @@ class NetworkSet {
13 13
14 void AddLink(int id1, int id2); 14 void AddLink(int id1, int id2);
15 15
16 void AddLinkToNetwork(int network_id, int id1, int id2);
17
16 bool IsItemInNetwork(int id) const; 18 bool IsItemInNetwork(int id) const;
17 19
18 const std::set<std::pair<int, int>>& GetNetworkGraph(int id) const; 20 const std::set<std::pair<int, int>>& GetNetworkGraph(int id) const;
diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 9bfedf9..e7ac317 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp
@@ -107,7 +107,7 @@ void SubwayMap::OnConnect() {
107 107
108 if (!AP_IsSunwarpShuffle() && subway_item.sunwarp && 108 if (!AP_IsSunwarpShuffle() && subway_item.sunwarp &&
109 subway_item.sunwarp->type != SubwaySunwarpType::kFinal) { 109 subway_item.sunwarp->type != SubwaySunwarpType::kFinal) {
110 std::string tag = fmt::format("subway{}", subway_item.sunwarp->dots); 110 std::string tag = fmt::format("sunwarp{}", subway_item.sunwarp->dots);
111 tagged[tag].push_back(subway_item.id); 111 tagged[tag].push_back(subway_item.id);
112 } 112 }
113 113
@@ -119,6 +119,9 @@ void SubwayMap::OnConnect() {
119 } 119 }
120 120
121 if (AP_IsSunwarpShuffle()) { 121 if (AP_IsSunwarpShuffle()) {
122 SubwaySunwarp final_sunwarp{.dots = 6, .type = SubwaySunwarpType::kFinal};
123 int final_sunwarp_item = GD_GetSubwayItemForSunwarp(final_sunwarp);
124
122 for (const auto &[index, mapping] : AP_GetSunwarpMapping()) { 125 for (const auto &[index, mapping] : AP_GetSunwarpMapping()) {
123 std::string tag = fmt::format("sunwarp{}", mapping.dots); 126 std::string tag = fmt::format("sunwarp{}", mapping.dots);
124 127
@@ -142,6 +145,11 @@ void SubwayMap::OnConnect() {
142 145
143 tagged[tag].push_back(GD_GetSubwayItemForSunwarp(fromWarp)); 146 tagged[tag].push_back(GD_GetSubwayItemForSunwarp(fromWarp));
144 tagged[tag].push_back(GD_GetSubwayItemForSunwarp(toWarp)); 147 tagged[tag].push_back(GD_GetSubwayItemForSunwarp(toWarp));
148
149 networks_.AddLinkToNetwork(
150 final_sunwarp_item, GD_GetSubwayItemForSunwarp(fromWarp),
151 mapping.dots == 6 ? final_sunwarp_item
152 : GD_GetSubwayItemForSunwarp(toWarp));
145 } 153 }
146 } 154 }
147 155
@@ -570,6 +578,16 @@ void SubwayMap::Redraw() {
570 brush_color = wxRED_BRUSH; 578 brush_color = wxRED_BRUSH;
571 } 579 }
572 } 580 }
581 } else if (subway_item.sunwarp &&
582 subway_item.sunwarp->type == SubwaySunwarpType::kFinal &&
583 AP_IsPilgrimageEnabled()) {
584 draw_type = ItemDrawType::kBox;
585
586 if (IsPilgrimageDoable()) {
587 brush_color = wxGREEN_BRUSH;
588 } else {
589 brush_color = wxRED_BRUSH;
590 }
573 } else if (!subway_item.paintings.empty()) { 591 } else if (!subway_item.paintings.empty()) {
574 if (AP_IsPaintingShuffle()) { 592 if (AP_IsPaintingShuffle()) {
575 bool has_checked_painting = false; 593 bool has_checked_painting = false;
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}
diff --git a/src/tracker_state.h b/src/tracker_state.h index c7857a0..a8f155d 100644 --- a/src/tracker_state.h +++ b/src/tracker_state.h
@@ -16,4 +16,6 @@ bool IsPaintingReachable(int painting_id);
16 16
17const std::map<std::string, bool>& GetDoorRequirements(int door_id); 17const std::map<std::string, bool>& GetDoorRequirements(int door_id);
18 18
19bool IsPilgrimageDoable();
20
19#endif /* end of include guard: TRACKER_STATE_H_8639BC90 */ 21#endif /* end of include guard: TRACKER_STATE_H_8639BC90 */