From 3b3c3ca4ed98c8d1e884f6c9f8f63d7b7c76e37b Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 10 Jun 2024 18:11:06 -0400 Subject: Fixed subway map when eye_painting is mapped --- src/game_data.cpp | 10 ++++------ src/game_data.h | 2 +- src/subway_map.cpp | 10 +++++++--- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/game_data.cpp b/src/game_data.cpp index 6f1a2e4..85f7f51 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -839,13 +839,11 @@ const SubwayItem &GD_GetSubwayItem(int id) { return GetState().subway_items_.at(id); } -int GD_GetSubwayItemForPainting(const std::string &painting_id) { -#ifndef NDEBUG - if (!GetState().subway_item_by_painting_.count(painting_id)) { - wxLogError("No subway item for painting %s", painting_id); +std::optional GD_GetSubwayItemForPainting(const std::string &painting_id) { + if (GetState().subway_item_by_painting_.count(painting_id)) { + return GetState().subway_item_by_painting_.at(painting_id); } -#endif - return GetState().subway_item_by_painting_.at(painting_id); + return std::nullopt; } int GD_GetSubwayItemForSunwarp(const SubwaySunwarp &sunwarp) { diff --git a/src/game_data.h b/src/game_data.h index e37c276..66f3e0e 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -164,7 +164,7 @@ const std::vector& GD_GetSunwarpDoors(); int GD_GetRoomForSunwarp(int index); const std::vector& GD_GetSubwayItems(); const SubwayItem& GD_GetSubwayItem(int id); -int GD_GetSubwayItemForPainting(const std::string& painting_id); +std::optional GD_GetSubwayItemForPainting(const std::string& painting_id); int GD_GetSubwayItemForSunwarp(const SubwaySunwarp& sunwarp); #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 408c4f0..5c99567 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp @@ -147,9 +147,13 @@ void SubwayMap::UpdateIndicators() { checked_paintings_.insert(painting_id); if (AP_GetPaintingMapping().count(painting_id)) { - networks_.AddLink(GD_GetSubwayItemForPainting(painting_id), - GD_GetSubwayItemForPainting( - AP_GetPaintingMapping().at(painting_id))); + std::optional from_id = GD_GetSubwayItemForPainting(painting_id); + std::optional to_id = GD_GetSubwayItemForPainting( + AP_GetPaintingMapping().at(painting_id)); + + if (from_id && to_id) { + networks_.AddLink(*from_id, *to_id); + } } } } -- cgit 1.4.1