reduced object state for objects in containers

This commit is contained in:
Marc Zinnschlag 2014-01-28 13:49:59 +01:00
parent 29c3a288e3
commit a623f03850
4 changed files with 27 additions and 22 deletions

View file

@ -75,7 +75,7 @@ void ESM::CellRef::load (ESMReader& esm, bool wideRefNum)
esm.getHT (mNam0);
}
void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum) const
void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory) const
{
if (wideRefNum)
esm.writeHNT ("FRMR", mRefNum, 8);
@ -107,29 +107,32 @@ void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum) const
esm.writeHNT("NAM9", mGoldValue);
}
if (mTeleport)
if (mTeleport && !inInventory)
{
esm.writeHNT("DODT", mDoorDest);
esm.writeHNOCString("DNAM", mDestCell);
}
if (mLockLevel != -1) {
if (mLockLevel != -1 && !inInventory)
esm.writeHNT("FLTV", mLockLevel);
}
esm.writeHNOCString("KNAM", mKey);
esm.writeHNOCString("TNAM", mTrap);
if (mReferenceBlocked != -1) {
if (!inInventory)
esm.writeHNOCString ("KNAM", mKey);
if (!inInventory)
esm.writeHNOCString ("TNAM", mTrap);
if (mReferenceBlocked != -1)
esm.writeHNT("UNAM", mReferenceBlocked);
}
if (mFltv != 0) {
esm.writeHNT("FLTV", mFltv);
}
esm.writeHNT("DATA", mPos, 24);
if (mNam0 != 0) {
if (mFltv != 0 && !inInventory)
esm.writeHNT("FLTV", mFltv);
if (!inInventory)
esm.writeHNT("DATA", mPos, 24);
if (mNam0 != 0 && !inInventory)
esm.writeHNT("NAM0", mNam0);
}
}
void ESM::CellRef::blank()

View file

@ -89,7 +89,7 @@ namespace ESM
void load (ESMReader& esm, bool wideRefNum = false);
void save(ESMWriter &esm, bool wideRefNum = false) const;
void save (ESMWriter &esm, bool wideRefNum = false, bool inInventory = false) const;
void blank();
};

View file

@ -25,9 +25,9 @@ void ESM::ObjectState::load (ESMReader &esm)
esm.getHNT (mLocalRotation, "LROT", 12);
}
void ESM::ObjectState::save (ESMWriter &esm) const
void ESM::ObjectState::save (ESMWriter &esm, bool inInventory) const
{
mRef.save (esm, true);
mRef.save (esm, true, inInventory);
if (mHasLocals)
{
@ -35,13 +35,15 @@ void ESM::ObjectState::save (ESMWriter &esm) const
mLocals.save (esm);
}
if (!mEnabled)
if (!mEnabled && !inInventory)
esm.writeHNT ("ENAB", mEnabled);
if (mCount!=1)
esm.writeHNT ("COUN", mCount);
esm.writeHNT ("POS_", mPosition, 24);
esm.writeHNT ("LROT", mLocalRotation, 12);
if (!inInventory)
{
esm.writeHNT ("POS_", mPosition, 24);
esm.writeHNT ("LROT", mLocalRotation, 12);
}
}

View file

@ -27,7 +27,7 @@ namespace ESM
float mLocalRotation[3];
void load (ESMReader &esm);
void save (ESMWriter &esm) const;
void save (ESMWriter &esm, bool inInventory = false) const;
};
}