Skip to content

Commit

Permalink
Go to house with no exit (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
maattch authored May 5, 2024
1 parent d32e045 commit da7152e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions source/house.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 13 additions & 4 deletions source/palette_house.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,19 @@ void HousePalettePanel::OnListBoxChange(wxCommandEvent& event)

void HousePalettePanel::OnListBoxDoubleClick(wxCommandEvent& event)
{
House* house = reinterpret_cast<House*>(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<House*>(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);
}
}
}

Expand Down

0 comments on commit da7152e

Please sign in to comment.