summaryrefslogtreecommitdiff
path: root/src/ai/ai_info.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-04-21 19:13:32 +0000
committeryexo <yexo@openttd.org>2009-04-21 19:13:32 +0000
commit3949050714463bf13ffb6da231019de6db22a8e5 (patch)
treeb6dc258527d34f2a1db659be97eb7f48e16a7da6 /src/ai/ai_info.cpp
parentd4d163e127a90aecc64ddcfb37c96acbde91d658 (diff)
downloadopenttd-3949050714463bf13ffb6da231019de6db22a8e5.tar.xz
(svn r16113) -Feature [NoAI]: Add UseAsRandomAI as function in info.nut. When an AI returns false, it'll never be chosen as random AI.
Diffstat (limited to 'src/ai/ai_info.cpp')
-rw-r--r--src/ai/ai_info.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp
index aa783c385..da9522d8d 100644
--- a/src/ai/ai_info.cpp
+++ b/src/ai/ai_info.cpp
@@ -66,6 +66,12 @@ AILibrary::~AILibrary()
} else {
info->min_loadable_version = info->GetVersion();
}
+ /* When there is an UseAsRandomAI function, call it. */
+ if (info->engine->MethodExists(*info->SQ_instance, "UseAsRandomAI")) {
+ if (!info->engine->CallBoolMethod(*info->SQ_instance, "UseAsRandomAI", &info->use_as_random)) return SQ_ERROR;
+ } else {
+ info->use_as_random = true;
+ }
/* Remove the link to the real instance, else it might get deleted by RegisterAI() */
sq_setinstanceup(vm, 2, NULL);