diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ap_state.cpp | 11 | ||||
| -rw-r--r-- | src/ap_state.h | 6 | ||||
| -rw-r--r-- | src/game_data.cpp | 95 | ||||
| -rw-r--r-- | src/game_data.h | 11 | ||||
| -rw-r--r-- | src/tracker_state.cpp | 384 |
5 files changed, 298 insertions, 209 deletions
| diff --git a/src/ap_state.cpp b/src/ap_state.cpp index fdc0219..1937597 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp | |||
| @@ -63,6 +63,8 @@ struct APState { | |||
| 63 | LocationChecks location_checks = kNORMAL_LOCATIONS; | 63 | LocationChecks location_checks = kNORMAL_LOCATIONS; |
| 64 | VictoryCondition victory_condition = kTHE_END; | 64 | VictoryCondition victory_condition = kTHE_END; |
| 65 | bool early_color_hallways = false; | 65 | bool early_color_hallways = false; |
| 66 | bool pilgrimage_enabled = false; | ||
| 67 | SunwarpAccess sunwarp_access = kSUNWARP_ACCESS_NORMAL; | ||
| 66 | 68 | ||
| 67 | std::map<std::string, std::string> painting_mapping; | 69 | std::map<std::string, std::string> painting_mapping; |
| 68 | 70 | ||
| @@ -132,6 +134,8 @@ struct APState { | |||
| 132 | location_checks = kNORMAL_LOCATIONS; | 134 | location_checks = kNORMAL_LOCATIONS; |
| 133 | victory_condition = kTHE_END; | 135 | victory_condition = kTHE_END; |
| 134 | early_color_hallways = false; | 136 | early_color_hallways = false; |
| 137 | pilgrimage_enabled = false; | ||
| 138 | sunwarp_access = kSUNWARP_ACCESS_NORMAL; | ||
| 135 | 139 | ||
| 136 | connected = false; | 140 | connected = false; |
| 137 | has_connection_result = false; | 141 | has_connection_result = false; |
| @@ -234,6 +238,9 @@ struct APState { | |||
| 234 | slot_data["victory_condition"].get<VictoryCondition>(); | 238 | slot_data["victory_condition"].get<VictoryCondition>(); |
| 235 | early_color_hallways = slot_data.contains("early_color_hallways") && | 239 | early_color_hallways = slot_data.contains("early_color_hallways") && |
| 236 | slot_data["early_color_hallways"].get<int>() == 1; | 240 | slot_data["early_color_hallways"].get<int>() == 1; |
| 241 | pilgrimage_enabled = slot_data.contains("enable_pilgrimage") && | ||
| 242 | slot_data["enable_pilgrimage"].get<int>() == 1; | ||
| 243 | sunwarp_access = slot_data["sunwarp_access"].get<SunwarpAccess>(); | ||
| 237 | 244 | ||
| 238 | if (painting_shuffle && slot_data.contains("painting_entrance_to_exit")) { | 245 | if (painting_shuffle && slot_data.contains("painting_entrance_to_exit")) { |
| 239 | painting_mapping.clear(); | 246 | painting_mapping.clear(); |
| @@ -445,4 +452,8 @@ bool AP_HasAchievement(const std::string& achievement_name) { | |||
| 445 | 452 | ||
| 446 | bool AP_HasEarlyColorHallways() { return GetState().early_color_hallways; } | 453 | bool AP_HasEarlyColorHallways() { return GetState().early_color_hallways; } |
| 447 | 454 | ||
| 455 | bool AP_IsPilgrimageEnabled() { return GetState().pilgrimage_enabled; } | ||
| 456 | |||
| 457 | SunwarpAccess AP_GetSunwarpAccess() { return GetState().sunwarp_access; } | ||
| 458 | |||
| 448 | bool AP_HasReachedGoal() { return GetState().HasReachedGoal(); } | 459 | bool AP_HasReachedGoal() { return GetState().HasReachedGoal(); } |
| diff --git a/src/ap_state.h b/src/ap_state.h index cc51a78..fe424fd 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 }; | |||
| 14 | 14 | ||
| 15 | enum LocationChecks { kNORMAL_LOCATIONS = 0, kREDUCED_LOCATIONS = 1, kPANELSANITY = 2 }; | 15 | enum LocationChecks { kNORMAL_LOCATIONS = 0, kREDUCED_LOCATIONS = 1, kPANELSANITY = 2 }; |
| 16 | 16 | ||
| 17 | enum SunwarpAccess { kSUNWARP_ACCESS_NORMAL = 0, kSUNWARP_ACCESS_DISABLED = 1, kSUNWARP_ACCESS_UNLOCK = 2, kSUNWARP_ACCESS_PROGRESSIVE = 3 }; | ||
| 18 | |||
| 17 | void AP_SetTrackerFrame(TrackerFrame* tracker_frame); | 19 | void AP_SetTrackerFrame(TrackerFrame* tracker_frame); |
| 18 | 20 | ||
| 19 | void AP_Connect(std::string server, std::string player, std::string password); | 21 | void AP_Connect(std::string server, std::string player, std::string password); |
| @@ -44,6 +46,10 @@ bool AP_HasAchievement(const std::string& achievement_name); | |||
| 44 | 46 | ||
| 45 | bool AP_HasEarlyColorHallways(); | 47 | bool AP_HasEarlyColorHallways(); |
| 46 | 48 | ||
| 49 | bool AP_IsPilgrimageEnabled(); | ||
| 50 | |||
| 51 | SunwarpAccess AP_GetSunwarpAccess(); | ||
| 52 | |||
| 47 | bool AP_HasReachedGoal(); | 53 | bool AP_HasReachedGoal(); |
| 48 | 54 | ||
| 49 | #endif /* end of include guard: AP_STATE_H_664A4180 */ | 55 | #endif /* end of include guard: AP_STATE_H_664A4180 */ |
| diff --git a/src/game_data.cpp b/src/game_data.cpp index 8f237b0..28ca598 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp | |||
| @@ -66,8 +66,6 @@ struct GameData { | |||
| 66 | YAML::LoadFile(GetAbsolutePath("assets/LL1.yaml")); | 66 | YAML::LoadFile(GetAbsolutePath("assets/LL1.yaml")); |
| 67 | YAML::Node areas_config = | 67 | YAML::Node areas_config = |
| 68 | YAML::LoadFile(GetAbsolutePath("assets/areas.yaml")); | 68 | YAML::LoadFile(GetAbsolutePath("assets/areas.yaml")); |
| 69 | YAML::Node pilgrimage_config = | ||
| 70 | YAML::LoadFile(GetAbsolutePath("assets/pilgrimage.yaml")); | ||
| 71 | YAML::Node ids_config = YAML::LoadFile(GetAbsolutePath("assets/ids.yaml")); | 69 | YAML::Node ids_config = YAML::LoadFile(GetAbsolutePath("assets/ids.yaml")); |
| 72 | 70 | ||
| 73 | auto init_color_id = [this, &ids_config](const std::string &color_name) { | 71 | auto init_color_id = [this, &ids_config](const std::string &color_name) { |
| @@ -102,6 +100,34 @@ struct GameData { | |||
| 102 | for (const auto &entrance_it : room_it.second["entrances"]) { | 100 | for (const auto &entrance_it : room_it.second["entrances"]) { |
| 103 | int from_room_id = AddOrGetRoom(entrance_it.first.as<std::string>()); | 101 | int from_room_id = AddOrGetRoom(entrance_it.first.as<std::string>()); |
| 104 | 102 | ||
| 103 | auto process_single_entrance = | ||
| 104 | [this, room_id, from_room_id](const YAML::Node &option) { | ||
| 105 | Exit exit_obj; | ||
| 106 | exit_obj.destination_room = room_id; | ||
| 107 | |||
| 108 | if (option["door"]) { | ||
| 109 | std::string door_room = rooms_[room_id].name; | ||
| 110 | if (option["room"]) { | ||
| 111 | door_room = option["room"].as<std::string>(); | ||
| 112 | } | ||
| 113 | exit_obj.door = AddOrGetDoor(door_room, option["door"].as<std::string>()); | ||
| 114 | } | ||
| 115 | |||
| 116 | if (option["painting"] && option["painting"].as<bool>()) { | ||
| 117 | exit_obj.type = EntranceType::kPainting; | ||
| 118 | } | ||
| 119 | |||
| 120 | if (option["sunwarp"] && option["sunwarp"].as<bool>()) { | ||
| 121 | exit_obj.type = EntranceType::kSunwarp; | ||
| 122 | } | ||
| 123 | |||
| 124 | if (option["warp"] && option["warp"].as<bool>()) { | ||
| 125 | exit_obj.type = EntranceType::kWarp; | ||
| 126 | } | ||
| 127 | |||
| 128 | rooms_[from_room_id].exits.push_back(exit_obj); | ||
| 129 | }; | ||
| 130 | |||
| 105 | switch (entrance_it.second.Type()) { | 131 | switch (entrance_it.second.Type()) { |
| 106 | case YAML::NodeType::Scalar: { | 132 | case YAML::NodeType::Scalar: { |
| 107 | // This is just "true". | 133 | // This is just "true". |
| @@ -109,42 +135,12 @@ struct GameData { | |||
| 109 | break; | 135 | break; |
| 110 | } | 136 | } |
| 111 | case YAML::NodeType::Map: { | 137 | case YAML::NodeType::Map: { |
| 112 | Exit exit_obj; | 138 | process_single_entrance(entrance_it.second); |
| 113 | exit_obj.destination_room = room_id; | ||
| 114 | |||
| 115 | if (entrance_it.second["door"]) { | ||
| 116 | std::string door_room = rooms_[room_id].name; | ||
| 117 | if (entrance_it.second["room"]) { | ||
| 118 | door_room = entrance_it.second["room"].as<std::string>(); | ||
| 119 | } | ||
| 120 | exit_obj.door = AddOrGetDoor( | ||
| 121 | door_room, entrance_it.second["door"].as<std::string>()); | ||
| 122 | } | ||
| 123 | |||
| 124 | if (entrance_it.second["painting"]) { | ||
| 125 | exit_obj.painting = entrance_it.second["painting"].as<bool>(); | ||
| 126 | } | ||
| 127 | |||
| 128 | rooms_[from_room_id].exits.push_back(exit_obj); | ||
| 129 | break; | 139 | break; |
| 130 | } | 140 | } |
| 131 | case YAML::NodeType::Sequence: { | 141 | case YAML::NodeType::Sequence: { |
| 132 | for (const auto &option : entrance_it.second) { | 142 | for (const auto &option : entrance_it.second) { |
| 133 | Exit exit_obj; | 143 | process_single_entrance(option); |
| 134 | exit_obj.destination_room = room_id; | ||
| 135 | |||
| 136 | std::string door_room = rooms_[room_id].name; | ||
| 137 | if (option["room"]) { | ||
| 138 | door_room = option["room"].as<std::string>(); | ||
| 139 | } | ||
| 140 | exit_obj.door = | ||
| 141 | AddOrGetDoor(door_room, option["door"].as<std::string>()); | ||
| 142 | |||
| 143 | if (option["painting"]) { | ||
| 144 | exit_obj.painting = option["painting"].as<bool>(); | ||
| 145 | } | ||
| 146 | |||
| 147 | rooms_[from_room_id].exits.push_back(exit_obj); | ||
| 148 | } | 144 | } |
| 149 | 145 | ||
| 150 | break; | 146 | break; |
| @@ -575,33 +571,6 @@ struct GameData { | |||
| 575 | } | 571 | } |
| 576 | } | 572 | } |
| 577 | 573 | ||
| 578 | // Set up fake pilgrimage. | ||
| 579 | int fake_pilgrim_panel_id = | ||
| 580 | AddOrGetPanel("Starting Room", "!! Fake Pilgrimage Panel"); | ||
| 581 | Panel &fake_pilgrim_panel_obj = panels_[fake_pilgrim_panel_id]; | ||
| 582 | fake_pilgrim_panel_obj.non_counting = true; | ||
| 583 | |||
| 584 | for (const auto &config_node : pilgrimage_config) { | ||
| 585 | fake_pilgrim_panel_obj.required_doors.push_back( | ||
| 586 | AddOrGetDoor(config_node["room"].as<std::string>(), | ||
| 587 | config_node["door"].as<std::string>())); | ||
| 588 | } | ||
| 589 | |||
| 590 | int fake_pilgrim_door_id = | ||
| 591 | AddOrGetDoor("Starting Room", "!! Fake Pilgrimage Door"); | ||
| 592 | Door &fake_pilgrim_door_obj = doors_[fake_pilgrim_door_id]; | ||
| 593 | fake_pilgrim_door_obj.panels.push_back(fake_pilgrim_panel_id); | ||
| 594 | fake_pilgrim_door_obj.skip_location = true; | ||
| 595 | fake_pilgrim_door_obj.skip_item = true; | ||
| 596 | fake_pilgrim_door_obj.is_event = true; | ||
| 597 | |||
| 598 | int starting_room_id = AddOrGetRoom("Starting Room"); | ||
| 599 | Room &starting_room_obj = rooms_[starting_room_id]; | ||
| 600 | starting_room_obj.panels.push_back(fake_pilgrim_panel_id); | ||
| 601 | starting_room_obj.exits.push_back( | ||
| 602 | Exit{.destination_room = AddOrGetRoom("Pilgrim Antechamber"), | ||
| 603 | .door = fake_pilgrim_door_id}); | ||
| 604 | |||
| 605 | // Report errors. | 574 | // Report errors. |
| 606 | for (const std::string &area : malconfigured_areas_) { | 575 | for (const std::string &area : malconfigured_areas_) { |
| 607 | std::ostringstream errstr; | 576 | std::ostringstream errstr; |
| @@ -679,6 +648,10 @@ const std::vector<Door> &GD_GetDoors() { return GetState().doors_; } | |||
| 679 | 648 | ||
| 680 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } | 649 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } |
| 681 | 650 | ||
| 651 | int GD_GetDoorByName(const std::string &name) { | ||
| 652 | return GetState().door_by_id_.at(name); | ||
| 653 | } | ||
| 654 | |||
| 682 | const Panel &GD_GetPanel(int panel_id) { | 655 | const Panel &GD_GetPanel(int panel_id) { |
| 683 | return GetState().panels_.at(panel_id); | 656 | return GetState().panels_.at(panel_id); |
| 684 | } | 657 | } |
| diff --git a/src/game_data.h b/src/game_data.h index 8a38264..2c18588 100644 --- a/src/game_data.h +++ b/src/game_data.h | |||
| @@ -23,6 +23,14 @@ constexpr int kLOCATION_NORMAL = 1; | |||
| 23 | constexpr int kLOCATION_REDUCED = 2; | 23 | constexpr int kLOCATION_REDUCED = 2; |
| 24 | constexpr int kLOCATION_INSANITY = 4; | 24 | constexpr int kLOCATION_INSANITY = 4; |
| 25 | 25 | ||
| 26 | enum class EntranceType { | ||
| 27 | kNormal, | ||
| 28 | kPainting, | ||
| 29 | kSunwarp, | ||
| 30 | kWarp, | ||
| 31 | kPilgrimage, | ||
| 32 | }; | ||
| 33 | |||
| 26 | struct Panel { | 34 | struct Panel { |
| 27 | int id; | 35 | int id; |
| 28 | int room; | 36 | int room; |
| @@ -66,7 +74,7 @@ struct Door { | |||
| 66 | struct Exit { | 74 | struct Exit { |
| 67 | int destination_room; | 75 | int destination_room; |
| 68 | std::optional<int> door; | 76 | std::optional<int> door; |
| 69 | bool painting = false; | 77 | EntranceType type = EntranceType::kNormal; |
| 70 | }; | 78 | }; |
| 71 | 79 | ||
| 72 | struct PaintingExit { | 80 | struct PaintingExit { |
| @@ -107,6 +115,7 @@ int GD_GetRoomByName(const std::string& name); | |||
| 107 | const Room& GD_GetRoom(int room_id); | 115 | const Room& GD_GetRoom(int room_id); |
| 108 | const std::vector<Door>& GD_GetDoors(); | 116 | const std::vector<Door>& GD_GetDoors(); |
| 109 | const Door& GD_GetDoor(int door_id); | 117 | const Door& GD_GetDoor(int door_id); |
| 118 | int GD_GetDoorByName(const std::string& name); | ||
| 110 | const Panel& GD_GetPanel(int panel_id); | 119 | const Panel& GD_GetPanel(int panel_id); |
| 111 | int GD_GetRoomForPainting(const std::string& painting_id); | 120 | int GD_GetRoomForPainting(const std::string& painting_id); |
| 112 | const std::vector<int>& GD_GetAchievementPanels(); | 121 | const std::vector<int>& GD_GetAchievementPanels(); |
| diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index e02ee14..cc941ef 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp | |||
| @@ -24,209 +24,299 @@ TrackerState& GetState() { | |||
| 24 | return *instance; | 24 | return *instance; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | Decision IsDoorReachable_Helper(int door_id, | 27 | struct StateCalculatorOptions { |
| 28 | const std::set<int>& reachable_rooms, | 28 | std::string start = "Menu"; |
| 29 | const std::set<int>& solveable_panels) { | 29 | bool pilgrimage = false; |
| 30 | const Door& door_obj = GD_GetDoor(door_id); | 30 | }; |
| 31 | 31 | ||
| 32 | if (AP_GetDoorShuffleMode() == kNO_DOORS || door_obj.skip_item) { | 32 | class StateCalculator { |
| 33 | if (!reachable_rooms.count(door_obj.room)) { | 33 | public: |
| 34 | return kMaybe; | 34 | StateCalculator() = default; |
| 35 | } | ||
| 36 | 35 | ||
| 37 | for (int panel_id : door_obj.panels) { | 36 | explicit StateCalculator(StateCalculatorOptions options) |
| 38 | if (!solveable_panels.count(panel_id)) { | 37 | : options_(options) {} |
| 39 | return kMaybe; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | 38 | ||
| 43 | return kYes; | 39 | void Calculate() { |
| 44 | } else if (AP_GetDoorShuffleMode() == kSIMPLE_DOORS && | 40 | std::list<int> panel_boundary; |
| 45 | !door_obj.group_name.empty()) { | 41 | std::list<Exit> flood_boundary; |
| 46 | return AP_HasItem(door_obj.group_ap_item_id) ? kYes : kNo; | 42 | flood_boundary.push_back( |
| 47 | } else { | 43 | {.destination_room = GD_GetRoomByName(options_.start)}); |
| 48 | bool has_item = AP_HasItem(door_obj.ap_item_id); | 44 | |
| 45 | bool reachable_changed = true; | ||
| 46 | while (reachable_changed) { | ||
| 47 | reachable_changed = false; | ||
| 49 | 48 | ||
| 50 | if (!has_item) { | 49 | std::list<int> new_panel_boundary; |
| 51 | for (const ProgressiveRequirement& prog_req : door_obj.progressives) { | 50 | for (int panel_id : panel_boundary) { |
| 52 | if (AP_HasItem(prog_req.ap_item_id, prog_req.quantity)) { | 51 | if (solveable_panels_.count(panel_id)) { |
| 53 | has_item = true; | 52 | continue; |
| 54 | break; | 53 | } |
| 54 | |||
| 55 | Decision panel_reachable = IsPanelReachable(panel_id); | ||
| 56 | if (panel_reachable == kYes) { | ||
| 57 | solveable_panels_.insert(panel_id); | ||
| 58 | reachable_changed = true; | ||
| 59 | } else if (panel_reachable == kMaybe) { | ||
| 60 | new_panel_boundary.push_back(panel_id); | ||
| 55 | } | 61 | } |
| 56 | } | 62 | } |
| 57 | } | ||
| 58 | 63 | ||
| 59 | return has_item ? kYes : kNo; | 64 | std::list<Exit> new_boundary; |
| 60 | } | 65 | for (const Exit& room_exit : flood_boundary) { |
| 61 | } | 66 | if (reachable_rooms_.count(room_exit.destination_room)) { |
| 67 | continue; | ||
| 68 | } | ||
| 62 | 69 | ||
| 63 | Decision IsPanelReachable_Helper(int panel_id, | 70 | bool valid_transition = false; |
| 64 | const std::set<int>& reachable_rooms, | ||
| 65 | const std::set<int>& solveable_panels) { | ||
| 66 | const Panel& panel_obj = GD_GetPanel(panel_id); | ||
| 67 | 71 | ||
| 68 | if (!reachable_rooms.count(panel_obj.room)) { | 72 | Decision exit_usable = IsExitUsable(room_exit); |
| 69 | return kMaybe; | 73 | if (exit_usable == kYes) { |
| 70 | } | 74 | valid_transition = true; |
| 75 | } else if (exit_usable == kMaybe) { | ||
| 76 | new_boundary.push_back(room_exit); | ||
| 77 | } | ||
| 78 | |||
| 79 | if (valid_transition) { | ||
| 80 | reachable_rooms_.insert(room_exit.destination_room); | ||
| 81 | reachable_changed = true; | ||
| 82 | |||
| 83 | const Room& room_obj = GD_GetRoom(room_exit.destination_room); | ||
| 84 | for (const Exit& out_edge : room_obj.exits) { | ||
| 85 | if (out_edge.type != EntranceType::kPainting || | ||
| 86 | !AP_IsPaintingShuffle()) { | ||
| 87 | new_boundary.push_back(out_edge); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | if (AP_IsPaintingShuffle()) { | ||
| 92 | for (const PaintingExit& out_edge : room_obj.paintings) { | ||
| 93 | if (AP_GetPaintingMapping().count(out_edge.id)) { | ||
| 94 | Exit painting_exit; | ||
| 95 | painting_exit.destination_room = GD_GetRoomForPainting( | ||
| 96 | AP_GetPaintingMapping().at(out_edge.id)); | ||
| 97 | painting_exit.door = out_edge.door; | ||
| 71 | 98 | ||
| 72 | if (panel_obj.name == "THE MASTER") { | 99 | new_boundary.push_back(painting_exit); |
| 73 | int achievements_accessible = 0; | 100 | } |
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { | ||
| 105 | new_boundary.push_back( | ||
| 106 | {.destination_room = GD_GetRoomByName("Outside The Undeterred"), | ||
| 107 | .type = EntranceType::kPainting}); | ||
| 108 | } | ||
| 74 | 109 | ||
| 75 | for (int achieve_id : GD_GetAchievementPanels()) { | 110 | if (AP_IsPilgrimageEnabled()) { |
| 76 | if (solveable_panels.count(achieve_id)) { | 111 | if (room_obj.name == "Hub Room") { |
| 77 | achievements_accessible++; | 112 | new_boundary.push_back( |
| 113 | {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), | ||
| 114 | .type = EntranceType::kPilgrimage}); | ||
| 115 | } | ||
| 116 | } else { | ||
| 117 | if (room_obj.name == "Starting Room") { | ||
| 118 | new_boundary.push_back( | ||
| 119 | {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), | ||
| 120 | .door = | ||
| 121 | GD_GetDoorByName("Pilgrim Antechamber - Sun Painting"), | ||
| 122 | .type = EntranceType::kPainting}); | ||
| 123 | } | ||
| 124 | } | ||
| 78 | 125 | ||
| 79 | if (achievements_accessible >= AP_GetMasteryRequirement()) { | 126 | for (int panel_id : room_obj.panels) { |
| 80 | break; | 127 | new_panel_boundary.push_back(panel_id); |
| 128 | } | ||
| 81 | } | 129 | } |
| 82 | } | 130 | } |
| 83 | } | ||
| 84 | 131 | ||
| 85 | return (achievements_accessible >= AP_GetMasteryRequirement()) ? kYes | 132 | flood_boundary = new_boundary; |
| 86 | : kMaybe; | 133 | panel_boundary = new_panel_boundary; |
| 134 | } | ||
| 87 | } | 135 | } |
| 88 | 136 | ||
| 89 | if ((panel_obj.name == "ANOTHER TRY" || panel_obj.name == "LEVEL 2") && | 137 | const std::set<int>& GetReachableRooms() const { return reachable_rooms_; } |
| 90 | AP_GetLevel2Requirement() > 1) { | ||
| 91 | int counting_panels_accessible = 0; | ||
| 92 | 138 | ||
| 93 | for (int solved_panel_id : solveable_panels) { | 139 | const std::set<int>& GetSolveablePanels() const { return solveable_panels_; } |
| 94 | const Panel& solved_panel = GD_GetPanel(solved_panel_id); | ||
| 95 | 140 | ||
| 96 | if (!solved_panel.non_counting) { | 141 | private: |
| 97 | counting_panels_accessible++; | 142 | Decision IsDoorReachable(int door_id) { |
| 143 | const Door& door_obj = GD_GetDoor(door_id); | ||
| 144 | |||
| 145 | if (!AP_IsPilgrimageEnabled() && | ||
| 146 | door_obj.item_name == "Pilgrim Room - Sun Painting") { | ||
| 147 | return AP_HasItem(door_obj.ap_item_id) ? kYes : kNo; | ||
| 148 | } else if (AP_GetDoorShuffleMode() == kNO_DOORS || door_obj.skip_item) { | ||
| 149 | if (!reachable_rooms_.count(door_obj.room)) { | ||
| 150 | return kMaybe; | ||
| 98 | } | 151 | } |
| 99 | } | ||
| 100 | 152 | ||
| 101 | return (counting_panels_accessible >= AP_GetLevel2Requirement() - 1) | 153 | for (int panel_id : door_obj.panels) { |
| 102 | ? kYes | 154 | if (!solveable_panels_.count(panel_id)) { |
| 103 | : kMaybe; | 155 | return kMaybe; |
| 104 | } | 156 | } |
| 157 | } | ||
| 105 | 158 | ||
| 106 | for (int room_id : panel_obj.required_rooms) { | 159 | return kYes; |
| 107 | if (!reachable_rooms.count(room_id)) { | 160 | } else if (AP_GetDoorShuffleMode() == kSIMPLE_DOORS && |
| 108 | return kMaybe; | 161 | !door_obj.group_name.empty()) { |
| 109 | } | 162 | return AP_HasItem(door_obj.group_ap_item_id) ? kYes : kNo; |
| 110 | } | 163 | } else { |
| 164 | bool has_item = AP_HasItem(door_obj.ap_item_id); | ||
| 165 | |||
| 166 | if (!has_item) { | ||
| 167 | for (const ProgressiveRequirement& prog_req : door_obj.progressives) { | ||
| 168 | if (AP_HasItem(prog_req.ap_item_id, prog_req.quantity)) { | ||
| 169 | has_item = true; | ||
| 170 | break; | ||
| 171 | } | ||
| 172 | } | ||
| 173 | } | ||
| 111 | 174 | ||
| 112 | for (int door_id : panel_obj.required_doors) { | 175 | return has_item ? kYes : kNo; |
| 113 | Decision door_reachable = | ||
| 114 | IsDoorReachable_Helper(door_id, reachable_rooms, solveable_panels); | ||
| 115 | if (door_reachable == kNo) { | ||
| 116 | const Door& door_obj = GD_GetDoor(door_id); | ||
| 117 | return (door_obj.is_event || AP_GetDoorShuffleMode() == kNO_DOORS) | ||
| 118 | ? kMaybe | ||
| 119 | : kNo; | ||
| 120 | } else if (door_reachable == kMaybe) { | ||
| 121 | return kMaybe; | ||
| 122 | } | 176 | } |
| 123 | } | 177 | } |
| 124 | 178 | ||
| 125 | for (int panel_id : panel_obj.required_panels) { | 179 | Decision IsPanelReachable(int panel_id) { |
| 126 | if (!solveable_panels.count(panel_id)) { | 180 | const Panel& panel_obj = GD_GetPanel(panel_id); |
| 181 | |||
| 182 | if (!reachable_rooms_.count(panel_obj.room)) { | ||
| 127 | return kMaybe; | 183 | return kMaybe; |
| 128 | } | 184 | } |
| 129 | } | ||
| 130 | 185 | ||
| 131 | if (AP_IsColorShuffle()) { | 186 | if (panel_obj.name == "THE MASTER") { |
| 132 | for (LingoColor color : panel_obj.colors) { | 187 | int achievements_accessible = 0; |
| 133 | if (!AP_HasItem(GD_GetItemIdForColor(color))) { | ||
| 134 | return kNo; | ||
| 135 | } | ||
| 136 | } | ||
| 137 | } | ||
| 138 | 188 | ||
| 139 | return kYes; | 189 | for (int achieve_id : GD_GetAchievementPanels()) { |
| 140 | } | 190 | if (solveable_panels_.count(achieve_id)) { |
| 191 | achievements_accessible++; | ||
| 141 | 192 | ||
| 142 | } // namespace | 193 | if (achievements_accessible >= AP_GetMasteryRequirement()) { |
| 194 | break; | ||
| 195 | } | ||
| 196 | } | ||
| 197 | } | ||
| 143 | 198 | ||
| 144 | void RecalculateReachability() { | 199 | return (achievements_accessible >= AP_GetMasteryRequirement()) ? kYes |
| 145 | std::set<int> reachable_rooms; | 200 | : kMaybe; |
| 146 | std::set<int> solveable_panels; | 201 | } |
| 147 | 202 | ||
| 148 | std::list<int> panel_boundary; | 203 | if ((panel_obj.name == "ANOTHER TRY" || panel_obj.name == "LEVEL 2") && |
| 149 | std::list<Exit> flood_boundary; | 204 | AP_GetLevel2Requirement() > 1) { |
| 150 | flood_boundary.push_back({.destination_room = GD_GetRoomByName("Menu")}); | 205 | int counting_panels_accessible = 0; |
| 151 | 206 | ||
| 152 | if (AP_HasEarlyColorHallways()) { | 207 | for (int solved_panel_id : solveable_panels_) { |
| 153 | flood_boundary.push_back( | 208 | const Panel& solved_panel = GD_GetPanel(solved_panel_id); |
| 154 | {.destination_room = GD_GetRoomByName("Outside The Undeterred")}); | 209 | |
| 155 | } | 210 | if (!solved_panel.non_counting) { |
| 211 | counting_panels_accessible++; | ||
| 212 | } | ||
| 213 | } | ||
| 156 | 214 | ||
| 157 | bool reachable_changed = true; | 215 | return (counting_panels_accessible >= AP_GetLevel2Requirement() - 1) |
| 158 | while (reachable_changed) { | 216 | ? kYes |
| 159 | reachable_changed = false; | 217 | : kMaybe; |
| 218 | } | ||
| 160 | 219 | ||
| 161 | std::list<int> new_panel_boundary; | 220 | for (int room_id : panel_obj.required_rooms) { |
| 162 | for (int panel_id : panel_boundary) { | 221 | if (!reachable_rooms_.count(room_id)) { |
| 163 | if (solveable_panels.count(panel_id)) { | 222 | return kMaybe; |
| 164 | continue; | ||
| 165 | } | 223 | } |
| 224 | } | ||
| 166 | 225 | ||
| 167 | Decision panel_reachable = | 226 | for (int door_id : panel_obj.required_doors) { |
| 168 | IsPanelReachable_Helper(panel_id, reachable_rooms, solveable_panels); | 227 | Decision door_reachable = IsDoorReachable(door_id); |
| 169 | if (panel_reachable == kYes) { | 228 | if (door_reachable == kNo) { |
| 170 | solveable_panels.insert(panel_id); | 229 | const Door& door_obj = GD_GetDoor(door_id); |
| 171 | reachable_changed = true; | 230 | return (door_obj.is_event || AP_GetDoorShuffleMode() == kNO_DOORS) |
| 172 | } else if (panel_reachable == kMaybe) { | 231 | ? kMaybe |
| 173 | new_panel_boundary.push_back(panel_id); | 232 | : kNo; |
| 233 | } else if (door_reachable == kMaybe) { | ||
| 234 | return kMaybe; | ||
| 174 | } | 235 | } |
| 175 | } | 236 | } |
| 176 | 237 | ||
| 177 | std::list<Exit> new_boundary; | 238 | for (int panel_id : panel_obj.required_panels) { |
| 178 | for (const Exit& room_exit : flood_boundary) { | 239 | if (!solveable_panels_.count(panel_id)) { |
| 179 | if (reachable_rooms.count(room_exit.destination_room)) { | 240 | return kMaybe; |
| 180 | continue; | ||
| 181 | } | 241 | } |
| 242 | } | ||
| 182 | 243 | ||
| 183 | bool valid_transition = false; | 244 | if (AP_IsColorShuffle()) { |
| 184 | if (room_exit.door.has_value()) { | 245 | for (LingoColor color : panel_obj.colors) { |
| 185 | Decision door_reachable = IsDoorReachable_Helper( | 246 | if (!AP_HasItem(GD_GetItemIdForColor(color))) { |
| 186 | *room_exit.door, reachable_rooms, solveable_panels); | 247 | return kNo; |
| 187 | if (door_reachable == kYes) { | ||
| 188 | valid_transition = true; | ||
| 189 | } else if (door_reachable == kMaybe) { | ||
| 190 | new_boundary.push_back(room_exit); | ||
| 191 | } | 248 | } |
| 192 | } else { | ||
| 193 | valid_transition = true; | ||
| 194 | } | 249 | } |
| 250 | } | ||
| 251 | |||
| 252 | return kYes; | ||
| 253 | } | ||
| 195 | 254 | ||
| 196 | if (valid_transition) { | 255 | Decision IsExitUsable(const Exit& room_exit) { |
| 197 | reachable_rooms.insert(room_exit.destination_room); | 256 | if (room_exit.type == EntranceType::kPilgrimage) { |
| 198 | reachable_changed = true; | 257 | if (options_.pilgrimage || !AP_IsPilgrimageEnabled()) { |
| 258 | return kNo; | ||
| 259 | } | ||
| 199 | 260 | ||
| 200 | const Room& room_obj = GD_GetRoom(room_exit.destination_room); | 261 | static const std::vector<std::tuple<std::string, std::string>> |
| 201 | for (const Exit& out_edge : room_obj.exits) { | 262 | pilgrimage_pairs = { |
| 202 | if (!out_edge.painting || !AP_IsPaintingShuffle()) { | 263 | {"Crossroads", "Hot Crusts Area"}, |
| 203 | new_boundary.push_back(out_edge); | 264 | // {"Orange Tower Third Floor", "Orange Tower Third Floor"}, |
| 204 | } | 265 | {"Outside The Initiated", "Orange Tower First Floor"}, |
| 266 | {"Outside The Undeterred", "Orange Tower Fourth Floor"}, | ||
| 267 | {"Color Hunt", "Outside The Agreeable"}}; | ||
| 268 | |||
| 269 | for (const auto& [from_room, to_room] : pilgrimage_pairs) { | ||
| 270 | StateCalculator pilgrimage_calculator( | ||
| 271 | {.start = from_room, .pilgrimage = true}); | ||
| 272 | pilgrimage_calculator.Calculate(); | ||
| 273 | |||
| 274 | if (!pilgrimage_calculator.GetReachableRooms().count( | ||
| 275 | GD_GetRoomByName(to_room))) { | ||
| 276 | return kMaybe; | ||
| 205 | } | 277 | } |
| 278 | } | ||
| 206 | 279 | ||
| 207 | if (AP_IsPaintingShuffle()) { | 280 | return kYes; |
| 208 | for (const PaintingExit& out_edge : room_obj.paintings) { | 281 | } |
| 209 | if (AP_GetPaintingMapping().count(out_edge.id)) { | ||
| 210 | Exit painting_exit; | ||
| 211 | painting_exit.destination_room = GD_GetRoomForPainting( | ||
| 212 | AP_GetPaintingMapping().at(out_edge.id)); | ||
| 213 | painting_exit.door = out_edge.door; | ||
| 214 | 282 | ||
| 215 | new_boundary.push_back(painting_exit); | 283 | if (options_.pilgrimage) { |
| 216 | } | 284 | if (room_exit.type == EntranceType::kWarp || |
| 217 | } | 285 | room_exit.type == EntranceType::kSunwarp) { |
| 218 | } | 286 | return kNo; |
| 287 | } | ||
| 288 | } | ||
| 219 | 289 | ||
| 220 | for (int panel_id : room_obj.panels) { | 290 | if (room_exit.type == EntranceType::kSunwarp) { |
| 221 | new_panel_boundary.push_back(panel_id); | 291 | if (AP_GetSunwarpAccess() == kSUNWARP_ACCESS_NORMAL) { |
| 222 | } | 292 | return kYes; |
| 293 | } else if (AP_GetSunwarpAccess() == kSUNWARP_ACCESS_DISABLED) { | ||
| 294 | return kNo; | ||
| 223 | } | 295 | } |
| 224 | } | 296 | } |
| 225 | 297 | ||
| 226 | flood_boundary = new_boundary; | 298 | if (room_exit.door.has_value()) { |
| 227 | panel_boundary = new_panel_boundary; | 299 | return IsDoorReachable(*room_exit.door); |
| 300 | } | ||
| 301 | |||
| 302 | return kYes; | ||
| 228 | } | 303 | } |
| 229 | 304 | ||
| 305 | StateCalculatorOptions options_; | ||
| 306 | |||
| 307 | std::set<int> reachable_rooms_; | ||
| 308 | std::set<int> solveable_panels_; | ||
| 309 | }; | ||
| 310 | |||
| 311 | } // namespace | ||
| 312 | |||
| 313 | void RecalculateReachability() { | ||
| 314 | StateCalculator state_calculator; | ||
| 315 | state_calculator.Calculate(); | ||
| 316 | |||
| 317 | const std::set<int>& reachable_rooms = state_calculator.GetReachableRooms(); | ||
| 318 | const std::set<int>& solveable_panels = state_calculator.GetSolveablePanels(); | ||
| 319 | |||
| 230 | std::map<int, bool> new_reachability; | 320 | std::map<int, bool> new_reachability; |
| 231 | for (const MapArea& map_area : GD_GetMapAreas()) { | 321 | for (const MapArea& map_area : GD_GetMapAreas()) { |
| 232 | for (size_t section_id = 0; section_id < map_area.locations.size(); | 322 | for (size_t section_id = 0; section_id < map_area.locations.size(); |
