Codechange: use std::optional<std::string> for changing the script over char *
This commit is contained in:
@@ -66,7 +66,7 @@ struct AIPLChunkHandler : ChunkHandler {
|
||||
|
||||
/* Free all current data */
|
||||
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
||||
AIConfig::GetConfig(c, AIConfig::SSS_FORCE_GAME)->Change(nullptr);
|
||||
AIConfig::GetConfig(c, AIConfig::SSS_FORCE_GAME)->Change(std::nullopt);
|
||||
}
|
||||
|
||||
CompanyID index;
|
||||
@@ -85,13 +85,13 @@ struct AIPLChunkHandler : ChunkHandler {
|
||||
AIConfig *config = AIConfig::GetConfig(index, AIConfig::SSS_FORCE_GAME);
|
||||
if (_ai_saveload_name.empty()) {
|
||||
/* A random AI. */
|
||||
config->Change(nullptr, -1, false, true);
|
||||
config->Change(std::nullopt, -1, false, true);
|
||||
} else {
|
||||
config->Change(_ai_saveload_name.c_str(), _ai_saveload_version, false, _ai_saveload_is_random);
|
||||
config->Change(_ai_saveload_name, _ai_saveload_version, false, _ai_saveload_is_random);
|
||||
if (!config->HasScript()) {
|
||||
/* No version of the AI available that can load the data. Try to load the
|
||||
* latest version of the AI instead. */
|
||||
config->Change(_ai_saveload_name.c_str(), -1, false, _ai_saveload_is_random);
|
||||
config->Change(_ai_saveload_name, -1, false, _ai_saveload_is_random);
|
||||
if (!config->HasScript()) {
|
||||
if (_ai_saveload_name.compare("%_dummy") != 0) {
|
||||
Debug(script, 0, "The savegame has an AI by the name '{}', version {} which is no longer available.", _ai_saveload_name, _ai_saveload_version);
|
||||
|
@@ -62,7 +62,7 @@ struct GSDTChunkHandler : ChunkHandler {
|
||||
const std::vector<SaveLoad> slt = SlCompatTableHeader(_game_script_desc, _game_script_sl_compat);
|
||||
|
||||
/* Free all current data */
|
||||
GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME)->Change(nullptr);
|
||||
GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME)->Change(std::nullopt);
|
||||
|
||||
if (SlIterateArray() == -1) return;
|
||||
|
||||
@@ -77,11 +77,11 @@ struct GSDTChunkHandler : ChunkHandler {
|
||||
|
||||
GameConfig *config = GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME);
|
||||
if (!_game_saveload_name.empty()) {
|
||||
config->Change(_game_saveload_name.c_str(), _game_saveload_version, false, _game_saveload_is_random);
|
||||
config->Change(_game_saveload_name, _game_saveload_version, false, _game_saveload_is_random);
|
||||
if (!config->HasScript()) {
|
||||
/* No version of the GameScript available that can load the data. Try to load the
|
||||
* latest version of the GameScript instead. */
|
||||
config->Change(_game_saveload_name.c_str(), -1, false, _game_saveload_is_random);
|
||||
config->Change(_game_saveload_name, -1, false, _game_saveload_is_random);
|
||||
if (!config->HasScript()) {
|
||||
if (_game_saveload_name.compare("%_dummy") != 0) {
|
||||
Debug(script, 0, "The savegame has an GameScript by the name '{}', version {} which is no longer available.", _game_saveload_name, _game_saveload_version);
|
||||
|
Reference in New Issue
Block a user