From f92b5040c660dfa94a583543db8a1d7c425c2956 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Wed, 1 Jan 2025 13:21:28 +0100 Subject: [PATCH] Don't add auto started local Lua scripts twice --- components/lua/scriptscontainer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/lua/scriptscontainer.cpp b/components/lua/scriptscontainer.cpp index 11d347dade..88f4b9c33c 100644 --- a/components/lua/scriptscontainer.cpp +++ b/components/lua/scriptscontainer.cpp @@ -92,13 +92,16 @@ namespace LuaUtil if (hasScript(scriptId)) return false; // already present + LoadedData& data = ensureLoaded(); + if (data.mScripts.count(scriptId) != 0) + return false; // bail if the script we're adding was auto started + const VFS::Path::Normalized& path = scriptPath(scriptId); std::string debugName = mNamePrefix; debugName.push_back('['); debugName.append(path); debugName.push_back(']'); - LoadedData& data = ensureLoaded(); Script& script = data.mScripts[scriptId]; script.mHiddenData = view.newTable(); script.mHiddenData[sScriptIdKey] = ScriptId{ this, scriptId };