Merge branch 'fix-7335-bis' into 'master'

OpenCS fixes the issues with the addon's saving

See merge request OpenMW/openmw!2952
simplify_debugging
psi29a 2 years ago
commit 67c0138aee

@ -256,13 +256,20 @@ void CSMDoc::CollectionReferencesStage::perform(int stage, Messages& messages)
if (record.isModified() || record.mState == CSMWorld::RecordBase::State_Deleted)
{
const ESM::RefId cellId
= record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell;
ESM::RefId cellId = record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell;
std::deque<int>& indices = mState.getOrInsertSubRecord(cellId);
// collect moved references at the end of the container
const bool interior = !cellId.is<ESM::ESM3ExteriorCellRefId>();
const bool interior = !cellId.startsWith("#");
std::ostringstream stream;
if (!interior)
{
// recalculate the ref's cell location
std::pair<int, int> index = record.get().getCellIndex();
cellId = ESM::RefId::stringRefId(ESM::RefId::esm3ExteriorCell(index.first, index.second).toString());
}
// 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.
@ -351,7 +358,7 @@ void CSMDoc::WriteCellCollectionStage::perform(int stage, Messages& messages)
std::deque<int> tempRefs;
std::deque<int> persistentRefs;
const std::deque<int>* references = mState.findSubRecord(static_cast<ESM::Cell>(cell.get()).mId);
const std::deque<int>* references = mState.findSubRecord(cell.get().mId);
if (cell.isModified() || cell.mState == CSMWorld::RecordBase::State_Deleted || references != nullptr)
{

@ -73,7 +73,7 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b
// Autocalculate the cell index from coordinates first
std::pair<int, int> index = ref.getCellIndex();
ref.mCell = ESM::RefId::esm3ExteriorCell(index.first, index.second);
ref.mCell = ESM::RefId::stringRefId(ESM::RefId::esm3ExteriorCell(index.first, index.second).toString());
// Handle non-base moved references
if (!base && isMoved)
@ -89,7 +89,8 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b
if (index.first != mref.mTarget[0] || index.second != mref.mTarget[1])
{
ESM::RefId indexCell = ref.mCell;
ref.mCell = ESM::RefId::esm3ExteriorCell(mref.mTarget[0], mref.mTarget[1]);
ref.mCell = ESM::RefId::stringRefId(
ESM::RefId::esm3ExteriorCell(mref.mTarget[0], mref.mTarget[1]).toString());
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Cell, mCells.getId(cellIndex));
messages.add(id, "The position of the moved reference " + ref.mRefID.toDebugString() + " (cell " + indexCell.toDebugString() + ")"

Loading…
Cancel
Save