diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 4ee95b96e..8180cb686 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -46,7 +46,11 @@ namespace MWClass { std::auto_ptr data (new CustomData); - // \todo add initial container content + MWWorld::LiveCellRef *ref = + ptr.get(); + + data->mContainerStore.fill( + ref->mBase->mInventory, ptr.getCellRef().mOwner, MWBase::Environment::get().getWorld()->getStore()); // store ptr.getRefData().setCustomData (data.release()); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 99da3b215..d142801df 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -91,6 +91,10 @@ namespace MWClass iter!=ref->mBase->mSpells.mList.end(); ++iter) data->mCreatureStats.getSpells().add (*iter); + // inventory + data->mContainerStore.fill(ref->mBase->mInventory, getId(ptr), + MWBase::Environment::get().getWorld()->getStore()); + // store ptr.getRefData().setCustomData (data.release()); } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index a468148b4..f2bfd1814 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -227,6 +227,10 @@ namespace MWClass iter!=ref->mBase->mSpells.mList.end(); ++iter) data->mCreatureStats.getSpells().add (*iter); + // inventory + data->mInventoryStore.fill(ref->mBase->mInventory, getId(ptr), + MWBase::Environment::get().getWorld()->getStore()); + // store ptr.getRefData().setCustomData (data.release()); } diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index cb2e49ca0..3495bdc06 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -44,39 +44,6 @@ void MWWorld::Cells::clear() mIdCacheIndex = 0; } -void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) -{ - for (CellRefList::List::iterator iter ( - cellStore.mContainers.mList.begin()); - iter!=cellStore.mContainers.mList.end(); ++iter) - { - Ptr container (&*iter, &cellStore); - - Class::get (container).getContainerStore (container).fill ( - iter->mBase->mInventory, container.getCellRef().mOwner, mStore); - } - - for (CellRefList::List::iterator iter ( - cellStore.mCreatures.mList.begin()); - iter!=cellStore.mCreatures.mList.end(); ++iter) - { - Ptr container (&*iter, &cellStore); - - Class::get (container).getContainerStore (container).fill ( - iter->mBase->mInventory, Class::get(container).getId(container), mStore); - } - - for (CellRefList::List::iterator iter ( - cellStore.mNpcs.mList.begin()); - iter!=cellStore.mNpcs.mList.end(); ++iter) - { - Ptr container (&*iter, &cellStore); - - Class::get (container).getContainerStore (container).fill ( - iter->mBase->mInventory, Class::get(container).getId(container), mStore); - } -} - MWWorld::Ptr MWWorld::Cells::getPtrAndCache (const std::string& name, Ptr::CellStore& cellStore) { Ptr ptr = getPtr (name, cellStore); @@ -129,7 +96,6 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y) { // Multiple plugin support for landscape data is much easier than for references. The last plugin wins. result->second.load (mStore, mReader); - fillContainers (result->second); } return &result->second; @@ -150,7 +116,6 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getInterior (const std::string& name) if (result->second.mState!=Ptr::CellStore::State_Loaded) { result->second.load (mStore, mReader); - fillContainers (result->second); } return &result->second; @@ -168,7 +133,6 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& ce if (std::binary_search (cell.mIds.begin(), cell.mIds.end(), lowerCase)) { cell.load (mStore, mReader); - fillContainers (cell); } else return Ptr(); diff --git a/apps/openmw/mwworld/cells.hpp b/apps/openmw/mwworld/cells.hpp index 53c72bb75..6f9c649fb 100644 --- a/apps/openmw/mwworld/cells.hpp +++ b/apps/openmw/mwworld/cells.hpp @@ -31,8 +31,6 @@ namespace MWWorld CellStore *getCellStore (const ESM::Cell *cell); - void fillContainers (CellStore& cellStore); - Ptr getPtrAndCache (const std::string& name, CellStore& cellStore); public: