mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use unique_ptr for fios company properties.
This is the data used to show company names in the saveload window.pull/10839/head
parent
bf8f24f9a8
commit
91e140c722
|
@ -25,7 +25,7 @@ enum SaveLoadInvalidateWindowData {
|
||||||
SLIWD_FILTER_CHANGES, ///< The filename filter has changed (via the editbox)
|
SLIWD_FILTER_CHANGES, ///< The filename filter has changed (via the editbox)
|
||||||
};
|
};
|
||||||
|
|
||||||
using CompanyPropertiesMap = std::map<uint, CompanyProperties *>;
|
using CompanyPropertiesMap = std::map<uint, std::unique_ptr<CompanyProperties>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for loading in mode SL_LOAD_CHECK.
|
* Container for loading in mode SL_LOAD_CHECK.
|
||||||
|
|
|
@ -55,9 +55,6 @@ void LoadCheckData::Clear()
|
||||||
this->current_date = 0;
|
this->current_date = 0;
|
||||||
this->settings = {};
|
this->settings = {};
|
||||||
|
|
||||||
for (auto &pair : this->companies) {
|
|
||||||
delete pair.second;
|
|
||||||
}
|
|
||||||
companies.clear();
|
companies.clear();
|
||||||
|
|
||||||
this->gamelog.Reset();
|
this->gamelog.Reset();
|
||||||
|
|
|
@ -527,8 +527,8 @@ struct PLYRChunkHandler : ChunkHandler {
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
while ((index = SlIterateArray()) != -1) {
|
while ((index = SlIterateArray()) != -1) {
|
||||||
CompanyProperties *cprops = new CompanyProperties();
|
std::unique_ptr<CompanyProperties> cprops = std::make_unique<CompanyProperties>();
|
||||||
SlObject(cprops, slt);
|
SlObject(cprops.get(), slt);
|
||||||
|
|
||||||
/* We do not load old custom names */
|
/* We do not load old custom names */
|
||||||
if (IsSavegameVersionBefore(SLV_84)) {
|
if (IsSavegameVersionBefore(SLV_84)) {
|
||||||
|
@ -549,9 +549,7 @@ struct PLYRChunkHandler : ChunkHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_load_check_data.companies.count(index) == 0) {
|
if (_load_check_data.companies.count(index) == 0) {
|
||||||
_load_check_data.companies[index] = cprops;
|
_load_check_data.companies[index] = std::move(cprops);
|
||||||
} else {
|
|
||||||
delete cprops;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue