summaryrefslogtreecommitdiff
path: root/src/ai/ai_info.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2009-01-13 16:53:03 +0000
committertruebrain <truebrain@openttd.org>2009-01-13 16:53:03 +0000
commit890074a03ee0c6b10aff40e4b64de7437c06f368 (patch)
treea7e2f1687e36828d0479f321da377f4a273f568c /src/ai/ai_info.cpp
parent0a357c0ac10601b6172610dbd46498ff44b978c1 (diff)
downloadopenttd-890074a03ee0c6b10aff40e4b64de7437c06f368.tar.xz
(svn r15063) -Fix [NoAI]: starting companies now listen correctly to 'start_date' set to the AI slot (Yexo)
-Add [NoAI]: add a 'deviation' value for all settings, giving a slight deviation of the value of a setting (Yexo)
Diffstat (limited to 'src/ai/ai_info.cpp')
-rw-r--r--src/ai/ai_info.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp
index 2b076536e..c67059f20 100644
--- a/src/ai/ai_info.cpp
+++ b/src/ai/ai_info.cpp
@@ -154,12 +154,13 @@ void AIFileInfo::CheckMethods(SQInteger *res, const char *name)
AIConfigItem config;
config.name = strdup("start_date");
config.description = strdup("The amount of months after the start of the last AI, this AI will start (give or take).");
- config.min_value = 0;
- config.max_value = 120;
+ config.min_value = AI::START_NEXT_MIN;
+ config.max_value = AI::START_NEXT_MAX;
config.easy_value = AI::START_NEXT_EASY;
config.medium_value = AI::START_NEXT_MEDIUM;
config.hard_value = AI::START_NEXT_HARD;
config.custom_value = AI::START_NEXT_MEDIUM;
+ config.random_deviation = AI::START_NEXT_DEVIATION;
config.flags = AICONFIG_NONE;
info->config_list.push_back(config);
@@ -256,6 +257,11 @@ SQInteger AIInfo::AddSetting(HSQUIRRELVM vm)
sq_getinteger(vm, -1, &res);
config.hard_value = res;
items |= 0x040;
+ } else if (strcmp(key, "random_deviation") == 0) {
+ SQInteger res;
+ sq_getinteger(vm, -1, &res);
+ config.random_deviation = res;
+ items |= 0x200;
} else if (strcmp(key, "custom_value") == 0) {
SQInteger res;
sq_getinteger(vm, -1, &res);
@@ -277,6 +283,17 @@ SQInteger AIInfo::AddSetting(HSQUIRRELVM vm)
}
sq_pop(vm, 1);
+ /* Don't allow both random_deviation and AICONFIG_RANDOM to
+ * be set for the same config item. */
+ if ((items & 0x200) != 0 && (config.flags & AICONFIG_RANDOM) != 0) {
+ char error[1024];
+ snprintf(error, sizeof(error), "Setting both random_deviation and AICONFIG_RANDOM is not allowed");
+ this->engine->ThrowError(error);
+ return SQ_ERROR;
+ }
+ /* Reset the bit for random_deviation as it's optional. */
+ items &= ~0x200;
+
/* Make sure all properties are defined */
uint mask = (config.flags & AICONFIG_BOOLEAN) ? 0x1F3 : 0x1FF;
if (items != mask) {