diff --git a/src/fios.h b/src/fios.h index 58c7844a32..70986135a2 100644 --- a/src/fios.h +++ b/src/fios.h @@ -25,7 +25,7 @@ enum SaveLoadInvalidateWindowData { SLIWD_FILTER_CHANGES, ///< The filename filter has changed (via the editbox) }; -using CompanyPropertiesMap = std::map; +using CompanyPropertiesMap = std::map>; /** * Container for loading in mode SL_LOAD_CHECK. diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 07e55384d7..7d0e8fe556 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -55,9 +55,6 @@ void LoadCheckData::Clear() this->current_date = 0; this->settings = {}; - for (auto &pair : this->companies) { - delete pair.second; - } companies.clear(); this->gamelog.Reset(); diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index 8457820d2e..0a474ae839 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -527,8 +527,8 @@ struct PLYRChunkHandler : ChunkHandler { int index; while ((index = SlIterateArray()) != -1) { - CompanyProperties *cprops = new CompanyProperties(); - SlObject(cprops, slt); + std::unique_ptr cprops = std::make_unique(); + SlObject(cprops.get(), slt); /* We do not load old custom names */ if (IsSavegameVersionBefore(SLV_84)) { @@ -549,9 +549,7 @@ struct PLYRChunkHandler : ChunkHandler { } if (_load_check_data.companies.count(index) == 0) { - _load_check_data.companies[index] = cprops; - } else { - delete cprops; + _load_check_data.companies[index] = std::move(cprops); } } }