Add NAME and DELE handling to ESM records.

Changed records are those where DELE is located after NAME sub-record.
And DELE is the last sub-record.
openmw-38
Stanislav Bas 10 years ago
parent 6691891bee
commit 926c825d0c

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Activator::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
while (esm.hasMoreSubs())
{
esm.getSubName();
@ -32,6 +39,13 @@ namespace ESM
}
void Activator::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("SCRI", mScript);
@ -42,5 +56,6 @@ namespace ESM
mName.clear();
mScript.clear();
mModel.clear();
mIsDeleted = false;
}
}

@ -17,6 +17,8 @@ struct Activator
std::string mId, mName, mScript, mModel;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -11,6 +12,13 @@ namespace ESM
void Potion::load(ESMReader &esm)
{
mEffects.mList.clear();
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -46,6 +54,13 @@ namespace ESM
}
void Potion::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("TEXT", mIcon);
esm.writeHNOCString("SCRI", mScript);
@ -64,5 +79,6 @@ namespace ESM
mIcon.clear();
mScript.clear();
mEffects.mList.clear();
mIsDeleted = false;
}
}

@ -33,6 +33,8 @@ struct Potion
std::string mId, mName, mModel, mIcon, mScript;
EffectList mEffects;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Apparatus::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -43,6 +50,13 @@ void Apparatus::load(ESMReader &esm)
void Apparatus::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNCString("FNAM", mName);
esm.writeHNT("AADT", mData, 16);
@ -60,5 +74,6 @@ void Apparatus::save(ESMWriter &esm) const
mIcon.clear();
mScript.clear();
mName.clear();
mIsDeleted = false;
}
}

@ -38,6 +38,8 @@ struct Apparatus
AADTstruct mData;
std::string mId, mModel, mIcon, mScript, mName;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -41,6 +42,13 @@ namespace ESM
void Armor::load(ESMReader &esm)
{
mParts.mParts.clear();
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -80,6 +88,13 @@ namespace ESM
void Armor::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("SCRI", mScript);
@ -103,5 +118,6 @@ namespace ESM
mIcon.clear();
mScript.clear();
mEnchant.clear();
mIsDeleted = false;
}
}

@ -96,6 +96,8 @@ struct Armor
std::string mId, mName, mModel, mIcon, mScript, mEnchant;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -11,6 +12,12 @@ namespace ESM
void BodyPart::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -38,6 +45,13 @@ void BodyPart::load(ESMReader &esm)
}
void BodyPart::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mRace);
esm.writeHNT("BYDT", mData, 4);
@ -52,5 +66,7 @@ void BodyPart::save(ESMWriter &esm) const
mModel.clear();
mRace.clear();
mIsDeleted = false;
}
}

@ -60,6 +60,8 @@ struct BodyPart
BYDTstruct mData;
std::string mId, mModel, mRace;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Book::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -48,6 +55,13 @@ namespace ESM
}
void Book::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNT("BKDT", mData, 20);
@ -70,5 +84,6 @@ namespace ESM
mScript.clear();
mEnchant.clear();
mText.clear();
mIsDeleted = false;
}
}

@ -28,6 +28,8 @@ struct Book
std::string mName, mModel, mIcon, mScript, mEnchant, mText;
std::string mId;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -5,6 +5,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -41,6 +42,12 @@ namespace ESM
void Class::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -69,6 +76,13 @@ namespace ESM
}
void Class::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNOCString("FNAM", mName);
esm.writeHNT("CLDT", mData, 60);
esm.writeHNOString("DESC", mDescription);
@ -87,5 +101,7 @@ namespace ESM
for (int i=0; i<5; ++i)
for (int i2=0; i2<2; ++i2)
mData.mSkills[i][i2] = 0;
mIsDeleted = false;
}
}

@ -73,6 +73,8 @@ struct Class
std::string mId, mName, mDescription;
CLDTstruct mData;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -11,6 +12,13 @@ namespace ESM
void Clothing::load(ESMReader &esm)
{
mParts.mParts.clear();
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -50,6 +58,13 @@ namespace ESM
void Clothing::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNT("CTDT", mData, 12);
@ -74,5 +89,6 @@ namespace ESM
mIcon.clear();
mEnchant.clear();
mScript.clear();
mIsDeleted = false;
}
}

@ -48,6 +48,8 @@ struct Clothing
std::string mId, mName, mModel, mIcon, mEnchant, mScript;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -27,6 +28,13 @@ namespace ESM
void Container::load(ESMReader &esm)
{
mInventory.mList.clear();
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasWeight = false;
bool hasFlags = false;
while (esm.hasMoreSubs())
@ -71,6 +79,13 @@ namespace ESM
void Container::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNT("CNDT", mWeight, 4);
@ -89,5 +104,6 @@ namespace ESM
mWeight = 0;
mFlags = 0x8; // set default flag value
mInventory.mList.clear();
mIsDeleted = false;
}
}

@ -52,6 +52,8 @@ struct Container
int mFlags;
InventoryList mInventory;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM {
@ -17,6 +18,12 @@ namespace ESM {
mSpells.mList.clear();
mTransport.mList.clear();
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
mScale = 1.f;
mHasAI = false;
bool hasNpdt = false;
@ -84,6 +91,13 @@ namespace ESM {
void Creature::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("CNAM", mOriginal);
esm.writeHNOCString("FNAM", mName);
@ -127,6 +141,7 @@ namespace ESM {
mAiData.mServices = 0;
mAiPackage.mList.clear();
mTransport.mList.clear();
mIsDeleted = false;
}
const std::vector<Transport::Dest>& Creature::getTransport() const

@ -91,12 +91,13 @@ struct Creature
InventoryList mInventory;
SpellList mSpells;
bool mHasAI;
AIData mAiData;
AIPackageList mAiPackage;
Transport mTransport;
bool mIsDeleted;
const std::vector<Transport::Dest>& getTransport() const;
void load(ESMReader &esm);

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Door::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
while (esm.hasMoreSubs())
{
esm.getSubName();
@ -39,6 +46,13 @@ namespace ESM
void Door::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("SCRI", mScript);
@ -53,5 +67,6 @@ namespace ESM
mScript.clear();
mOpenSound.clear();
mCloseSound.clear();
mIsDeleted = false;
}
}

@ -17,6 +17,8 @@ struct Door
std::string mId, mName, mModel, mScript, mOpenSound, mCloseSound;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -11,6 +12,13 @@ namespace ESM
void Enchantment::load(ESMReader &esm)
{
mEffects.mList.clear();
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -36,6 +44,13 @@ void Enchantment::load(ESMReader &esm)
void Enchantment::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNT("ENDT", mData, 16);
mEffects.save(esm);
}
@ -48,5 +63,7 @@ void Enchantment::save(ESMWriter &esm) const
mData.mAutocalc = 0;
mEffects.mList.clear();
mIsDeleted = false;
}
}

@ -42,6 +42,8 @@ struct Enchantment
ENDTstruct mData;
EffectList mEffects;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -5,6 +5,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -32,6 +33,12 @@ void Faction::load(ESMReader &esm)
for (int i=0;i<10;++i)
mRanks[i].clear();
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
int rankCounter=0;
bool hasData = false;
while (esm.hasMoreSubs())
@ -71,6 +78,13 @@ void Faction::load(ESMReader &esm)
}
void Faction::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNOCString("FNAM", mName);
for (int i = 0; i < 10; i++)
@ -109,5 +123,7 @@ void Faction::save(ESMWriter &esm) const
mData.mSkills[i] = 0;
mReactions.clear();
mIsDeleted = false;
}
}

@ -62,6 +62,8 @@ struct Faction
// Name of faction ranks (may be empty for NPC factions)
std::string mRanks[10];
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Ingredient::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -67,6 +74,13 @@ namespace ESM
void Ingredient::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNT("IRDT", mData, 56);
@ -89,5 +103,7 @@ namespace ESM
mModel.clear();
mIcon.clear();
mScript.clear();
mIsDeleted = false;
}
}

@ -31,6 +31,8 @@ struct Ingredient
IRDTstruct mData;
std::string mId, mName, mModel, mIcon, mScript;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,12 +3,19 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
void LevelledListBase::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
esm.getHNT(mFlags, "DATA");
esm.getHNT(mChanceNone, "NNAM");
@ -42,6 +49,13 @@ namespace ESM
}
void LevelledListBase::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNT("DATA", mFlags);
esm.writeHNT("NNAM", mChanceNone);
esm.writeHNT<int>("INDX", mList.size());
@ -58,6 +72,7 @@ namespace ESM
mFlags = 0;
mChanceNone = 0;
mList.clear();
mIsDeleted = false;
}
unsigned int CreatureLevList::sRecordId = REC_LEVC;

@ -36,6 +36,8 @@ struct LevelledListBase
std::vector<LevelItem> mList;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Light::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -45,6 +52,13 @@ namespace ESM
}
void Light::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("ITEX", mIcon);
@ -66,5 +80,6 @@ namespace ESM
mModel.clear();
mIcon.clear();
mName.clear();
mIsDeleted = false;
}
}

@ -47,6 +47,8 @@ struct Light
std::string mSound, mScript, mModel, mIcon, mName, mId;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Lockpick::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = true;
while (esm.hasMoreSubs())
{
@ -43,6 +50,13 @@ namespace ESM
void Lockpick::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
@ -61,5 +75,6 @@ namespace ESM
mModel.clear();
mIcon.clear();
mScript.clear();
mIsDeleted = false;
}
}

@ -27,6 +27,8 @@ struct Lockpick
Data mData;
std::string mId, mName, mModel, mIcon, mScript;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Miscellaneous::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -41,6 +48,13 @@ namespace ESM
void Miscellaneous::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNT("MCDT", mData, 12);
@ -57,5 +71,6 @@ namespace ESM
mModel.clear();
mIcon.clear();
mScript.clear();
mIsDeleted = false;
}
}

@ -32,6 +32,8 @@ struct Miscellaneous
std::string mId, mName, mModel, mIcon, mScript;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -17,6 +18,12 @@ namespace ESM
mTransport.mList.clear();
mAiPackage.mList.clear();
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasNpdt = false;
bool hasFlags = false;
mHasAI = false;
@ -103,6 +110,13 @@ namespace ESM
}
void NPC::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNOCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNCString("RNAM", mRace);
@ -178,6 +192,7 @@ namespace ESM
mScript.clear();
mHair.clear();
mHead.clear();
mIsDeleted = false;
}
int NPC::getFactionRank() const

@ -130,6 +130,8 @@ struct NPC
// body parts
std::string mHair, mHead;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Probe::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = true;
while (esm.hasMoreSubs())
{
@ -43,6 +50,13 @@ namespace ESM
void Probe::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
@ -61,5 +75,6 @@ namespace ESM
mModel.clear();
mIcon.clear();
mScript.clear();
mIsDeleted = false;
}
}

@ -27,6 +27,8 @@ struct Probe
Data mData;
std::string mId, mName, mModel, mIcon, mScript;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Repair::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = true;
while (esm.hasMoreSubs())
{
@ -43,6 +50,13 @@ void Repair::load(ESMReader &esm)
void Repair::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
@ -61,5 +75,6 @@ void Repair::save(ESMWriter &esm) const
mModel.clear();
mIcon.clear();
mScript.clear();
mIsDeleted = false;
}
}

@ -27,6 +27,8 @@ struct Repair
Data mData;
std::string mId, mName, mModel, mIcon, mScript;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void SoundGenerator::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -36,6 +43,13 @@ namespace ESM
}
void SoundGenerator::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNT("DATA", mType, 4);
esm.writeHNOCString("CNAM", mCreature);
esm.writeHNOCString("SNAM", mSound);
@ -46,5 +60,6 @@ namespace ESM
mType = LeftFoot;
mCreature.clear();
mSound.clear();
mIsDeleted = false;
}
}

@ -36,6 +36,8 @@ struct SoundGenerator
std::string mId, mCreature, mSound;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Sound::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -34,6 +41,13 @@ namespace ESM
void Sound::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNOCString("FNAM", mSound);
esm.writeHNT("DATA", mData, 3);
}
@ -45,5 +59,7 @@ namespace ESM
mData.mVolume = 128;
mData.mMinRange = 0;
mData.mMaxRange = 255;
mIsDeleted = false;
}
}

@ -23,6 +23,8 @@ struct Sound
SOUNstruct mData;
std::string mId, mSound;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -11,6 +12,13 @@ namespace ESM
void Spell::load(ESMReader &esm)
{
mEffects.mList.clear();
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -39,6 +47,13 @@ namespace ESM
void Spell::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNOCString("FNAM", mName);
esm.writeHNT("SPDT", mData, 12);
mEffects.save(esm);
@ -53,5 +68,7 @@ namespace ESM
mName.clear();
mEffects.mList.clear();
mIsDeleted = false;
}
}

@ -45,6 +45,8 @@ struct Spell
std::string mId, mName;
EffectList mEffects;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,15 +11,29 @@ namespace ESM
void Static::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
mModel = esm.getHNString("MODL");
}
void Static::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
}
void Static::blank()
{
mModel.clear();
mIsDeleted = false;
}
}

@ -28,6 +28,8 @@ struct Static
std::string mId, mModel;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -3,6 +3,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
#include "util.hpp"
namespace ESM
{
@ -10,6 +11,12 @@ namespace ESM
void Weapon::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false;
while (esm.hasMoreSubs())
{
@ -45,6 +52,13 @@ namespace ESM
}
void Weapon::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNT("WPDT", mData, 32);
@ -72,5 +86,7 @@ namespace ESM
mIcon.clear();
mEnchant.clear();
mScript.clear();
mIsDeleted = false;
}
}

@ -69,6 +69,8 @@ struct Weapon
std::string mId, mName, mModel, mIcon, mEnchant, mScript;
bool mIsDeleted;
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

@ -0,0 +1,20 @@
#include "util.hpp"
namespace ESM
{
bool readDeleSubRecord(ESMReader &esm)
{
if (esm.isNextSub("DELE"))
{
esm.getSubName();
esm.skipHSub();
return true;
}
return false;
}
void writeDeleSubRecord(ESMWriter &esm)
{
esm.writeHNString("DELE", "");
}
}

@ -1,9 +1,15 @@
#ifndef OPENMW_ESM_UTIL_H
#define OPENMW_ESM_UTIL_H
#include <string>
#include <osg/Vec3f>
#include <osg/Quat>
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "loadbsgn.hpp"
namespace ESM
{
@ -48,6 +54,9 @@ struct Vector3
}
};
bool readDeleSubRecord(ESMReader &esm);
void writeDeleSubRecord(ESMWriter &esm);
}
#endif

Loading…
Cancel
Save