diff options
Diffstat (limited to 'src/tracker_state.cpp')
-rw-r--r-- | src/tracker_state.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index da8f426..ba615d1 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 | ||
@@ -217,6 +221,7 @@ class StateCalculator { | |||
217 | PaintingExit target_painting = | 221 | PaintingExit target_painting = |
218 | GD_GetPaintingExit(GD_GetPaintingByName( | 222 | GD_GetPaintingExit(GD_GetPaintingByName( |
219 | AP_GetPaintingMapping().at(cur_painting.internal_id))); | 223 | AP_GetPaintingMapping().at(cur_painting.internal_id))); |
224 | painting_exit.source_room = cur_painting.room; | ||
220 | painting_exit.destination_room = target_painting.room; | 225 | painting_exit.destination_room = target_painting.room; |
221 | painting_exit.type = EntranceType::kPainting; | 226 | painting_exit.type = EntranceType::kPainting; |
222 | 227 | ||
@@ -245,6 +250,12 @@ class StateCalculator { | |||
245 | reachable_rooms_.insert(room_exit.destination_room); | 250 | reachable_rooms_.insert(room_exit.destination_room); |
246 | reachable_changed = true; | 251 | reachable_changed = true; |
247 | 252 | ||
253 | #ifndef NDEBUG | ||
254 | std::list<int> room_path = paths_[room_exit.source_room]; | ||
255 | room_path.push_back(room_exit.destination_room); | ||
256 | paths_[room_exit.destination_room] = room_path; | ||
257 | #endif | ||
258 | |||
248 | const Room& room_obj = GD_GetRoom(room_exit.destination_room); | 259 | const Room& room_obj = GD_GetRoom(room_exit.destination_room); |
249 | for (const Exit& out_edge : room_obj.exits) { | 260 | for (const Exit& out_edge : room_obj.exits) { |
250 | if (out_edge.type == EntranceType::kPainting && | 261 | if (out_edge.type == EntranceType::kPainting && |
@@ -283,7 +294,8 @@ class StateCalculator { | |||
283 | 294 | ||
284 | if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { | 295 | if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { |
285 | new_boundary.push_back( | 296 | new_boundary.push_back( |
286 | {.destination_room = GD_GetRoomByName("Outside The Undeterred"), | 297 | {.source_room = room_exit.destination_room, |
298 | .destination_room = GD_GetRoomByName("Outside The Undeterred"), | ||
287 | .type = EntranceType::kPainting}); | 299 | .type = EntranceType::kPainting}); |
288 | } | 300 | } |
289 | 301 | ||
@@ -300,13 +312,15 @@ class StateCalculator { | |||
300 | 312 | ||
301 | if (room_exit.destination_room == pilgrimage_start_id) { | 313 | if (room_exit.destination_room == pilgrimage_start_id) { |
302 | new_boundary.push_back( | 314 | new_boundary.push_back( |
303 | {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), | 315 | {.source_room = room_exit.destination_room, |
316 | .destination_room = GD_GetRoomByName("Pilgrim Antechamber"), | ||
304 | .type = EntranceType::kPilgrimage}); | 317 | .type = EntranceType::kPilgrimage}); |
305 | } | 318 | } |
306 | } else { | 319 | } else { |
307 | if (room_obj.name == "Starting Room") { | 320 | if (room_obj.name == "Starting Room") { |
308 | new_boundary.push_back( | 321 | new_boundary.push_back( |
309 | {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), | 322 | {.source_room = room_exit.destination_room, |
323 | .destination_room = GD_GetRoomByName("Pilgrim Antechamber"), | ||
310 | .door = | 324 | .door = |
311 | GD_GetDoorByName("Pilgrim Antechamber - Sun Painting"), | 325 | GD_GetDoorByName("Pilgrim Antechamber - Sun Painting"), |
312 | .type = EntranceType::kPainting}); | 326 | .type = EntranceType::kPainting}); |
@@ -347,6 +361,19 @@ class StateCalculator { | |||
347 | return door_report_; | 361 | return door_report_; |
348 | } | 362 | } |
349 | 363 | ||
364 | std::string GetPathToRoom(int room_id) const { | ||
365 | if (!paths_.count(room_id)) { | ||
366 | return ""; | ||
367 | } | ||
368 | |||
369 | const std::list<int>& path = paths_.at(room_id); | ||
370 | std::vector<std::string> room_names; | ||
371 | for (int room_id : path) { | ||
372 | room_names.push_back(GD_GetRoom(room_id).name); | ||
373 | } | ||
374 | return hatkirby::implode(room_names, " -> "); | ||
375 | } | ||
376 | |||
350 | private: | 377 | private: |
351 | Decision IsNonGroupedDoorReachable(const Door& door_obj) { | 378 | Decision IsNonGroupedDoorReachable(const Door& door_obj) { |
352 | bool has_item = AP_HasItem(door_obj.ap_item_id); | 379 | bool has_item = AP_HasItem(door_obj.ap_item_id); |
@@ -585,6 +612,8 @@ class StateCalculator { | |||
585 | std::set<int> solveable_panels_; | 612 | std::set<int> solveable_panels_; |
586 | std::set<int> reachable_paintings_; | 613 | std::set<int> reachable_paintings_; |
587 | std::map<int, std::map<std::string, bool>> door_report_; | 614 | std::map<int, std::map<std::string, bool>> door_report_; |
615 | |||
616 | std::map<int, std::list<int>> paths_; | ||
588 | }; | 617 | }; |
589 | 618 | ||
590 | } // namespace | 619 | } // namespace |