diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-07-16 15:17:21 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-07-16 15:17:21 -0400 |
commit | 558fcd9bf0852b5c909822c374f7e445b63026e5 (patch) | |
tree | f78d74f389c63f83da1878c9982de9a8e3343df0 /src/tracker_state.cpp | |
parent | 2944687cbbaa53d0815fea9f5f2506500e2e1db3 (diff) | |
parent | a40d5a90a4759ecb03fe4591878c011d3c8c07be (diff) | |
download | lingo-ap-tracker-558fcd9bf0852b5c909822c374f7e445b63026e5.tar.gz lingo-ap-tracker-558fcd9bf0852b5c909822c374f7e445b63026e5.tar.bz2 lingo-ap-tracker-558fcd9bf0852b5c909822c374f7e445b63026e5.zip |
Merge branch 'main' into panels
Diffstat (limited to 'src/tracker_state.cpp')
-rw-r--r-- | src/tracker_state.cpp | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index eaf3e6b..14d302b 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp | |||
@@ -1,5 +1,8 @@ | |||
1 | #include "tracker_state.h" | 1 | #include "tracker_state.h" |
2 | 2 | ||
3 | #include <fmt/core.h> | ||
4 | #include <hkutil/string.h> | ||
5 | |||
3 | #include <list> | 6 | #include <list> |
4 | #include <map> | 7 | #include <map> |
5 | #include <mutex> | 8 | #include <mutex> |
@@ -9,6 +12,7 @@ | |||
9 | 12 | ||
10 | #include "ap_state.h" | 13 | #include "ap_state.h" |
11 | #include "game_data.h" | 14 | #include "game_data.h" |
15 | #include "logger.h" | ||
12 | 16 | ||
13 | namespace { | 17 | namespace { |
14 | 18 | ||
@@ -231,7 +235,9 @@ class StateCalculator { | |||
231 | PaintingExit target_painting = | 235 | PaintingExit target_painting = |
232 | GD_GetPaintingExit(GD_GetPaintingByName( | 236 | GD_GetPaintingExit(GD_GetPaintingByName( |
233 | AP_GetPaintingMapping().at(cur_painting.internal_id))); | 237 | AP_GetPaintingMapping().at(cur_painting.internal_id))); |
238 | painting_exit.source_room = cur_painting.room; | ||
234 | painting_exit.destination_room = target_painting.room; | 239 | painting_exit.destination_room = target_painting.room; |
240 | painting_exit.type = EntranceType::kPainting; | ||
235 | 241 | ||
236 | new_boundary.push_back(painting_exit); | 242 | new_boundary.push_back(painting_exit); |
237 | } | 243 | } |
@@ -258,6 +264,12 @@ class StateCalculator { | |||
258 | reachable_rooms_.insert(room_exit.destination_room); | 264 | reachable_rooms_.insert(room_exit.destination_room); |
259 | reachable_changed = true; | 265 | reachable_changed = true; |
260 | 266 | ||
267 | #ifndef NDEBUG | ||
268 | std::list<int> room_path = paths_[room_exit.source_room]; | ||
269 | room_path.push_back(room_exit.destination_room); | ||
270 | paths_[room_exit.destination_room] = room_path; | ||
271 | #endif | ||
272 | |||
261 | const Room& room_obj = GD_GetRoom(room_exit.destination_room); | 273 | const Room& room_obj = GD_GetRoom(room_exit.destination_room); |
262 | for (const Exit& out_edge : room_obj.exits) { | 274 | for (const Exit& out_edge : room_obj.exits) { |
263 | if (out_edge.type == EntranceType::kPainting && | 275 | if (out_edge.type == EntranceType::kPainting && |
@@ -296,20 +308,33 @@ class StateCalculator { | |||
296 | 308 | ||
297 | if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { | 309 | if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { |
298 | new_boundary.push_back( | 310 | new_boundary.push_back( |
299 | {.destination_room = GD_GetRoomByName("Outside The Undeterred"), | 311 | {.source_room = room_exit.destination_room, |
312 | .destination_room = GD_GetRoomByName("Outside The Undeterred"), | ||
300 | .type = EntranceType::kPainting}); | 313 | .type = EntranceType::kPainting}); |
301 | } | 314 | } |
302 | 315 | ||
303 | if (AP_IsPilgrimageEnabled()) { | 316 | if (AP_IsPilgrimageEnabled()) { |
304 | if (room_obj.name == "Hub Room") { | 317 | int pilgrimage_start_id = GD_GetRoomByName("Hub Room"); |
318 | if (AP_IsSunwarpShuffle()) { | ||
319 | for (const auto& [start_index, mapping] : | ||
320 | AP_GetSunwarpMapping()) { | ||
321 | if (mapping.dots == 1) { | ||
322 | pilgrimage_start_id = GD_GetRoomForSunwarp(start_index); | ||
323 | } | ||
324 | } | ||
325 | } | ||
326 | |||
327 | if (room_exit.destination_room == pilgrimage_start_id) { | ||
305 | new_boundary.push_back( | 328 | new_boundary.push_back( |
306 | {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), | 329 | {.source_room = room_exit.destination_room, |
330 | .destination_room = GD_GetRoomByName("Pilgrim Antechamber"), | ||
307 | .type = EntranceType::kPilgrimage}); | 331 | .type = EntranceType::kPilgrimage}); |
308 | } | 332 | } |
309 | } else { | 333 | } else { |
310 | if (room_obj.name == "Starting Room") { | 334 | if (room_obj.name == "Starting Room") { |
311 | new_boundary.push_back( | 335 | new_boundary.push_back( |
312 | {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), | 336 | {.source_room = room_exit.destination_room, |
337 | .destination_room = GD_GetRoomByName("Pilgrim Antechamber"), | ||
313 | .door = | 338 | .door = |
314 | GD_GetDoorByName("Pilgrim Antechamber - Sun Painting"), | 339 | GD_GetDoorByName("Pilgrim Antechamber - Sun Painting"), |
315 | .type = EntranceType::kPainting}); | 340 | .type = EntranceType::kPainting}); |
@@ -350,6 +375,19 @@ class StateCalculator { | |||
350 | return door_report_; | 375 | return door_report_; |
351 | } | 376 | } |
352 | 377 | ||
378 | std::string GetPathToRoom(int room_id) const { | ||
379 | if (!paths_.count(room_id)) { | ||
380 | return ""; | ||
381 | } | ||
382 | |||
383 | const std::list<int>& path = paths_.at(room_id); | ||
384 | std::vector<std::string> room_names; | ||
385 | for (int room_id : path) { | ||
386 | room_names.push_back(GD_GetRoom(room_id).name); | ||
387 | } | ||
388 | return hatkirby::implode(room_names, " -> "); | ||
389 | } | ||
390 | |||
353 | private: | 391 | private: |
354 | template <typename T> | 392 | template <typename T> |
355 | Decision IsNonGroupedDoorReachable(const T& door_obj) { | 393 | Decision IsNonGroupedDoorReachable(const T& door_obj) { |
@@ -603,6 +641,8 @@ class StateCalculator { | |||
603 | std::set<int> solveable_panels_; | 641 | std::set<int> solveable_panels_; |
604 | std::set<int> reachable_paintings_; | 642 | std::set<int> reachable_paintings_; |
605 | std::map<int, std::map<std::string, bool>> door_report_; | 643 | std::map<int, std::map<std::string, bool>> door_report_; |
644 | |||
645 | std::map<int, std::list<int>> paths_; | ||
606 | }; | 646 | }; |
607 | 647 | ||
608 | } // namespace | 648 | } // namespace |