moved code for writing/reading ref nums into RefNum struct

moveref
Marc Zinnschlag 10 years ago
parent 9670e0881d
commit 764c155cec

@ -4,6 +4,23 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::RefNum::load (ESMReader& esm, bool wide)
{
if (wide)
esm.getHNT (*this, "FRMR", 8);
else
esm.getHNT (mIndex, "FRMR");
}
void ESM::RefNum::save (ESMWriter &esm, bool wide) const
{
if (wide)
esm.writeHNT ("FRMR", *this, 8);
else
esm.writeHNT ("FRMR", mIndex, 4);
}
void ESM::CellRef::load (ESMReader& esm, bool wideRefNum)
{
// According to Hrnchamd, this does not belong to the actual ref. Instead, it is a marker indicating that
@ -13,10 +30,7 @@ void ESM::CellRef::load (ESMReader& esm, bool wideRefNum)
if (esm.isNextSub ("NAM0"))
esm.skipHSub();
if (wideRefNum)
esm.getHNT (mRefNum, "FRMR", 8);
else
esm.getHNT (mRefNum.mIndex, "FRMR");
mRefNum.load (esm, wideRefNum);
mRefID = esm.getHNString ("NAME");
@ -74,10 +88,7 @@ void ESM::CellRef::load (ESMReader& esm, bool wideRefNum)
void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory) const
{
if (wideRefNum)
esm.writeHNT ("FRMR", mRefNum, 8);
else
esm.writeHNT ("FRMR", mRefNum.mIndex, 4);
mRefNum.save (esm, wideRefNum);
esm.writeHNCString("NAME", mRefID);

@ -15,6 +15,10 @@ namespace ESM
{
int mIndex;
int mContentFile; // -1 no content file
void load (ESMReader& esm, bool wide = false);
void save (ESMWriter &esm, bool wide = false) const;
};
/* Cell reference. This represents ONE object (of many) inside the

Loading…
Cancel
Save