Add NAME and DELE handling to ESM records.

Changed records are those where DELE is inserted at the beginning of a
record (before NAME).
The record has all required sub-records in this case.
pull/678/head
Stanislav Bas 10 years ago
parent 926c825d0c
commit 9ac20a3355

@ -3,6 +3,7 @@
#include "esmreader.hpp" #include "esmreader.hpp"
#include "esmwriter.hpp" #include "esmwriter.hpp"
#include "defs.hpp" #include "defs.hpp"
#include "util.hpp"
namespace ESM namespace ESM
{ {
@ -11,6 +12,10 @@ namespace ESM
void BirthSign::load(ESMReader &esm) void BirthSign::load(ESMReader &esm)
{ {
mPowers.mList.clear(); mPowers.mList.clear();
mIsDeleted = readDeleSubRecord(esm);
mId = esm.getHNString("NAME");
while (esm.hasMoreSubs()) while (esm.hasMoreSubs())
{ {
esm.getSubName(); esm.getSubName();
@ -37,6 +42,11 @@ void BirthSign::load(ESMReader &esm)
void BirthSign::save(ESMWriter &esm) const void BirthSign::save(ESMWriter &esm) const
{ {
if (mIsDeleted)
{
writeDeleSubRecord(esm);
}
esm.writeHNCString("NAME", mId);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("TNAM", mTexture); esm.writeHNOCString("TNAM", mTexture);
esm.writeHNOCString("DESC", mDescription); esm.writeHNOCString("DESC", mDescription);
@ -50,6 +60,7 @@ void BirthSign::save(ESMWriter &esm) const
mDescription.clear(); mDescription.clear();
mTexture.clear(); mTexture.clear();
mPowers.mList.clear(); mPowers.mList.clear();
mIsDeleted = false;
} }
} }

@ -22,6 +22,8 @@ struct BirthSign
// List of powers and abilities that come with this birth sign. // List of powers and abilities that come with this birth sign.
SpellList mPowers; SpellList mPowers;
bool mIsDeleted;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp" #include "esmreader.hpp"
#include "esmwriter.hpp" #include "esmwriter.hpp"
#include "defs.hpp" #include "defs.hpp"
#include "util.hpp"
namespace ESM namespace ESM
{ {
@ -10,11 +11,18 @@ namespace ESM
void LandTexture::load(ESMReader &esm) void LandTexture::load(ESMReader &esm)
{ {
mIsDeleted = readDeleSubRecord(esm);
mId = esm.getHNString("NAME");
esm.getHNT(mIndex, "INTV"); esm.getHNT(mIndex, "INTV");
mTexture = esm.getHNString("DATA"); mTexture = esm.getHNString("DATA");
} }
void LandTexture::save(ESMWriter &esm) const void LandTexture::save(ESMWriter &esm) const
{ {
if (mIsDeleted)
{
writeDeleSubRecord(esm);
}
esm.writeHNCString("NAME", mId);
esm.writeHNT("INTV", mIndex); esm.writeHNT("INTV", mIndex);
esm.writeHNCString("DATA", mTexture); esm.writeHNCString("DATA", mTexture);
} }
@ -23,6 +31,7 @@ void LandTexture::blank()
{ {
mTexture.clear(); mTexture.clear();
mIndex = -1; mIndex = -1;
mIsDeleted = false;
} }
} }

@ -34,6 +34,8 @@ struct LandTexture
std::string mId, mTexture; std::string mId, mTexture;
int mIndex; int mIndex;
bool mIsDeleted;
void blank(); void blank();
///< Set record to default state (does not touch the ID). ///< Set record to default state (does not touch the ID).

@ -3,6 +3,7 @@
#include "esmreader.hpp" #include "esmreader.hpp"
#include "esmwriter.hpp" #include "esmwriter.hpp"
#include "defs.hpp" #include "defs.hpp"
#include "util.hpp"
namespace ESM namespace ESM
{ {
@ -10,6 +11,8 @@ namespace ESM
void Region::load(ESMReader &esm) void Region::load(ESMReader &esm)
{ {
mIsDeleted = readDeleSubRecord(esm);
mId = esm.getHNString("NAME");
mName = esm.getHNOString("FNAM"); mName = esm.getHNOString("FNAM");
esm.getSubNameIs("WEAT"); esm.getSubNameIs("WEAT");
@ -49,6 +52,11 @@ void Region::load(ESMReader &esm)
} }
void Region::save(ESMWriter &esm) const void Region::save(ESMWriter &esm) const
{ {
if (mIsDeleted)
{
writeDeleSubRecord(esm);
}
esm.writeHNString("NAME", mId);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
if (esm.getVersion() == VER_12) if (esm.getVersion() == VER_12)
@ -77,5 +85,7 @@ void Region::save(ESMWriter &esm) const
mName.clear(); mName.clear();
mSleepList.clear(); mSleepList.clear();
mSoundList.clear(); mSoundList.clear();
mIsDeleted = false;
} }
} }

@ -51,6 +51,8 @@ struct Region
std::vector<SoundRef> mSoundList; std::vector<SoundRef> mSoundList;
bool mIsDeleted;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

Loading…
Cancel
Save