From f891a7c3b3e225737f0e735b176399d16b5e6380 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Mon, 24 Feb 2025 17:07:32 +0100 Subject: [PATCH] Turn ActorActiveEffects:remove into a delayed action --- CMakeLists.txt | 2 +- apps/openmw/mwlua/magicbindings.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 170a56aade..1805ea6fea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...") set(OPENMW_VERSION_MAJOR 0) set(OPENMW_VERSION_MINOR 49) set(OPENMW_VERSION_RELEASE 0) -set(OPENMW_LUA_API_REVISION 70) +set(OPENMW_LUA_API_REVISION 71) set(OPENMW_POSTPROCESSING_API_REVISION 2) set(OPENMW_VERSION_COMMITHASH "") diff --git a/apps/openmw/mwlua/magicbindings.cpp b/apps/openmw/mwlua/magicbindings.cpp index 7259d03f4c..19dada74a7 100644 --- a/apps/openmw/mwlua/magicbindings.cpp +++ b/apps/openmw/mwlua/magicbindings.cpp @@ -1061,7 +1061,7 @@ namespace MWLua }; // types.Actor.activeEffects(o):removeEffect(id, ?arg) - activeEffectsT["remove"] = [getEffectKey](const ActorActiveEffects& effects, std::string_view idStr, + activeEffectsT["remove"] = [getEffectKey, context](const ActorActiveEffects& effects, std::string_view idStr, sol::optional argStr) { if (!effects.isActor()) return; @@ -1071,12 +1071,14 @@ namespace MWLua MWMechanics::EffectKey key = getEffectKey(idStr, argStr); - // Note that, although this is member method of ActorActiveEffects and we are removing an effect (not a - // spell), we still need to use the active spells store to purge this effect from active spells. - const auto& ptr = effects.mActor.ptr(); + context.mLuaManager->addAction([key, effects]() { + // Note that, although this is member method of ActorActiveEffects and we are removing an effect (not a + // spell), we still need to use the active spells store to purge this effect from active spells. + const auto& ptr = effects.mActor.ptr(); - auto& activeSpells = ptr.getClass().getCreatureStats(ptr).getActiveSpells(); - activeSpells.purgeEffect(ptr, key.mId, key.mArg); + auto& activeSpells = ptr.getClass().getCreatureStats(ptr).getActiveSpells(); + activeSpells.purgeEffect(ptr, key.mId, key.mArg); + }); }; // types.Actor.activeEffects(o):set(value, id, ?arg)