Skip to content

Commit

Permalink
fix: go to house without exit
Browse files Browse the repository at this point in the history
  • Loading branch information
phacUFPE committed Aug 9, 2024
1 parent 639c26a commit 9554e77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions source/house.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 13 additions & 4 deletions source/palette_house.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,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 9554e77

Please sign in to comment.