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 --- 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 +++++++++++++++++++++++++++++++++++-- 5 files changed, 73 insertions(+), 20 deletions(-) (limited to 'src') 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