1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-05-29 15:11:31 +00:00

Merge branch 'fix_7448' into 'master'

Fix #7448 (onConsume don't work after loading a save if inventory wasn't accessed from Lua)

Closes #7448

See merge request OpenMW/openmw!3194
This commit is contained in:
psi29a 2023-07-08 12:36:52 +00:00
commit 29ffc2840e

View file

@ -50,6 +50,7 @@
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/localscripts.hpp" #include "../mwworld/localscripts.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/worldmodel.hpp"
#include "../mwrender/npcanimation.hpp" #include "../mwrender/npcanimation.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
@ -1136,6 +1137,7 @@ namespace MWClass
MWBase::Environment::get().getWorld()->breakInvisibility(actor); MWBase::Environment::get().getWorld()->breakInvisibility(actor);
MWMechanics::CastSpell cast(actor, actor); MWMechanics::CastSpell cast(actor, actor);
const ESM::RefId& recordId = consumable.getCellRef().getRefId(); const ESM::RefId& recordId = consumable.getCellRef().getRefId();
MWBase::Environment::get().getWorldModel()->registerPtr(consumable);
MWBase::Environment::get().getLuaManager()->itemConsumed(consumable, actor); MWBase::Environment::get().getLuaManager()->itemConsumed(consumable, actor);
actor.getClass().getContainerStore(actor).remove(consumable, 1); actor.getClass().getContainerStore(actor).remove(consumable, 1);
return cast.cast(recordId); return cast.cast(recordId);