mirror of https://github.com/OpenTTD/OpenTTD.git
This commit is contained in:
parent
634b67bf13
commit
ef40c5e240
|
@ -214,25 +214,30 @@
|
|||
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());
|
||||
_settings_game.ai_config[c]->Change(std::nullopt);
|
||||
if (Company::IsValidAiID(c)) {
|
||||
/* 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
|
||||
* 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. */
|
||||
AI::Stop(c);
|
||||
AI::StartNew(c);
|
||||
}
|
||||
} else if (Company::IsValidAiID(c)) {
|
||||
/* Update the reference in the Company struct. */
|
||||
Company::Get(c)->ai_info = _settings_game.ai_config[c]->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);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
* 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
|
||||
* like what would happen if the AI was missing during loading. */
|
||||
AI::Stop(c);
|
||||
AI::StartNew(c);
|
||||
} else {
|
||||
/* Update the reference in the Company struct. */
|
||||
Company::Get(c)->ai_info = config->GetInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue