handle deleted records

pull/16/head
Marc Zinnschlag 12 years ago
parent c1cd8305bc
commit dd2b7d5c63

@ -321,32 +321,54 @@ namespace CSMWorld
{ {
std::string id = reader.getHNOString ("NAME"); std::string id = reader.getHNOString ("NAME");
/// \todo deal with deleted flag
ESXRecordT record;
record.mId = id;
record.load (reader);
int index = searchId (id); int index = searchId (id);
if (index==-1) if (reader.isNextSub ("DELE"))
{ {
// new record reader.skipRecord();
Record<ESXRecordT> record2;
record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
(base ? record2.mBase : record2.mModified) = record;
appendRecord (record2); if (index==-1)
{
// deleting a record that does not exist
// ignore it for now
/// \todo report the problem to the user
}
else if (base)
{
removeRows (index, 1);
}
else
{
mRecords[index].mState = RecordBase::State_Deleted;
}
} }
else else
{ {
// old record ESXRecordT record;
Record<ESXRecordT>& record2 = mRecords[index]; record.mId = id;
record.load (reader);
if (index==-1)
{
// new record
Record<ESXRecordT> record2;
record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
(base ? record2.mBase : record2.mModified) = record;
if (base) appendRecord (record2);
record2.mBase = record; }
else else
record2.setModified (record); {
// old record
Record<ESXRecordT>& record2 = mRecords[index];
if (base)
record2.mBase = record;
else
record2.setModified (record);
}
} }
} }

Loading…
Cancel
Save