From 744198fc4435f984e4d4d848c611e4c8fb23e27a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 8 Jun 2013 15:49:59 +0200 Subject: [PATCH] added blank function to CellRef and moved a function that was in the wrong file --- components/esm/cellref.cpp | 87 +++++++++++++++++++++++++++++++++++++ components/esm/cellref.hpp | 2 + components/esm/loadcell.cpp | 52 ---------------------- 3 files changed, 89 insertions(+), 52 deletions(-) create mode 100644 components/esm/cellref.cpp diff --git a/components/esm/cellref.cpp b/components/esm/cellref.cpp new file mode 100644 index 0000000000..95cf24d331 --- /dev/null +++ b/components/esm/cellref.cpp @@ -0,0 +1,87 @@ + +#include "cellref.hpp" + +#include "esmwriter.hpp" + +void ESM::CellRef::save(ESMWriter &esm) +{ + esm.writeHNT("FRMR", mRefnum); + esm.writeHNCString("NAME", mRefID); + + if (mScale != 1.0) { + esm.writeHNT("XSCL", mScale); + } + + esm.writeHNOCString("ANAM", mOwner); + esm.writeHNOCString("BNAM", mGlob); + esm.writeHNOCString("XSOL", mSoul); + + esm.writeHNOCString("CNAM", mFaction); + if (mFactIndex != -2) { + esm.writeHNT("INDX", mFactIndex); + } + + if (mEnchantmentCharge != -1) + esm.writeHNT("XCHG", mEnchantmentCharge); + + if (mCharge != -1) + esm.writeHNT("INTV", mCharge); + + if (mGoldValue != 1) { + esm.writeHNT("NAM9", mGoldValue); + } + + if (mTeleport) + { + esm.writeHNT("DODT", mDoorDest); + esm.writeHNOCString("DNAM", mDestCell); + } + + if (mLockLevel != -1) { + esm.writeHNT("FLTV", mLockLevel); + } + esm.writeHNOCString("KNAM", mKey); + 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) { + esm.writeHNT("NAM0", mNam0); + } +} + +void ESM::CellRef::blank() +{ + mRefnum = 0; + mRefID.clear(); + mScale = 1; + mOwner.clear(); + mGlob.clear(); + mSoul.clear(); + mFaction.clear(); + mFactIndex = -1; + mCharge = 0; + mEnchantmentCharge = 0; + mGoldValue = 0; + mDestCell.clear(); + mLockLevel = 0; + mKey.clear(); + mTrap.clear(); + mReferenceBlocked = 0; + mFltv = 0; + mNam0 = 0; + + for (int i=0; i<3; ++i) + { + mDoorDest.pos[i] = 0; + mDoorDest.rot[i] = 0; + mPos.pos[i] = 0; + mPos.rot[i] = 0; + } +} \ No newline at end of file diff --git a/components/esm/cellref.hpp b/components/esm/cellref.hpp index fb03a90844..31889914ce 100644 --- a/components/esm/cellref.hpp +++ b/components/esm/cellref.hpp @@ -84,6 +84,8 @@ namespace ESM Position mPos; void save(ESMWriter &esm); + + void blank(); }; } diff --git a/components/esm/loadcell.cpp b/components/esm/loadcell.cpp index 779f303f3e..b1f9986be4 100644 --- a/components/esm/loadcell.cpp +++ b/components/esm/loadcell.cpp @@ -22,58 +22,6 @@ bool operator==(const CellRef& ref, int pRefnum) return (ref.mRefnum == pRefnum); } -void CellRef::save(ESMWriter &esm) -{ - esm.writeHNT("FRMR", mRefnum); - esm.writeHNCString("NAME", mRefID); - - if (mScale != 1.0) { - esm.writeHNT("XSCL", mScale); - } - - esm.writeHNOCString("ANAM", mOwner); - esm.writeHNOCString("BNAM", mGlob); - esm.writeHNOCString("XSOL", mSoul); - - esm.writeHNOCString("CNAM", mFaction); - if (mFactIndex != -2) { - esm.writeHNT("INDX", mFactIndex); - } - - if (mEnchantmentCharge != -1) - esm.writeHNT("XCHG", mEnchantmentCharge); - - if (mCharge != -1) - esm.writeHNT("INTV", mCharge); - - if (mGoldValue != 1) { - esm.writeHNT("NAM9", mGoldValue); - } - - if (mTeleport) - { - esm.writeHNT("DODT", mDoorDest); - esm.writeHNOCString("DNAM", mDestCell); - } - - if (mLockLevel != -1) { - esm.writeHNT("FLTV", mLockLevel); - } - esm.writeHNOCString("KNAM", mKey); - 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) { - esm.writeHNT("NAM0", mNam0); - } -} void Cell::load(ESMReader &esm, bool saveContext) {