summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2012-08-13 19:22:26 +0000
committeryexo <yexo@openttd.org>2012-08-13 19:22:26 +0000
commit54aa43c81b4adbaaf1eaab03062fa871d85fbeab (patch)
tree7f7ca92995edd09bd9dc41499d1aae60d8869bc3 /src/ai
parent51921552536d2fbc56c8cdaf682da038e26a168c (diff)
downloadopenttd-54aa43c81b4adbaaf1eaab03062fa871d85fbeab.tar.xz
(svn r24468) -Add [FS#5219]: API compatibility scripts for Goal Scripts (Hirundo)
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_instance.cpp25
-rw-r--r--src/ai/ai_instance.hpp7
2 files changed, 1 insertions, 31 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp
index 6ef776b28..4d808e055 100644
--- a/src/ai/ai_instance.cpp
+++ b/src/ai/ai_instance.cpp
@@ -81,7 +81,6 @@
#include "../company_base.h"
#include "../company_func.h"
-#include "../fileio_func.h"
AIInstance::AIInstance() :
ScriptInstance("AI")
@@ -194,29 +193,7 @@ void AIInstance::RegisterAPI()
SQAIWaypointList_Register(this->engine);
SQAIWaypointList_Vehicle_Register(this->engine);
- if (!this->LoadCompatibilityScripts(this->versionAPI)) this->Died();
-}
-
-bool AIInstance::LoadCompatibilityScripts(const char *api_version)
-{
- char script_name[32];
- seprintf(script_name, lastof(script_name), "compat_%s.nut", api_version);
- char buf[MAX_PATH];
- Searchpath sp;
- FOR_ALL_SEARCHPATHS(sp) {
- FioAppendDirectory(buf, MAX_PATH, sp, AI_DIR);
- ttd_strlcat(buf, script_name, MAX_PATH);
- if (!FileExists(buf)) continue;
-
- if (this->engine->LoadScript(buf)) return true;
-
- ScriptLog::Error("Failed to load API compatibility script");
- DEBUG(script, 0, "Error compiling / running API compatibility script: %s", buf);
- return false;
- }
-
- ScriptLog::Warning("API compatibility script not found");
- return true;
+ if (!this->LoadCompatibilityScripts(this->versionAPI, AI_DIR)) this->Died();
}
void AIInstance::Died()
diff --git a/src/ai/ai_instance.hpp b/src/ai/ai_instance.hpp
index d9bd33640..204bf9712 100644
--- a/src/ai/ai_instance.hpp
+++ b/src/ai/ai_instance.hpp
@@ -29,17 +29,10 @@ public:
/* virtual */ ScriptInfo *FindLibrary(const char *library, int version);
private:
- const char *versionAPI; ///< Current API used by this script.
-
/* virtual */ void RegisterAPI();
/* virtual */ void Died();
/* virtual */ CommandCallback *GetDoCommandCallback();
/* virtual */ void LoadDummyScript();
-
- /**
- * Load squirrel scripts to emulate an older API.
- */
- bool LoadCompatibilityScripts(const char *api_version);
};
#endif /* AI_INSTANCE_HPP */