|
|
@ -214,23 +214,28 @@
|
|
|
|
if (!_settings_game.ai_config[c]->ResetInfo(true)) {
|
|
|
|
if (!_settings_game.ai_config[c]->ResetInfo(true)) {
|
|
|
|
Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
|
|
|
|
Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
|
|
|
|
_settings_game.ai_config[c]->Change(std::nullopt);
|
|
|
|
_settings_game.ai_config[c]->Change(std::nullopt);
|
|
|
|
if (Company::IsValidAiID(c)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_settings_newgame.ai_config[c] != nullptr && _settings_newgame.ai_config[c]->HasScript()) {
|
|
|
|
|
|
|
|
if (!_settings_newgame.ai_config[c]->ResetInfo(false)) {
|
|
|
|
|
|
|
|
Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
|
|
|
|
|
|
|
|
_settings_newgame.ai_config[c]->Change(std::nullopt);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Company::IsValidAiID(c) && Company::Get(c)->ai_config != nullptr) {
|
|
|
|
|
|
|
|
AIConfig *config = Company::Get(c)->ai_config.get();
|
|
|
|
|
|
|
|
if (!config->ResetInfo(true)) {
|
|
|
|
/* The code belonging to an already running AI was deleted. We can only do
|
|
|
|
/* The code belonging to an already running AI was deleted. We can only do
|
|
|
|
* one thing here to keep everything sane and that is kill the AI. After
|
|
|
|
* one thing here to keep everything sane and that is kill the AI. After
|
|
|
|
* killing the offending AI we start a random other one in it's place, just
|
|
|
|
* killing the offending AI we start a random other one in it's place, just
|
|
|
|
* like what would happen if the AI was missing during loading. */
|
|
|
|
* like what would happen if the AI was missing during loading. */
|
|
|
|
AI::Stop(c);
|
|
|
|
AI::Stop(c);
|
|
|
|
AI::StartNew(c);
|
|
|
|
AI::StartNew(c);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else if (Company::IsValidAiID(c)) {
|
|
|
|
|
|
|
|
/* Update the reference in the Company struct. */
|
|
|
|
/* Update the reference in the Company struct. */
|
|
|
|
Company::Get(c)->ai_info = _settings_game.ai_config[c]->GetInfo();
|
|
|
|
Company::Get(c)->ai_info = config->GetInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_settings_newgame.ai_config[c] != nullptr && _settings_newgame.ai_config[c]->HasScript()) {
|
|
|
|
|
|
|
|
if (!_settings_newgame.ai_config[c]->ResetInfo(false)) {
|
|
|
|
|
|
|
|
Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
|
|
|
|
|
|
|
|
_settings_newgame.ai_config[c]->Change(std::nullopt);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|