mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-13 02:52:37 +00:00
(svn r23293) -Codechange: make LoadScript/LoadFile non-static
This commit is contained in:
parent
f4735ce234
commit
54ec3a2a3f
@ -134,7 +134,7 @@ bool AIScanner::ImportLibrary(const char *library, const char *class_name, int v
|
|||||||
sq_pushstring(vm, OTTD2SQ(fake_class), -1);
|
sq_pushstring(vm, OTTD2SQ(fake_class), -1);
|
||||||
sq_newclass(vm, SQFalse);
|
sq_newclass(vm, SQFalse);
|
||||||
/* Load the library */
|
/* Load the library */
|
||||||
if (!Squirrel::LoadScript(vm, (*iter).second->GetMainScript(), false)) {
|
if (!this->engine->LoadScript(vm, (*iter).second->GetMainScript(), false)) {
|
||||||
char error[1024];
|
char error[1024];
|
||||||
snprintf(error, sizeof(error), "there was a compile error when importing '%s' version %d", library, version);
|
snprintf(error, sizeof(error), "there was a compile error when importing '%s' version %d", library, version);
|
||||||
sq_throwerror(vm, OTTD2SQ(error));
|
sq_throwerror(vm, OTTD2SQ(error));
|
||||||
|
@ -425,7 +425,7 @@ static SQInteger _io_file_read(SQUserPointer file, SQUserPointer buf, SQInteger
|
|||||||
return ret;
|
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;
|
size_t size;
|
||||||
FILE *file = FioFOpenFile(filename, "rb", AI_DIR, &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"));
|
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 */
|
/* Make sure we are always in the root-table */
|
||||||
if (in_root) sq_pushroottable(vm);
|
if (in_root) sq_pushroottable(vm);
|
||||||
|
@ -69,12 +69,12 @@ public:
|
|||||||
* @return False if loading failed.
|
* @return False if loading failed.
|
||||||
*/
|
*/
|
||||||
bool LoadScript(const char *script);
|
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.
|
* 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
|
* Adds a function to the stack. Depending on the current state this means
|
||||||
|
@ -71,7 +71,8 @@ SQInteger SquirrelStd::require(HSQUIRRELVM vm)
|
|||||||
for (char *n = filen; *n != '\0'; n++) if (*n == '/') *n = PATHSEPCHAR;
|
for (char *n = filen; *n != '\0'; n++) if (*n == '/') *n = PATHSEPCHAR;
|
||||||
#endif
|
#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 */
|
/* Reset the top, so the stack stays correct */
|
||||||
sq_settop(vm, top);
|
sq_settop(vm, top);
|
||||||
|
Loading…
Reference in New Issue
Block a user