summaryrefslogtreecommitdiff
path: root/src/ai/ai_scanner.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2009-01-13 01:46:46 +0000
committertruebrain <truebrain@openttd.org>2009-01-13 01:46:46 +0000
commitbcbbf2c366b829994983513d2858762874e99964 (patch)
treea2e699a90fbe7d2ebd18ddd9ea713546f3f641bc /src/ai/ai_scanner.cpp
parente6883c5cc7dedad23dfcf7a303a7154520db7f5e (diff)
downloadopenttd-bcbbf2c366b829994983513d2858762874e99964.tar.xz
(svn r15045) -Add [NoAI API CHANGE]: in info.nut you can now have (optional) a CanLoadFromVersion(version), which should return true/false, to indicate if you can load a savegame made with your AI of version 'version'
-Add [NoAI API CHANGE]: in main.nut the Load() function now should be Load(version, data), where 'version' is the version of your AI which made the savegame -Codechange [NoAI]: various of function renames to make things more sane -Add [NoAI]: push the 'version' of the AI through various of layers -Codechange [NoAI]: various of code cleanups -Add [NoAI]: store the version of the AI in the savegame too
Diffstat (limited to 'src/ai/ai_scanner.cpp')
-rw-r--r--src/ai/ai_scanner.cpp25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp
index 68d53660d..6bcf883e7 100644
--- a/src/ai/ai_scanner.cpp
+++ b/src/ai/ai_scanner.cpp
@@ -344,26 +344,10 @@ AIInfo *AIScanner::SelectRandomAI()
AIInfoList::iterator it = this->info_list.begin();
for (; pos > 0; pos--) it++;
AIInfoList::iterator first_it = it;
- AIInfo *i = (*it).second;
-
- if (!i->AllowStartup()) {
- /* We can't start this AI, try to find the next best */
- do {
- it++;
- if (it == this->info_list.end()) it = this->info_list.begin();
- /* Back at the beginning? We can't start an AI. */
- if (first_it == it) {
- DEBUG(ai, 0, "No suitable AI found, loading 'dummy' AI.");
- return this->info_dummy;
- }
-
- i = (*it).second;
- } while (!i->AllowStartup());
- }
- return i;
+ return (*it).second;
}
-AIInfo *AIScanner::FindAI(const char *name)
+AIInfo *AIScanner::FindInfo(const char *name, int version)
{
if (this->info_list.size() == 0) return NULL;
if (name == NULL) return NULL;
@@ -372,7 +356,7 @@ AIInfo *AIScanner::FindAI(const char *name)
for (; it != this->info_list.end(); it++) {
AIInfo *i = (*it).second;
- if (strcasecmp(name, (*it).first) == 0 && i->AllowStartup()) {
+ if (strcasecmp(name, (*it).first) == 0 && i->CanLoadFromVersion(version)) {
return i;
}
}
@@ -386,8 +370,7 @@ char *AIScanner::GetAIConsoleList(char *p, const char *last)
AIInfoList::iterator it = this->info_list.begin();
for (; it != this->info_list.end(); it++) {
AIInfo *i = (*it).second;
- if (!i->AllowStartup()) continue;
- p += seprintf(p, last, "%10s: %s\n", (*it).first, i->GetDescription());
+ p += seprintf(p, last, "%10s (v%d): %s\n", (*it).first, i->GetVersion(), i->GetDescription());
}
p += seprintf(p, last, "\n");