From 004fb711a86d91985d8e94e1b87089db2ac2cadc Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Apr 2024 11:34:49 -0400 Subject: Support panels mode door shuffle --- src/tracker_state.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/tracker_state.cpp') diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index e02ee14..9d2c6d1 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -29,7 +29,7 @@ Decision IsDoorReachable_Helper(int door_id, const std::set& solveable_panels) { const Door& door_obj = GD_GetDoor(door_id); - if (AP_GetDoorShuffleMode() == kNO_DOORS || door_obj.skip_item) { + if (AP_GetDoorShuffleMode() != kDOORS_MODE || door_obj.skip_item) { if (!reachable_rooms.count(door_obj.room)) { return kMaybe; } @@ -41,7 +41,7 @@ Decision IsDoorReachable_Helper(int door_id, } return kYes; - } else if (AP_GetDoorShuffleMode() == kSIMPLE_DOORS && + } else if (AP_GetDoorShuffleMode() == kDOORS_MODE && AP_AreDoorsGrouped() && !door_obj.group_name.empty()) { return AP_HasItem(door_obj.group_ap_item_id) ? kYes : kNo; } else { @@ -136,6 +136,28 @@ Decision IsPanelReachable_Helper(int panel_id, } } + if (panel_obj.panel_door != -1 && AP_GetDoorShuffleMode() == kPANELS_MODE) { + const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_obj.panel_door); + + if (AP_AreDoorsGrouped() && panel_door_obj.group_ap_item_id != -1) { + return AP_HasItem(panel_door_obj.group_ap_item_id) ? kYes : kNo; + } else { + bool has_item = AP_HasItem(panel_door_obj.ap_item_id); + + if (!has_item) { + for (const ProgressiveRequirement& prog_req : + panel_door_obj.progressives) { + if (AP_HasItem(prog_req.ap_item_id, prog_req.quantity)) { + has_item = true; + break; + } + } + } + + return has_item ? kYes : kNo; + } + } + return kYes; } -- cgit 1.4.1 From 37f78b958c98d6707d84eaf0e3854282a37b6644 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 27 Apr 2024 12:49:51 -0400 Subject: Fixed merge errors --- src/tracker_state.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/tracker_state.cpp') diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index d3dde0d..0d9a9cd 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -212,7 +212,7 @@ class StateCalculator { } return kYes; - } else if ((AP_GetDoorShuffleMode() == kDOORS_MODE && AP_AreDoorsGrouped() && + } else if (AP_GetDoorShuffleMode() == kDOORS_MODE && AP_AreDoorsGrouped() && !door_obj.group_name.empty()) { return AP_HasItem(door_obj.group_ap_item_id) ? kYes : kNo; } else { @@ -302,33 +302,34 @@ class StateCalculator { } } - if (AP_IsColorShuffle()) { - for (LingoColor color : panel_obj.colors) { - if (!AP_HasItem(GD_GetItemIdForColor(color))) { - return kNo; + if (AP_IsColorShuffle()) { + for (LingoColor color : panel_obj.colors) { + if (!AP_HasItem(GD_GetItemIdForColor(color))) { + return kNo; + } } } - } - if (panel_obj.panel_door != -1 && AP_GetDoorShuffleMode() == kPANELS_MODE) { - const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_obj.panel_door); + if (panel_obj.panel_door != -1 && AP_GetDoorShuffleMode() == kPANELS_MODE) { + const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_obj.panel_door); - if (AP_AreDoorsGrouped() && panel_door_obj.group_ap_item_id != -1) { - return AP_HasItem(panel_door_obj.group_ap_item_id) ? kYes : kNo; - } else { - bool has_item = AP_HasItem(panel_door_obj.ap_item_id); + if (AP_AreDoorsGrouped() && panel_door_obj.group_ap_item_id != -1) { + return AP_HasItem(panel_door_obj.group_ap_item_id) ? kYes : kNo; + } else { + bool has_item = AP_HasItem(panel_door_obj.ap_item_id); - if (!has_item) { - for (const ProgressiveRequirement& prog_req : - panel_door_obj.progressives) { - if (AP_HasItem(prog_req.ap_item_id, prog_req.quantity)) { - has_item = true; - break; + if (!has_item) { + for (const ProgressiveRequirement& prog_req : + panel_door_obj.progressives) { + if (AP_HasItem(prog_req.ap_item_id, prog_req.quantity)) { + has_item = true; + break; + } } } - } - return has_item ? kYes : kNo; + return has_item ? kYes : kNo; + } } return kYes; -- cgit 1.4.1 From 63d11be5961c0a5647af8f2c411aa2f3ca58e5b6 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 9 Jun 2024 23:50:35 -0400 Subject: Revert subway map crashing on hover before connect --- src/tracker_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tracker_state.cpp') diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index c475fb7..fb143f8 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -672,5 +672,5 @@ bool IsPaintingReachable(int painting_id) { const std::map& GetDoorRequirements(int door_id) { std::lock_guard reachability_guard(GetState().reachability_mutex); - return GetState().door_reports.at(door_id); + return GetState().door_reports[door_id]; } -- cgit 1.4.1 From 2944687cbbaa53d0815fea9f5f2506500e2e1db3 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 9 Jun 2024 23:52:14 -0400 Subject: Fix panel door reachability calculation --- src/tracker_state.cpp | 69 ++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 31 deletions(-) (limited to 'src/tracker_state.cpp') 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 { struct Requirements { bool disabled = false; - std::set doors; // non-grouped, handles progressive - std::set items; // all other items - std::set rooms; // maybe - bool mastery = false; // maybe - bool panel_hunt = false; // maybe + std::set doors; // non-grouped, handles progressive + std::set panel_doors; // non-grouped, handles progressive + std::set items; // all other items + std::set rooms; // maybe + bool mastery = false; // maybe + bool panel_hunt = false; // maybe void Merge(const Requirements& rhs) { if (rhs.disabled) { @@ -29,6 +30,9 @@ struct Requirements { for (int id : rhs.doors) { doors.insert(id); } + for (int id : rhs.panel_doors) { + panel_doors.insert(id); + } for (int id : rhs.items) { items.insert(id); } @@ -74,15 +78,14 @@ class RequirementCalculator { requirements.doors.insert(door_obj.id); break; } - } else if (AP_GetDoorShuffleMode() == kNO_DOORS || door_obj.skip_item) { + } else if (AP_GetDoorShuffleMode() != kDOORS_MODE || door_obj.skip_item) { requirements.rooms.insert(door_obj.room); for (int panel_id : door_obj.panels) { const Requirements& panel_reqs = GetPanel(panel_id); requirements.Merge(panel_reqs); } - } else if (AP_GetDoorShuffleMode() == kSIMPLE_DOORS && - !door_obj.group_name.empty()) { + } else if (AP_AreDoorsGrouped() && !door_obj.group_name.empty()) { requirements.items.insert(door_obj.group_ap_item_id); } else { requirements.doors.insert(door_obj.id); @@ -129,6 +132,17 @@ class RequirementCalculator { requirements.items.insert(GD_GetItemIdForColor(color)); } } + + if (panel_obj.panel_door != -1 && + AP_GetDoorShuffleMode() == kPANELS_MODE) { + const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_obj.panel_door); + + if (panel_door_obj.group_ap_item_id != -1 && AP_AreDoorsGrouped()) { + requirements.items.insert(panel_door_obj.group_ap_item_id); + } else { + requirements.panel_doors.insert(panel_obj.panel_door); + } + } panels_[panel_id] = requirements; } @@ -337,7 +351,8 @@ class StateCalculator { } private: - Decision IsNonGroupedDoorReachable(const Door& door_obj) { + template + Decision IsNonGroupedDoorReachable(const T& door_obj) { bool has_item = AP_HasItem(door_obj.ap_item_id); if (!has_item) { @@ -373,6 +388,20 @@ class StateCalculator { } } + for (int panel_door_id : reqs.panel_doors) { + const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_door_id); + Decision decision = IsNonGroupedDoorReachable(panel_door_obj); + + if (report) { + (*report)[AP_GetItemName(panel_door_obj.ap_item_id)] = + (decision == kYes); + } + + if (decision != kYes) { + final_decision = decision; + } + } + for (int item_id : reqs.items) { bool has_item = AP_HasItem(item_id); if (report) { @@ -486,28 +515,6 @@ class StateCalculator { return IsDoorReachable(*painting.door); } - if (panel_obj.panel_door != -1 && AP_GetDoorShuffleMode() == kPANELS_MODE) { - const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_obj.panel_door); - - if (AP_AreDoorsGrouped() && panel_door_obj.group_ap_item_id != -1) { - return AP_HasItem(panel_door_obj.group_ap_item_id) ? kYes : kNo; - } else { - bool has_item = AP_HasItem(panel_door_obj.ap_item_id); - - if (!has_item) { - for (const ProgressiveRequirement& prog_req : - panel_door_obj.progressives) { - if (AP_HasItem(prog_req.ap_item_id, prog_req.quantity)) { - has_item = true; - break; - } - } - } - - return has_item ? kYes : kNo; - } - } - return kYes; } -- cgit 1.4.1