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;
Activator::Activator()
: mIsDeleted(false)
{}
void Activator::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");

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

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

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

@ -9,60 +9,64 @@ namespace ESM
{
unsigned int Apparatus::sRecordId = REC_APPA;
void Apparatus::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
Apparatus::Apparatus()
: mIsDeleted(false)
{}
bool hasData = false;
while (esm.hasMoreSubs())
void Apparatus::load(ESMReader &esm)
{
esm.getSubName();
uint32_t name = esm.retSubName().val;
switch (name)
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
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");
return;
}
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
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
void Apparatus::save(ESMWriter &esm) const
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNCString("FNAM", mName);
esm.writeHNT("AADT", mData, 16);
esm.writeHNOCString("SCRI", mScript);
esm.writeHNCString("ITEX", mIcon);
}
esm.writeHNCString("MODL", mModel);
esm.writeHNCString("FNAM", mName);
esm.writeHNT("AADT", mData, 16);
esm.writeHNOCString("SCRI", mScript);
esm.writeHNCString("ITEX", mIcon);
}
void Apparatus::blank()
{

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -13,125 +13,128 @@ namespace ESM
{
unsigned int Dialogue::sRecordId = REC_DIAL;
void Dialogue::load(ESMReader &esm)
{
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");
}
Dialogue::Dialogue()
: mIsDeleted(false)
{}
void Dialogue::save(ESMWriter &esm) const
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
void Dialogue::load(ESMReader &esm)
{
esm.writeHNT("DATA", static_cast<int32_t>(0));
writeDeleSubRecord(esm);
}
else
{
esm.writeHNT("DATA", mType);
}
}
void Dialogue::blank()
{
mInfo.clear();
}
void Dialogue::readInfo(ESMReader &esm, bool merge)
{
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;
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");
}
ESM::Dialogue::InfoContainer::iterator it = mInfo.end();
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
void Dialogue::save(ESMWriter &esm) const
{
info.mId = id;
info.load(esm);
esm.writeHNCString("NAME", mId);
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);
return;
}
if (info.mPrev.empty())
{
mLookup[id] = mInfo.insert(mInfo.begin(), info);
return;
mInfo.clear();
}
lookup = mLookup.find(info.mPrev);
if (lookup != mLookup.end())
void Dialogue::readInfo(ESMReader &esm, bool merge)
{
it = lookup->second;
const std::string& id = esm.getHNOString("INAM");
mLookup[id] = mInfo.insert(++it, info);
return;
}
if (!merge || mInfo.empty())
{
ESM::DialInfo info;
info.mId = id;
info.load(esm);
mLookup[id] = mInfo.insert(mInfo.end(), info);
return;
}
lookup = mLookup.find(info.mNext);
if (lookup != mLookup.end())
{
it = lookup->second;
ESM::Dialogue::InfoContainer::iterator it = mInfo.end();
mLookup[id] = mInfo.insert(it, info);
return;
}
std::map<std::string, ESM::Dialogue::InfoContainer::iterator>::iterator lookup;
std::cerr << "Failed to insert info " << id << std::endl;
}
lookup = mLookup.find(id);
void Dialogue::clearDeletedInfos()
{
for (InfoContainer::iterator it = mInfo.begin(); it != mInfo.end(); )
{
if (it->mQuestStatus == DialInfo::QS_Deleted)
it = mInfo.erase(it);
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
++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;
Dialogue();
void load(ESMReader &esm);
void save(ESMWriter &esm) const;

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

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

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

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

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

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

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

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

@ -9,169 +9,173 @@ namespace ESM
{
unsigned int DialInfo::sRecordId = REC_INFO;
void DialInfo::load(ESMReader &esm)
{
mQuestStatus = QS_None;
mFactionLess = false;
mPrev = esm.getHNString("PNAM");
mNext = esm.getHNString("NNAM");
DialInfo::DialInfo()
: mIsDeleted(false)
{}
// Since there's no way to mark selects as "deleted", we have to clear the SelectStructs from all previous loadings
mSelects.clear();
// If the info is deleted, NAME and DELE sub-records are followed after NNAM
if (esm.isNextSub("NAME"))
void DialInfo::load(ESMReader &esm)
{
mResponse = esm.getHString();
mIsDeleted = readDeleSubRecord(esm);
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.
mQuestStatus = QS_None;
mFactionLess = false;
// subName is a reference to the original, so it changes whenever
// a new sub name is read. esm.isEmptyOrGetName() will get the
// next name for us, or return true if there are no more records.
esm.getSubName();
const NAME &subName = esm.retSubName();
mPrev = esm.getHNString("PNAM");
mNext = esm.getHNString("NNAM");
if (subName.val == REC_ONAM)
{
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;
}
// Since there's no way to mark selects as "deleted", we have to clear the SelectStructs from all previous loadings
mSelects.clear();
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())
// If the info is deleted, NAME and DELE sub-records are followed after NNAM
if (esm.isNextSub("NAME"))
{
mResponse = esm.getHString();
mIsDeleted = readDeleSubRecord(esm);
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;
}
esm.getSubNameIs("DATA");
esm.getHT(mData, 12);
if (subName.val == REC_BNAM)
{
mResultScript = esm.getHString();
if (esm.isEmptyOrGetName())
if (!esm.hasMoreSubs())
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();
}
void DialInfo::save(ESMWriter &esm) const
{
esm.writeHNCString("PNAM", mPrev);
esm.writeHNCString("NNAM", mNext);
if (mIsDeleted)
{
esm.writeHNCString("NAME", mResponse);
writeDeleSubRecord(esm);
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
// a new sub name is read. esm.isEmptyOrGetName() will get the
// 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)
{
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)
{
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);
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)
void DialInfo::save(ESMWriter &esm) const
{
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;
esm.writeHNCString("PNAM", mPrev);
esm.writeHNCString("NNAM", mNext);
if (mIsDeleted)
{
esm.writeHNCString("NAME", mResponse);
writeDeleSubRecord(esm);
return;
}
esm.writeHNT("DATA", mData, 12);
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);
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()
{

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

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

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

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

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

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

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

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

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

@ -9,29 +9,32 @@ namespace ESM
{
unsigned int LandTexture::sRecordId = REC_LTEX;
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)
LandTexture::LandTexture()
: mIsDeleted(false)
{}
void LandTexture::load(ESMReader &esm)
{
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;
void blank();
///< Set record to default state (does not touch the ID).
LandTexture();
void load(ESMReader &esm);
void save(ESMWriter &esm) const;
void blank();
///< Set record to default state (does not touch the ID).
};
}
#endif

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

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

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

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

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

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

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

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

@ -9,61 +9,65 @@ namespace ESM
{
unsigned int Repair::sRecordId = REC_REPA;
void Repair::load(ESMReader &esm)
{
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
return;
}
Repair::Repair()
: mIsDeleted(false)
{}
bool hasData = true;
while (esm.hasMoreSubs())
void Repair::load(ESMReader &esm)
{
esm.getSubName();
uint32_t name = esm.retSubName().val;
switch (name)
mId = esm.getHNString("NAME");
if (mIsDeleted = readDeleSubRecord(esm))
{
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");
return;
}
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
{
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
void Repair::save(ESMWriter &esm) const
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("NAME", mId);
if (mIsDeleted)
{
writeDeleSubRecord(esm);
return;
}
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName);
esm.writeHNT("RIDT", mData, 16);
esm.writeHNOString("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon);
}
esm.writeHNT("RIDT", mData, 16);
esm.writeHNOString("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon);
}
void Repair::blank()
{

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save