Skip to content

Commit

Permalink
feat: add complement 'beds' option for houses (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luan Luciano authored Oct 7, 2023
1 parent 1b93e6f commit c0b839e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/house.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ std::string House::getDescription()
{
std::ostringstream os;
os << name;
os << " (ID:" << id << "; Rent: " << rent << ")";
os << " (ID:" << id << "; Rent: " << rent << "; Max Beds: " << beds << ")";
return os.str();
}

Expand Down
8 changes: 8 additions & 0 deletions source/iomap_otmm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,16 @@ bool IOMapOTMM::loadMap(Map& map, NodeFileReadHandle& f, const FileName& identif
continue;
}

uint32_t beds;
if(!houseNode->getU32(beds)) {
warning("Could not read house max beds.");
continue;
}

house->name = house_name;
house->townid = town_id;
house->rent = rent;
house->beds = beds;

uint16_t x;
uint16_t y;
Expand Down Expand Up @@ -1097,6 +1104,7 @@ bool IOMapOTMM::saveMap(Map& map, NodeFileWriteHandle& f, const FileName& identi
f.addString(house->name);
f.addU16(house->townid);
f.addU16(house->rent);
f.addU16(house->beds);
f.addU16(house->getExit().x);
f.addU16(house->getExit().y);
f.addU8(house->getExit().z & 0xf);
Expand Down
11 changes: 8 additions & 3 deletions source/palette_house.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,17 +521,22 @@ void EditHouseDialog::OnClickOK(wxCommandEvent& WXUNUSED(event))
long new_house_rent;
house_rent.ToLong(&new_house_rent);

long new_house_clientid;
house_clientid.ToLong(&new_house_clientid);

long new_house_beds;
house_beds.ToLong(&new_house_beds);

long new_house_clientid;
house_clientid.ToLong(&new_house_clientid);

if(new_house_rent < 0) {
g_gui.PopupDialog(this, "Error", "House rent cannot be less than 0.", wxOK);
return;
}

if(new_house_beds < 0) {
g_gui.PopupDialog(this, "Error", "House beds cannot be less than 0.", wxOK);
return;
}

if(house_name.length() == 0) {
g_gui.PopupDialog(this, "Error", "House name cannot be nil.", wxOK);
return;
Expand Down

0 comments on commit c0b839e

Please sign in to comment.