forked from teamnwah/openmw-tes3coop
implemented item count
This commit is contained in:
parent
7ba6bdb56c
commit
e0a3b1b1db
3 changed files with 36 additions and 26 deletions
|
@ -48,24 +48,25 @@ void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::NPC, MWWorld::R
|
|||
//get the part of the bodypart id which describes the race and the gender
|
||||
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
|
||||
std::string headModel = "meshes\\" + store.bodyParts.find(headID)->model;
|
||||
|
||||
|
||||
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<typename T>
|
||||
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<MWWorld::RefData> &cell, const ESMS::ESMStore& store)
|
||||
|
@ -92,5 +93,3 @@ void CellRenderImp::insertCell(ESMS::CellStore<MWWorld::RefData> &cell, const ES
|
|||
insertCellRefList (*this, store, cell.statics);
|
||||
insertCellRefList (*this, store, cell.weapons);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<MWMechanics::CreatureStats> 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<MWMechanics::CreatureStats>& getCreatureStats()
|
||||
{
|
||||
return mCreatureStats;
|
||||
return mCreatureStats;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue