From e07e0318666e9b05b2a78b7de0979d5706cc28b7 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 2 Mar 2024 21:17:14 -0500 Subject: Added sunwarp shuffle --- src/ap_state.cpp | 23 +++++++++++++++++++++++ src/ap_state.h | 9 +++++++++ src/connection_dialog.cpp | 8 ++++---- src/game_data.cpp | 20 +++++++++++++++++++- src/game_data.h | 2 ++ src/tracker_panel.h | 2 +- src/tracker_state.cpp | 36 ++++++++++++++++++++++++++++++------ 7 files changed, 88 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ap_state.cpp b/src/ap_state.cpp index bdd9cb2..1ac6575 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -67,8 +67,10 @@ struct APState { bool pilgrimage_allows_roof_access = false; bool pilgrimage_allows_paintings = false; SunwarpAccess sunwarp_access = kSUNWARP_ACCESS_NORMAL; + bool sunwarp_shuffle = false; std::map painting_mapping; + std::map sunwarp_mapping; void Connect(std::string server, std::string player, std::string password) { if (!initialized) { @@ -140,6 +142,8 @@ struct APState { pilgrimage_allows_roof_access = false; pilgrimage_allows_paintings = false; sunwarp_access = kSUNWARP_ACCESS_NORMAL; + sunwarp_shuffle = false; + sunwarp_mapping.clear(); connected = false; has_connection_result = false; @@ -251,6 +255,7 @@ struct APState { slot_data.contains("pilgrimage_allows_paintings") && slot_data["pilgrimage_allows_paintings"].get() == 1; sunwarp_access = slot_data["sunwarp_access"].get(); + sunwarp_shuffle = slot_data["shuffle_sunwarps"].get() == 1; if (painting_shuffle && slot_data.contains("painting_entrance_to_exit")) { painting_mapping.clear(); @@ -261,6 +266,18 @@ struct APState { } } + if (sunwarp_shuffle && slot_data.contains("sunwarp_permutation")) { + std::vector inverted_sunwarps; + for (const auto& item : slot_data["sunwarp_permutation"]) { + inverted_sunwarps.push_back(item); + } + + for (int i = 0; i < 6; i++) { + sunwarp_mapping[inverted_sunwarps[i]] = SunwarpMapping{ + .dots = i + 1, .exit_index = inverted_sunwarps[i + 6]}; + } + } + connected = true; has_connection_result = true; @@ -474,4 +491,10 @@ bool AP_DoesPilgrimageAllowPaintings() { SunwarpAccess AP_GetSunwarpAccess() { return GetState().sunwarp_access; } +bool AP_IsSunwarpShuffle() { return GetState().sunwarp_shuffle; } + +const std::map& AP_GetSunwarpMapping() { + return GetState().sunwarp_mapping; +} + bool AP_HasReachedGoal() { return GetState().HasReachedGoal(); } diff --git a/src/ap_state.h b/src/ap_state.h index e1f34c7..36694b2 100644 --- a/src/ap_state.h +++ b/src/ap_state.h @@ -31,6 +31,11 @@ enum SunwarpAccess { kSUNWARP_ACCESS_PROGRESSIVE = 4 }; +struct SunwarpMapping { + int dots; + int exit_index; +}; + void AP_SetTrackerFrame(TrackerFrame* tracker_frame); void AP_Connect(std::string server, std::string player, std::string password); @@ -69,6 +74,10 @@ bool AP_DoesPilgrimageAllowPaintings(); SunwarpAccess AP_GetSunwarpAccess(); +bool AP_IsSunwarpShuffle(); + +const std::map& AP_GetSunwarpMapping(); + bool AP_HasReachedGoal(); #endif /* end of include guard: AP_STATE_H_664A4180 */ diff --git a/src/connection_dialog.cpp b/src/connection_dialog.cpp index 9dd9984..45be8b8 100644 --- a/src/connection_dialog.cpp +++ b/src/connection_dialog.cpp @@ -4,10 +4,10 @@ ConnectionDialog::ConnectionDialog() : wxDialog(nullptr, wxID_ANY, "Connect to Archipelago") { - server_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_server, wxDefaultPosition, - {300, -1}); - player_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_player, wxDefaultPosition, - {300, -1}); + server_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_server, + wxDefaultPosition, {300, -1}); + player_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_player, + wxDefaultPosition, {300, -1}); password_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_password, wxDefaultPosition, {300, -1}); diff --git a/src/game_data.cpp b/src/game_data.cpp index 75c5b7e..7db6413 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -53,6 +53,7 @@ struct GameData { std::vector door_definition_order_; std::map room_by_painting_; + std::map room_by_sunwarp_; std::vector achievement_panels_; @@ -112,7 +113,8 @@ struct GameData { if (option["room"]) { door_room = option["room"].as(); } - exit_obj.door = AddOrGetDoor(door_room, option["door"].as()); + exit_obj.door = + AddOrGetDoor(door_room, option["door"].as()); } if (option["painting"] && option["painting"].as()) { @@ -443,6 +445,18 @@ struct GameData { } } + if (room_it.second["sunwarps"]) { + for (const auto &sunwarp : room_it.second["sunwarps"]) { + int index = sunwarp["dots"].as() - 1; + if (sunwarp["direction"].as() == "exit") { + index += 6; + } + + rooms_[room_id].sunwarps.push_back(index); + room_by_sunwarp_[index] = room_id; + } + } + if (room_it.second["progression"]) { for (const auto &progression_it : room_it.second["progression"]) { std::string progressive_item_name = @@ -686,3 +700,7 @@ int GD_GetItemIdForColor(LingoColor color) { const std::vector &GD_GetSunwarpDoors() { return GetState().sunwarp_doors_; } + +int GD_GetRoomForSunwarp(int index) { + return GetState().room_by_sunwarp_.at(index); +} diff --git a/src/game_data.h b/src/game_data.h index 16d006c..cd09627 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -94,6 +94,7 @@ struct Room { std::string name; std::vector exits; std::vector paintings; + std::vector sunwarps; std::vector panels; }; @@ -129,5 +130,6 @@ int GD_GetRoomForPainting(const std::string& painting_id); const std::vector& GD_GetAchievementPanels(); int GD_GetItemIdForColor(LingoColor color); const std::vector& GD_GetSunwarpDoors(); +int GD_GetRoomForSunwarp(int index); #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ diff --git a/src/tracker_panel.h b/src/tracker_panel.h index cb4f082..2dc034c 100644 --- a/src/tracker_panel.h +++ b/src/tracker_panel.h @@ -25,7 +25,7 @@ class TrackerPanel : public wxPanel { int real_y2 = 0; bool active = true; }; - + void OnPaint(wxPaintEvent &event); void OnMouseMove(wxMouseEvent &event); diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index 5a99254..0101e98 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp @@ -85,10 +85,17 @@ class StateCalculator { 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 (out_edge.type == EntranceType::kPainting && + AP_IsPaintingShuffle()) { + continue; } + + if (out_edge.type == EntranceType::kSunwarp && + AP_IsSunwarpShuffle()) { + continue; + } + + new_boundary.push_back(out_edge); } if (AP_IsPaintingShuffle()) { @@ -104,6 +111,21 @@ class StateCalculator { } } + if (AP_IsSunwarpShuffle()) { + for (int index : room_obj.sunwarps) { + if (AP_GetSunwarpMapping().count(index)) { + const SunwarpMapping& sm = AP_GetSunwarpMapping().at(index); + + Exit sunwarp_exit; + sunwarp_exit.destination_room = + GD_GetRoomForSunwarp(sm.exit_index); + sunwarp_exit.door = GD_GetSunwarpDoors().at(sm.dots - 1); + + new_boundary.push_back(sunwarp_exit); + } + } + } + if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { new_boundary.push_back( {.destination_room = GD_GetRoomByName("Outside The Undeterred"), @@ -139,12 +161,14 @@ class StateCalculator { const std::set& GetReachableRooms() const { return reachable_rooms_; } - const std::map& GetDoorDecisions() const { return door_decisions_; } + const std::map& GetDoorDecisions() const { + return door_decisions_; + } const std::set& GetSolveablePanels() const { return solveable_panels_; } private: - Decision IsNonGroupedDoorReachable(const Door& door_obj) { + Decision IsNonGroupedDoorReachable(const Door& door_obj) { bool has_item = AP_HasItem(door_obj.ap_item_id); if (!has_item) { @@ -209,7 +233,7 @@ class StateCalculator { if (result != kMaybe) { door_decisions_[door_id] = result; } - + return result; } -- cgit 1.4.1