diff options
author | truebrain <truebrain@openttd.org> | 2011-11-29 23:26:44 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-11-29 23:26:44 +0000 |
commit | 4505edbd4715befb0944e91ad7f986a8ca83f113 (patch) | |
tree | 90fc3eee3172861db8b3243682e6f70fc52bccba | |
parent | 34d7f01cccfbb4dcd09f0b68ded513f495fa69ed (diff) | |
download | openttd-4505edbd4715befb0944e91ad7f986a8ca83f113.tar.xz |
(svn r23365) -Codechange: move constants to a single place, to avoid duplication (and in time, different values)
-rw-r--r-- | src/ai/ai_info.cpp | 11 | ||||
-rw-r--r-- | src/script/script_info.cpp | 8 | ||||
-rw-r--r-- | src/script/script_info.hpp | 12 | ||||
-rw-r--r-- | src/script/script_instance.cpp | 6 |
4 files changed, 17 insertions, 20 deletions
diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp index d43ff8f7d..0ce4f5297 100644 --- a/src/ai/ai_info.cpp +++ b/src/ai/ai_info.cpp @@ -20,9 +20,6 @@ #include "../rev.h" #include "ai.hpp" -/** Maximum number of operations allowed for getting a particular setting. */ -static const int MAX_GET_SETTING_OPS = 100000; - /** * Check if the API version provided by the AI is supported. * @param api_version The API version as provided by the AI. @@ -78,19 +75,19 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; } info->config_list.push_front(config); if (info->engine->MethodExists(*info->SQ_instance, "MinVersionToLoad")) { - if (!info->engine->CallIntegerMethod(*info->SQ_instance, "MinVersionToLoad", &info->min_loadable_version, MAX_GET_SETTING_OPS)) return SQ_ERROR; + if (!info->engine->CallIntegerMethod(*info->SQ_instance, "MinVersionToLoad", &info->min_loadable_version, MAX_GET_OPS)) return SQ_ERROR; } 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, MAX_GET_SETTING_OPS)) return SQ_ERROR; + if (!info->engine->CallBoolMethod(*info->SQ_instance, "UseAsRandomAI", &info->use_as_random, MAX_GET_OPS)) return SQ_ERROR; } else { info->use_as_random = true; } /* Try to get the API version the AI is written for. */ if (info->engine->MethodExists(*info->SQ_instance, "GetAPIVersion")) { - if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAPIVersion", &info->api_version, MAX_GET_SETTING_OPS)) return SQ_ERROR; + if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAPIVersion", &info->api_version, MAX_GET_OPS)) return SQ_ERROR; if (!CheckAPIVersion(info->api_version)) { DEBUG(ai, 1, "Loading info.nut from (%s.%d): GetAPIVersion returned invalid version", info->GetName(), info->GetVersion()); return SQ_ERROR; @@ -172,7 +169,7 @@ AILibrary::~AILibrary() } /* Cache the category */ - if (!library->CheckMethod("GetCategory") || !library->engine->CallStringMethodStrdup(*library->SQ_instance, "GetCategory", &library->category, MAX_GET_SETTING_OPS)) { + if (!library->CheckMethod("GetCategory") || !library->engine->CallStringMethodStrdup(*library->SQ_instance, "GetCategory", &library->category, MAX_GET_OPS)) { delete library; return SQ_ERROR; } diff --git a/src/script/script_info.cpp b/src/script/script_info.cpp index afa90f40e..779236ebc 100644 --- a/src/script/script_info.cpp +++ b/src/script/script_info.cpp @@ -17,14 +17,6 @@ #include "script_info.hpp" #include "script_scanner.hpp" -/** Number of operations to get the author and similar information. */ -static const int MAX_GET_OPS = 1000; -/** Number of operations to create an instance of a script. */ -static const int MAX_CREATEINSTANCE_OPS = 100000; -/** Maximum number of operations allowed for getting a particular setting. */ -static const int MAX_GET_SETTING_OPS = 100000; - - ScriptInfo::~ScriptInfo() { /* Free all allocated strings */ diff --git a/src/script/script_info.hpp b/src/script/script_info.hpp index b686d53f4..4e59c7d72 100644 --- a/src/script/script_info.hpp +++ b/src/script/script_info.hpp @@ -17,6 +17,18 @@ #include "script_config.hpp" +/** The maximum number of operations for saving or loading the data of a script. */ +static const int MAX_SL_OPS = 100000; +/** The maximum number of operations for initial start of a script. */ +static const int MAX_CONSTRUCTOR_OPS = 100000; +/** Number of operations to create an instance of a script. */ +static const int MAX_CREATEINSTANCE_OPS = 100000; +/** Number of operations to get the author and similar information. */ +static const int MAX_GET_OPS = 1000; +/** Maximum number of operations allowed for getting a particular setting. */ +static const int MAX_GET_SETTING_OPS = 100000; + +/** All static information from an Script like name, version, etc. */ class ScriptInfo : public SimpleCountedObject { public: ScriptInfo() : diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index fa69932ce..beebe2fd7 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -18,6 +18,7 @@ #include "script_fatalerror.hpp" #include "script_storage.hpp" +#include "script_info.hpp" #include "script_instance.hpp" #include "api/script_controller.hpp" @@ -29,11 +30,6 @@ #include "../company_func.h" #include "../fileio_func.h" -/** The maximum number of operations for saving or loading the data of a script. */ -static const int MAX_SL_OPS = 100000; -/** The maximum number of operations for initial start of a script. */ -static const int MAX_CONSTRUCTOR_OPS = 100000; - ScriptStorage::~ScriptStorage() { /* Free our pointers */ |