diff options
author | truebrain <truebrain@openttd.org> | 2011-11-29 23:27:08 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-11-29 23:27:08 +0000 |
commit | e0d4c75cf4411f66771524bf9a7f98d15cdc6fcf (patch) | |
tree | 55736dab87d443eae5d1071680b8f4e2d4a0468e /src | |
parent | 880f377fa61d8c87dc409f25447515509348bb45 (diff) | |
download | openttd-e0d4c75cf4411f66771524bf9a7f98d15cdc6fcf.tar.xz |
(svn r23368) -Codechange: move FindLibrary down a few layers, so there is no layer violation anymore
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/ai_instance.cpp | 6 | ||||
-rw-r--r-- | src/ai/ai_instance.hpp | 1 | ||||
-rw-r--r-- | src/script/api/script_controller.cpp | 3 | ||||
-rw-r--r-- | src/script/script_instance.hpp | 8 |
4 files changed, 16 insertions, 2 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index a360d516c..d7459005d 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -18,6 +18,7 @@ #include "ai_config.hpp" #include "ai_gui.hpp" +#include "ai.hpp" #include "../script/script_fatalerror.hpp" #include "../script/script_suspend.hpp" @@ -240,6 +241,11 @@ int AIInstance::GetSetting(const char *name) return AIConfig::GetConfig(_current_company)->GetSetting(name); } +ScriptInfo *AIInstance::FindLibrary(const char *library, int version) +{ + return (ScriptInfo *)AI::FindLibrary(library, version); +} + /** * DoCommand callback function for all commands executed by AIs. * @param result The result of the command. diff --git a/src/ai/ai_instance.hpp b/src/ai/ai_instance.hpp index 01c472b03..d2642219b 100644 --- a/src/ai/ai_instance.hpp +++ b/src/ai/ai_instance.hpp @@ -27,6 +27,7 @@ public: void Initialize(class AIInfo *info); /* virtual */ int GetSetting(const char *name); + /* virtual */ ScriptInfo *FindLibrary(const char *library, int version); private: const char *versionAPI; ///< Current API used by this script. diff --git a/src/script/api/script_controller.cpp b/src/script/api/script_controller.cpp index 7fe174756..055774be3 100644 --- a/src/script/api/script_controller.cpp +++ b/src/script/api/script_controller.cpp @@ -16,7 +16,6 @@ #include "script_controller.hpp" #include "../../ai/ai_instance.hpp" -#include "../../ai/ai.hpp" #include "../script_fatalerror.hpp" #include "../script_info.hpp" #include "../script_suspend.hpp" @@ -94,7 +93,7 @@ ScriptController::~ScriptController() snprintf(library_name, sizeof(library_name), "%s.%d", library, version); strtolower(library_name); - ScriptInfo *lib = (ScriptInfo *)AI::FindLibrary(library, version); + ScriptInfo *lib = ScriptObject::GetActiveInstance()->FindLibrary(library, version); if (lib == NULL) { char error[1024]; snprintf(error, sizeof(error), "couldn't find library '%s' with version %d", library, version); diff --git a/src/script/script_instance.hpp b/src/script/script_instance.hpp index 122cc5808..8aa85744c 100644 --- a/src/script/script_instance.hpp +++ b/src/script/script_instance.hpp @@ -44,6 +44,14 @@ public: virtual int GetSetting(const char *name) = 0; /** + * Find a library. + * @param library The library name to find. + * @param version The version the library should have. + * @return The library if found, NULL otherwise. + */ + virtual class ScriptInfo *FindLibrary(const char *library, int version) = 0; + + /** * A script in multiplayer waits for the server to handle his DoCommand. * It keeps waiting for this until this function is called. */ |