From ac8de2173a2d33cd8678fece231ddc79bf53234c Mon Sep 17 00:00:00 2001 From: ZavGaro Date: Tue, 20 Aug 2024 21:29:52 +0300 Subject: [PATCH] Do not load mod if given init script doesn't exist --- src/script/cpp_api/s_base.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp index e9907f304..cddd8cd34 100644 --- a/src/script/cpp_api/s_base.cpp +++ b/src/script/cpp_api/s_base.cpp @@ -266,6 +266,11 @@ std::string ScriptApiBase::getCurrentModName(lua_State *L) void ScriptApiBase::loadMod(const std::string &script_path, const std::string &mod_name) { + if (!fs::IsFile(script_path)) { + errorstream << "Mod error: Failed to load mod \"" << mod_name + << "\" as script \"" << script_path << "\" does not exist" << std::endl; + return; + } ModNameStorer mod_name_storer(getStack(), mod_name); loadScript(script_path);