diff options
author | rubidium <rubidium@openttd.org> | 2010-01-09 14:41:22 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-01-09 14:41:22 +0000 |
commit | f65f276d10e528ffe2581656cfa8066a20002995 (patch) | |
tree | 40c36e7a0eb0070dbb4cb04eda09480fee9d0bbf /src/ai/ai_core.cpp | |
parent | 7f6016031e8367c8ce53a4017e5dadd47dc1974e (diff) | |
download | openttd-f65f276d10e528ffe2581656cfa8066a20002995.tar.xz |
(svn r18763) -Feature [FS#3095]: rerandomise AIs on reloading (via the debug window) when they were randomly chosen
Diffstat (limited to 'src/ai/ai_core.cpp')
-rw-r--r-- | src/ai/ai_core.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index a8e96085b..baf738920 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -32,19 +32,20 @@ return !_networking || (_network_server && _settings_game.ai.ai_in_multiplayer); } -/* static */ void AI::StartNew(CompanyID company) +/* static */ void AI::StartNew(CompanyID company, bool rerandomise_ai) { assert(Company::IsValidID(company)); /* Clients shouldn't start AIs */ if (_networking && !_network_server) return; - AIInfo *info = AIConfig::GetConfig(company)->GetInfo(); - if (info == NULL) { + AIConfig *config = AIConfig::GetConfig(company); + AIInfo *info = config->GetInfo(); + if (info == NULL || (rerandomise_ai && config->IsRandomAI())) { info = AI::ai_scanner->SelectRandomAI(); assert(info != NULL); /* Load default data and store the name in the settings */ - AIConfig::GetConfig(company)->ChangeAI(info->GetName()); + config->ChangeAI(info->GetName(), -1, true); } _current_company = company; |