From 9554e77cdc463e04777f7ac086f83b7b8f57a242 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Alves Cruz Date: Thu, 8 Aug 2024 23:16:51 -0300 Subject: [PATCH] fix: go to house without exit --- source/house.h | 4 ++++ source/palette_house.cpp | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/source/house.h b/source/house.h index 35664aec..027602eb 100644 --- a/source/house.h +++ b/source/house.h @@ -53,6 +53,10 @@ class House { uint8_t getEmptyDoorID() const; Position getDoorPositionByID(uint8_t id) const; + const PositionList &getTiles() const { + return tiles; + } + protected: Map* map; PositionList tiles; diff --git a/source/palette_house.cpp b/source/palette_house.cpp index 7eb5df85..d1521930 100644 --- a/source/palette_house.cpp +++ b/source/palette_house.cpp @@ -322,10 +322,19 @@ void HousePalettePanel::OnListBoxChange(wxCommandEvent &event) { } void HousePalettePanel::OnListBoxDoubleClick(wxCommandEvent &event) { - House* house = reinterpret_cast(event.GetClientData()); - // I find it extremly unlikely that one actually wants the exit at 0,0,0, so just treat it as the null value - if (house && house->getExit() != Position(0, 0, 0)) { - g_gui.SetScreenCenterPosition(house->getExit()); + if (House* house = reinterpret_cast(event.GetClientData())) { + const Position &position = house->getExit(); + if (!position.isValid()) { + // find a valid tile position + for (const Position &tilePosition : house->getTiles()) { + if (tilePosition.isValid()) { + g_gui.SetScreenCenterPosition(tilePosition); + break; + } + } + } else { + g_gui.SetScreenCenterPosition(position); + } } }