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

fix: sonar issues #76

Merged
merged 5 commits into from
Jun 7, 2024
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
4 changes: 2 additions & 2 deletions source/actions_history_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ ActionsHistoryWindow::ActionsHistoryWindow(wxWindow* parent) :
Layout();

// Connect Events
list->Connect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(ActionsHistoryWindow::OnListSelected), NULL, this);
list->Connect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(ActionsHistoryWindow::OnListSelected), nullptr, this);
}

ActionsHistoryWindow::~ActionsHistoryWindow() {
// Disconnect Events
list->Disconnect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(ActionsHistoryWindow::OnListSelected), NULL, this);
list->Disconnect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(ActionsHistoryWindow::OnListSelected), nullptr, this);
}

void ActionsHistoryWindow::RefreshActions() {
Expand Down
4 changes: 2 additions & 2 deletions source/browse_tile_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ BrowseTileWindow::BrowseTileWindow(wxWindow* parent, Tile* tile, wxPoint positio
SetSizerAndFit(sizer);

// Connect Events
item_list->Connect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(BrowseTileWindow::OnItemSelected), NULL, this);
item_list->Connect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(BrowseTileWindow::OnItemSelected), nullptr, this);
}

BrowseTileWindow::~BrowseTileWindow() {
// Disconnect Events
item_list->Disconnect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(BrowseTileWindow::OnItemSelected), NULL, this);
item_list->Disconnect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(BrowseTileWindow::OnItemSelected), nullptr, this);
}

void BrowseTileWindow::OnItemSelected(wxCommandEvent &WXUNUSED(event)) {
Expand Down
4 changes: 2 additions & 2 deletions source/carpet_brush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ bool CarpetBrush::load(pugi::xml_node node, wxArrayString &warnings) {

int32_t chance = attribute.as_int();

ItemType* type = g_items.getRawItemType(id);
auto type = g_items.getRawItemType(id);
if (!type) {
warnings.push_back("There is no itemtype with id " + std::to_string(id));
continue;
Expand Down Expand Up @@ -117,7 +117,7 @@ bool CarpetBrush::load(pugi::xml_node node, wxArrayString &warnings) {
}

uint16_t id = attribute.as_uint();
ItemType* type = g_items.getRawItemType(id);
auto type = g_items.getRawItemType(id);
if (!type) {
warnings.push_back("There is no itemtype with id " + std::to_string(id));
return false;
Expand Down
4 changes: 2 additions & 2 deletions source/doodad_brush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bool DoodadBrush::loadAlternative(pugi::xml_node node, wxArrayString &warnings,
continue;
}

ItemType* type = g_items.getRawItemType(item->getID());
auto type = g_items.getRawItemType(item->getID());
if (type) {
type->doodad_brush = this;
}
Expand Down Expand Up @@ -147,7 +147,7 @@ bool DoodadBrush::loadAlternative(pugi::xml_node node, wxArrayString &warnings,
if (item) {
items.push_back(item);

ItemType* type = g_items.getRawItemType(item->getID());
auto type = g_items.getRawItemType(item->getID());
if (type) {
type->doodad_brush = this;
}
Expand Down
96 changes: 48 additions & 48 deletions source/find_item_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,58 +172,58 @@ FindItemDialog::FindItemDialog(wxWindow* parent, const wxString &title, bool onl
this->RefreshContentsInternal();

// Connect Events
options_radio_box->Connect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(FindItemDialog::OnOptionChange), NULL, this);
server_id_spin->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler(FindItemDialog::OnServerIdChange), NULL, this);
server_id_spin->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnServerIdChange), NULL, this);
client_id_spin->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler(FindItemDialog::OnClientIdChange), NULL, this);
client_id_spin->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnClientIdChange), NULL, this);
name_text_input->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnText), NULL, this);

types_radio_box->Connect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(FindItemDialog::OnTypeChange), NULL, this);

unpassable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
unmovable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
block_missiles->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
block_pathfinder->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
readable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
writeable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
pickupable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
stackable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
rotatable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
hangable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
hook_east->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
hook_south->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
has_elevation->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
ignore_look->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
floor_change->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
options_radio_box->Connect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(FindItemDialog::OnOptionChange), nullptr, this);
server_id_spin->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler(FindItemDialog::OnServerIdChange), nullptr, this);
server_id_spin->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnServerIdChange), nullptr, this);
client_id_spin->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler(FindItemDialog::OnClientIdChange), nullptr, this);
client_id_spin->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnClientIdChange), nullptr, this);
name_text_input->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnText), nullptr, this);

types_radio_box->Connect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(FindItemDialog::OnTypeChange), nullptr, this);

unpassable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
unmovable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
block_missiles->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
block_pathfinder->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
readable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
writeable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
pickupable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
stackable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
rotatable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
hangable->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
hook_east->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
hook_south->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
has_elevation->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
ignore_look->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
floor_change->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
}

FindItemDialog::~FindItemDialog() {
// Disconnect Events
options_radio_box->Disconnect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(FindItemDialog::OnOptionChange), NULL, this);
server_id_spin->Disconnect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler(FindItemDialog::OnServerIdChange), NULL, this);
server_id_spin->Disconnect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnServerIdChange), NULL, this);
client_id_spin->Disconnect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler(FindItemDialog::OnClientIdChange), NULL, this);
client_id_spin->Disconnect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnClientIdChange), NULL, this);
name_text_input->Disconnect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnText), NULL, this);

types_radio_box->Disconnect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(FindItemDialog::OnTypeChange), NULL, this);

unpassable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
unmovable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
block_missiles->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
block_pathfinder->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
readable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
writeable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
pickupable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
stackable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
rotatable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
hangable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
hook_east->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
hook_south->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
has_elevation->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
ignore_look->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
floor_change->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), NULL, this);
options_radio_box->Disconnect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(FindItemDialog::OnOptionChange), nullptr, this);
server_id_spin->Disconnect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler(FindItemDialog::OnServerIdChange), nullptr, this);
server_id_spin->Disconnect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnServerIdChange), nullptr, this);
client_id_spin->Disconnect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler(FindItemDialog::OnClientIdChange), nullptr, this);
client_id_spin->Disconnect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnClientIdChange), nullptr, this);
name_text_input->Disconnect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(FindItemDialog::OnText), nullptr, this);

types_radio_box->Disconnect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(FindItemDialog::OnTypeChange), nullptr, this);

unpassable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
unmovable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
block_missiles->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
block_pathfinder->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
readable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
writeable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
pickupable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
stackable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
rotatable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
hangable->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
hook_east->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
hook_south->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
has_elevation->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
ignore_look->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
floor_change->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FindItemDialog::OnPropertyChange), nullptr, this);
}

FindItemDialog::SearchMode FindItemDialog::getSearchMode() const {
Expand Down
25 changes: 12 additions & 13 deletions source/ground_brush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ bool AutoBorder::load(pugi::xml_node node, wxArrayString &warnings, GroundBrush*

const std::string &orientation = attribute.as_string();

ItemType* type = g_items.getRawItemType(itemid);
auto type = g_items.getRawItemType(itemid);
if (!type) {
warnings.push_back("Invalid item ID " + std::to_string(itemid) + " for border " + std::to_string(id));
continue;
Expand All @@ -91,7 +91,7 @@ bool AutoBorder::load(pugi::xml_node node, wxArrayString &warnings, GroundBrush*
type->ground_equivalent = ground_equivalent;
type->brush = owner;

ItemType* type2 = g_items.getRawItemType(ground_equivalent);
auto type2 = g_items.getRawItemType(ground_equivalent);
type2->has_equivalent = type2->id != 0;
}

Expand Down Expand Up @@ -166,7 +166,7 @@ bool GroundBrush::load(pugi::xml_node node, wxArrayString &warnings) {
uint16_t itemId = childNode.attribute("id").as_uint();
int32_t chance = childNode.attribute("chance").as_int();

ItemType* type = g_items.getRawItemType(itemId);
auto type = g_items.getRawItemType(itemId);
if (!type) {
warnings.push_back("\nInvalid item id " + std::to_string(itemId));
return false;
Expand Down Expand Up @@ -325,7 +325,7 @@ bool GroundBrush::load(pugi::xml_node node, wxArrayString &warnings) {
continue;
}

SpecificCaseBlock* specificCaseBlock = nullptr;
auto specificCaseBlock = std::make_unique<SpecificCaseBlock>();
for (pugi::xml_node superChildNode = subChildNode.first_child(); superChildNode; superChildNode = superChildNode.next_sibling()) {
const std::string &superChildName = as_lower_str(superChildNode.name());
if (superChildName == "conditions") {
Expand Down Expand Up @@ -353,7 +353,7 @@ bool GroundBrush::load(pugi::xml_node node, wxArrayString &warnings) {

uint32_t match_itemid = autoBorder->tiles[edge_id];
if (!specificCaseBlock) {
specificCaseBlock = newd SpecificCaseBlock();
specificCaseBlock = std::make_unique<SpecificCaseBlock>();
}
specificCaseBlock->items_to_match.push_back(match_itemid);
} else if (conditionName == "match_group") {
Expand All @@ -368,7 +368,7 @@ bool GroundBrush::load(pugi::xml_node node, wxArrayString &warnings) {

int32_t edge_id = AutoBorder::edgeNameToID(attribute.as_string());
if (!specificCaseBlock) {
specificCaseBlock = newd SpecificCaseBlock();
specificCaseBlock = std::make_unique<SpecificCaseBlock>();
}

specificCaseBlock->match_group = group;
Expand All @@ -381,7 +381,7 @@ bool GroundBrush::load(pugi::xml_node node, wxArrayString &warnings) {

int32_t match_itemid = attribute.as_int();
if (!specificCaseBlock) {
specificCaseBlock = newd SpecificCaseBlock();
specificCaseBlock = std::make_unique<SpecificCaseBlock>();
}

specificCaseBlock->match_group = 0;
Expand Down Expand Up @@ -416,14 +416,14 @@ bool GroundBrush::load(pugi::xml_node node, wxArrayString &warnings) {
AutoBorder* autoBorder = itt->second;
ASSERT(autoBorder != nullptr);

ItemType* type = g_items.getRawItemType(with_id);
auto type = g_items.getRawItemType(with_id);
if (!type) {
return false;
}

type->isBorder = true;
if (!specificCaseBlock) {
specificCaseBlock = newd SpecificCaseBlock();
specificCaseBlock = std::make_unique<SpecificCaseBlock>();
}

specificCaseBlock->to_replace_id = autoBorder->tiles[edge_id];
Expand All @@ -439,22 +439,21 @@ bool GroundBrush::load(pugi::xml_node node, wxArrayString &warnings) {
}

int32_t with_id = attribute.as_int();
ItemType* type = g_items.getRawItemType(with_id);
auto type = g_items.getRawItemType(with_id);
if (!type) {
return false;
delete specificCaseBlock;
}

type->isBorder = true;
if (!specificCaseBlock) {
specificCaseBlock = newd SpecificCaseBlock();
specificCaseBlock = std::make_unique<SpecificCaseBlock>();
}

specificCaseBlock->to_replace_id = to_replace_id;
specificCaseBlock->with_id = with_id;
} else if (actionName == "delete_borders") {
if (!specificCaseBlock) {
specificCaseBlock = newd SpecificCaseBlock();
specificCaseBlock = std::make_unique<SpecificCaseBlock>();
}
specificCaseBlock->delete_all = true;
}
Expand Down
27 changes: 14 additions & 13 deletions source/iomap_otbm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,22 +1155,23 @@ bool IOMapOTBM::loadHouses(Map &map, pugi::xml_document &doc) {
}

House* house = nullptr;
if ((attribute = houseNode.attribute("houseid"))) {
house = map.houses.getHouse(attribute.as_uint());
if (!house) {
break;
}
const auto houseIdAttribute = houseNode.attribute("houseid");
if (!houseIdAttribute) {
warnings.push_back(fmt::format("IOMapOTBM::loadHouses: Could not load house, missing 'houseid' attribute."));
continue;
}

if (house != nullptr) {
if ((attribute = houseNode.attribute("name"))) {
house->name = attribute.as_string();
} else {
house->name = "House #" + std::to_string(house->id);
}
house = map.houses.getHouse(houseIdAttribute.as_uint());

if (!house) {
warnings.push_back(fmt::format("IOMapOTBM::loadHouses: Could not load house #{}", houseIdAttribute.as_uint()));
continue;
}

if ((attribute = houseNode.attribute("name"))) {
house->name = attribute.as_string();
} else {
// Tratar o erro: house é nullptr.
// Você pode lançar uma exceção, retornar um código de erro, ou registrar um aviso, por exemplo.
house->name = "House #" + std::to_string(house->id);
}

Position exitPosition(
Expand Down
Loading
Loading