diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-03-02 21:17:14 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-03-02 21:17:14 -0500 |
commit | e07e0318666e9b05b2a78b7de0979d5706cc28b7 (patch) | |
tree | e01a2587666d01a59eddb38003e008420505b845 | |
parent | 2c2d9e9f39ea780b5a04159f9c62fd5540471b86 (diff) | |
download | lingo-ap-tracker-e07e0318666e9b05b2a78b7de0979d5706cc28b7.tar.gz lingo-ap-tracker-e07e0318666e9b05b2a78b7de0979d5706cc28b7.tar.bz2 lingo-ap-tracker-e07e0318666e9b05b2a78b7de0979d5706cc28b7.zip |
Added sunwarp shuffle
-rw-r--r-- | src/ap_state.cpp | 23 | ||||
-rw-r--r-- | src/ap_state.h | 9 | ||||
-rw-r--r-- | src/connection_dialog.cpp | 8 | ||||
-rw-r--r-- | src/game_data.cpp | 20 | ||||
-rw-r--r-- | src/game_data.h | 2 | ||||
-rw-r--r-- | src/tracker_panel.h | 2 | ||||
-rw-r--r-- | src/tracker_state.cpp | 36 |
7 files changed, 88 insertions, 12 deletions
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 { | |||
67 | bool pilgrimage_allows_roof_access = false; | 67 | bool pilgrimage_allows_roof_access = false; |
68 | bool pilgrimage_allows_paintings = false; | 68 | bool pilgrimage_allows_paintings = false; |
69 | SunwarpAccess sunwarp_access = kSUNWARP_ACCESS_NORMAL; | 69 | SunwarpAccess sunwarp_access = kSUNWARP_ACCESS_NORMAL; |
70 | bool sunwarp_shuffle = false; | ||
70 | 71 | ||
71 | std::map<std::string, std::string> painting_mapping; | 72 | std::map<std::string, std::string> painting_mapping; |
73 | std::map<int, SunwarpMapping> sunwarp_mapping; | ||
72 | 74 | ||
73 | void Connect(std::string server, std::string player, std::string password) { | 75 | void Connect(std::string server, std::string player, std::string password) { |
74 | if (!initialized) { | 76 | if (!initialized) { |
@@ -140,6 +142,8 @@ struct APState { | |||
140 | pilgrimage_allows_roof_access = false; | 142 | pilgrimage_allows_roof_access = false; |
141 | pilgrimage_allows_paintings = false; | 143 | pilgrimage_allows_paintings = false; |
142 | sunwarp_access = kSUNWARP_ACCESS_NORMAL; | 144 | sunwarp_access = kSUNWARP_ACCESS_NORMAL; |
145 | sunwarp_shuffle = false; | ||
146 | sunwarp_mapping.clear(); | ||
143 | 147 | ||
144 | connected = false; | 148 | connected = false; |
145 | has_connection_result = false; | 149 | has_connection_result = false; |
@@ -251,6 +255,7 @@ struct APState { | |||
251 | slot_data.contains("pilgrimage_allows_paintings") && | 255 | slot_data.contains("pilgrimage_allows_paintings") && |
252 | slot_data["pilgrimage_allows_paintings"].get<int>() == 1; | 256 | slot_data["pilgrimage_allows_paintings"].get<int>() == 1; |
253 | sunwarp_access = slot_data["sunwarp_access"].get<SunwarpAccess>(); | 257 | sunwarp_access = slot_data["sunwarp_access"].get<SunwarpAccess>(); |
258 | sunwarp_shuffle = slot_data["shuffle_sunwarps"].get<int>() == 1; | ||
254 | 259 | ||
255 | if (painting_shuffle && slot_data.contains("painting_entrance_to_exit")) { | 260 | if (painting_shuffle && slot_data.contains("painting_entrance_to_exit")) { |
256 | painting_mapping.clear(); | 261 | painting_mapping.clear(); |
@@ -261,6 +266,18 @@ struct APState { | |||
261 | } | 266 | } |
262 | } | 267 | } |
263 | 268 | ||
269 | if (sunwarp_shuffle && slot_data.contains("sunwarp_permutation")) { | ||
270 | std::vector<int> inverted_sunwarps; | ||
271 | for (const auto& item : slot_data["sunwarp_permutation"]) { | ||
272 | inverted_sunwarps.push_back(item); | ||
273 | } | ||
274 | |||
275 | for (int i = 0; i < 6; i++) { | ||
276 | sunwarp_mapping[inverted_sunwarps[i]] = SunwarpMapping{ | ||
277 | .dots = i + 1, .exit_index = inverted_sunwarps[i + 6]}; | ||
278 | } | ||
279 | } | ||
280 | |||
264 | connected = true; | 281 | connected = true; |
265 | has_connection_result = true; | 282 | has_connection_result = true; |
266 | 283 | ||
@@ -474,4 +491,10 @@ bool AP_DoesPilgrimageAllowPaintings() { | |||
474 | 491 | ||
475 | SunwarpAccess AP_GetSunwarpAccess() { return GetState().sunwarp_access; } | 492 | SunwarpAccess AP_GetSunwarpAccess() { return GetState().sunwarp_access; } |
476 | 493 | ||
494 | bool AP_IsSunwarpShuffle() { return GetState().sunwarp_shuffle; } | ||
495 | |||
496 | const std::map<int, SunwarpMapping>& AP_GetSunwarpMapping() { | ||
497 | return GetState().sunwarp_mapping; | ||
498 | } | ||
499 | |||
477 | bool AP_HasReachedGoal() { return GetState().HasReachedGoal(); } | 500 | 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 { | |||
31 | kSUNWARP_ACCESS_PROGRESSIVE = 4 | 31 | kSUNWARP_ACCESS_PROGRESSIVE = 4 |
32 | }; | 32 | }; |
33 | 33 | ||
34 | struct SunwarpMapping { | ||
35 | int dots; | ||
36 | int exit_index; | ||
37 | }; | ||
38 | |||
34 | void AP_SetTrackerFrame(TrackerFrame* tracker_frame); | 39 | void AP_SetTrackerFrame(TrackerFrame* tracker_frame); |
35 | 40 | ||
36 | void AP_Connect(std::string server, std::string player, std::string password); | 41 | void AP_Connect(std::string server, std::string player, std::string password); |
@@ -69,6 +74,10 @@ bool AP_DoesPilgrimageAllowPaintings(); | |||
69 | 74 | ||
70 | SunwarpAccess AP_GetSunwarpAccess(); | 75 | SunwarpAccess AP_GetSunwarpAccess(); |
71 | 76 | ||
77 | bool AP_IsSunwarpShuffle(); | ||
78 | |||
79 | const std::map<int, SunwarpMapping>& AP_GetSunwarpMapping(); | ||
80 | |||
72 | bool AP_HasReachedGoal(); | 81 | bool AP_HasReachedGoal(); |
73 | 82 | ||
74 | #endif /* end of include guard: AP_STATE_H_664A4180 */ | 83 | #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 @@ | |||
4 | 4 | ||
5 | ConnectionDialog::ConnectionDialog() | 5 | ConnectionDialog::ConnectionDialog() |
6 | : wxDialog(nullptr, wxID_ANY, "Connect to Archipelago") { | 6 | : wxDialog(nullptr, wxID_ANY, "Connect to Archipelago") { |
7 | server_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_server, wxDefaultPosition, | 7 | server_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_server, |
8 | {300, -1}); | 8 | wxDefaultPosition, {300, -1}); |
9 | player_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_player, wxDefaultPosition, | 9 | player_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_player, |
10 | {300, -1}); | 10 | wxDefaultPosition, {300, -1}); |
11 | password_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_password, | 11 | password_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_password, |
12 | wxDefaultPosition, {300, -1}); | 12 | wxDefaultPosition, {300, -1}); |
13 | 13 | ||
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 { | |||
53 | std::vector<int> door_definition_order_; | 53 | std::vector<int> door_definition_order_; |
54 | 54 | ||
55 | std::map<std::string, int> room_by_painting_; | 55 | std::map<std::string, int> room_by_painting_; |
56 | std::map<int, int> room_by_sunwarp_; | ||
56 | 57 | ||
57 | std::vector<int> achievement_panels_; | 58 | std::vector<int> achievement_panels_; |
58 | 59 | ||
@@ -112,7 +113,8 @@ struct GameData { | |||
112 | if (option["room"]) { | 113 | if (option["room"]) { |
113 | door_room = option["room"].as<std::string>(); | 114 | door_room = option["room"].as<std::string>(); |
114 | } | 115 | } |
115 | exit_obj.door = AddOrGetDoor(door_room, option["door"].as<std::string>()); | 116 | exit_obj.door = |
117 | AddOrGetDoor(door_room, option["door"].as<std::string>()); | ||
116 | } | 118 | } |
117 | 119 | ||
118 | if (option["painting"] && option["painting"].as<bool>()) { | 120 | if (option["painting"] && option["painting"].as<bool>()) { |
@@ -443,6 +445,18 @@ struct GameData { | |||
443 | } | 445 | } |
444 | } | 446 | } |
445 | 447 | ||
448 | if (room_it.second["sunwarps"]) { | ||
449 | for (const auto &sunwarp : room_it.second["sunwarps"]) { | ||
450 | int index = sunwarp["dots"].as<int>() - 1; | ||
451 | if (sunwarp["direction"].as<std::string>() == "exit") { | ||
452 | index += 6; | ||
453 | } | ||
454 | |||
455 | rooms_[room_id].sunwarps.push_back(index); | ||
456 | room_by_sunwarp_[index] = room_id; | ||
457 | } | ||
458 | } | ||
459 | |||
446 | if (room_it.second["progression"]) { | 460 | if (room_it.second["progression"]) { |
447 | for (const auto &progression_it : room_it.second["progression"]) { | 461 | for (const auto &progression_it : room_it.second["progression"]) { |
448 | std::string progressive_item_name = | 462 | std::string progressive_item_name = |
@@ -686,3 +700,7 @@ int GD_GetItemIdForColor(LingoColor color) { | |||
686 | const std::vector<int> &GD_GetSunwarpDoors() { | 700 | const std::vector<int> &GD_GetSunwarpDoors() { |
687 | return GetState().sunwarp_doors_; | 701 | return GetState().sunwarp_doors_; |
688 | } | 702 | } |
703 | |||
704 | int GD_GetRoomForSunwarp(int index) { | ||
705 | return GetState().room_by_sunwarp_.at(index); | ||
706 | } | ||
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 { | |||
94 | std::string name; | 94 | std::string name; |
95 | std::vector<Exit> exits; | 95 | std::vector<Exit> exits; |
96 | std::vector<PaintingExit> paintings; | 96 | std::vector<PaintingExit> paintings; |
97 | std::vector<int> sunwarps; | ||
97 | std::vector<int> panels; | 98 | std::vector<int> panels; |
98 | }; | 99 | }; |
99 | 100 | ||
@@ -129,5 +130,6 @@ int GD_GetRoomForPainting(const std::string& painting_id); | |||
129 | const std::vector<int>& GD_GetAchievementPanels(); | 130 | const std::vector<int>& GD_GetAchievementPanels(); |
130 | int GD_GetItemIdForColor(LingoColor color); | 131 | int GD_GetItemIdForColor(LingoColor color); |
131 | const std::vector<int>& GD_GetSunwarpDoors(); | 132 | const std::vector<int>& GD_GetSunwarpDoors(); |
133 | int GD_GetRoomForSunwarp(int index); | ||
132 | 134 | ||
133 | #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ | 135 | #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 { | |||
25 | int real_y2 = 0; | 25 | int real_y2 = 0; |
26 | bool active = true; | 26 | bool active = true; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | void OnPaint(wxPaintEvent &event); | 29 | void OnPaint(wxPaintEvent &event); |
30 | void OnMouseMove(wxMouseEvent &event); | 30 | void OnMouseMove(wxMouseEvent &event); |
31 | 31 | ||
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 { | |||
85 | 85 | ||
86 | const Room& room_obj = GD_GetRoom(room_exit.destination_room); | 86 | const Room& room_obj = GD_GetRoom(room_exit.destination_room); |
87 | for (const Exit& out_edge : room_obj.exits) { | 87 | for (const Exit& out_edge : room_obj.exits) { |
88 | if (out_edge.type != EntranceType::kPainting || | 88 | if (out_edge.type == EntranceType::kPainting && |
89 | !AP_IsPaintingShuffle()) { | 89 | AP_IsPaintingShuffle()) { |
90 | new_boundary.push_back(out_edge); | 90 | continue; |
91 | } | 91 | } |
92 | |||
93 | if (out_edge.type == EntranceType::kSunwarp && | ||
94 | AP_IsSunwarpShuffle()) { | ||
95 | continue; | ||
96 | } | ||
97 | |||
98 | new_boundary.push_back(out_edge); | ||
92 | } | 99 | } |
93 | 100 | ||
94 | if (AP_IsPaintingShuffle()) { | 101 | if (AP_IsPaintingShuffle()) { |
@@ -104,6 +111,21 @@ class StateCalculator { | |||
104 | } | 111 | } |
105 | } | 112 | } |
106 | 113 | ||
114 | if (AP_IsSunwarpShuffle()) { | ||
115 | for (int index : room_obj.sunwarps) { | ||
116 | if (AP_GetSunwarpMapping().count(index)) { | ||
117 | const SunwarpMapping& sm = AP_GetSunwarpMapping().at(index); | ||
118 | |||
119 | Exit sunwarp_exit; | ||
120 | sunwarp_exit.destination_room = | ||
121 | GD_GetRoomForSunwarp(sm.exit_index); | ||
122 | sunwarp_exit.door = GD_GetSunwarpDoors().at(sm.dots - 1); | ||
123 | |||
124 | new_boundary.push_back(sunwarp_exit); | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | |||
107 | if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { | 129 | if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { |
108 | new_boundary.push_back( | 130 | new_boundary.push_back( |
109 | {.destination_room = GD_GetRoomByName("Outside The Undeterred"), | 131 | {.destination_room = GD_GetRoomByName("Outside The Undeterred"), |
@@ -139,12 +161,14 @@ class StateCalculator { | |||
139 | 161 | ||
140 | const std::set<int>& GetReachableRooms() const { return reachable_rooms_; } | 162 | const std::set<int>& GetReachableRooms() const { return reachable_rooms_; } |
141 | 163 | ||
142 | const std::map<int, Decision>& GetDoorDecisions() const { return door_decisions_; } | 164 | const std::map<int, Decision>& GetDoorDecisions() const { |
165 | return door_decisions_; | ||
166 | } | ||
143 | 167 | ||
144 | const std::set<int>& GetSolveablePanels() const { return solveable_panels_; } | 168 | const std::set<int>& GetSolveablePanels() const { return solveable_panels_; } |
145 | 169 | ||
146 | private: | 170 | private: |
147 | Decision IsNonGroupedDoorReachable(const Door& door_obj) { | 171 | Decision IsNonGroupedDoorReachable(const Door& door_obj) { |
148 | bool has_item = AP_HasItem(door_obj.ap_item_id); | 172 | bool has_item = AP_HasItem(door_obj.ap_item_id); |
149 | 173 | ||
150 | if (!has_item) { | 174 | if (!has_item) { |
@@ -209,7 +233,7 @@ class StateCalculator { | |||
209 | if (result != kMaybe) { | 233 | if (result != kMaybe) { |
210 | door_decisions_[door_id] = result; | 234 | door_decisions_[door_id] = result; |
211 | } | 235 | } |
212 | 236 | ||
213 | return result; | 237 | return result; |
214 | } | 238 | } |
215 | 239 | ||