Codechange: use std::string for script names to load

pull/562/head
Rubidium 1 year ago committed by rubidium42
parent 9b0123ab66
commit a30f7c83bd

@ -120,7 +120,7 @@ bool ScriptInstance::LoadCompatibilityScripts(const std::string &api_version, Su
buf += script_name;
if (!FileExists(buf)) continue;
if (this->engine->LoadScript(buf.c_str())) return true;
if (this->engine->LoadScript(buf)) return true;
ScriptLog::Error("Failed to load API compatibility script");
Debug(script, 0, "Error compiling / running API compatibility script: {}", buf);

@ -36,7 +36,7 @@ bool ScriptScanner::AddFile(const std::string &filename, size_t basepath_length,
this->ResetEngine();
try {
this->engine->LoadScript(filename.c_str());
this->engine->LoadScript(filename);
} catch (Script_FatalError &e) {
Debug(script, 0, "Fatal error '{}' when trying to load the script '{}'.", e.GetErrorMessage(), filename);
return false;

@ -634,7 +634,7 @@ static SQInteger _io_file_read(SQUserPointer file, SQUserPointer buf, SQInteger
return ret;
}
SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printerror)
SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const std::string &filename, SQBool printerror)
{
ScriptAllocatorScope alloc_scope(this);
@ -712,7 +712,7 @@ SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printer
}
SQFile f(file, size);
if (SQ_SUCCEEDED(sq_compile(vm, func, &f, filename, printerror))) {
if (SQ_SUCCEEDED(sq_compile(vm, func, &f, filename.c_str(), printerror))) {
FioFCloseFile(file);
return SQ_OK;
}
@ -720,7 +720,7 @@ SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printer
return SQ_ERROR;
}
bool Squirrel::LoadScript(HSQUIRRELVM vm, const char *script, bool in_root)
bool Squirrel::LoadScript(HSQUIRRELVM vm, const std::string &script, bool in_root)
{
ScriptAllocatorScope alloc_scope(this);
@ -744,7 +744,7 @@ bool Squirrel::LoadScript(HSQUIRRELVM vm, const char *script, bool in_root)
return false;
}
bool Squirrel::LoadScript(const char *script)
bool Squirrel::LoadScript(const std::string &script)
{
return LoadScript(this->vm, script);
}

@ -84,13 +84,13 @@ public:
* @param script The full script-name to load.
* @return False if loading failed.
*/
bool LoadScript(const char *script);
bool LoadScript(HSQUIRRELVM vm, const char *script, bool in_root = true);
bool LoadScript(const std::string &script);
bool LoadScript(HSQUIRRELVM vm, const std::string &script, bool in_root = true);
/**
* Load a file to a given VM.
*/
SQRESULT LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printerror);
SQRESULT LoadFile(HSQUIRRELVM vm, const std::string &filename, SQBool printerror);
/**
* Adds a function to the stack. Depending on the current state this means

Loading…
Cancel
Save