mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-18 01:42:38 +01:00
Codechange: Use std::unique_ptr for ai/game config.
This commit is contained in:
committed by
Peter Nelson
parent
7f3820fa7e
commit
422ff9dbd8
@@ -2009,3 +2009,31 @@ void IConsoleListSettings(const char *prefilter)
|
||||
|
||||
IConsolePrint(CC_HELP, "Use 'setting' command to change a value.");
|
||||
}
|
||||
|
||||
ScriptConfigSettings::ScriptConfigSettings()
|
||||
{
|
||||
/* Instantiate here, because unique_ptr needs a complete type. */
|
||||
}
|
||||
|
||||
ScriptConfigSettings::~ScriptConfigSettings()
|
||||
{
|
||||
/* Instantiate here, because unique_ptr needs a complete type. */
|
||||
}
|
||||
|
||||
ScriptConfigSettings::ScriptConfigSettings(const ScriptConfigSettings &other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
ScriptConfigSettings &ScriptConfigSettings::operator=(const ScriptConfigSettings &other)
|
||||
{
|
||||
for (CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
|
||||
if (other.ai[c] != nullptr) {
|
||||
this->ai[c] = std::make_unique<AIConfig>(*other.ai[c]);
|
||||
}
|
||||
}
|
||||
if (other.game != nullptr) {
|
||||
this->game = std::make_unique<GameConfig>(*other.game);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user