From 75e47f859c572724d4a3b01079713f3f56b7b080 Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Tue, 18 Apr 2023 22:19:01 +0200 Subject: [PATCH] Restore logic that was accidentally removed in !2852. Because of it `onUpdate` handler in local Lua scripts doesn't work. --- apps/openmw/mwlua/luamanagerimp.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwlua/luamanagerimp.cpp b/apps/openmw/mwlua/luamanagerimp.cpp index 43dd3fbfc1..33ffed0c4f 100644 --- a/apps/openmw/mwlua/luamanagerimp.cpp +++ b/apps/openmw/mwlua/luamanagerimp.cpp @@ -292,14 +292,19 @@ namespace MWLua mWorldView.objectAddedToScene(ptr); // assigns generated RefNum if it is not set yet. mEngineEvents.addToQueue(EngineEvents::OnActive{ getId(ptr) }); - if (!ptr.getRefData().getLuaScripts()) + LocalScripts* localScripts = ptr.getRefData().getLuaScripts(); + if (!localScripts) { LuaUtil::ScriptIdsWithInitializationData autoStartConf = mConfiguration.getLocalConf(getLiveCellRefType(ptr.mRef), ptr.getCellRef().getRefId(), getId(ptr)); - // TODO: put to a queue and apply `addAutoStartedScripts` on next `update()` if (!autoStartConf.empty()) - createLocalScripts(ptr, std::move(autoStartConf))->addAutoStartedScripts(); + { + localScripts = createLocalScripts(ptr, std::move(autoStartConf)); + localScripts->addAutoStartedScripts(); // TODO: put to a queue and apply on next `update()` + } } + if (localScripts) + mActiveLocalScripts.insert(localScripts); } void LuaManager::objectRemovedFromScene(const MWWorld::Ptr& ptr)