about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-06-09 23:52:14 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-06-09 23:52:14 -0400
commit2944687cbbaa53d0815fea9f5f2506500e2e1db3 (patch)
tree38005dcde07b7830f24686b9bf0367b60630d3c3
parent6676e8fda6c58a93ae9d5cea0c4ad622a77305be (diff)
downloadlingo-ap-tracker-2944687cbbaa53d0815fea9f5f2506500e2e1db3.tar.gz
lingo-ap-tracker-2944687cbbaa53d0815fea9f5f2506500e2e1db3.tar.bz2
lingo-ap-tracker-2944687cbbaa53d0815fea9f5f2506500e2e1db3.zip
Fix panel door reachability calculation
-rw-r--r--src/tracker_state.cpp69
1 files changed, 38 insertions, 31 deletions
diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index fb143f8..eaf3e6b 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp
@@ -15,11 +15,12 @@ namespace {
15struct Requirements { 15struct Requirements {
16 bool disabled = false; 16 bool disabled = false;
17 17
18 std::set<int> doors; // non-grouped, handles progressive 18 std::set<int> doors; // non-grouped, handles progressive
19 std::set<int> items; // all other items 19 std::set<int> panel_doors; // non-grouped, handles progressive
20 std::set<int> rooms; // maybe 20 std::set<int> items; // all other items
21 bool mastery = false; // maybe 21 std::set<int> rooms; // maybe
22 bool panel_hunt = false; // maybe 22 bool mastery = false; // maybe
23 bool panel_hunt = false; // maybe
23 24
24 void Merge(const Requirements& rhs) { 25 void Merge(const Requirements& rhs) {
25 if (rhs.disabled) { 26 if (rhs.disabled) {
@@ -29,6 +30,9 @@ struct Requirements {
29 for (int id : rhs.doors) { 30 for (int id : rhs.doors) {
30 doors.insert(id); 31 doors.insert(id);
31 } 32 }
33 for (int id : rhs.panel_doors) {
34 panel_doors.insert(id);
35 }
32 for (int id : rhs.items) { 36 for (int id : rhs.items) {
33 items.insert(id); 37 items.insert(id);
34 } 38 }
@@ -74,15 +78,14 @@ class RequirementCalculator {
74 requirements.doors.insert(door_obj.id); 78 requirements.doors.insert(door_obj.id);
75 break; 79 break;
76 } 80 }
77 } else if (AP_GetDoorShuffleMode() == kNO_DOORS || door_obj.skip_item) { 81 } else if (AP_GetDoorShuffleMode() != kDOORS_MODE || door_obj.skip_item) {
78 requirements.rooms.insert(door_obj.room); 82 requirements.rooms.insert(door_obj.room);
79 83
80 for (int panel_id : door_obj.panels) { 84 for (int panel_id : door_obj.panels) {
81 const Requirements& panel_reqs = GetPanel(panel_id); 85 const Requirements& panel_reqs = GetPanel(panel_id);
82 requirements.Merge(panel_reqs); 86 requirements.Merge(panel_reqs);
83 } 87 }
84 } else if (AP_GetDoorShuffleMode() == kSIMPLE_DOORS && 88 } else if (AP_AreDoorsGrouped() && !door_obj.group_name.empty()) {
85 !door_obj.group_name.empty()) {
86 requirements.items.insert(door_obj.group_ap_item_id); 89 requirements.items.insert(door_obj.group_ap_item_id);
87 } else { 90 } else {
88 requirements.doors.insert(door_obj.id); 91 requirements.doors.insert(door_obj.id);
@@ -129,6 +132,17 @@ class RequirementCalculator {
129 requirements.items.insert(GD_GetItemIdForColor(color)); 132 requirements.items.insert(GD_GetItemIdForColor(color));
130 } 133 }
131 } 134 }
135
136 if (panel_obj.panel_door != -1 &&
137 AP_GetDoorShuffleMode() == kPANELS_MODE) {
138 const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_obj.panel_door);
139
140 if (panel_door_obj.group_ap_item_id != -1 && AP_AreDoorsGrouped()) {
141 requirements.items.insert(panel_door_obj.group_ap_item_id);
142 } else {
143 requirements.panel_doors.insert(panel_obj.panel_door);
144 }
145 }
132 146
133 panels_[panel_id] = requirements; 147 panels_[panel_id] = requirements;
134 } 148 }
@@ -337,7 +351,8 @@ class StateCalculator {
337 } 351 }
338 352
339 private: 353 private:
340 Decision IsNonGroupedDoorReachable(const Door& door_obj) { 354 template <typename T>
355 Decision IsNonGroupedDoorReachable(const T& door_obj) {
341 bool has_item = AP_HasItem(door_obj.ap_item_id); 356 bool has_item = AP_HasItem(door_obj.ap_item_id);
342 357
343 if (!has_item) { 358 if (!has_item) {
@@ -373,6 +388,20 @@ class StateCalculator {
373 } 388 }
374 } 389 }
375 390
391 for (int panel_door_id : reqs.panel_doors) {
392 const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_door_id);
393 Decision decision = IsNonGroupedDoorReachable(panel_door_obj);
394
395 if (report) {
396 (*report)[AP_GetItemName(panel_door_obj.ap_item_id)] =
397 (decision == kYes);
398 }
399
400 if (decision != kYes) {
401 final_decision = decision;
402 }
403 }
404
376 for (int item_id : reqs.items) { 405 for (int item_id : reqs.items) {
377 bool has_item = AP_HasItem(item_id); 406 bool has_item = AP_HasItem(item_id);
378 if (report) { 407 if (report) {
@@ -486,28 +515,6 @@ class StateCalculator {
486 return IsDoorReachable(*painting.door); 515 return IsDoorReachable(*painting.door);
487 } 516 }
488 517
489 if (panel_obj.panel_door != -1 && AP_GetDoorShuffleMode() == kPANELS_MODE) {
490 const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_obj.panel_door);
491
492 if (AP_AreDoorsGrouped() && panel_door_obj.group_ap_item_id != -1) {
493 return AP_HasItem(panel_door_obj.group_ap_item_id) ? kYes : kNo;
494 } else {
495 bool has_item = AP_HasItem(panel_door_obj.ap_item_id);
496
497 if (!has_item) {
498 for (const ProgressiveRequirement& prog_req :
499 panel_door_obj.progressives) {
500 if (AP_HasItem(prog_req.ap_item_id, prog_req.quantity)) {
501 has_item = true;
502 break;
503 }
504 }
505 }
506
507 return has_item ? kYes : kNo;
508 }
509 }
510
511 return kYes; 518 return kYes;
512 } 519 }
513 520