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); + } } }