1
0
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:
Peter Nelson
2025-03-23 23:29:33 +00:00
committed by Peter Nelson
parent 7f3820fa7e
commit 422ff9dbd8
12 changed files with 86 additions and 73 deletions

View File

@@ -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;
}