diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index c0a4f200d9..c04d3c2fec 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -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); diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp index 8dd88d3ff6..4035dd649a 100644 --- a/src/script/script_scanner.cpp +++ b/src/script/script_scanner.cpp @@ -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; diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index b51e051e8c..3c8a802cc8 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -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); } diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp index d290c3ec1a..f9471ff14b 100644 --- a/src/script/squirrel.hpp +++ b/src/script/squirrel.hpp @@ -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