Handle deleted records in RefCollection

openmw-38
Stanislav Bas 10 years ago
parent e8a9567be3
commit 3ba73f5fd9

@ -20,12 +20,10 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
Cell& cell2 = base ? cell.mBase : cell.mModified; Cell& cell2 = base ? cell.mBase : cell.mModified;
CellRef ref; CellRef ref;
bool deleted = false;
ESM::MovedCellRef mref; ESM::MovedCellRef mref;
// hack to initialise mindex // hack to initialise mindex
while (!(mref.mRefNum.mIndex = 0) && ESM::Cell::getNextRef(reader, ref, deleted, true, &mref)) while (!(mref.mRefNum.mIndex = 0) && ESM::Cell::getNextRef(reader, ref, true, &mref))
{ {
// Keep mOriginalCell empty when in modified (as an indicator that the // Keep mOriginalCell empty when in modified (as an indicator that the
// original cell will always be equal the current cell). // original cell will always be equal the current cell).
@ -50,17 +48,6 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
// https://forum.openmw.org/viewtopic.php?f=6&t=577&start=30 // https://forum.openmw.org/viewtopic.php?f=6&t=577&start=30
ref.mOriginalCell = cell2.mId; ref.mOriginalCell = cell2.mId;
if (deleted)
{
// FIXME: how to mark the record deleted?
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Cell,
mCells.getId (cellIndex));
messages.add (id, "Moved reference "+ref.mRefID+" is in DELE state");
continue;
}
// It is not always possibe to ignore moved references sub-record and // It is not always possibe to ignore moved references sub-record and
// calculate from coordinates. Some mods may place the ref in positions // calculate from coordinates. Some mods may place the ref in positions
// outside normal bounds, resulting in non sensical cell id's. This often // outside normal bounds, resulting in non sensical cell id's. This often
@ -92,7 +79,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
break; break;
} }
if (deleted) if (ref.mIsDeleted)
{ {
if (iter==cache.end()) if (iter==cache.end())
{ {
@ -100,7 +87,6 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
mCells.getId (cellIndex)); mCells.getId (cellIndex));
messages.add (id, "Attempt to delete a non-existing reference"); messages.add (id, "Attempt to delete a non-existing reference");
continue; continue;
} }
@ -108,7 +94,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
Record<CellRef> record = getRecord (index); Record<CellRef> record = getRecord (index);
if (record.mState==RecordBase::State_BaseOnly) if (base)
{ {
removeRows (index, 1); removeRows (index, 1);
cache.erase (iter); cache.erase (iter);

Loading…
Cancel
Save