1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 10:23:52 +00:00

Initial container content should inherit the owner of its container

This commit is contained in:
scrawl 2013-04-07 22:07:04 +02:00
parent 480467b6eb
commit 9e08497f02
3 changed files with 11 additions and 10 deletions

View file

@ -45,7 +45,7 @@ void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore)
Ptr container (&*iter, &cellStore); Ptr container (&*iter, &cellStore);
Class::get (container).getContainerStore (container).fill ( Class::get (container).getContainerStore (container).fill (
iter->mBase->mInventory, mStore); iter->mBase->mInventory, container.getCellRef().mOwner, mStore);
} }
for (CellRefList<ESM::Creature>::List::iterator iter ( for (CellRefList<ESM::Creature>::List::iterator iter (
@ -55,7 +55,7 @@ void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore)
Ptr container (&*iter, &cellStore); Ptr container (&*iter, &cellStore);
Class::get (container).getContainerStore (container).fill ( Class::get (container).getContainerStore (container).fill (
iter->mBase->mInventory, mStore); iter->mBase->mInventory, Class::get(container).getId(container), mStore);
} }
for (CellRefList<ESM::NPC>::List::iterator iter ( for (CellRefList<ESM::NPC>::List::iterator iter (
@ -65,7 +65,7 @@ void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore)
Ptr container (&*iter, &cellStore); Ptr container (&*iter, &cellStore);
Class::get (container).getContainerStore (container).fill ( Class::get (container).getContainerStore (container).fill (
iter->mBase->mInventory, mStore); iter->mBase->mInventory, Class::get(container).getId(container), mStore);
} }
} }

View file

@ -177,19 +177,19 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImpl (const Ptr& ptr
return it; return it;
} }
void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const MWWorld::ESMStore& store) void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const std::string& owner, const MWWorld::ESMStore& store)
{ {
for (std::vector<ESM::ContItem>::const_iterator iter (items.mList.begin()); iter!=items.mList.end(); for (std::vector<ESM::ContItem>::const_iterator iter (items.mList.begin()); iter!=items.mList.end();
++iter) ++iter)
{ {
std::string id = iter->mItem.toString(); std::string id = iter->mItem.toString();
addInitialItem(id, iter->mCount); addInitialItem(id, owner, iter->mCount);
} }
flagAsModified(); flagAsModified();
} }
void MWWorld::ContainerStore::addInitialItem (const std::string& id, int count, unsigned char failChance, bool topLevel) void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::string& owner, int count, unsigned char failChance, bool topLevel)
{ {
count = std::abs(count); /// \todo implement item restocking (indicated by negative count) count = std::abs(count); /// \todo implement item restocking (indicated by negative count)
@ -208,7 +208,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, int count,
if (topLevel && count > 1 && levItem->mFlags & ESM::ItemLevList::Each) if (topLevel && count > 1 && levItem->mFlags & ESM::ItemLevList::Each)
{ {
for (int i=0; i<count; ++i) for (int i=0; i<count; ++i)
addInitialItem(id, 1, failChance, false); addInitialItem(id, owner, 1, failChance, false);
return; return;
} }
@ -238,12 +238,13 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, int count,
if (!candidates.size()) if (!candidates.size())
return; return;
std::string item = candidates[std::rand()%candidates.size()]; std::string item = candidates[std::rand()%candidates.size()];
addInitialItem(item, count, failChance, false); addInitialItem(item, owner, count, failChance, false);
} }
} }
else else
{ {
ref.getPtr().getRefData().setCount (count); ref.getPtr().getRefData().setCount (count);
ref.getPtr().getCellRef().mOwner = owner;
addImp (ref.getPtr()); addImp (ref.getPtr());
} }
} }

View file

@ -53,7 +53,7 @@ namespace MWWorld
mutable float mCachedWeight; mutable float mCachedWeight;
mutable bool mWeightUpToDate; mutable bool mWeightUpToDate;
ContainerStoreIterator addImp (const Ptr& ptr); ContainerStoreIterator addImp (const Ptr& ptr);
void addInitialItem (const std::string& id, int count, unsigned char failChance=0, bool topLevel=true); void addInitialItem (const std::string& id, const std::string& owner, int count, unsigned char failChance=0, bool topLevel=true);
public: public:
@ -85,7 +85,7 @@ namespace MWWorld
public: public:
void fill (const ESM::InventoryList& items, const MWWorld::ESMStore& store); void fill (const ESM::InventoryList& items, const std::string& owner, const MWWorld::ESMStore& store);
///< Insert items into *this. ///< Insert items into *this.
void clear(); void clear();