diff --git a/components/esm/loadbsgn.cpp b/components/esm/loadbsgn.cpp index e0cd83ea07..7892bfc68c 100644 --- a/components/esm/loadbsgn.cpp +++ b/components/esm/loadbsgn.cpp @@ -3,6 +3,7 @@ #include "esmreader.hpp" #include "esmwriter.hpp" #include "defs.hpp" +#include "util.hpp" namespace ESM { @@ -11,6 +12,10 @@ namespace ESM void BirthSign::load(ESMReader &esm) { mPowers.mList.clear(); + + mIsDeleted = readDeleSubRecord(esm); + mId = esm.getHNString("NAME"); + while (esm.hasMoreSubs()) { esm.getSubName(); @@ -37,6 +42,11 @@ void BirthSign::load(ESMReader &esm) void BirthSign::save(ESMWriter &esm) const { + if (mIsDeleted) + { + writeDeleSubRecord(esm); + } + esm.writeHNCString("NAME", mId); esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("TNAM", mTexture); esm.writeHNOCString("DESC", mDescription); @@ -50,6 +60,7 @@ void BirthSign::save(ESMWriter &esm) const mDescription.clear(); mTexture.clear(); mPowers.mList.clear(); + mIsDeleted = false; } } diff --git a/components/esm/loadbsgn.hpp b/components/esm/loadbsgn.hpp index f91f91c974..41c70fb248 100644 --- a/components/esm/loadbsgn.hpp +++ b/components/esm/loadbsgn.hpp @@ -22,6 +22,8 @@ struct BirthSign // List of powers and abilities that come with this birth sign. SpellList mPowers; + bool mIsDeleted; + void load(ESMReader &esm); void save(ESMWriter &esm) const; diff --git a/components/esm/loadltex.cpp b/components/esm/loadltex.cpp index c3e2d50ff5..0ee30b11cd 100644 --- a/components/esm/loadltex.cpp +++ b/components/esm/loadltex.cpp @@ -3,6 +3,7 @@ #include "esmreader.hpp" #include "esmwriter.hpp" #include "defs.hpp" +#include "util.hpp" namespace ESM { @@ -10,11 +11,18 @@ namespace ESM void LandTexture::load(ESMReader &esm) { + mIsDeleted = readDeleSubRecord(esm); + mId = esm.getHNString("NAME"); esm.getHNT(mIndex, "INTV"); mTexture = esm.getHNString("DATA"); } void LandTexture::save(ESMWriter &esm) const { + if (mIsDeleted) + { + writeDeleSubRecord(esm); + } + esm.writeHNCString("NAME", mId); esm.writeHNT("INTV", mIndex); esm.writeHNCString("DATA", mTexture); } @@ -23,6 +31,7 @@ void LandTexture::blank() { mTexture.clear(); mIndex = -1; + mIsDeleted = false; } } diff --git a/components/esm/loadltex.hpp b/components/esm/loadltex.hpp index 50a7881054..e019e269e1 100644 --- a/components/esm/loadltex.hpp +++ b/components/esm/loadltex.hpp @@ -34,6 +34,8 @@ struct LandTexture std::string mId, mTexture; int mIndex; + bool mIsDeleted; + void blank(); ///< Set record to default state (does not touch the ID). diff --git a/components/esm/loadregn.cpp b/components/esm/loadregn.cpp index 1b08b72172..b0adc6f58e 100644 --- a/components/esm/loadregn.cpp +++ b/components/esm/loadregn.cpp @@ -3,6 +3,7 @@ #include "esmreader.hpp" #include "esmwriter.hpp" #include "defs.hpp" +#include "util.hpp" namespace ESM { @@ -10,6 +11,8 @@ namespace ESM void Region::load(ESMReader &esm) { + mIsDeleted = readDeleSubRecord(esm); + mId = esm.getHNString("NAME"); mName = esm.getHNOString("FNAM"); esm.getSubNameIs("WEAT"); @@ -49,6 +52,11 @@ void Region::load(ESMReader &esm) } void Region::save(ESMWriter &esm) const { + if (mIsDeleted) + { + writeDeleSubRecord(esm); + } + esm.writeHNString("NAME", mId); esm.writeHNOCString("FNAM", mName); if (esm.getVersion() == VER_12) @@ -77,5 +85,7 @@ void Region::save(ESMWriter &esm) const mName.clear(); mSleepList.clear(); mSoundList.clear(); + + mIsDeleted = false; } } diff --git a/components/esm/loadregn.hpp b/components/esm/loadregn.hpp index 1e241fffbe..921ab887b6 100644 --- a/components/esm/loadregn.hpp +++ b/components/esm/loadregn.hpp @@ -51,6 +51,8 @@ struct Region std::vector mSoundList; + bool mIsDeleted; + void load(ESMReader &esm); void save(ESMWriter &esm) const;