Set Deleted flag to false when initializing ESM records

openmw-38
Stanislav Bas 10 years ago
parent 20723581a1
commit 7ecb54a776

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Activator::sRecordId = REC_ACTI; unsigned int Activator::sRecordId = REC_ACTI;
Activator::Activator()
: mIsDeleted(false)
{}
void Activator::load(ESMReader &esm) void Activator::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -19,6 +19,8 @@ struct Activator
bool mIsDeleted; bool mIsDeleted;
Activator();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Potion::sRecordId = REC_ALCH; unsigned int Potion::sRecordId = REC_ALCH;
Potion::Potion()
: mIsDeleted(false)
{}
void Potion::load(ESMReader &esm) void Potion::load(ESMReader &esm)
{ {
mEffects.mList.clear(); mEffects.mList.clear();

@ -35,6 +35,8 @@ struct Potion
bool mIsDeleted; bool mIsDeleted;
Potion();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,60 +9,64 @@ namespace ESM
{ {
unsigned int Apparatus::sRecordId = REC_APPA; unsigned int Apparatus::sRecordId = REC_APPA;
void Apparatus::load(ESMReader &esm) Apparatus::Apparatus()
{ : mIsDeleted(false)
mId = esm.getHNString("NAME"); {}
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false; void Apparatus::load(ESMReader &esm)
while (esm.hasMoreSubs())
{ {
esm.getSubName(); mId = esm.getHNString("NAME");
uint32_t name = esm.retSubName().val; if (mIsDeleted = readDeleSubRecord(esm))
switch (name)
{ {
case ESM::FourCC<'M','O','D','L'>::value: return;
mModel = esm.getHString();
break;
case ESM::FourCC<'F','N','A','M'>::value:
mName = esm.getHString();
break;
case ESM::FourCC<'A','A','D','T'>::value:
esm.getHT(mData);
hasData = true;
break;
case ESM::FourCC<'S','C','R','I'>::value:
mScript = esm.getHString();
break;
case ESM::FourCC<'I','T','E','X'>::value:
mIcon = esm.getHString();
break;
default:
esm.fail("Unknown subrecord");
} }
bool hasData = false;
while (esm.hasMoreSubs())
{
esm.getSubName();
uint32_t name = esm.retSubName().val;
switch (name)
{
case ESM::FourCC<'M','O','D','L'>::value:
mModel = esm.getHString();
break;
case ESM::FourCC<'F','N','A','M'>::value:
mName = esm.getHString();
break;
case ESM::FourCC<'A','A','D','T'>::value:
esm.getHT(mData);
hasData = true;
break;
case ESM::FourCC<'S','C','R','I'>::value:
mScript = esm.getHString();
break;
case ESM::FourCC<'I','T','E','X'>::value:
mIcon = esm.getHString();
break;
default:
esm.fail("Unknown subrecord");
}
}
if (!hasData)
esm.fail("Missing AADT");
} }
if (!hasData)
esm.fail("Missing AADT");
}
void Apparatus::save(ESMWriter &esm) const void Apparatus::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{ {
writeDeleSubRecord(esm); esm.writeHNCString("NAME", mId);
return; if (mIsDeleted)
} {
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNCString("FNAM", mName); esm.writeHNCString("FNAM", mName);
esm.writeHNT("AADT", mData, 16); esm.writeHNT("AADT", mData, 16);
esm.writeHNOCString("SCRI", mScript); esm.writeHNOCString("SCRI", mScript);
esm.writeHNCString("ITEX", mIcon); esm.writeHNCString("ITEX", mIcon);
} }
void Apparatus::blank() void Apparatus::blank()
{ {

@ -40,6 +40,8 @@ struct Apparatus
bool mIsDeleted; bool mIsDeleted;
Apparatus();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -39,6 +39,10 @@ namespace ESM
unsigned int Armor::sRecordId = REC_ARMO; unsigned int Armor::sRecordId = REC_ARMO;
Armor::Armor()
: mIsDeleted(false)
{}
void Armor::load(ESMReader &esm) void Armor::load(ESMReader &esm)
{ {
mParts.mParts.clear(); mParts.mParts.clear();

@ -98,6 +98,8 @@ struct Armor
bool mIsDeleted; bool mIsDeleted;
Armor();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,53 +9,57 @@ namespace ESM
{ {
unsigned int BodyPart::sRecordId = REC_BODY; unsigned int BodyPart::sRecordId = REC_BODY;
BodyPart::BodyPart()
: mIsDeleted(false)
{}
void BodyPart::load(ESMReader &esm) void BodyPart::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{ {
return; mId = esm.getHNString("NAME");
} if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = false; bool hasData = false;
while (esm.hasMoreSubs()) while (esm.hasMoreSubs())
{
esm.getSubName();
uint32_t name = esm.retSubName().val;
switch (name)
{ {
case ESM::FourCC<'M','O','D','L'>::value: esm.getSubName();
mModel = esm.getHString(); uint32_t name = esm.retSubName().val;
break; switch (name)
case ESM::FourCC<'F','N','A','M'>::value: {
mRace = esm.getHString(); case ESM::FourCC<'M','O','D','L'>::value:
break; mModel = esm.getHString();
case ESM::FourCC<'B','Y','D','T'>::value: break;
esm.getHT(mData, 4); case ESM::FourCC<'F','N','A','M'>::value:
hasData = true; mRace = esm.getHString();
break; break;
default: case ESM::FourCC<'B','Y','D','T'>::value:
esm.fail("Unknown subrecord"); esm.getHT(mData, 4);
hasData = true;
break;
default:
esm.fail("Unknown subrecord");
}
} }
if (!hasData)
esm.fail("Missing BYDT subrecord");
} }
if (!hasData) void BodyPart::save(ESMWriter &esm) const
esm.fail("Missing BYDT subrecord");
}
void BodyPart::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{ {
writeDeleSubRecord(esm); esm.writeHNCString("NAME", mId);
return; if (mIsDeleted)
} {
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mRace); esm.writeHNOCString("FNAM", mRace);
esm.writeHNT("BYDT", mData, 4); esm.writeHNT("BYDT", mData, 4);
} }
void BodyPart::blank() void BodyPart::blank()
{ {

@ -62,6 +62,8 @@ struct BodyPart
bool mIsDeleted; bool mIsDeleted;
BodyPart();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Book::sRecordId = REC_BOOK; unsigned int Book::sRecordId = REC_BOOK;
Book::Book()
: mIsDeleted(false)
{}
void Book::load(ESMReader &esm) void Book::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -30,6 +30,8 @@ struct Book
bool mIsDeleted; bool mIsDeleted;
Book();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,50 +9,54 @@ namespace ESM
{ {
unsigned int BirthSign::sRecordId = REC_BSGN; unsigned int BirthSign::sRecordId = REC_BSGN;
void BirthSign::load(ESMReader &esm) BirthSign::BirthSign()
{ : mIsDeleted(false)
mPowers.mList.clear(); {}
mIsDeleted = readDeleSubRecord(esm);
mId = esm.getHNString("NAME");
while (esm.hasMoreSubs()) void BirthSign::load(ESMReader &esm)
{ {
esm.getSubName(); mPowers.mList.clear();
uint32_t name = esm.retSubName().val;
switch (name) mIsDeleted = readDeleSubRecord(esm);
mId = esm.getHNString("NAME");
while (esm.hasMoreSubs())
{ {
case ESM::FourCC<'F','N','A','M'>::value: esm.getSubName();
mName = esm.getHString(); uint32_t name = esm.retSubName().val;
break; switch (name)
case ESM::FourCC<'T','N','A','M'>::value: {
mTexture = esm.getHString(); case ESM::FourCC<'F','N','A','M'>::value:
break; mName = esm.getHString();
case ESM::FourCC<'D','E','S','C'>::value: break;
mDescription = esm.getHString(); case ESM::FourCC<'T','N','A','M'>::value:
break; mTexture = esm.getHString();
case ESM::FourCC<'N','P','C','S'>::value: break;
mPowers.add(esm); case ESM::FourCC<'D','E','S','C'>::value:
break; mDescription = esm.getHString();
default: break;
esm.fail("Unknown subrecord"); case ESM::FourCC<'N','P','C','S'>::value:
mPowers.add(esm);
break;
default:
esm.fail("Unknown subrecord");
}
} }
} }
}
void BirthSign::save(ESMWriter &esm) const void BirthSign::save(ESMWriter &esm) const
{
if (mIsDeleted)
{ {
writeDeleSubRecord(esm); if (mIsDeleted)
} {
esm.writeHNCString("NAME", mId); writeDeleSubRecord(esm);
esm.writeHNOCString("FNAM", mName); }
esm.writeHNOCString("TNAM", mTexture); esm.writeHNCString("NAME", mId);
esm.writeHNOCString("DESC", mDescription); esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("TNAM", mTexture);
esm.writeHNOCString("DESC", mDescription);
mPowers.save(esm); mPowers.save(esm);
} }
void BirthSign::blank() void BirthSign::blank()
{ {

@ -24,6 +24,8 @@ struct BirthSign
bool mIsDeleted; bool mIsDeleted;
BirthSign();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -85,7 +85,8 @@ struct Cell
mWater(0), mWater(0),
mWaterInt(false), mWaterInt(false),
mMapColor(0), mMapColor(0),
mRefNumCounter(0) mRefNumCounter(0),
mIsDeleted(false)
{} {}
// Interior cells are indexed by this (it's the 'id'), for exterior // Interior cells are indexed by this (it's the 'id'), for exterior

@ -23,6 +23,9 @@ namespace ESM
"sSpecializationStealth" "sSpecializationStealth"
}; };
Class::Class()
: mIsDeleted(false)
{}
int& Class::CLDTstruct::getSkill (int index, bool major) int& Class::CLDTstruct::getSkill (int index, bool major)
{ {

@ -75,6 +75,8 @@ struct Class
bool mIsDeleted; bool mIsDeleted;
Class();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Clothing::sRecordId = REC_CLOT; unsigned int Clothing::sRecordId = REC_CLOT;
Clothing::Clothing()
: mIsDeleted(false)
{}
void Clothing::load(ESMReader &esm) void Clothing::load(ESMReader &esm)
{ {
mParts.mParts.clear(); mParts.mParts.clear();

@ -50,6 +50,8 @@ struct Clothing
bool mIsDeleted; bool mIsDeleted;
Clothing();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -25,6 +25,10 @@ namespace ESM
unsigned int Container::sRecordId = REC_CONT; unsigned int Container::sRecordId = REC_CONT;
Container::Container()
: mIsDeleted(false)
{}
void Container::load(ESMReader &esm) void Container::load(ESMReader &esm)
{ {
mInventory.mList.clear(); mInventory.mList.clear();

@ -54,6 +54,8 @@ struct Container
bool mIsDeleted; bool mIsDeleted;
Container();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM {
unsigned int Creature::sRecordId = REC_CREA; unsigned int Creature::sRecordId = REC_CREA;
Creature::Creature()
: mIsDeleted(false)
{}
void Creature::load(ESMReader &esm) void Creature::load(ESMReader &esm)
{ {
mPersistent = (esm.getRecordFlags() & 0x0400) != 0; mPersistent = (esm.getRecordFlags() & 0x0400) != 0;

@ -98,6 +98,8 @@ struct Creature
bool mIsDeleted; bool mIsDeleted;
Creature();
const std::vector<Transport::Dest>& getTransport() const; const std::vector<Transport::Dest>& getTransport() const;
void load(ESMReader &esm); void load(ESMReader &esm);

@ -13,125 +13,128 @@ namespace ESM
{ {
unsigned int Dialogue::sRecordId = REC_DIAL; unsigned int Dialogue::sRecordId = REC_DIAL;
void Dialogue::load(ESMReader &esm) Dialogue::Dialogue()
{ : mIsDeleted(false)
mIsDeleted = false; {}
mId = esm.getHNString("NAME");
esm.getSubNameIs("DATA");
esm.getSubHeader();
int si = esm.getSubSize();
if (si == 1)
esm.getT(mType);
else if (si == 4) // The dialogue is deleted
{
int32_t empty;
esm.getT(empty); // Skip an empty DATA
mIsDeleted = readDeleSubRecord(esm);
}
else
esm.fail("Unknown sub record size");
}
void Dialogue::save(ESMWriter &esm) const void Dialogue::load(ESMReader &esm)
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{ {
esm.writeHNT("DATA", static_cast<int32_t>(0)); mIsDeleted = false;
writeDeleSubRecord(esm);
} mId = esm.getHNString("NAME");
else esm.getSubNameIs("DATA");
{ esm.getSubHeader();
esm.writeHNT("DATA", mType); int si = esm.getSubSize();
} if (si == 1)
} esm.getT(mType);
else if (si == 4) // The dialogue is deleted
void Dialogue::blank() {
{ int32_t empty;
mInfo.clear(); esm.getT(empty); // Skip an empty DATA
} mIsDeleted = readDeleSubRecord(esm);
}
void Dialogue::readInfo(ESMReader &esm, bool merge) else
{ esm.fail("Unknown sub record size");
const std::string& id = esm.getHNOString("INAM");
if (!merge || mInfo.empty())
{
ESM::DialInfo info;
info.mId = id;
info.load(esm);
mLookup[id] = mInfo.insert(mInfo.end(), info);
return;
} }
ESM::Dialogue::InfoContainer::iterator it = mInfo.end(); void Dialogue::save(ESMWriter &esm) const
std::map<std::string, ESM::Dialogue::InfoContainer::iterator>::iterator lookup;
lookup = mLookup.find(id);
ESM::DialInfo info;
if (lookup != mLookup.end())
{
it = lookup->second;
// Merge with existing record. Only the subrecords that are present in
// the new record will be overwritten.
it->load(esm);
info = *it;
// Since the record merging may have changed the next/prev linked list connection, we need to re-insert the record
mInfo.erase(it);
mLookup.erase(lookup);
}
else
{ {
info.mId = id; esm.writeHNCString("NAME", mId);
info.load(esm); if (mIsDeleted)
{
esm.writeHNT("DATA", static_cast<int32_t>(0));
writeDeleSubRecord(esm);
}
else
{
esm.writeHNT("DATA", mType);
}
} }
if (info.mNext.empty()) void Dialogue::blank()
{ {
mLookup[id] = mInfo.insert(mInfo.end(), info); mInfo.clear();
return;
}
if (info.mPrev.empty())
{
mLookup[id] = mInfo.insert(mInfo.begin(), info);
return;
} }
lookup = mLookup.find(info.mPrev); void Dialogue::readInfo(ESMReader &esm, bool merge)
if (lookup != mLookup.end())
{ {
it = lookup->second; const std::string& id = esm.getHNOString("INAM");
mLookup[id] = mInfo.insert(++it, info); if (!merge || mInfo.empty())
return; {
} ESM::DialInfo info;
info.mId = id;
info.load(esm);
mLookup[id] = mInfo.insert(mInfo.end(), info);
return;
}
lookup = mLookup.find(info.mNext); ESM::Dialogue::InfoContainer::iterator it = mInfo.end();
if (lookup != mLookup.end())
{
it = lookup->second;
mLookup[id] = mInfo.insert(it, info); std::map<std::string, ESM::Dialogue::InfoContainer::iterator>::iterator lookup;
return;
}
std::cerr << "Failed to insert info " << id << std::endl; lookup = mLookup.find(id);
}
void Dialogue::clearDeletedInfos() ESM::DialInfo info;
{ if (lookup != mLookup.end())
for (InfoContainer::iterator it = mInfo.begin(); it != mInfo.end(); ) {
{ it = lookup->second;
if (it->mQuestStatus == DialInfo::QS_Deleted)
it = mInfo.erase(it); // Merge with existing record. Only the subrecords that are present in
// the new record will be overwritten.
it->load(esm);
info = *it;
// Since the record merging may have changed the next/prev linked list connection, we need to re-insert the record
mInfo.erase(it);
mLookup.erase(lookup);
}
else else
++it; {
info.mId = id;
info.load(esm);
}
if (info.mNext.empty())
{
mLookup[id] = mInfo.insert(mInfo.end(), info);
return;
}
if (info.mPrev.empty())
{
mLookup[id] = mInfo.insert(mInfo.begin(), info);
return;
}
lookup = mLookup.find(info.mPrev);
if (lookup != mLookup.end())
{
it = lookup->second;
mLookup[id] = mInfo.insert(++it, info);
return;
}
lookup = mLookup.find(info.mNext);
if (lookup != mLookup.end())
{
it = lookup->second;
mLookup[id] = mInfo.insert(it, info);
return;
}
std::cerr << "Failed to insert info " << id << std::endl;
} }
}
void Dialogue::clearDeletedInfos()
{
for (InfoContainer::iterator it = mInfo.begin(); it != mInfo.end(); )
{
if (it->mQuestStatus == DialInfo::QS_Deleted)
it = mInfo.erase(it);
else
++it;
}
}
} }

@ -47,6 +47,8 @@ struct Dialogue
bool mIsDeleted; bool mIsDeleted;
Dialogue();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Door::sRecordId = REC_DOOR; unsigned int Door::sRecordId = REC_DOOR;
Door::Door()
: mIsDeleted(false)
{}
void Door::load(ESMReader &esm) void Door::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -19,6 +19,8 @@ struct Door
bool mIsDeleted; bool mIsDeleted;
Door();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,51 +9,55 @@ namespace ESM
{ {
unsigned int Enchantment::sRecordId = REC_ENCH; unsigned int Enchantment::sRecordId = REC_ENCH;
void Enchantment::load(ESMReader &esm) Enchantment::Enchantment()
{ : mIsDeleted(false)
mEffects.mList.clear(); {}
mId = esm.getHNString("NAME"); void Enchantment::load(ESMReader &esm)
if (mIsDeleted = readDeleSubRecord(esm))
{ {
return; mEffects.mList.clear();
}
bool hasData = false; mId = esm.getHNString("NAME");
while (esm.hasMoreSubs()) if (mIsDeleted = readDeleSubRecord(esm))
{ {
esm.getSubName(); return;
uint32_t name = esm.retSubName().val; }
switch (name)
bool hasData = false;
while (esm.hasMoreSubs())
{ {
case ESM::FourCC<'E','N','D','T'>::value: esm.getSubName();
esm.getHT(mData, 16); uint32_t name = esm.retSubName().val;
hasData = true; switch (name)
break; {
case ESM::FourCC<'E','N','A','M'>::value: case ESM::FourCC<'E','N','D','T'>::value:
mEffects.add(esm); esm.getHT(mData, 16);
break; hasData = true;
default: break;
esm.fail("Unknown subrecord"); case ESM::FourCC<'E','N','A','M'>::value:
break; mEffects.add(esm);
break;
default:
esm.fail("Unknown subrecord");
break;
}
} }
if (!hasData)
esm.fail("Missing ENDT subrecord");
} }
if (!hasData)
esm.fail("Missing ENDT subrecord");
}
void Enchantment::save(ESMWriter &esm) const void Enchantment::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{ {
writeDeleSubRecord(esm); esm.writeHNCString("NAME", mId);
return; if (mIsDeleted)
} {
writeDeleSubRecord(esm);
return;
}
esm.writeHNT("ENDT", mData, 16); esm.writeHNT("ENDT", mData, 16);
mEffects.save(esm); mEffects.save(esm);
} }
void Enchantment::blank() void Enchantment::blank()
{ {

@ -44,6 +44,8 @@ struct Enchantment
bool mIsDeleted; bool mIsDeleted;
Enchantment();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -11,6 +11,10 @@ namespace ESM
{ {
unsigned int Faction::sRecordId = REC_FACT; unsigned int Faction::sRecordId = REC_FACT;
Faction::Faction()
: mIsDeleted(false)
{}
int& Faction::FADTstruct::getSkill (int index, bool ignored) int& Faction::FADTstruct::getSkill (int index, bool ignored)
{ {
if (index<0 || index>=7) if (index<0 || index>=7)
@ -27,82 +31,83 @@ namespace ESM
return mSkills[index]; return mSkills[index];
} }
void Faction::load(ESMReader &esm) void Faction::load(ESMReader &esm)
{
mReactions.clear();
for (int i=0;i<10;++i)
mRanks[i].clear();
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{ {
return; mReactions.clear();
} for (int i=0;i<10;++i)
mRanks[i].clear();
int rankCounter=0; mId = esm.getHNString("NAME");
bool hasData = false; if (mIsDeleted = readDeleSubRecord(esm))
while (esm.hasMoreSubs())
{
esm.getSubName();
uint32_t name = esm.retSubName().val;
switch (name)
{ {
case ESM::FourCC<'F','N','A','M'>::value: return;
mName = esm.getHString(); }
break;
case ESM::FourCC<'R','N','A','M'>::value: int rankCounter=0;
if (rankCounter >= 10) bool hasData = false;
esm.fail("Rank out of range"); while (esm.hasMoreSubs())
mRanks[rankCounter++] = esm.getHString(); {
break; esm.getSubName();
case ESM::FourCC<'F','A','D','T'>::value: uint32_t name = esm.retSubName().val;
esm.getHT(mData, 240); switch (name)
if (mData.mIsHidden > 1)
esm.fail("Unknown flag!");
hasData = true;
break;
case ESM::FourCC<'A','N','A','M'>::value:
{ {
std::string faction = esm.getHString(); case ESM::FourCC<'F','N','A','M'>::value:
int reaction; mName = esm.getHString();
esm.getHNT(reaction, "INTV"); break;
mReactions[faction] = reaction; case ESM::FourCC<'R','N','A','M'>::value:
break; if (rankCounter >= 10)
esm.fail("Rank out of range");
mRanks[rankCounter++] = esm.getHString();
break;
case ESM::FourCC<'F','A','D','T'>::value:
esm.getHT(mData, 240);
if (mData.mIsHidden > 1)
esm.fail("Unknown flag!");
hasData = true;
break;
case ESM::FourCC<'A','N','A','M'>::value:
{
std::string faction = esm.getHString();
int reaction;
esm.getHNT(reaction, "INTV");
mReactions[faction] = reaction;
break;
}
default:
esm.fail("Unknown subrecord");
} }
default:
esm.fail("Unknown subrecord");
} }
if (!hasData)
esm.fail("Missing FADT subrecord");
} }
if (!hasData)
esm.fail("Missing FADT subrecord"); void Faction::save(ESMWriter &esm) const
}
void Faction::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{ {
writeDeleSubRecord(esm); esm.writeHNCString("NAME", mId);
return; if (mIsDeleted)
} {
writeDeleSubRecord(esm);
return;
}
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
if (mRanks[i].empty()) if (mRanks[i].empty())
break; break;
esm.writeHNString("RNAM", mRanks[i], 32); esm.writeHNString("RNAM", mRanks[i], 32);
} }
esm.writeHNT("FADT", mData, 240); esm.writeHNT("FADT", mData, 240);
for (std::map<std::string, int>::const_iterator it = mReactions.begin(); it != mReactions.end(); ++it) for (std::map<std::string, int>::const_iterator it = mReactions.begin(); it != mReactions.end(); ++it)
{ {
esm.writeHNString("ANAM", it->first); esm.writeHNString("ANAM", it->first);
esm.writeHNT("INTV", it->second); esm.writeHNT("INTV", it->second);
}
} }
}
void Faction::blank() void Faction::blank()
{ {

@ -64,6 +64,8 @@ struct Faction
bool mIsDeleted; bool mIsDeleted;
Faction();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Global::sRecordId = REC_GLOB; unsigned int Global::sRecordId = REC_GLOB;
Global::Global()
: mIsDeleted(false)
{}
void Global::load (ESMReader &esm) void Global::load (ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -26,6 +26,8 @@ struct Global
bool mIsDeleted; bool mIsDeleted;
Global();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,169 +9,173 @@ namespace ESM
{ {
unsigned int DialInfo::sRecordId = REC_INFO; unsigned int DialInfo::sRecordId = REC_INFO;
void DialInfo::load(ESMReader &esm) DialInfo::DialInfo()
{ : mIsDeleted(false)
mQuestStatus = QS_None; {}
mFactionLess = false;
mPrev = esm.getHNString("PNAM");
mNext = esm.getHNString("NNAM");
// Since there's no way to mark selects as "deleted", we have to clear the SelectStructs from all previous loadings void DialInfo::load(ESMReader &esm)
mSelects.clear();
// If the info is deleted, NAME and DELE sub-records are followed after NNAM
if (esm.isNextSub("NAME"))
{ {
mResponse = esm.getHString(); mQuestStatus = QS_None;
mIsDeleted = readDeleSubRecord(esm); mFactionLess = false;
return;
}
esm.getSubNameIs("DATA");
esm.getHT(mData, 12);
if (!esm.hasMoreSubs())
return;
// What follows is somewhat spaghetti-ish, but it's worth if for
// an extra speedup. INFO is by far the most common record type.
// subName is a reference to the original, so it changes whenever mPrev = esm.getHNString("PNAM");
// a new sub name is read. esm.isEmptyOrGetName() will get the mNext = esm.getHNString("NNAM");
// next name for us, or return true if there are no more records.
esm.getSubName();
const NAME &subName = esm.retSubName();
if (subName.val == REC_ONAM) // Since there's no way to mark selects as "deleted", we have to clear the SelectStructs from all previous loadings
{ mSelects.clear();
mActor = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_RNAM)
{
mRace = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_CNAM)
{
mClass = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_FNAM) // If the info is deleted, NAME and DELE sub-records are followed after NNAM
{ if (esm.isNextSub("NAME"))
mFaction = esm.getHString(); {
if (mFaction == "FFFF") mResponse = esm.getHString();
mFactionLess = true; mIsDeleted = readDeleSubRecord(esm);
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_ANAM)
{
mCell = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_DNAM)
{
mPcFaction = esm.getHString();
if (esm.isEmptyOrGetName())
return; return;
} }
if (subName.val == REC_SNAM)
{
mSound = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_NAME)
{
mResponse = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
while (subName.val == REC_SCVR) esm.getSubNameIs("DATA");
{ esm.getHT(mData, 12);
SelectStruct ss;
ss.mSelectRule = esm.getHString();
ss.mValue.read (esm, Variant::Format_Info);
mSelects.push_back(ss);
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_BNAM) if (!esm.hasMoreSubs())
{
mResultScript = esm.getHString();
if (esm.isEmptyOrGetName())
return; return;
}
if (subName.val == REC_QSTN) // What follows is somewhat spaghetti-ish, but it's worth if for
mQuestStatus = QS_Name; // an extra speedup. INFO is by far the most common record type.
else if (subName.val == REC_QSTF)
mQuestStatus = QS_Finished; // subName is a reference to the original, so it changes whenever
else if (subName.val == REC_QSTR) // a new sub name is read. esm.isEmptyOrGetName() will get the
mQuestStatus = QS_Restart; // next name for us, or return true if there are no more records.
else if (subName.val == REC_DELE) esm.getSubName();
mQuestStatus = QS_Deleted; const NAME &subName = esm.retSubName();
else
esm.fail( if (subName.val == REC_ONAM)
"Don't know what to do with " + subName.toString() {
+ " in INFO " + mId); mActor = esm.getHString();
if (esm.isEmptyOrGetName())
if (mQuestStatus != QS_None) return;
// Skip rest of record }
esm.skipRecord(); if (subName.val == REC_RNAM)
} {
mRace = esm.getHString();
void DialInfo::save(ESMWriter &esm) const if (esm.isEmptyOrGetName())
{ return;
esm.writeHNCString("PNAM", mPrev); }
esm.writeHNCString("NNAM", mNext); if (subName.val == REC_CNAM)
if (mIsDeleted) {
{ mClass = esm.getHString();
esm.writeHNCString("NAME", mResponse); if (esm.isEmptyOrGetName())
writeDeleSubRecord(esm); return;
return; }
if (subName.val == REC_FNAM)
{
mFaction = esm.getHString();
if (mFaction == "FFFF")
mFactionLess = true;
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_ANAM)
{
mCell = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_DNAM)
{
mPcFaction = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_SNAM)
{
mSound = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_NAME)
{
mResponse = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
while (subName.val == REC_SCVR)
{
SelectStruct ss;
ss.mSelectRule = esm.getHString();
ss.mValue.read (esm, Variant::Format_Info);
mSelects.push_back(ss);
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_BNAM)
{
mResultScript = esm.getHString();
if (esm.isEmptyOrGetName())
return;
}
if (subName.val == REC_QSTN)
mQuestStatus = QS_Name;
else if (subName.val == REC_QSTF)
mQuestStatus = QS_Finished;
else if (subName.val == REC_QSTR)
mQuestStatus = QS_Restart;
else if (subName.val == REC_DELE)
mQuestStatus = QS_Deleted;
else
esm.fail(
"Don't know what to do with " + subName.toString()
+ " in INFO " + mId);
if (mQuestStatus != QS_None)
// Skip rest of record
esm.skipRecord();
} }
esm.writeHNT("DATA", mData, 12); void DialInfo::save(ESMWriter &esm) const
esm.writeHNOCString("ONAM", mActor);
esm.writeHNOCString("RNAM", mRace);
esm.writeHNOCString("CNAM", mClass);
esm.writeHNOCString("FNAM", mFaction);
esm.writeHNOCString("ANAM", mCell);
esm.writeHNOCString("DNAM", mPcFaction);
esm.writeHNOCString("SNAM", mSound);
esm.writeHNOString("NAME", mResponse);
for (std::vector<SelectStruct>::const_iterator it = mSelects.begin(); it != mSelects.end(); ++it)
{ {
esm.writeHNString("SCVR", it->mSelectRule); esm.writeHNCString("PNAM", mPrev);
it->mValue.write (esm, Variant::Format_Info); esm.writeHNCString("NNAM", mNext);
} if (mIsDeleted)
{
esm.writeHNOString("BNAM", mResultScript); esm.writeHNCString("NAME", mResponse);
writeDeleSubRecord(esm);
switch(mQuestStatus) return;
{ }
case QS_Name: esm.writeHNT("QSTN",'\1'); break;
case QS_Finished: esm.writeHNT("QSTF", '\1'); break; esm.writeHNT("DATA", mData, 12);
case QS_Restart: esm.writeHNT("QSTR", '\1'); break; esm.writeHNOCString("ONAM", mActor);
case QS_Deleted: esm.writeHNT("DELE", '\1'); break; esm.writeHNOCString("RNAM", mRace);
default: break; esm.writeHNOCString("CNAM", mClass);
esm.writeHNOCString("FNAM", mFaction);
esm.writeHNOCString("ANAM", mCell);
esm.writeHNOCString("DNAM", mPcFaction);
esm.writeHNOCString("SNAM", mSound);
esm.writeHNOString("NAME", mResponse);
for (std::vector<SelectStruct>::const_iterator it = mSelects.begin(); it != mSelects.end(); ++it)
{
esm.writeHNString("SCVR", it->mSelectRule);
it->mValue.write (esm, Variant::Format_Info);
}
esm.writeHNOString("BNAM", mResultScript);
switch(mQuestStatus)
{
case QS_Name: esm.writeHNT("QSTN",'\1'); break;
case QS_Finished: esm.writeHNT("QSTF", '\1'); break;
case QS_Restart: esm.writeHNT("QSTR", '\1'); break;
case QS_Deleted: esm.writeHNT("DELE", '\1'); break;
default: break;
}
} }
}
void DialInfo::blank() void DialInfo::blank()
{ {

@ -108,6 +108,8 @@ struct DialInfo
bool mIsDeleted; bool mIsDeleted;
DialInfo();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Ingredient::sRecordId = REC_INGR; unsigned int Ingredient::sRecordId = REC_INGR;
Ingredient::Ingredient()
: mIsDeleted(false)
{}
void Ingredient::load(ESMReader &esm) void Ingredient::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -33,6 +33,8 @@ struct Ingredient
bool mIsDeleted; bool mIsDeleted;
Ingredient();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -7,6 +7,9 @@
namespace ESM namespace ESM
{ {
LevelledListBase::LevelledListBase()
: mIsDeleted(false)
{}
void LevelledListBase::load(ESMReader &esm) void LevelledListBase::load(ESMReader &esm)
{ {

@ -38,6 +38,8 @@ struct LevelledListBase
bool mIsDeleted; bool mIsDeleted;
LevelledListBase();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Light::sRecordId = REC_LIGH; unsigned int Light::sRecordId = REC_LIGH;
Light::Light()
: mIsDeleted(false)
{}
void Light::load(ESMReader &esm) void Light::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -49,6 +49,8 @@ struct Light
bool mIsDeleted; bool mIsDeleted;
Light();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Lockpick::sRecordId = REC_LOCK; unsigned int Lockpick::sRecordId = REC_LOCK;
Lockpick::Lockpick()
: mIsDeleted(false)
{}
void Lockpick::load(ESMReader &esm) void Lockpick::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -29,6 +29,8 @@ struct Lockpick
bool mIsDeleted; bool mIsDeleted;
Lockpick();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,29 +9,32 @@ namespace ESM
{ {
unsigned int LandTexture::sRecordId = REC_LTEX; unsigned int LandTexture::sRecordId = REC_LTEX;
void LandTexture::load(ESMReader &esm) LandTexture::LandTexture()
{ : mIsDeleted(false)
mIsDeleted = readDeleSubRecord(esm); {}
mId = esm.getHNString("NAME");
esm.getHNT(mIndex, "INTV"); void LandTexture::load(ESMReader &esm)
mTexture = esm.getHNString("DATA");
}
void LandTexture::save(ESMWriter &esm) const
{
if (mIsDeleted)
{ {
writeDeleSubRecord(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);
} }
esm.writeHNCString("NAME", mId);
esm.writeHNT("INTV", mIndex);
esm.writeHNCString("DATA", mTexture);
}
void LandTexture::blank()
{
mTexture.clear();
mIndex = -1;
mIsDeleted = false;
}
void LandTexture::blank()
{
mTexture.clear();
mIndex = -1;
mIsDeleted = false;
}
} }

@ -36,11 +36,13 @@ struct LandTexture
bool mIsDeleted; bool mIsDeleted;
void blank(); LandTexture();
///< Set record to default state (does not touch the ID).
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;
void blank();
///< Set record to default state (does not touch the ID).
}; };
} }
#endif #endif

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Miscellaneous::sRecordId = REC_MISC; unsigned int Miscellaneous::sRecordId = REC_MISC;
Miscellaneous::Miscellaneous()
: mIsDeleted(false)
{}
void Miscellaneous::load(ESMReader &esm) void Miscellaneous::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -34,6 +34,8 @@ struct Miscellaneous
bool mIsDeleted; bool mIsDeleted;
Miscellaneous();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int NPC::sRecordId = REC_NPC_; unsigned int NPC::sRecordId = REC_NPC_;
NPC::NPC()
: mIsDeleted(false)
{}
void NPC::load(ESMReader &esm) void NPC::load(ESMReader &esm)
{ {
mPersistent = (esm.getRecordFlags() & 0x0400) != 0; mPersistent = (esm.getRecordFlags() & 0x0400) != 0;

@ -132,6 +132,8 @@ struct NPC
bool mIsDeleted; bool mIsDeleted;
NPC();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Probe::sRecordId = REC_PROB; unsigned int Probe::sRecordId = REC_PROB;
Probe::Probe()
: mIsDeleted(false)
{}
void Probe::load(ESMReader &esm) void Probe::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -29,6 +29,8 @@ struct Probe
bool mIsDeleted; bool mIsDeleted;
Probe();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,69 +9,74 @@ namespace ESM
{ {
unsigned int Region::sRecordId = REC_REGN; unsigned int Region::sRecordId = REC_REGN;
void Region::load(ESMReader &esm) Region::Region()
{ : mIsDeleted(false)
mIsDeleted = readDeleSubRecord(esm); {}
mId = esm.getHNString("NAME");
mName = esm.getHNOString("FNAM");
esm.getSubNameIs("WEAT"); void Region::load(ESMReader &esm)
esm.getSubHeader();
if (esm.getVer() == VER_12)
{
mData.mA = 0;
mData.mB = 0;
esm.getExact(&mData, sizeof(mData) - 2);
}
else if (esm.getVer() == VER_13)
{ {
// May include the additional two bytes (but not necessarily) mIsDeleted = readDeleSubRecord(esm);
if (esm.getSubSize() == sizeof(mData)) mId = esm.getHNString("NAME");
esm.getExact(&mData, sizeof(mData)); mName = esm.getHNOString("FNAM");
else
esm.getSubNameIs("WEAT");
esm.getSubHeader();
if (esm.getVer() == VER_12)
{ {
mData.mA = 0; mData.mA = 0;
mData.mB = 0; mData.mB = 0;
esm.getExact(&mData, sizeof(mData)-2); esm.getExact(&mData, sizeof(mData) - 2);
} }
} else if (esm.getVer() == VER_13)
else {
esm.fail("Don't know what to do in this version"); // May include the additional two bytes (but not necessarily)
if (esm.getSubSize() == sizeof(mData))
esm.getExact(&mData, sizeof(mData));
else
{
mData.mA = 0;
mData.mB = 0;
esm.getExact(&mData, sizeof(mData)-2);
}
}
else
esm.fail("Don't know what to do in this version");
mSleepList = esm.getHNOString("BNAM"); mSleepList = esm.getHNOString("BNAM");
esm.getHNT(mMapColor, "CNAM"); esm.getHNT(mMapColor, "CNAM");
mSoundList.clear(); mSoundList.clear();
while (esm.hasMoreSubs()) while (esm.hasMoreSubs())
{ {
SoundRef sr; SoundRef sr;
esm.getHNT(sr, "SNAM", 33); esm.getHNT(sr, "SNAM", 33);
mSoundList.push_back(sr); mSoundList.push_back(sr);
}
} }
}
void Region::save(ESMWriter &esm) const void Region::save(ESMWriter &esm) const
{
if (mIsDeleted)
{ {
writeDeleSubRecord(esm); if (mIsDeleted)
} {
esm.writeHNString("NAME", mId); writeDeleSubRecord(esm);
esm.writeHNOCString("FNAM", mName); }
esm.writeHNString("NAME", mId);
esm.writeHNOCString("FNAM", mName);
if (esm.getVersion() == VER_12) if (esm.getVersion() == VER_12)
esm.writeHNT("WEAT", mData, sizeof(mData) - 2); esm.writeHNT("WEAT", mData, sizeof(mData) - 2);
else else
esm.writeHNT("WEAT", mData); esm.writeHNT("WEAT", mData);
esm.writeHNOCString("BNAM", mSleepList); esm.writeHNOCString("BNAM", mSleepList);
esm.writeHNT("CNAM", mMapColor); esm.writeHNT("CNAM", mMapColor);
for (std::vector<SoundRef>::const_iterator it = mSoundList.begin(); it != mSoundList.end(); ++it) for (std::vector<SoundRef>::const_iterator it = mSoundList.begin(); it != mSoundList.end(); ++it)
{ {
esm.writeHNT<SoundRef>("SNAM", *it); esm.writeHNT<SoundRef>("SNAM", *it);
}
} }
}
void Region::blank() void Region::blank()
{ {

@ -53,6 +53,8 @@ struct Region
bool mIsDeleted; bool mIsDeleted;
Region();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,61 +9,65 @@ namespace ESM
{ {
unsigned int Repair::sRecordId = REC_REPA; unsigned int Repair::sRecordId = REC_REPA;
void Repair::load(ESMReader &esm) Repair::Repair()
{ : mIsDeleted(false)
mId = esm.getHNString("NAME"); {}
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
bool hasData = true; void Repair::load(ESMReader &esm)
while (esm.hasMoreSubs())
{ {
esm.getSubName(); mId = esm.getHNString("NAME");
uint32_t name = esm.retSubName().val; if (mIsDeleted = readDeleSubRecord(esm))
switch (name)
{ {
case ESM::FourCC<'M','O','D','L'>::value: return;
mModel = esm.getHString();
break;
case ESM::FourCC<'F','N','A','M'>::value:
mName = esm.getHString();
break;
case ESM::FourCC<'R','I','D','T'>::value:
esm.getHT(mData, 16);
hasData = true;
break;
case ESM::FourCC<'S','C','R','I'>::value:
mScript = esm.getHString();
break;
case ESM::FourCC<'I','T','E','X'>::value:
mIcon = esm.getHString();
break;
default:
esm.fail("Unknown subrecord");
} }
bool hasData = true;
while (esm.hasMoreSubs())
{
esm.getSubName();
uint32_t name = esm.retSubName().val;
switch (name)
{
case ESM::FourCC<'M','O','D','L'>::value:
mModel = esm.getHString();
break;
case ESM::FourCC<'F','N','A','M'>::value:
mName = esm.getHString();
break;
case ESM::FourCC<'R','I','D','T'>::value:
esm.getHT(mData, 16);
hasData = true;
break;
case ESM::FourCC<'S','C','R','I'>::value:
mScript = esm.getHString();
break;
case ESM::FourCC<'I','T','E','X'>::value:
mIcon = esm.getHString();
break;
default:
esm.fail("Unknown subrecord");
}
}
if (!hasData)
esm.fail("Missing RIDT subrecord");
} }
if (!hasData)
esm.fail("Missing RIDT subrecord");
}
void Repair::save(ESMWriter &esm) const void Repair::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{ {
writeDeleSubRecord(esm); esm.writeHNCString("NAME", mId);
return; if (mIsDeleted)
} {
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNT("RIDT", mData, 16); esm.writeHNT("RIDT", mData, 16);
esm.writeHNOString("SCRI", mScript); esm.writeHNOString("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
} }
void Repair::blank() void Repair::blank()
{ {

@ -29,6 +29,8 @@ struct Repair
bool mIsDeleted; bool mIsDeleted;
Repair();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,9 +9,12 @@
namespace ESM namespace ESM
{ {
unsigned int Script::sRecordId = REC_SCPT; unsigned int Script::sRecordId = REC_SCPT;
Script::Script()
: mIsDeleted(false)
{}
void Script::loadSCVR(ESMReader &esm) void Script::loadSCVR(ESMReader &esm)
{ {
int s = mData.mStringTableSize; int s = mData.mStringTableSize;

@ -52,6 +52,8 @@ public:
bool mIsDeleted; bool mIsDeleted;
Script();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int SoundGenerator::sRecordId = REC_SNDG; unsigned int SoundGenerator::sRecordId = REC_SNDG;
SoundGenerator::SoundGenerator()
: mIsDeleted(false)
{}
void SoundGenerator::load(ESMReader &esm) void SoundGenerator::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -38,6 +38,8 @@ struct SoundGenerator
bool mIsDeleted; bool mIsDeleted;
SoundGenerator();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Sound::sRecordId = REC_SOUN; unsigned int Sound::sRecordId = REC_SOUN;
Sound::Sound()
: mIsDeleted(false)
{}
void Sound::load(ESMReader &esm) void Sound::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -25,6 +25,8 @@ struct Sound
bool mIsDeleted; bool mIsDeleted;
Sound();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Spell::sRecordId = REC_SPEL; unsigned int Spell::sRecordId = REC_SPEL;
Spell::Spell()
: mIsDeleted(false)
{}
void Spell::load(ESMReader &esm) void Spell::load(ESMReader &esm)
{ {
mEffects.mList.clear(); mEffects.mList.clear();

@ -47,6 +47,8 @@ struct Spell
bool mIsDeleted; bool mIsDeleted;
Spell();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Static::sRecordId = REC_STAT; unsigned int Static::sRecordId = REC_STAT;
Static::Static()
: mIsDeleted(false)
{}
void Static::load(ESMReader &esm) void Static::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -30,6 +30,8 @@ struct Static
bool mIsDeleted; bool mIsDeleted;
Static();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

@ -9,6 +9,10 @@ namespace ESM
{ {
unsigned int Weapon::sRecordId = REC_WEAP; unsigned int Weapon::sRecordId = REC_WEAP;
Weapon::Weapon()
: mIsDeleted(false)
{}
void Weapon::load(ESMReader &esm) void Weapon::load(ESMReader &esm)
{ {
mId = esm.getHNString("NAME"); mId = esm.getHNString("NAME");

@ -71,6 +71,8 @@ struct Weapon
bool mIsDeleted; bool mIsDeleted;
Weapon();
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm) const; void save(ESMWriter &esm) const;

Loading…
Cancel
Save