Initial container content should inherit the owner of its container

actorid
scrawl 12 years ago
parent 480467b6eb
commit 9e08497f02

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

@ -177,19 +177,19 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImpl (const Ptr& ptr
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();
++iter)
{
std::string id = iter->mItem.toString();
addInitialItem(id, iter->mCount);
addInitialItem(id, owner, iter->mCount);
}
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)
@ -208,7 +208,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, int count,
if (topLevel && count > 1 && levItem->mFlags & ESM::ItemLevList::Each)
{
for (int i=0; i<count; ++i)
addInitialItem(id, 1, failChance, false);
addInitialItem(id, owner, 1, failChance, false);
return;
}
@ -238,12 +238,13 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, int count,
if (!candidates.size())
return;
std::string item = candidates[std::rand()%candidates.size()];
addInitialItem(item, count, failChance, false);
addInitialItem(item, owner, count, failChance, false);
}
}
else
{
ref.getPtr().getRefData().setCount (count);
ref.getPtr().getCellRef().mOwner = owner;
addImp (ref.getPtr());
}
}

@ -53,7 +53,7 @@ namespace MWWorld
mutable float mCachedWeight;
mutable bool mWeightUpToDate;
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:
@ -85,7 +85,7 @@ namespace MWWorld
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.
void clear();

Loading…
Cancel
Save