From f5684174bf34e447bc36eb4b1760e5420f38de2f Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 19 Jan 2024 18:31:09 -0500 Subject: Handle renamed bearer entrance --- assets/pilgrimage.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'assets/pilgrimage.yaml') diff --git a/assets/pilgrimage.yaml b/assets/pilgrimage.yaml index 7fba98f..bed0a34 100644 --- a/assets/pilgrimage.yaml +++ b/assets/pilgrimage.yaml @@ -18,7 +18,7 @@ - room: Champion's Rest door: Shortcut to The Steady - room: The Bearer - door: Shortcut to The Bold + door: Entrance - room: Art Gallery door: Exit - room: The Tenacious -- cgit 1.4.1 From 90a208870cfe150f494e21b351152119f98633a2 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 21 Jan 2024 08:46:12 -0500 Subject: Handle Color Hunt changes --- assets/areas.yaml | 2 ++ assets/pilgrimage.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'assets/pilgrimage.yaml') diff --git a/assets/areas.yaml b/assets/areas.yaml index 89e8d97..a1e3423 100755 --- a/assets/areas.yaml +++ b/assets/areas.yaml @@ -67,6 +67,8 @@ map: [1285, 928] Color Hunt: map: [1790, 2079] + Color Barriers: + fold_into: Color Hunt Orange Tower Third Floor: map: [1935, 1575] Orange Tower Fourth Floor: diff --git a/assets/pilgrimage.yaml b/assets/pilgrimage.yaml index bed0a34..7eb8e66 100644 --- a/assets/pilgrimage.yaml +++ b/assets/pilgrimage.yaml @@ -15,7 +15,7 @@ door: Salt Pepper Door - room: Hub Room door: Crossroads Entrance - - room: Champion's Rest + - room: Color Hunt door: Shortcut to The Steady - room: The Bearer door: Entrance -- cgit 1.4.1 From b13d3678a9b09ba5dd8a58a7ab441d1e09ee5b77 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 31 Jan 2024 15:20:57 -0500 Subject: Added sunwarp access support --- assets/pilgrimage.yaml | 18 ++++++++++++++++++ src/ap_state.cpp | 5 +++++ src/ap_state.h | 4 ++++ src/game_data.cpp | 44 ++++++++++++++++++++++++++------------------ src/game_data.h | 3 +++ src/tracker_state.cpp | 37 +++++++++++++++++++++++++++++++++++-- 6 files changed, 91 insertions(+), 20 deletions(-) (limited to 'assets/pilgrimage.yaml') diff --git a/assets/pilgrimage.yaml b/assets/pilgrimage.yaml index 7eb8e66..04487da 100644 --- a/assets/pilgrimage.yaml +++ b/assets/pilgrimage.yaml @@ -1,20 +1,35 @@ --- - room: Second Room door: Exit Door + - room: Hub Room + door: 1 Sunwarp + sunwarp: True - room: Crossroads door: Tower Entrance - room: Orange Tower Fourth Floor door: Hot Crusts Door + - room: Hot Crusts Area + door: 2 Sunwarp + sunwarp: True + - room: Orange Tower Third Floor + door: 3 Sunwarp + sunwarp: True - room: Outside The Initiated door: Shortcut to Hub Room - room: Orange Tower First Floor door: Shortcut to Hub Room + - room: Orange Tower First Floor + door: 4 Sunwarp + sunwarp: True - room: Directional Gallery door: Shortcut to The Undeterred - room: Orange Tower First Floor door: Salt Pepper Door - room: Hub Room door: Crossroads Entrance + - room: Orange Tower Fourth Floor + door: 5 Sunwarp + sunwarp: True - room: Color Hunt door: Shortcut to The Steady - room: The Bearer @@ -25,3 +40,6 @@ door: Shortcut to Hub Room - room: Outside The Agreeable door: Tenacious Entrance + - room: Outside The Agreeable + door: 6 Sunwarp + sunwarp: True diff --git a/src/ap_state.cpp b/src/ap_state.cpp index 5b02ba6..efa94bf 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -60,6 +60,7 @@ struct APState { LocationChecks location_checks = kNORMAL_LOCATIONS; VictoryCondition victory_condition = kTHE_END; bool early_color_hallways = false; + SunwarpAccess sunwarp_access = kSUNWARP_ACCESS_NORMAL; std::map painting_mapping; @@ -128,6 +129,7 @@ struct APState { location_checks = kNORMAL_LOCATIONS; victory_condition = kTHE_END; early_color_hallways = false; + sunwarp_access = kSUNWARP_ACCESS_NORMAL; connected = false; has_connection_result = false; @@ -222,6 +224,7 @@ struct APState { slot_data["victory_condition"].get(); early_color_hallways = slot_data.contains("early_color_hallways") && slot_data["early_color_hallways"].get() == 1; + sunwarp_access = slot_data["sunwarp_access"].get(); if (painting_shuffle && slot_data.contains("painting_entrance_to_exit")) { painting_mapping.clear(); @@ -417,3 +420,5 @@ bool AP_HasAchievement(const std::string& achievement_name) { } bool AP_HasEarlyColorHallways() { return GetState().early_color_hallways; } + +SunwarpAccess AP_GetSunwarpAccess() { return GetState().sunwarp_access; } diff --git a/src/ap_state.h b/src/ap_state.h index 9b94a72..0231628 100644 --- a/src/ap_state.h +++ b/src/ap_state.h @@ -14,6 +14,8 @@ enum VictoryCondition { kTHE_END = 0, kTHE_MASTER = 1, kLEVEL_2 = 2 }; enum LocationChecks { kNORMAL_LOCATIONS = 0, kREDUCED_LOCATIONS = 1, kPANELSANITY = 2 }; +enum SunwarpAccess { kSUNWARP_ACCESS_NORMAL = 0, kSUNWARP_ACCESS_DISABLED = 1, kSUNWARP_ACCESS_UNLOCK = 2, kSUNWARP_ACCESS_PROGRESSIVE = 3 }; + void AP_SetTrackerFrame(TrackerFrame* tracker_frame); void AP_Connect(std::string server, std::string player, std::string password); @@ -44,4 +46,6 @@ bool AP_HasAchievement(const std::string& achievement_name); bool AP_HasEarlyColorHallways(); +SunwarpAccess AP_GetSunwarpAccess(); + #endif /* end of include guard: AP_STATE_H_664A4180 */ diff --git a/src/game_data.cpp b/src/game_data.cpp index 8f237b0..dd6e924 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -58,6 +58,9 @@ struct GameData { std::map ap_id_by_color_; + std::vector pilgrimage_; + std::vector pilgrimage_with_sunwarps_; + bool loaded_area_data_ = false; std::set malconfigured_areas_; @@ -125,6 +128,10 @@ struct GameData { exit_obj.painting = entrance_it.second["painting"].as(); } + if (entrance_it.second["sunwarp"]) { + exit_obj.sunwarp = entrance_it.second["sunwarp"].as(); + } + rooms_[from_room_id].exits.push_back(exit_obj); break; } @@ -144,6 +151,10 @@ struct GameData { exit_obj.painting = option["painting"].as(); } + if (option["sunwarp"]) { + exit_obj.sunwarp = option["sunwarp"].as(); + } + rooms_[from_room_id].exits.push_back(exit_obj); } @@ -576,31 +587,20 @@ struct GameData { } // Set up fake pilgrimage. - int fake_pilgrim_panel_id = - AddOrGetPanel("Starting Room", "!! Fake Pilgrimage Panel"); - Panel &fake_pilgrim_panel_obj = panels_[fake_pilgrim_panel_id]; - fake_pilgrim_panel_obj.non_counting = true; - for (const auto &config_node : pilgrimage_config) { - fake_pilgrim_panel_obj.required_doors.push_back( - AddOrGetDoor(config_node["room"].as(), - config_node["door"].as())); + int door_id = AddOrGetDoor(config_node["room"].as(), + config_node["door"].as()); + if (config_node["sunwarp"] && config_node["sunwarp"].as()) { + pilgrimage_with_sunwarps_.push_back(door_id); + } + pilgrimage_.push_back(door_id); } - int fake_pilgrim_door_id = - AddOrGetDoor("Starting Room", "!! Fake Pilgrimage Door"); - Door &fake_pilgrim_door_obj = doors_[fake_pilgrim_door_id]; - fake_pilgrim_door_obj.panels.push_back(fake_pilgrim_panel_id); - fake_pilgrim_door_obj.skip_location = true; - fake_pilgrim_door_obj.skip_item = true; - fake_pilgrim_door_obj.is_event = true; - int starting_room_id = AddOrGetRoom("Starting Room"); Room &starting_room_obj = rooms_[starting_room_id]; - starting_room_obj.panels.push_back(fake_pilgrim_panel_id); starting_room_obj.exits.push_back( Exit{.destination_room = AddOrGetRoom("Pilgrim Antechamber"), - .door = fake_pilgrim_door_id}); + .pilgrimage = true}); // Report errors. for (const std::string &area : malconfigured_areas_) { @@ -694,3 +694,11 @@ const std::vector &GD_GetAchievementPanels() { int GD_GetItemIdForColor(LingoColor color) { return GetState().ap_id_by_color_.at(color); } + +const std::vector &GD_GetPilgrimageDoors(bool include_sunwarps) { + if (include_sunwarps) { + return GetState().pilgrimage_with_sunwarps_; + } else { + return GetState().pilgrimage_; + } +} diff --git a/src/game_data.h b/src/game_data.h index 8a38264..c230034 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -67,6 +67,8 @@ struct Exit { int destination_room; std::optional door; bool painting = false; + bool sunwarp = false; + bool pilgrimage = false; }; struct PaintingExit { @@ -111,5 +113,6 @@ const Panel& GD_GetPanel(int panel_id); int GD_GetRoomForPainting(const std::string& painting_id); const std::vector& GD_GetAchievementPanels(); int GD_GetItemIdForColor(LingoColor color); +const std::vector& GD_GetPilgrimageDoors(bool include_sunwarps); #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index e02ee14..43f84b4 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -182,13 +182,46 @@ void RecalculateReachability() { bool valid_transition = false; if (room_exit.door.has_value()) { - Decision door_reachable = IsDoorReachable_Helper( - *room_exit.door, reachable_rooms, solveable_panels); + Decision door_reachable = kMaybe; + if (room_exit.sunwarp) { + if (AP_GetSunwarpAccess() == kSUNWARP_ACCESS_NORMAL) { + door_reachable = kYes; + } else if (AP_GetSunwarpAccess() == kSUNWARP_ACCESS_DISABLED) { + door_reachable = kNo; + } else { + door_reachable = IsDoorReachable_Helper( + *room_exit.door, reachable_rooms, solveable_panels); + } + } else { + door_reachable = IsDoorReachable_Helper( + *room_exit.door, reachable_rooms, solveable_panels); + } if (door_reachable == kYes) { valid_transition = true; } else if (door_reachable == kMaybe) { new_boundary.push_back(room_exit); } + } else if (room_exit.pilgrimage) { + Decision pilgrimage_reachable = kYes; + if (AP_GetSunwarpAccess() == kSUNWARP_ACCESS_DISABLED) { + pilgrimage_reachable = kNo; + } + if (pilgrimage_reachable == kYes) { + for (int door_id : GD_GetPilgrimageDoors( + AP_GetSunwarpAccess() == kSUNWARP_ACCESS_UNLOCK || + AP_GetSunwarpAccess() == kSUNWARP_ACCESS_PROGRESSIVE)) { + pilgrimage_reachable = IsDoorReachable_Helper( + door_id, reachable_rooms, solveable_panels); + if (pilgrimage_reachable != kYes) { + break; + } + } + } + if (pilgrimage_reachable == kYes) { + valid_transition = true; + } else if (pilgrimage_reachable == kMaybe) { + new_boundary.push_back(room_exit); + } } else { valid_transition = true; } -- cgit 1.4.1 From efa0587b4399a45faecf5aa941ff75a40595a124 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 26 Feb 2024 19:15:20 -0500 Subject: Added real pilgrimage detection --- assets/areas.yaml | 4 + assets/pilgrimage.yaml | 45 ------ src/ap_state.cpp | 6 + src/ap_state.h | 2 + src/game_data.cpp | 103 ++++-------- src/game_data.h | 14 +- src/tracker_state.cpp | 417 ++++++++++++++++++++++++++++--------------------- 7 files changed, 293 insertions(+), 298 deletions(-) delete mode 100644 assets/pilgrimage.yaml (limited to 'assets/pilgrimage.yaml') diff --git a/assets/areas.yaml b/assets/areas.yaml index a1e3423..d38ceb8 100755 --- a/assets/areas.yaml +++ b/assets/areas.yaml @@ -35,8 +35,12 @@ fold_into: Symmetry Room Outside The Agreeable: map: [1766, 700] + Compass Room: + fold_into: Outside The Agreeable Hallway Room: map: [573, 1631] + Hallway Room (1): + fold_into: Hallway Room Hallway Room (2): fold_into: Hallway Room Hallway Room (3): diff --git a/assets/pilgrimage.yaml b/assets/pilgrimage.yaml deleted file mode 100644 index 04487da..0000000 --- a/assets/pilgrimage.yaml +++ /dev/null @@ -1,45 +0,0 @@ ---- - - room: Second Room - door: Exit Door - - room: Hub Room - door: 1 Sunwarp - sunwarp: True - - room: Crossroads - door: Tower Entrance - - room: Orange Tower Fourth Floor - door: Hot Crusts Door - - room: Hot Crusts Area - door: 2 Sunwarp - sunwarp: True - - room: Orange Tower Third Floor - door: 3 Sunwarp - sunwarp: True - - room: Outside The Initiated - door: Shortcut to Hub Room - - room: Orange Tower First Floor - door: Shortcut to Hub Room - - room: Orange Tower First Floor - door: 4 Sunwarp - sunwarp: True - - room: Directional Gallery - door: Shortcut to The Undeterred - - room: Orange Tower First Floor - door: Salt Pepper Door - - room: Hub Room - door: Crossroads Entrance - - room: Orange Tower Fourth Floor - door: 5 Sunwarp - sunwarp: True - - room: Color Hunt - door: Shortcut to The Steady - - room: The Bearer - door: Entrance - - room: Art Gallery - door: Exit - - room: The Tenacious - door: Shortcut to Hub Room - - room: Outside The Agreeable - door: Tenacious Entrance - - room: Outside The Agreeable - door: 6 Sunwarp - sunwarp: True diff --git a/src/ap_state.cpp b/src/ap_state.cpp index efa94bf..ea74c93 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -60,6 +60,7 @@ struct APState { LocationChecks location_checks = kNORMAL_LOCATIONS; VictoryCondition victory_condition = kTHE_END; bool early_color_hallways = false; + bool pilgrimage_enabled = false; SunwarpAccess sunwarp_access = kSUNWARP_ACCESS_NORMAL; std::map painting_mapping; @@ -129,6 +130,7 @@ struct APState { location_checks = kNORMAL_LOCATIONS; victory_condition = kTHE_END; early_color_hallways = false; + pilgrimage_enabled = false; sunwarp_access = kSUNWARP_ACCESS_NORMAL; connected = false; @@ -224,6 +226,8 @@ struct APState { slot_data["victory_condition"].get(); early_color_hallways = slot_data.contains("early_color_hallways") && slot_data["early_color_hallways"].get() == 1; + pilgrimage_enabled = slot_data.contains("enable_pilgrimage") && + slot_data["enable_pilgrimage"].get() == 1; sunwarp_access = slot_data["sunwarp_access"].get(); if (painting_shuffle && slot_data.contains("painting_entrance_to_exit")) { @@ -421,4 +425,6 @@ bool AP_HasAchievement(const std::string& achievement_name) { bool AP_HasEarlyColorHallways() { return GetState().early_color_hallways; } +bool AP_IsPilgrimageEnabled() { return GetState().pilgrimage_enabled; } + SunwarpAccess AP_GetSunwarpAccess() { return GetState().sunwarp_access; } diff --git a/src/ap_state.h b/src/ap_state.h index 0231628..e145066 100644 --- a/src/ap_state.h +++ b/src/ap_state.h @@ -46,6 +46,8 @@ bool AP_HasAchievement(const std::string& achievement_name); bool AP_HasEarlyColorHallways(); +bool AP_IsPilgrimageEnabled(); + SunwarpAccess AP_GetSunwarpAccess(); #endif /* end of include guard: AP_STATE_H_664A4180 */ diff --git a/src/game_data.cpp b/src/game_data.cpp index dd6e924..28ca598 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -58,9 +58,6 @@ struct GameData { std::map ap_id_by_color_; - std::vector pilgrimage_; - std::vector pilgrimage_with_sunwarps_; - bool loaded_area_data_ = false; std::set malconfigured_areas_; @@ -69,8 +66,6 @@ struct GameData { YAML::LoadFile(GetAbsolutePath("assets/LL1.yaml")); YAML::Node areas_config = YAML::LoadFile(GetAbsolutePath("assets/areas.yaml")); - YAML::Node pilgrimage_config = - YAML::LoadFile(GetAbsolutePath("assets/pilgrimage.yaml")); YAML::Node ids_config = YAML::LoadFile(GetAbsolutePath("assets/ids.yaml")); auto init_color_id = [this, &ids_config](const std::string &color_name) { @@ -105,6 +100,34 @@ struct GameData { for (const auto &entrance_it : room_it.second["entrances"]) { int from_room_id = AddOrGetRoom(entrance_it.first.as()); + auto process_single_entrance = + [this, room_id, from_room_id](const YAML::Node &option) { + Exit exit_obj; + exit_obj.destination_room = room_id; + + if (option["door"]) { + std::string door_room = rooms_[room_id].name; + if (option["room"]) { + door_room = option["room"].as(); + } + exit_obj.door = AddOrGetDoor(door_room, option["door"].as()); + } + + if (option["painting"] && option["painting"].as()) { + exit_obj.type = EntranceType::kPainting; + } + + if (option["sunwarp"] && option["sunwarp"].as()) { + exit_obj.type = EntranceType::kSunwarp; + } + + if (option["warp"] && option["warp"].as()) { + exit_obj.type = EntranceType::kWarp; + } + + rooms_[from_room_id].exits.push_back(exit_obj); + }; + switch (entrance_it.second.Type()) { case YAML::NodeType::Scalar: { // This is just "true". @@ -112,50 +135,12 @@ struct GameData { break; } case YAML::NodeType::Map: { - Exit exit_obj; - exit_obj.destination_room = room_id; - - if (entrance_it.second["door"]) { - std::string door_room = rooms_[room_id].name; - if (entrance_it.second["room"]) { - door_room = entrance_it.second["room"].as(); - } - exit_obj.door = AddOrGetDoor( - door_room, entrance_it.second["door"].as()); - } - - if (entrance_it.second["painting"]) { - exit_obj.painting = entrance_it.second["painting"].as(); - } - - if (entrance_it.second["sunwarp"]) { - exit_obj.sunwarp = entrance_it.second["sunwarp"].as(); - } - - rooms_[from_room_id].exits.push_back(exit_obj); + process_single_entrance(entrance_it.second); break; } case YAML::NodeType::Sequence: { for (const auto &option : entrance_it.second) { - Exit exit_obj; - exit_obj.destination_room = room_id; - - std::string door_room = rooms_[room_id].name; - if (option["room"]) { - door_room = option["room"].as(); - } - exit_obj.door = - AddOrGetDoor(door_room, option["door"].as()); - - if (option["painting"]) { - exit_obj.painting = option["painting"].as(); - } - - if (option["sunwarp"]) { - exit_obj.sunwarp = option["sunwarp"].as(); - } - - rooms_[from_room_id].exits.push_back(exit_obj); + process_single_entrance(option); } break; @@ -586,22 +571,6 @@ struct GameData { } } - // Set up fake pilgrimage. - for (const auto &config_node : pilgrimage_config) { - int door_id = AddOrGetDoor(config_node["room"].as(), - config_node["door"].as()); - if (config_node["sunwarp"] && config_node["sunwarp"].as()) { - pilgrimage_with_sunwarps_.push_back(door_id); - } - pilgrimage_.push_back(door_id); - } - - int starting_room_id = AddOrGetRoom("Starting Room"); - Room &starting_room_obj = rooms_[starting_room_id]; - starting_room_obj.exits.push_back( - Exit{.destination_room = AddOrGetRoom("Pilgrim Antechamber"), - .pilgrimage = true}); - // Report errors. for (const std::string &area : malconfigured_areas_) { std::ostringstream errstr; @@ -679,6 +648,10 @@ const std::vector &GD_GetDoors() { return GetState().doors_; } const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } +int GD_GetDoorByName(const std::string &name) { + return GetState().door_by_id_.at(name); +} + const Panel &GD_GetPanel(int panel_id) { return GetState().panels_.at(panel_id); } @@ -694,11 +667,3 @@ const std::vector &GD_GetAchievementPanels() { int GD_GetItemIdForColor(LingoColor color) { return GetState().ap_id_by_color_.at(color); } - -const std::vector &GD_GetPilgrimageDoors(bool include_sunwarps) { - if (include_sunwarps) { - return GetState().pilgrimage_with_sunwarps_; - } else { - return GetState().pilgrimage_; - } -} diff --git a/src/game_data.h b/src/game_data.h index c230034..2c18588 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -23,6 +23,14 @@ constexpr int kLOCATION_NORMAL = 1; constexpr int kLOCATION_REDUCED = 2; constexpr int kLOCATION_INSANITY = 4; +enum class EntranceType { + kNormal, + kPainting, + kSunwarp, + kWarp, + kPilgrimage, +}; + struct Panel { int id; int room; @@ -66,9 +74,7 @@ struct Door { struct Exit { int destination_room; std::optional door; - bool painting = false; - bool sunwarp = false; - bool pilgrimage = false; + EntranceType type = EntranceType::kNormal; }; struct PaintingExit { @@ -109,10 +115,10 @@ int GD_GetRoomByName(const std::string& name); const Room& GD_GetRoom(int room_id); const std::vector& GD_GetDoors(); const Door& GD_GetDoor(int door_id); +int GD_GetDoorByName(const std::string& name); const Panel& GD_GetPanel(int panel_id); int GD_GetRoomForPainting(const std::string& painting_id); const std::vector& GD_GetAchievementPanels(); int GD_GetItemIdForColor(LingoColor color); -const std::vector& GD_GetPilgrimageDoors(bool include_sunwarps); #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index 43f84b4..cc941ef 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -24,242 +24,299 @@ TrackerState& GetState() { return *instance; } -Decision IsDoorReachable_Helper(int door_id, - const std::set& reachable_rooms, - const std::set& solveable_panels) { - const Door& door_obj = GD_GetDoor(door_id); +struct StateCalculatorOptions { + std::string start = "Menu"; + bool pilgrimage = false; +}; - if (AP_GetDoorShuffleMode() == kNO_DOORS || door_obj.skip_item) { - if (!reachable_rooms.count(door_obj.room)) { - return kMaybe; - } +class StateCalculator { + public: + StateCalculator() = default; - for (int panel_id : door_obj.panels) { - if (!solveable_panels.count(panel_id)) { - return kMaybe; - } - } + explicit StateCalculator(StateCalculatorOptions options) + : options_(options) {} - return kYes; - } else if (AP_GetDoorShuffleMode() == kSIMPLE_DOORS && - !door_obj.group_name.empty()) { - return AP_HasItem(door_obj.group_ap_item_id) ? kYes : kNo; - } else { - bool has_item = AP_HasItem(door_obj.ap_item_id); + void Calculate() { + std::list panel_boundary; + std::list flood_boundary; + flood_boundary.push_back( + {.destination_room = GD_GetRoomByName(options_.start)}); + + bool reachable_changed = true; + while (reachable_changed) { + reachable_changed = false; - if (!has_item) { - for (const ProgressiveRequirement& prog_req : door_obj.progressives) { - if (AP_HasItem(prog_req.ap_item_id, prog_req.quantity)) { - has_item = true; - break; + std::list new_panel_boundary; + for (int panel_id : panel_boundary) { + if (solveable_panels_.count(panel_id)) { + continue; + } + + Decision panel_reachable = IsPanelReachable(panel_id); + if (panel_reachable == kYes) { + solveable_panels_.insert(panel_id); + reachable_changed = true; + } else if (panel_reachable == kMaybe) { + new_panel_boundary.push_back(panel_id); } } - } - return has_item ? kYes : kNo; - } -} + std::list new_boundary; + for (const Exit& room_exit : flood_boundary) { + if (reachable_rooms_.count(room_exit.destination_room)) { + continue; + } -Decision IsPanelReachable_Helper(int panel_id, - const std::set& reachable_rooms, - const std::set& solveable_panels) { - const Panel& panel_obj = GD_GetPanel(panel_id); + bool valid_transition = false; - if (!reachable_rooms.count(panel_obj.room)) { - return kMaybe; - } + Decision exit_usable = IsExitUsable(room_exit); + if (exit_usable == kYes) { + valid_transition = true; + } else if (exit_usable == kMaybe) { + new_boundary.push_back(room_exit); + } + + if (valid_transition) { + reachable_rooms_.insert(room_exit.destination_room); + reachable_changed = true; + + const Room& room_obj = GD_GetRoom(room_exit.destination_room); + for (const Exit& out_edge : room_obj.exits) { + if (out_edge.type != EntranceType::kPainting || + !AP_IsPaintingShuffle()) { + new_boundary.push_back(out_edge); + } + } + + if (AP_IsPaintingShuffle()) { + for (const PaintingExit& out_edge : room_obj.paintings) { + if (AP_GetPaintingMapping().count(out_edge.id)) { + Exit painting_exit; + painting_exit.destination_room = GD_GetRoomForPainting( + AP_GetPaintingMapping().at(out_edge.id)); + painting_exit.door = out_edge.door; + + new_boundary.push_back(painting_exit); + } + } + } - if (panel_obj.name == "THE MASTER") { - int achievements_accessible = 0; + if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { + new_boundary.push_back( + {.destination_room = GD_GetRoomByName("Outside The Undeterred"), + .type = EntranceType::kPainting}); + } - for (int achieve_id : GD_GetAchievementPanels()) { - if (solveable_panels.count(achieve_id)) { - achievements_accessible++; + if (AP_IsPilgrimageEnabled()) { + if (room_obj.name == "Hub Room") { + new_boundary.push_back( + {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), + .type = EntranceType::kPilgrimage}); + } + } else { + if (room_obj.name == "Starting Room") { + new_boundary.push_back( + {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), + .door = + GD_GetDoorByName("Pilgrim Antechamber - Sun Painting"), + .type = EntranceType::kPainting}); + } + } - if (achievements_accessible >= AP_GetMasteryRequirement()) { - break; + for (int panel_id : room_obj.panels) { + new_panel_boundary.push_back(panel_id); + } } } - } - return (achievements_accessible >= AP_GetMasteryRequirement()) ? kYes - : kMaybe; + flood_boundary = new_boundary; + panel_boundary = new_panel_boundary; + } } - if ((panel_obj.name == "ANOTHER TRY" || panel_obj.name == "LEVEL 2") && - AP_GetLevel2Requirement() > 1) { - int counting_panels_accessible = 0; + const std::set& GetReachableRooms() const { return reachable_rooms_; } - for (int solved_panel_id : solveable_panels) { - const Panel& solved_panel = GD_GetPanel(solved_panel_id); + const std::set& GetSolveablePanels() const { return solveable_panels_; } - if (!solved_panel.non_counting) { - counting_panels_accessible++; + private: + Decision IsDoorReachable(int door_id) { + const Door& door_obj = GD_GetDoor(door_id); + + if (!AP_IsPilgrimageEnabled() && + door_obj.item_name == "Pilgrim Room - Sun Painting") { + return AP_HasItem(door_obj.ap_item_id) ? kYes : kNo; + } else if (AP_GetDoorShuffleMode() == kNO_DOORS || door_obj.skip_item) { + if (!reachable_rooms_.count(door_obj.room)) { + return kMaybe; } - } - return (counting_panels_accessible >= AP_GetLevel2Requirement() - 1) - ? kYes - : kMaybe; - } + for (int panel_id : door_obj.panels) { + if (!solveable_panels_.count(panel_id)) { + return kMaybe; + } + } - for (int room_id : panel_obj.required_rooms) { - if (!reachable_rooms.count(room_id)) { - return kMaybe; - } - } + return kYes; + } else if (AP_GetDoorShuffleMode() == kSIMPLE_DOORS && + !door_obj.group_name.empty()) { + return AP_HasItem(door_obj.group_ap_item_id) ? kYes : kNo; + } else { + bool has_item = AP_HasItem(door_obj.ap_item_id); + + if (!has_item) { + for (const ProgressiveRequirement& prog_req : door_obj.progressives) { + if (AP_HasItem(prog_req.ap_item_id, prog_req.quantity)) { + has_item = true; + break; + } + } + } - for (int door_id : panel_obj.required_doors) { - Decision door_reachable = - IsDoorReachable_Helper(door_id, reachable_rooms, solveable_panels); - if (door_reachable == kNo) { - const Door& door_obj = GD_GetDoor(door_id); - return (door_obj.is_event || AP_GetDoorShuffleMode() == kNO_DOORS) - ? kMaybe - : kNo; - } else if (door_reachable == kMaybe) { - return kMaybe; + return has_item ? kYes : kNo; } } - for (int panel_id : panel_obj.required_panels) { - if (!solveable_panels.count(panel_id)) { + Decision IsPanelReachable(int panel_id) { + const Panel& panel_obj = GD_GetPanel(panel_id); + + if (!reachable_rooms_.count(panel_obj.room)) { return kMaybe; } - } - if (AP_IsColorShuffle()) { - for (LingoColor color : panel_obj.colors) { - if (!AP_HasItem(GD_GetItemIdForColor(color))) { - return kNo; - } - } - } + if (panel_obj.name == "THE MASTER") { + int achievements_accessible = 0; - return kYes; -} + for (int achieve_id : GD_GetAchievementPanels()) { + if (solveable_panels_.count(achieve_id)) { + achievements_accessible++; -} // namespace + if (achievements_accessible >= AP_GetMasteryRequirement()) { + break; + } + } + } -void RecalculateReachability() { - std::set reachable_rooms; - std::set solveable_panels; + return (achievements_accessible >= AP_GetMasteryRequirement()) ? kYes + : kMaybe; + } - std::list panel_boundary; - std::list flood_boundary; - flood_boundary.push_back({.destination_room = GD_GetRoomByName("Menu")}); + if ((panel_obj.name == "ANOTHER TRY" || panel_obj.name == "LEVEL 2") && + AP_GetLevel2Requirement() > 1) { + int counting_panels_accessible = 0; - if (AP_HasEarlyColorHallways()) { - flood_boundary.push_back( - {.destination_room = GD_GetRoomByName("Outside The Undeterred")}); - } + for (int solved_panel_id : solveable_panels_) { + const Panel& solved_panel = GD_GetPanel(solved_panel_id); - bool reachable_changed = true; - while (reachable_changed) { - reachable_changed = false; + if (!solved_panel.non_counting) { + counting_panels_accessible++; + } + } + + return (counting_panels_accessible >= AP_GetLevel2Requirement() - 1) + ? kYes + : kMaybe; + } - std::list new_panel_boundary; - for (int panel_id : panel_boundary) { - if (solveable_panels.count(panel_id)) { - continue; + for (int room_id : panel_obj.required_rooms) { + if (!reachable_rooms_.count(room_id)) { + return kMaybe; } + } - Decision panel_reachable = - IsPanelReachable_Helper(panel_id, reachable_rooms, solveable_panels); - if (panel_reachable == kYes) { - solveable_panels.insert(panel_id); - reachable_changed = true; - } else if (panel_reachable == kMaybe) { - new_panel_boundary.push_back(panel_id); + for (int door_id : panel_obj.required_doors) { + Decision door_reachable = IsDoorReachable(door_id); + if (door_reachable == kNo) { + const Door& door_obj = GD_GetDoor(door_id); + return (door_obj.is_event || AP_GetDoorShuffleMode() == kNO_DOORS) + ? kMaybe + : kNo; + } else if (door_reachable == kMaybe) { + return kMaybe; } } - std::list new_boundary; - for (const Exit& room_exit : flood_boundary) { - if (reachable_rooms.count(room_exit.destination_room)) { - continue; + for (int panel_id : panel_obj.required_panels) { + if (!solveable_panels_.count(panel_id)) { + return kMaybe; } + } - bool valid_transition = false; - if (room_exit.door.has_value()) { - Decision door_reachable = kMaybe; - if (room_exit.sunwarp) { - if (AP_GetSunwarpAccess() == kSUNWARP_ACCESS_NORMAL) { - door_reachable = kYes; - } else if (AP_GetSunwarpAccess() == kSUNWARP_ACCESS_DISABLED) { - door_reachable = kNo; - } else { - door_reachable = IsDoorReachable_Helper( - *room_exit.door, reachable_rooms, solveable_panels); - } - } else { - door_reachable = IsDoorReachable_Helper( - *room_exit.door, reachable_rooms, solveable_panels); - } - if (door_reachable == kYes) { - valid_transition = true; - } else if (door_reachable == kMaybe) { - new_boundary.push_back(room_exit); - } - } else if (room_exit.pilgrimage) { - Decision pilgrimage_reachable = kYes; - if (AP_GetSunwarpAccess() == kSUNWARP_ACCESS_DISABLED) { - pilgrimage_reachable = kNo; + if (AP_IsColorShuffle()) { + for (LingoColor color : panel_obj.colors) { + if (!AP_HasItem(GD_GetItemIdForColor(color))) { + return kNo; } - if (pilgrimage_reachable == kYes) { - for (int door_id : GD_GetPilgrimageDoors( - AP_GetSunwarpAccess() == kSUNWARP_ACCESS_UNLOCK || - AP_GetSunwarpAccess() == kSUNWARP_ACCESS_PROGRESSIVE)) { - pilgrimage_reachable = IsDoorReachable_Helper( - door_id, reachable_rooms, solveable_panels); - if (pilgrimage_reachable != kYes) { - break; - } - } - } - if (pilgrimage_reachable == kYes) { - valid_transition = true; - } else if (pilgrimage_reachable == kMaybe) { - new_boundary.push_back(room_exit); - } - } else { - valid_transition = true; } + } - if (valid_transition) { - reachable_rooms.insert(room_exit.destination_room); - reachable_changed = true; + return kYes; + } - const Room& room_obj = GD_GetRoom(room_exit.destination_room); - for (const Exit& out_edge : room_obj.exits) { - if (!out_edge.painting || !AP_IsPaintingShuffle()) { - new_boundary.push_back(out_edge); - } + Decision IsExitUsable(const Exit& room_exit) { + if (room_exit.type == EntranceType::kPilgrimage) { + if (options_.pilgrimage || !AP_IsPilgrimageEnabled()) { + return kNo; + } + + static const std::vector> + pilgrimage_pairs = { + {"Crossroads", "Hot Crusts Area"}, + // {"Orange Tower Third Floor", "Orange Tower Third Floor"}, + {"Outside The Initiated", "Orange Tower First Floor"}, + {"Outside The Undeterred", "Orange Tower Fourth Floor"}, + {"Color Hunt", "Outside The Agreeable"}}; + + for (const auto& [from_room, to_room] : pilgrimage_pairs) { + StateCalculator pilgrimage_calculator( + {.start = from_room, .pilgrimage = true}); + pilgrimage_calculator.Calculate(); + + if (!pilgrimage_calculator.GetReachableRooms().count( + GD_GetRoomByName(to_room))) { + return kMaybe; } + } - if (AP_IsPaintingShuffle()) { - for (const PaintingExit& out_edge : room_obj.paintings) { - if (AP_GetPaintingMapping().count(out_edge.id)) { - Exit painting_exit; - painting_exit.destination_room = GD_GetRoomForPainting( - AP_GetPaintingMapping().at(out_edge.id)); - painting_exit.door = out_edge.door; + return kYes; + } - new_boundary.push_back(painting_exit); - } - } - } + if (options_.pilgrimage) { + if (room_exit.type == EntranceType::kWarp || + room_exit.type == EntranceType::kSunwarp) { + return kNo; + } + } - for (int panel_id : room_obj.panels) { - new_panel_boundary.push_back(panel_id); - } + if (room_exit.type == EntranceType::kSunwarp) { + if (AP_GetSunwarpAccess() == kSUNWARP_ACCESS_NORMAL) { + return kYes; + } else if (AP_GetSunwarpAccess() == kSUNWARP_ACCESS_DISABLED) { + return kNo; } } - flood_boundary = new_boundary; - panel_boundary = new_panel_boundary; + if (room_exit.door.has_value()) { + return IsDoorReachable(*room_exit.door); + } + + return kYes; } + StateCalculatorOptions options_; + + std::set reachable_rooms_; + std::set solveable_panels_; +}; + +} // namespace + +void RecalculateReachability() { + StateCalculator state_calculator; + state_calculator.Calculate(); + + const std::set& reachable_rooms = state_calculator.GetReachableRooms(); + const std::set& solveable_panels = state_calculator.GetSolveablePanels(); + std::map new_reachability; for (const MapArea& map_area : GD_GetMapAreas()) { for (size_t section_id = 0; section_id < map_area.locations.size(); -- cgit 1.4.1