From da7152ec94031c76732e997de4624c8f1c010225 Mon Sep 17 00:00:00 2001 From: wtver <51377408+maattch@users.noreply.github.com> Date: Sun, 5 May 2024 09:48:19 -0300 Subject: [PATCH] Go to house with no exit (#435) --- source/house.h | 2 ++ source/palette_house.cpp | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/source/house.h b/source/house.h index db202580..8ce495e0 100644 --- a/source/house.h +++ b/source/house.h @@ -50,6 +50,8 @@ 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 568f7f3f..a19684c1 100644 --- a/source/palette_house.cpp +++ b/source/palette_house.cpp @@ -333,10 +333,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); + } } }