about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/game_data.cpp3
-rw-r--r--src/game_data.h1
-rw-r--r--src/tracker_state.cpp35
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 {
109 auto process_single_entrance = 109 auto process_single_entrance =
110 [this, room_id, from_room_id](const YAML::Node &option) { 110 [this, room_id, from_room_id](const YAML::Node &option) {
111 Exit exit_obj; 111 Exit exit_obj;
112 exit_obj.source_room = from_room_id;
112 exit_obj.destination_room = room_id; 113 exit_obj.destination_room = room_id;
113 114
114 if (option["door"]) { 115 if (option["door"]) {
@@ -143,7 +144,7 @@ struct GameData {
143 switch (entrance_it.second.Type()) { 144 switch (entrance_it.second.Type()) {
144 case YAML::NodeType::Scalar: { 145 case YAML::NodeType::Scalar: {
145 // This is just "true". 146 // This is just "true".
146 rooms_[from_room_id].exits.push_back({.destination_room = room_id}); 147 rooms_[from_room_id].exits.push_back({.source_room = from_room_id, .destination_room = room_id});
147 break; 148 break;
148 } 149 }
149 case YAML::NodeType::Map: { 150 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 {
83}; 83};
84 84
85struct Exit { 85struct Exit {
86 int source_room;
86 int destination_room; 87 int destination_room;
87 std::optional<int> door; 88 std::optional<int> door;
88 EntranceType type = EntranceType::kNormal; 89 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 @@
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
13namespace { 17namespace {
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