summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2009-01-13 01:51:39 +0000
committertruebrain <truebrain@openttd.org>2009-01-13 01:51:39 +0000
commitc9d20bfd4774c9dc44f30a2a0e855f5b8d0a47d8 (patch)
treefba61dfebcfbb1d44714c9bfb651077ef9ab9463
parente06e372529db5e52bb1dc0a7d9891974fefa4ae5 (diff)
downloadopenttd-c9d20bfd4774c9dc44f30a2a0e855f5b8d0a47d8.tar.xz
(svn r15047) -Fix [NoAI]: AICONFIG_BOOLEAN (in AddSetting) doesn't require (or even allow) a min/max setting .. it is always 0/1 (Yexo)
-rw-r--r--src/ai/ai_info.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp
index 0b2539bba..9f9d6d5f3 100644
--- a/src/ai/ai_info.cpp
+++ b/src/ai/ai_info.cpp
@@ -206,6 +206,7 @@ SQInteger AIInfo::AddSetting(HSQUIRRELVM vm)
{
AIConfigItem config;
memset(&config, 0, sizeof(config));
+ config.max_value = 1;
int items = 0;
/* Read the table, and find all properties we care about */
@@ -277,9 +278,10 @@ SQInteger AIInfo::AddSetting(HSQUIRRELVM vm)
sq_pop(vm, 1);
/* Make sure all properties are defined */
- if (items != 0x1FF) {
+ uint mask = (config.flags & AICONFIG_BOOLEAN) ? 0x1F3 : 0x1FF;
+ if (items != mask) {
char error[1024];
- snprintf(error, sizeof(error), "please define all properties of a setting");
+ snprintf(error, sizeof(error), "please define all properties of a setting (min/max not allowed for booleans)");
this->engine->ThrowError(error);
return SQ_ERROR;
}