diff options
author | truebrain <truebrain@openttd.org> | 2009-01-13 14:00:26 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2009-01-13 14:00:26 +0000 |
commit | c3249d599fb4805b6c59e89c28c4d2720a7bcae0 (patch) | |
tree | fcc285a1912310512f00a09a911ee585210e5611 /src/ai/ai_core.cpp | |
parent | 405239758ecd3dad1d52322b2fea05ed350d15bb (diff) | |
download | openttd-c3249d599fb4805b6c59e89c28c4d2720a7bcae0.tar.xz |
(svn r15059) -Add [NoAI]: use 'start_date' from the AI configure to see when an AI should start next
Diffstat (limited to 'src/ai/ai_core.cpp')
-rw-r--r-- | src/ai/ai_core.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index 3d8fc7707..f5703e58d 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -227,6 +227,28 @@ void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2) } } +/* static */ int AI::GetStartNextTime() +{ + for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { + if (IsValidCompanyID(c)) continue; + + AIConfig *config = AIConfig::GetConfig(c); + if (config->HasAI()) return config->GetSetting("start_date"); + + /* No AI configured, so fall back to some defaults */ + switch (_settings_game.difficulty.diff_level) { + case 0: return AI::START_NEXT_EASY; + case 1: return AI::START_NEXT_MEDIUM; + case 2: return AI::START_NEXT_HARD; + case 3: return AI::START_NEXT_MEDIUM; + default: NOT_REACHED(); + } + } + + /* Currently no AI can be started, check again in a year. */ + return 12; +} + /* static */ char *AI::GetConsoleList(char *p, const char *last) { return AI::ai_scanner->GetAIConsoleList(p, last); |