|
|
@ -10,29 +10,25 @@ namespace ESM
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unsigned int Dialogue::sRecordId = REC_DIAL;
|
|
|
|
unsigned int Dialogue::sRecordId = REC_DIAL;
|
|
|
|
|
|
|
|
|
|
|
|
Dialogue::Dialogue()
|
|
|
|
void Dialogue::load(ESMReader &esm, bool &isDeleted)
|
|
|
|
: mIsDeleted(false)
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Dialogue::load(ESMReader &esm)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
loadId(esm);
|
|
|
|
loadId(esm);
|
|
|
|
loadData(esm);
|
|
|
|
loadData(esm, isDeleted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Dialogue::loadId(ESMReader &esm)
|
|
|
|
void Dialogue::loadId(ESMReader &esm)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mIsDeleted = false;
|
|
|
|
|
|
|
|
mId = esm.getHNString("NAME");
|
|
|
|
mId = esm.getHNString("NAME");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Dialogue::loadData(ESMReader &esm)
|
|
|
|
void Dialogue::loadData(ESMReader &esm, bool &isDeleted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
isDeleted = false;
|
|
|
|
|
|
|
|
|
|
|
|
while (esm.hasMoreSubs())
|
|
|
|
while (esm.hasMoreSubs())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
esm.getSubName();
|
|
|
|
esm.getSubName();
|
|
|
|
uint32_t name = esm.retSubName().val;
|
|
|
|
switch (esm.retSubName().val)
|
|
|
|
switch (name)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case ESM::FourCC<'D','A','T','A'>::value:
|
|
|
|
case ESM::FourCC<'D','A','T','A'>::value:
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -51,7 +47,7 @@ namespace ESM
|
|
|
|
case ESM::FourCC<'D','E','L','E'>::value:
|
|
|
|
case ESM::FourCC<'D','E','L','E'>::value:
|
|
|
|
esm.skipHSub();
|
|
|
|
esm.skipHSub();
|
|
|
|
mType = Unknown;
|
|
|
|
mType = Unknown;
|
|
|
|
mIsDeleted = true;
|
|
|
|
isDeleted = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
esm.fail("Unknown subrecord");
|
|
|
|
esm.fail("Unknown subrecord");
|
|
|
@ -60,10 +56,10 @@ namespace ESM
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Dialogue::save(ESMWriter &esm) const
|
|
|
|
void Dialogue::save(ESMWriter &esm, bool isDeleted) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
esm.writeHNCString("NAME", mId);
|
|
|
|
esm.writeHNCString("NAME", mId);
|
|
|
|
if (mIsDeleted)
|
|
|
|
if (isDeleted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
esm.writeHNCString("DELE", "");
|
|
|
|
esm.writeHNCString("DELE", "");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -76,7 +72,6 @@ namespace ESM
|
|
|
|
void Dialogue::blank()
|
|
|
|
void Dialogue::blank()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mInfo.clear();
|
|
|
|
mInfo.clear();
|
|
|
|
mIsDeleted = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Dialogue::readInfo(ESMReader &esm, bool merge)
|
|
|
|
void Dialogue::readInfo(ESMReader &esm, bool merge)
|
|
|
@ -84,25 +79,27 @@ namespace ESM
|
|
|
|
ESM::DialInfo info;
|
|
|
|
ESM::DialInfo info;
|
|
|
|
info.loadId(esm);
|
|
|
|
info.loadId(esm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isDeleted = false;
|
|
|
|
if (!merge || mInfo.empty())
|
|
|
|
if (!merge || mInfo.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
info.loadInfo(esm);
|
|
|
|
info.loadData(esm, isDeleted);
|
|
|
|
mLookup[info.mId] = mInfo.insert(mInfo.end(), info);
|
|
|
|
mLookup[info.mId] = std::make_pair(mInfo.insert(mInfo.end(), info), isDeleted);
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ESM::Dialogue::InfoContainer::iterator it = mInfo.end();
|
|
|
|
InfoContainer::iterator it = mInfo.end();
|
|
|
|
|
|
|
|
|
|
|
|
std::map<std::string, ESM::Dialogue::InfoContainer::iterator>::iterator lookup;
|
|
|
|
LookupMap::iterator lookup;
|
|
|
|
lookup = mLookup.find(info.mId);
|
|
|
|
lookup = mLookup.find(info.mId);
|
|
|
|
|
|
|
|
|
|
|
|
if (lookup != mLookup.end())
|
|
|
|
if (lookup != mLookup.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
it = lookup->second;
|
|
|
|
it = lookup->second.first;
|
|
|
|
|
|
|
|
|
|
|
|
// Merge with existing record. Only the subrecords that are present in
|
|
|
|
// Merge with existing record. Only the subrecords that are present in
|
|
|
|
// the new record will be overwritten.
|
|
|
|
// the new record will be overwritten.
|
|
|
|
it->loadInfo(esm);
|
|
|
|
it->loadData(esm, isDeleted);
|
|
|
|
info = *it;
|
|
|
|
info = *it;
|
|
|
|
|
|
|
|
|
|
|
|
// Since the record merging may have changed the next/prev linked list connection, we need to re-insert the record
|
|
|
|
// Since the record merging may have changed the next/prev linked list connection, we need to re-insert the record
|
|
|
@ -111,35 +108,35 @@ namespace ESM
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
info.loadInfo(esm);
|
|
|
|
info.loadData(esm, isDeleted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (info.mNext.empty())
|
|
|
|
if (info.mNext.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mLookup[info.mId] = mInfo.insert(mInfo.end(), info);
|
|
|
|
mLookup[info.mId] = std::make_pair(mInfo.insert(mInfo.end(), info), isDeleted);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (info.mPrev.empty())
|
|
|
|
if (info.mPrev.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mLookup[info.mId] = mInfo.insert(mInfo.begin(), info);
|
|
|
|
mLookup[info.mId] = std::make_pair(mInfo.insert(mInfo.begin(), info), isDeleted);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lookup = mLookup.find(info.mPrev);
|
|
|
|
lookup = mLookup.find(info.mPrev);
|
|
|
|
if (lookup != mLookup.end())
|
|
|
|
if (lookup != mLookup.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
it = lookup->second;
|
|
|
|
it = lookup->second.first;
|
|
|
|
|
|
|
|
|
|
|
|
mLookup[info.mId] = mInfo.insert(++it, info);
|
|
|
|
mLookup[info.mId] = std::make_pair(mInfo.insert(++it, info), isDeleted);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lookup = mLookup.find(info.mNext);
|
|
|
|
lookup = mLookup.find(info.mNext);
|
|
|
|
if (lookup != mLookup.end())
|
|
|
|
if (lookup != mLookup.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
it = lookup->second;
|
|
|
|
it = lookup->second.first;
|
|
|
|
|
|
|
|
|
|
|
|
mLookup[info.mId] = mInfo.insert(it, info);
|
|
|
|
mLookup[info.mId] = std::make_pair(mInfo.insert(it, info), isDeleted);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -148,12 +145,15 @@ namespace ESM
|
|
|
|
|
|
|
|
|
|
|
|
void Dialogue::clearDeletedInfos()
|
|
|
|
void Dialogue::clearDeletedInfos()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (InfoContainer::iterator it = mInfo.begin(); it != mInfo.end(); )
|
|
|
|
LookupMap::const_iterator current = mLookup.begin();
|
|
|
|
|
|
|
|
LookupMap::const_iterator end = mLookup.end();
|
|
|
|
|
|
|
|
for (; current != end; ++current)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (it->mIsDeleted)
|
|
|
|
if (current->second.second)
|
|
|
|
it = mInfo.erase(it);
|
|
|
|
{
|
|
|
|
else
|
|
|
|
mInfo.erase(current->second.first);
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mLookup.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|