Skip to content

Commit

Permalink
avoid creating move tags for instances that exist only in the current…
Browse files Browse the repository at this point in the history
…ly edited content file
  • Loading branch information
zinnschlag committed Apr 2, 2016
1 parent 1774f6d commit 8f699b5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/opencs/model/doc/savingstages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <components/misc/stringops.hpp>

#include "../world/infocollection.hpp"
#include "../world/cellcoordinates.hpp"

#include "document.hpp"
#include "savingstate.hpp"
Expand Down Expand Up @@ -238,7 +239,7 @@ void CSMDoc::CollectionReferencesStage::perform (int stage, Messages& messages)
// An empty mOriginalCell is meant to indicate that it is the same as
// the current cell. It is possible that a moved ref is moved again.
if ((record.get().mOriginalCell.empty() ?
record.get().mCell : record.get().mOriginalCell) != stream.str() && !interior)
record.get().mCell : record.get().mOriginalCell) != stream.str() && !interior && record.mState!=CSMWorld::RecordBase::State_ModifiedOnly && !record.get().mNew)
indices.push_back (i);
else
indices.push_front (i);
Expand Down Expand Up @@ -283,7 +284,10 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages)
const CSMWorld::Record<CSMWorld::CellRef>& ref =
mDocument.getData().getReferences().getRecord (*iter);

if (ref.get().mNew)
if (ref.get().mNew ||
(!interior && ref.mState==CSMWorld::RecordBase::State_ModifiedOnly &&
/// \todo consider worldspace
CSMWorld::CellCoordinates (ref.get().getCellIndex()).getId("")!=ref.get().mCell))
++cellRecord.mRefNumCounter;
}
}
Expand Down Expand Up @@ -325,7 +329,9 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages)
stream << "#" << index.first << " " << index.second;
}

if (refRecord.mNew)
if (refRecord.mNew ||
(!interior && ref.mState==CSMWorld::RecordBase::State_ModifiedOnly &&
refRecord.mCell!=stream.str()))
{
refRecord.mRefNum.mIndex = newRefNum++;
}
Expand Down

0 comments on commit 8f699b5

Please sign in to comment.