Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add complement 'beds' option for houses. #45

Merged
merged 5 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading