diff options
author | truebrain <truebrain@openttd.org> | 2011-11-23 13:37:48 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-11-23 13:37:48 +0000 |
commit | 54ec3a2a3f6b130251dca48662db8aca605141b8 (patch) | |
tree | c7e553fa0e698aa7f113a893aa957df9cb994f60 | |
parent | f4735ce234544eddcc21ccee4612509a78b8502d (diff) | |
download | openttd-54ec3a2a3f6b130251dca48662db8aca605141b8.tar.xz |
(svn r23293) -Codechange: make LoadScript/LoadFile non-static
-rw-r--r-- | src/ai/ai_scanner.cpp | 2 | ||||
-rw-r--r-- | src/script/squirrel.cpp | 4 | ||||
-rw-r--r-- | src/script/squirrel.hpp | 4 | ||||
-rw-r--r-- | src/script/squirrel_std.cpp | 3 |
4 files changed, 7 insertions, 6 deletions
diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp index 46032e1d5..a2954c6d9 100644 --- a/src/ai/ai_scanner.cpp +++ b/src/ai/ai_scanner.cpp @@ -134,7 +134,7 @@ bool AIScanner::ImportLibrary(const char *library, const char *class_name, int v sq_pushstring(vm, OTTD2SQ(fake_class), -1); sq_newclass(vm, SQFalse); /* Load the library */ - if (!Squirrel::LoadScript(vm, (*iter).second->GetMainScript(), false)) { + if (!this->engine->LoadScript(vm, (*iter).second->GetMainScript(), false)) { char error[1024]; snprintf(error, sizeof(error), "there was a compile error when importing '%s' version %d", library, version); sq_throwerror(vm, OTTD2SQ(error)); diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index e0f50f1d9..a3697dcb4 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -425,7 +425,7 @@ static SQInteger _io_file_read(SQUserPointer file, SQUserPointer buf, SQInteger return ret; } -/* static */ SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printerror) +SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printerror) { size_t size; FILE *file = FioFOpenFile(filename, "rb", AI_DIR, &size); @@ -477,7 +477,7 @@ static SQInteger _io_file_read(SQUserPointer file, SQUserPointer buf, SQInteger return sq_throwerror(vm, _SC("cannot open the file")); } -/* static */ bool Squirrel::LoadScript(HSQUIRRELVM vm, const char *script, bool in_root) +bool Squirrel::LoadScript(HSQUIRRELVM vm, const char *script, bool in_root) { /* Make sure we are always in the root-table */ if (in_root) sq_pushroottable(vm); diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp index fd298bcca..9dd8b3e4f 100644 --- a/src/script/squirrel.hpp +++ b/src/script/squirrel.hpp @@ -69,12 +69,12 @@ public: * @return False if loading failed. */ bool LoadScript(const char *script); - static bool LoadScript(HSQUIRRELVM vm, const char *script, bool in_root = true); + bool LoadScript(HSQUIRRELVM vm, const char *script, bool in_root = true); /** * Load a file to a given VM. */ - static SQRESULT LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printerror); + SQRESULT LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printerror); /** * Adds a function to the stack. Depending on the current state this means diff --git a/src/script/squirrel_std.cpp b/src/script/squirrel_std.cpp index 21639ee10..9de119e1e 100644 --- a/src/script/squirrel_std.cpp +++ b/src/script/squirrel_std.cpp @@ -71,7 +71,8 @@ SQInteger SquirrelStd::require(HSQUIRRELVM vm) for (char *n = filen; *n != '\0'; n++) if (*n == '/') *n = PATHSEPCHAR; #endif - bool ret = Squirrel::LoadScript(vm, filen); + Squirrel *engine = (Squirrel *)sq_getforeignptr(vm); + bool ret = engine->LoadScript(vm, filen); /* Reset the top, so the stack stays correct */ sq_settop(vm, top); |