1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 23:15:43 +00:00

Handle deleted records in RefCollection

(cherry picked from commit 3ba73f5fd9)
This commit is contained in:
Stanislav Bas 2015-07-15 20:53:08 +03:00 committed by cc9cii
parent 3686c1e32d
commit 4e199697cc

View file

@ -19,12 +19,10 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
Cell& cell2 = base ? cell.mBase : cell.mModified;
CellRef ref;
bool deleted = false;
ESM::MovedCellRef mref;
// 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
// original cell will always be equal the current cell).
@ -49,17 +47,6 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
// https://forum.openmw.org/viewtopic.php?f=6&t=577&start=30
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
// calculate from coordinates. Some mods may place the ref in positions
// outside normal bounds, resulting in non sensical cell id's. This often
@ -91,7 +78,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
break;
}
if (deleted)
if (ref.mIsDeleted)
{
if (iter==cache.end())
{
@ -99,7 +86,6 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
mCells.getId (cellIndex));
messages.add (id, "Attempt to delete a non-existing reference");
continue;
}
@ -107,7 +93,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
Record<CellRef> record = getRecord (index);
if (record.mState==RecordBase::State_BaseOnly)
if (base)
{
removeRows (index, 1);
cache.erase (iter);