mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +00:00
Merge branch 'fix-#7335' into 'master'
Fix issue #7335 Closes #7335 See merge request OpenMW/openmw!2940
This commit is contained in:
commit
0204cb51c0
@ -256,25 +256,17 @@ void CSMDoc::CollectionReferencesStage::perform(int stage, Messages& messages)
|
||||
|
||||
if (record.isModified() || record.mState == CSMWorld::RecordBase::State_Deleted)
|
||||
{
|
||||
const ESM::RefId& cellId
|
||||
const 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.startsWith("#");
|
||||
std::ostringstream stream;
|
||||
if (!interior)
|
||||
{
|
||||
// recalculate the ref's cell location
|
||||
std::pair<int, int> index = record.get().getCellIndex();
|
||||
stream << "#" << index.first << " " << index.second;
|
||||
}
|
||||
const bool interior = !cellId.is<ESM::ESM3ExteriorCellRefId>();
|
||||
|
||||
// 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)
|
||||
!= ESM::RefId::stringRefId(stream.str())
|
||||
if ((record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell) != cellId
|
||||
&& !interior && record.mState != CSMWorld::RecordBase::State_ModifiedOnly && !record.get().mNew)
|
||||
indices.push_back(i);
|
||||
else
|
||||
@ -359,7 +351,7 @@ void CSMDoc::WriteCellCollectionStage::perform(int stage, Messages& messages)
|
||||
std::deque<int> tempRefs;
|
||||
std::deque<int> persistentRefs;
|
||||
|
||||
const std::deque<int>* references = mState.findSubRecord(cell.get().mId);
|
||||
const std::deque<int>* references = mState.findSubRecord(static_cast<ESM::Cell>(cell.get()).mId);
|
||||
|
||||
if (cell.isModified() || cell.mState == CSMWorld::RecordBase::State_Deleted || references != nullptr)
|
||||
{
|
||||
|
@ -6,11 +6,5 @@ void CSMWorld::Cell::load(ESM::ESMReader& esm, bool& isDeleted)
|
||||
{
|
||||
ESM::Cell::load(esm, isDeleted, false);
|
||||
|
||||
mId = ESM::RefId::stringRefId(mName);
|
||||
if (isExterior())
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "#" << mData.mX << " " << mData.mY;
|
||||
mId = ESM::RefId::stringRefId(stream.str());
|
||||
}
|
||||
mId = ESM::RefId::stringRefId(ESM::Cell::mId.toString());
|
||||
}
|
||||
|
@ -869,7 +869,7 @@ namespace CSMWorld
|
||||
|
||||
QVariant get(const Record<ESXRecordT>& record) const override
|
||||
{
|
||||
return QString::fromUtf8(record.get().mCell.getRefIdString().c_str());
|
||||
return QString::fromUtf8(record.get().mCell.toString().c_str());
|
||||
}
|
||||
|
||||
void set(Record<ESXRecordT>& record, const QVariant& data) override
|
||||
|
@ -95,7 +95,7 @@ bool CSVRender::Cell::addObjects(int start, int end)
|
||||
|
||||
for (int i = start; i <= end; ++i)
|
||||
{
|
||||
const auto& cellId = collection.getRecord(i).get().mCell;
|
||||
const auto& cellId = ESM::RefId::stringRefId(collection.getRecord(i).get().mCell.toString());
|
||||
|
||||
CSMWorld::RecordBase::State state = collection.getRecord(i).mState;
|
||||
|
||||
|
@ -254,11 +254,11 @@ namespace ESM
|
||||
{ RefId::generated(42), "0x2a" },
|
||||
{ RefId::generated(std::numeric_limits<std::uint64_t>::max()), "0xffffffffffffffff" },
|
||||
{ RefId::index(REC_ARMO, 42), "ARMO:0x2a" },
|
||||
{ RefId::esm3ExteriorCell(-13, 42), "-13:42" },
|
||||
{ RefId::esm3ExteriorCell(-13, 42), "#-13 42" },
|
||||
{ RefId::esm3ExteriorCell(std::numeric_limits<int>::min(), std::numeric_limits<int>::min()),
|
||||
"-2147483648:-2147483648" },
|
||||
"#-2147483648 -2147483648" },
|
||||
{ RefId::esm3ExteriorCell(std::numeric_limits<int>::max(), std::numeric_limits<int>::max()),
|
||||
"2147483647:2147483647" },
|
||||
"#2147483647 2147483647" },
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(ESMRefIdToString, ESMRefIdToStringTest, ValuesIn(toStringParams));
|
||||
|
@ -11,9 +11,10 @@ namespace ESM
|
||||
{
|
||||
constexpr std::size_t separator = 1;
|
||||
std::string result;
|
||||
result.resize(getDecIntegralCapacity(mX) + separator + getDecIntegralCapacity(mY), '\0');
|
||||
const std::size_t endX = serializeDecIntegral(mX, 0, result);
|
||||
result[endX] = ':';
|
||||
result.resize(separator + getDecIntegralCapacity(mX) + separator + getDecIntegralCapacity(mY), '\0');
|
||||
result[0] = '#';
|
||||
const std::size_t endX = serializeDecIntegral(mX, separator, result);
|
||||
result[endX] = ' ';
|
||||
const std::size_t endY = serializeDecIntegral(mY, endX + separator, result);
|
||||
result.resize(endY);
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user