From 53b14c8b42d46d3300a609a65352a7a8f0c57770 Mon Sep 17 00:00:00 2001 From: "florent.teppe" Date: Sat, 25 Mar 2023 17:45:49 +0100 Subject: [PATCH] fix tests hopefully also fixes clang tidy --- apps/opencs/model/world/refcollection.cpp | 20 +++++++++++--------- components/esm3/cellid.cpp | 8 ++++++++ components/esm3/formatversion.hpp | 1 - 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/apps/opencs/model/world/refcollection.cpp b/apps/opencs/model/world/refcollection.cpp index a0bf5fb3b9..5d67900c10 100644 --- a/apps/opencs/model/world/refcollection.cpp +++ b/apps/opencs/model/world/refcollection.cpp @@ -53,14 +53,17 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b Cell& cell2 = base ? cell.mBase : cell.mModified; - CellRef ref; - ref.mNew = false; ESM::MovedCellRef mref; bool isDeleted = false; bool isMoved = false; - while (ESM::Cell::getNextRef(reader, ref, isDeleted, mref, isMoved)) + while (true) { + CellRef ref; + ref.mNew = false; + + if (!ESM::Cell::getNextRef(reader, ref, isDeleted, mref, isMoved)) + break; // Keep mOriginalCell empty when in modified (as an indicator that the // original cell will always be equal the current cell). ref.mOriginalCell = base ? cell2.mId : ESM::RefId(); @@ -70,7 +73,7 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b // Autocalculate the cell index from coordinates first std::pair index = ref.getCellIndex(); - ref.mCell = ESM::RefId::stringRefId("#" + std::to_string(index.first) + " " + std::to_string(index.second)); + ref.mCell = ESM::RefId::vec2i(index); // Handle non-base moved references if (!base && isMoved) @@ -86,12 +89,11 @@ 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::stringRefId( - "#" + std::to_string(mref.mTarget[0]) + " " + std::to_string(mref.mTarget[1])); + ref.mCell = ESM::RefId::vec2i({ mref.mTarget[0], mref.mTarget[1] }); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Cell, mCells.getId(cellIndex)); - messages.add(id, "The position of the moved reference " + ref.mRefID.getRefIdString() + " (cell " + indexCell.getRefIdString() + ")" - " does not match the target cell (" + ref.mCell.getRefIdString() + ")", + messages.add(id, "The position of the moved reference " + ref.mRefID.toDebugString() + " (cell " + indexCell.toDebugString() + ")" + " does not match the target cell (" + ref.mCell.toDebugString() + ")", std::string(), CSMDoc::Message::Severity_Warning); } } @@ -118,7 +120,7 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b messages.add(id, "Attempt to move a non-existent reference - RefNum index " + std::to_string(ref.mRefNum.mIndex) - + ", refID " + ref.mRefID.getRefIdString() + ", content file index " + + ", refID " + ref.mRefID.toDebugString() + ", content file index " + std::to_string(ref.mRefNum.mContentFile), /*hint*/ "", CSMDoc::Message::Severity_Warning); continue; diff --git a/components/esm3/cellid.cpp b/components/esm3/cellid.cpp index 517f6cd755..00a0b93ca4 100644 --- a/components/esm3/cellid.cpp +++ b/components/esm3/cellid.cpp @@ -34,6 +34,14 @@ namespace ESM struct VisitCellRefId { + CellId operator()(const ESM::EmptyRefId) + { + CellId out; + out.mPaged = true; + out.mIndex = {}; + return out; + } + CellId operator()(const ESM::StringRefId& id) { CellId out; diff --git a/components/esm3/formatversion.hpp b/components/esm3/formatversion.hpp index f273542458..bb34d2eb7c 100644 --- a/components/esm3/formatversion.hpp +++ b/components/esm3/formatversion.hpp @@ -25,7 +25,6 @@ namespace ESM inline constexpr FormatVersion MaxNameIsRefIdOnlyFormatVersion = 25; inline constexpr FormatVersion MaxUseEsmCellId = 26; inline constexpr FormatVersion CurrentSaveGameFormatVersion = 27; - } #endif