From 0f608f388ef84db438eda67c06409dcd58056a1e Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Sat, 8 Jul 2023 14:44:50 +0200 Subject: [PATCH] Generate new refnum for the new stack created when unstacking. --- apps/openmw/mwworld/containerstore.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 838a44b48b..b429bc31ed 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -218,6 +218,12 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::unstack(const Ptr& ptr, if (ptr.getRefData().getCount() <= count) return end(); MWWorld::ContainerStoreIterator it = addNewStack(ptr, subtractItems(ptr.getRefData().getCount(false), count)); + + MWWorld::Ptr newPtr = *it; + newPtr.getCellRef().unsetRefNum(); + newPtr.getRefData().setLuaScripts(nullptr); + MWBase::Environment::get().getWorldModel()->registerPtr(newPtr); + const ESM::RefId& script = it->getClass().getScript(*it); if (!script.empty()) MWBase::Environment::get().getWorld()->getLocalScripts().add(script, *it);