1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 03:35:27 +00:00

Queue auto started scripts until next update

This commit is contained in:
uramer 2024-01-30 18:58:34 +01:00
parent ad8a05e2a1
commit 76915ce6e9
2 changed files with 7 additions and 2 deletions

View File

@ -166,6 +166,10 @@ namespace MWLua
mObjectLists.update();
for (auto scripts : mQueuedAutoStartedScripts)
scripts->addAutoStartedScripts();
mQueuedAutoStartedScripts.clear();
std::erase_if(mActiveLocalScripts,
[](const LocalScripts* l) { return l->getPtrOrEmpty().isEmpty() || l->getPtrOrEmpty().mRef->isDeleted(); });
@ -343,7 +347,7 @@ namespace MWLua
if (!localScripts)
{
localScripts = createLocalScripts(ptr);
localScripts->addAutoStartedScripts();
mQueuedAutoStartedScripts.push_back(localScripts);
}
mActiveLocalScripts.insert(localScripts);
mEngineEvents.addToQueue(EngineEvents::OnActive{ getId(ptr) });
@ -459,7 +463,7 @@ namespace MWLua
if (!autoStartConf.empty())
{
localScripts = createLocalScripts(ptr, std::move(autoStartConf));
localScripts->addAutoStartedScripts(); // TODO: put to a queue and apply on next `update()`
mQueuedAutoStartedScripts.push_back(localScripts);
}
}
if (localScripts)

View File

@ -176,6 +176,7 @@ namespace MWLua
MenuScripts mMenuScripts{ &mLua };
GlobalScripts mGlobalScripts{ &mLua };
std::set<LocalScripts*> mActiveLocalScripts;
std::vector<LocalScripts*> mQueuedAutoStartedScripts;
ObjectLists mObjectLists;
MWWorld::Ptr mPlayer;