From 52bc9fdf99d452c592e174acd9cb174ec00e19d7 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Jul 2024 00:47:11 -0400 Subject: Added path tracking for debugging --- src/game_data.cpp | 3 ++- src/game_data.h | 1 + src/tracker_state.cpp | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/game_data.cpp b/src/game_data.cpp index e75170e..4c0104f 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -109,6 +109,7 @@ struct GameData { auto process_single_entrance = [this, room_id, from_room_id](const YAML::Node &option) { Exit exit_obj; + exit_obj.source_room = from_room_id; exit_obj.destination_room = room_id; if (option["door"]) { @@ -143,7 +144,7 @@ struct GameData { switch (entrance_it.second.Type()) { case YAML::NodeType::Scalar: { // This is just "true". - rooms_[from_room_id].exits.push_back({.destination_room = room_id}); + rooms_[from_room_id].exits.push_back({.source_room = from_room_id, .destination_room = room_id}); break; } case YAML::NodeType::Map: { diff --git a/src/game_data.h b/src/game_data.h index b787e6f..23f7b3a 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -83,6 +83,7 @@ struct Door { }; struct Exit { + int source_room; int destination_room; std::optional door; EntranceType type = EntranceType::kNormal; 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 @@ #include "tracker_state.h" +#include +#include + #include #include #include @@ -9,6 +12,7 @@ #include "ap_state.h" #include "game_data.h" +#include "logger.h" namespace { @@ -217,6 +221,7 @@ class StateCalculator { PaintingExit target_painting = GD_GetPaintingExit(GD_GetPaintingByName( AP_GetPaintingMapping().at(cur_painting.internal_id))); + painting_exit.source_room = cur_painting.room; painting_exit.destination_room = target_painting.room; painting_exit.type = EntranceType::kPainting; @@ -245,6 +250,12 @@ class StateCalculator { reachable_rooms_.insert(room_exit.destination_room); reachable_changed = true; +#ifndef NDEBUG + std::list room_path = paths_[room_exit.source_room]; + room_path.push_back(room_exit.destination_room); + paths_[room_exit.destination_room] = room_path; +#endif + const Room& room_obj = GD_GetRoom(room_exit.destination_room); for (const Exit& out_edge : room_obj.exits) { if (out_edge.type == EntranceType::kPainting && @@ -283,7 +294,8 @@ class StateCalculator { if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { new_boundary.push_back( - {.destination_room = GD_GetRoomByName("Outside The Undeterred"), + {.source_room = room_exit.destination_room, + .destination_room = GD_GetRoomByName("Outside The Undeterred"), .type = EntranceType::kPainting}); } @@ -300,13 +312,15 @@ class StateCalculator { if (room_exit.destination_room == pilgrimage_start_id) { new_boundary.push_back( - {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), + {.source_room = room_exit.destination_room, + .destination_room = GD_GetRoomByName("Pilgrim Antechamber"), .type = EntranceType::kPilgrimage}); } } else { if (room_obj.name == "Starting Room") { new_boundary.push_back( - {.destination_room = GD_GetRoomByName("Pilgrim Antechamber"), + {.source_room = room_exit.destination_room, + .destination_room = GD_GetRoomByName("Pilgrim Antechamber"), .door = GD_GetDoorByName("Pilgrim Antechamber - Sun Painting"), .type = EntranceType::kPainting}); @@ -347,6 +361,19 @@ class StateCalculator { return door_report_; } + std::string GetPathToRoom(int room_id) const { + if (!paths_.count(room_id)) { + return ""; + } + + const std::list& path = paths_.at(room_id); + std::vector room_names; + for (int room_id : path) { + room_names.push_back(GD_GetRoom(room_id).name); + } + return hatkirby::implode(room_names, " -> "); + } + private: Decision IsNonGroupedDoorReachable(const Door& door_obj) { bool has_item = AP_HasItem(door_obj.ap_item_id); @@ -585,6 +612,8 @@ class StateCalculator { std::set solveable_panels_; std::set reachable_paintings_; std::map> door_report_; + + std::map> paths_; }; } // namespace -- cgit 1.4.1