Codechange: use std::optional<std::string> for changing the script over char *

This commit is contained in:
Rubidium
2023-05-05 21:59:50 +02:00
committed by rubidium42
parent 0fd9eb0faa
commit 9f2fc860ad
9 changed files with 25 additions and 21 deletions

View File

@@ -869,7 +869,7 @@ static void AILoadConfig(IniFile &ini, const char *grpname)
/* Clean any configured AI */
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
AIConfig::GetConfig(c, AIConfig::SSS_FORCE_NEWGAME)->Change(nullptr);
AIConfig::GetConfig(c, AIConfig::SSS_FORCE_NEWGAME)->Change(std::nullopt);
}
/* If no group exists, return */
@@ -879,7 +879,7 @@ static void AILoadConfig(IniFile &ini, const char *grpname)
for (item = group->item; c < MAX_COMPANIES && item != nullptr; c++, item = item->next) {
AIConfig *config = AIConfig::GetConfig(c, AIConfig::SSS_FORCE_NEWGAME);
config->Change(item->name.c_str());
config->Change(item->name);
if (!config->HasScript()) {
if (item->name != "none") {
Debug(script, 0, "The AI by the name '{}' was no longer found, and removed from the list.", item->name);
@@ -896,7 +896,7 @@ static void GameLoadConfig(IniFile &ini, const char *grpname)
IniItem *item;
/* Clean any configured GameScript */
GameConfig::GetConfig(GameConfig::SSS_FORCE_NEWGAME)->Change(nullptr);
GameConfig::GetConfig(GameConfig::SSS_FORCE_NEWGAME)->Change(std::nullopt);
/* If no group exists, return */
if (group == nullptr) return;
@@ -906,7 +906,7 @@ static void GameLoadConfig(IniFile &ini, const char *grpname)
GameConfig *config = GameConfig::GetConfig(AIConfig::SSS_FORCE_NEWGAME);
config->Change(item->name.c_str());
config->Change(item->name);
if (!config->HasScript()) {
if (item->name != "none") {
Debug(script, 0, "The GameScript by the name '{}' was no longer found, and removed from the list.", item->name);