diff --git a/apps/openmw/mwrender/cellimp.cpp b/apps/openmw/mwrender/cellimp.cpp index 50047c1d9..121f17383 100644 --- a/apps/openmw/mwrender/cellimp.cpp +++ b/apps/openmw/mwrender/cellimp.cpp @@ -48,24 +48,25 @@ void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRefmodel; - + cellRender.insertBegin(liveRef.ref); cellRender.insertMesh(headModel); //TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the right place cellRender.insertMesh("meshes\\" + store.bodyParts.find(bodyRaceID + "chest")->model); - + liveRef.mData.setHandle (cellRender.insertEnd (liveRef.mData.isEnabled())); } - + template void insertCellRefList (CellRenderImp& cellRender, const ESMS::ESMStore& store, T& cellRefList) { - for(typename T::List::iterator it = cellRefList.list.begin(); - it != cellRefList.list.end(); it++) - { - insertObj (cellRender, *it, store); - } + for(typename T::List::iterator it = cellRefList.list.begin(); + it != cellRefList.list.end(); it++) + { + if (it->mData.getCount()) + insertObj (cellRender, *it, store); + } } void CellRenderImp::insertCell(ESMS::CellStore &cell, const ESMS::ESMStore& store) @@ -92,5 +93,3 @@ void CellRenderImp::insertCell(ESMS::CellStore &cell, const ES insertCellRefList (*this, store, cell.statics); insertCellRefList (*this, store, cell.weapons); } - - diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index 919f4f8a0..8f76635f9 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -22,28 +22,34 @@ namespace MWWorld class RefData { std::string mHandle; - + MWScript::Locals mLocals; // if we find the overhead of heaving a locals // object in the refdata of refs without a script, // we can make this a pointer later. bool mHasLocals; bool mEnabled; - + int mCount; // 0: deleted + // we are using shared pointer here to avoid having to create custom copy-constructor, // assignment operator and destructor. As a consequence though copying a RefData object // manually will probably give unexcepted results. This is not a problem since RefData // are never copied outside of container operations. boost::shared_ptr mCreatureStats; - + public: - - RefData() : mHasLocals (false), mEnabled (true) {} - + + RefData() : mHasLocals (false), mEnabled (true), mCount (1) {} + std::string getHandle() { return mHandle; } - + + int getCount() const + { + return mCount; + } + void setLocals (const ESM::Script& script) { if (!mHasLocals) @@ -52,37 +58,42 @@ namespace MWWorld mHasLocals = true; } } - + void setHandle (const std::string& handle) { mHandle = handle; } - + + void setCount (int count) + { + mCount = count; + } + MWScript::Locals& getLocals() { return mLocals; } - + bool isEnabled() const { return mEnabled; } - + void enable() { mEnabled = true; } - + void disable() { mEnabled = true; } - + boost::shared_ptr& getCreatureStats() { - return mCreatureStats; + return mCreatureStats; } - }; + }; } #endif diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 73a9d6ad3..430f518ec 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -25,7 +25,7 @@ namespace cellRefList.list.begin()); iter!=cellRefList.list.end(); ++iter) { - if (!iter->base->script.empty()) + if (!iter->base->script.empty() && iter->mData.getCount()) { if (const ESM::Script *script = store.scripts.find (iter->base->script)) {