mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 20:23:54 +00:00
moved CellRef loading code to the CellRef class
This commit is contained in:
parent
9025210965
commit
e453468eff
3 changed files with 73 additions and 69 deletions
|
@ -1,12 +1,80 @@
|
||||||
|
|
||||||
#include "cellref.hpp"
|
#include "cellref.hpp"
|
||||||
|
|
||||||
|
#include "esmreader.hpp"
|
||||||
#include "esmwriter.hpp"
|
#include "esmwriter.hpp"
|
||||||
|
|
||||||
|
void ESM::CellRef::load (ESMReader& esm, bool wideRefNum)
|
||||||
|
{
|
||||||
|
// NAM0 sometimes appears here, sometimes further on
|
||||||
|
mNam0 = 0;
|
||||||
|
if (esm.isNextSub ("NAM0"))
|
||||||
|
esm.getHT (mNam0);
|
||||||
|
|
||||||
|
if (wideRefNum)
|
||||||
|
esm.getHNT (mRefNum, "FRMR", 8);
|
||||||
|
else
|
||||||
|
esm.getHNT (mRefNum.mIndex, "FRMR");
|
||||||
|
|
||||||
|
mRefID = esm.getHNString ("NAME");
|
||||||
|
|
||||||
|
mScale = 1.0;
|
||||||
|
esm.getHNOT (mScale, "XSCL");
|
||||||
|
|
||||||
|
mOwner = esm.getHNOString ("ANAM");
|
||||||
|
mGlob = esm.getHNOString ("BNAM");
|
||||||
|
mSoul = esm.getHNOString ("XSOL");
|
||||||
|
|
||||||
|
mFaction = esm.getHNOString ("CNAM");
|
||||||
|
mFactIndex = -2;
|
||||||
|
esm.getHNOT (mFactIndex, "INDX");
|
||||||
|
|
||||||
|
mGoldValue = 1;
|
||||||
|
mCharge = -1;
|
||||||
|
mEnchantmentCharge = -1;
|
||||||
|
|
||||||
|
esm.getHNOT (mEnchantmentCharge, "XCHG");
|
||||||
|
|
||||||
|
esm.getHNOT (mCharge, "INTV");
|
||||||
|
|
||||||
|
esm.getHNOT (mGoldValue, "NAM9");
|
||||||
|
|
||||||
|
// Present for doors that teleport you to another cell.
|
||||||
|
if (esm.isNextSub ("DODT"))
|
||||||
|
{
|
||||||
|
mTeleport = true;
|
||||||
|
esm.getHT (mDoorDest);
|
||||||
|
mDestCell = esm.getHNOString ("DNAM");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mTeleport = false;
|
||||||
|
|
||||||
|
mLockLevel = -1;
|
||||||
|
esm.getHNOT (mLockLevel, "FLTV");
|
||||||
|
mKey = esm.getHNOString ("KNAM");
|
||||||
|
mTrap = esm.getHNOString ("TNAM");
|
||||||
|
|
||||||
|
mReferenceBlocked = -1;
|
||||||
|
mFltv = 0;
|
||||||
|
esm.getHNOT (mReferenceBlocked, "UNAM");
|
||||||
|
esm.getHNOT (mFltv, "FLTV");
|
||||||
|
|
||||||
|
esm.getHNOT(mPos, "DATA", 24);
|
||||||
|
|
||||||
|
// Number of references in the cell? Maximum once in each cell,
|
||||||
|
// but not always at the beginning, and not always right. In other
|
||||||
|
// words, completely useless.
|
||||||
|
// Update: Well, maybe not completely useless. This might actually be
|
||||||
|
// number_of_references + number_of_references_moved_here_Across_boundaries,
|
||||||
|
// and could be helpful for collecting these weird moved references.
|
||||||
|
if (esm.isNextSub ("NAM0"))
|
||||||
|
esm.getHT (mNam0);
|
||||||
|
}
|
||||||
|
|
||||||
void ESM::CellRef::save(ESMWriter &esm) const
|
void ESM::CellRef::save(ESMWriter &esm) const
|
||||||
{
|
{
|
||||||
esm.writeHNT("FRMR", mRefNum.mIndex);
|
esm.writeHNT("FRMR", mRefNum.mIndex);
|
||||||
/// \todo read content file index (if present)
|
|
||||||
esm.writeHNCString("NAME", mRefID);
|
esm.writeHNCString("NAME", mRefID);
|
||||||
|
|
||||||
if (mScale != 1.0) {
|
if (mScale != 1.0) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
class ESMWriter;
|
class ESMWriter;
|
||||||
|
class ESMReader;
|
||||||
|
|
||||||
/* Cell reference. This represents ONE object (of many) inside the
|
/* Cell reference. This represents ONE object (of many) inside the
|
||||||
cell. The cell references are not loaded as part of the normal
|
cell. The cell references are not loaded as part of the normal
|
||||||
|
@ -86,6 +87,8 @@ namespace ESM
|
||||||
// Position and rotation of this object within the cell
|
// Position and rotation of this object within the cell
|
||||||
Position mPos;
|
Position mPos;
|
||||||
|
|
||||||
|
void load (ESMReader& esm, bool wideRefNum = false);
|
||||||
|
|
||||||
void save(ESMWriter &esm) const;
|
void save(ESMWriter &esm) const;
|
||||||
|
|
||||||
void blank();
|
void blank();
|
||||||
|
|
|
@ -177,78 +177,11 @@ bool Cell::getNextRef(ESMReader &esm, CellRef &ref, bool& deleted)
|
||||||
// That should be it, I haven't seen any other fields yet.
|
// That should be it, I haven't seen any other fields yet.
|
||||||
}
|
}
|
||||||
|
|
||||||
// NAM0 sometimes appears here, sometimes further on
|
ref.load (esm);
|
||||||
ref.mNam0 = 0;
|
|
||||||
if (esm.isNextSub("NAM0"))
|
|
||||||
{
|
|
||||||
esm.getHT(ref.mNam0);
|
|
||||||
//esm.getHNOT(NAM0, "NAM0");
|
|
||||||
}
|
|
||||||
|
|
||||||
esm.getHNT (ref.mRefNum.mIndex, "FRMR");
|
|
||||||
ref.mRefID = esm.getHNString("NAME");
|
|
||||||
|
|
||||||
// Identify references belonging to a parent file and adapt the ID accordingly.
|
// Identify references belonging to a parent file and adapt the ID accordingly.
|
||||||
adjustRefNum (ref.mRefNum, esm);
|
adjustRefNum (ref.mRefNum, esm);
|
||||||
|
|
||||||
// getHNOT will not change the existing value if the subrecord is
|
|
||||||
// missing
|
|
||||||
ref.mScale = 1.0;
|
|
||||||
esm.getHNOT(ref.mScale, "XSCL");
|
|
||||||
|
|
||||||
ref.mOwner = esm.getHNOString("ANAM");
|
|
||||||
ref.mGlob = esm.getHNOString("BNAM");
|
|
||||||
ref.mSoul = esm.getHNOString("XSOL");
|
|
||||||
|
|
||||||
ref.mFaction = esm.getHNOString("CNAM");
|
|
||||||
ref.mFactIndex = -2;
|
|
||||||
esm.getHNOT(ref.mFactIndex, "INDX");
|
|
||||||
|
|
||||||
ref.mGoldValue = 1;
|
|
||||||
ref.mCharge = -1;
|
|
||||||
ref.mEnchantmentCharge = -1;
|
|
||||||
|
|
||||||
esm.getHNOT(ref.mEnchantmentCharge, "XCHG");
|
|
||||||
|
|
||||||
esm.getHNOT(ref.mCharge, "INTV");
|
|
||||||
|
|
||||||
esm.getHNOT(ref.mGoldValue, "NAM9");
|
|
||||||
|
|
||||||
// Present for doors that teleport you to another cell.
|
|
||||||
if (esm.isNextSub("DODT"))
|
|
||||||
{
|
|
||||||
ref.mTeleport = true;
|
|
||||||
esm.getHT(ref.mDoorDest);
|
|
||||||
ref.mDestCell = esm.getHNOString("DNAM");
|
|
||||||
} else {
|
|
||||||
ref.mTeleport = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Integer, despite the name suggesting otherwise
|
|
||||||
ref.mLockLevel = -1;
|
|
||||||
esm.getHNOT(ref.mLockLevel, "FLTV");
|
|
||||||
ref.mKey = esm.getHNOString("KNAM");
|
|
||||||
ref.mTrap = esm.getHNOString("TNAM");
|
|
||||||
|
|
||||||
ref.mReferenceBlocked = -1;
|
|
||||||
ref.mFltv = 0;
|
|
||||||
esm.getHNOT(ref.mReferenceBlocked, "UNAM");
|
|
||||||
esm.getHNOT(ref.mFltv, "FLTV");
|
|
||||||
|
|
||||||
esm.getHNOT(ref.mPos, "DATA", 24);
|
|
||||||
|
|
||||||
// Number of references in the cell? Maximum once in each cell,
|
|
||||||
// but not always at the beginning, and not always right. In other
|
|
||||||
// words, completely useless.
|
|
||||||
// Update: Well, maybe not completely useless. This might actually be
|
|
||||||
// number_of_references + number_of_references_moved_here_Across_boundaries,
|
|
||||||
// and could be helpful for collecting these weird moved references.
|
|
||||||
if (esm.isNextSub("NAM0"))
|
|
||||||
{
|
|
||||||
esm.getHT(ref.mNam0);
|
|
||||||
//esm.getHNOT(NAM0, "NAM0");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (esm.isNextSub("DELE"))
|
if (esm.isNextSub("DELE"))
|
||||||
{
|
{
|
||||||
esm.skipHSub();
|
esm.skipHSub();
|
||||||
|
|
Loading…
Reference in a new issue