From e3fa3a371283abd95d73097c07da95dfd29e015c Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Mon, 3 Jul 2023 02:13:41 +0200 Subject: [PATCH] Fix 7448 (onConsume don't work after loading a save if inventory wasn't accessed from Lua) --- apps/openmw/mwclass/npc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 6c37b72b5b..77ed831c3e 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -50,6 +50,7 @@ #include "../mwworld/inventorystore.hpp" #include "../mwworld/localscripts.hpp" #include "../mwworld/ptr.hpp" +#include "../mwworld/worldmodel.hpp" #include "../mwrender/npcanimation.hpp" #include "../mwrender/objects.hpp" @@ -1144,6 +1145,7 @@ namespace MWClass MWBase::Environment::get().getWorld()->breakInvisibility(actor); MWMechanics::CastSpell cast(actor, actor); const ESM::RefId& recordId = consumable.getCellRef().getRefId(); + MWBase::Environment::get().getWorldModel()->registerPtr(consumable); MWBase::Environment::get().getLuaManager()->itemConsumed(consumable, actor); actor.getClass().getContainerStore(actor).remove(consumable, 1); return cast.cast(recordId);