From 3bbf60373a0c9dd12ab152f33f532c55d051e350 Mon Sep 17 00:00:00 2001 From: "florent.teppe" Date: Wed, 19 Apr 2023 10:19:09 +0200 Subject: [PATCH] Keep things coherent between references and and cell table --- apps/opencs/model/world/cell.cpp | 8 +------- apps/opencs/model/world/columnimp.hpp | 2 +- apps/openmw_test_suite/esm/testrefid.cpp | 4 ++-- components/esm/esm3exteriorcellrefid.cpp | 7 ++++--- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/apps/opencs/model/world/cell.cpp b/apps/opencs/model/world/cell.cpp index f4b0084ef4..edf3b0d40c 100644 --- a/apps/opencs/model/world/cell.cpp +++ b/apps/opencs/model/world/cell.cpp @@ -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()); } diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index ad84520b37..6ce7b96815 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -869,7 +869,7 @@ namespace CSMWorld QVariant get(const Record& record) const override { - return QString::fromUtf8(record.get().mCell.serializeText().c_str()); + return QString::fromUtf8(record.get().mCell.toString().c_str()); } void set(Record& record, const QVariant& data) override diff --git a/apps/openmw_test_suite/esm/testrefid.cpp b/apps/openmw_test_suite/esm/testrefid.cpp index 763484867a..6f50b465ef 100644 --- a/apps/openmw_test_suite/esm/testrefid.cpp +++ b/apps/openmw_test_suite/esm/testrefid.cpp @@ -256,9 +256,9 @@ namespace ESM { RefId::index(REC_ARMO, 42), "ARMO:0x2a" }, { RefId::esm3ExteriorCell(-13, 42), "-13:42" }, { RefId::esm3ExteriorCell(std::numeric_limits::min(), std::numeric_limits::min()), - "-2147483648:-2147483648" }, + "#2147483648 -2147483648" }, { RefId::esm3ExteriorCell(std::numeric_limits::max(), std::numeric_limits::max()), - "2147483647:2147483647" }, + "#2147483647 2147483647" }, }; INSTANTIATE_TEST_SUITE_P(ESMRefIdToString, ESMRefIdToStringTest, ValuesIn(toStringParams)); diff --git a/components/esm/esm3exteriorcellrefid.cpp b/components/esm/esm3exteriorcellrefid.cpp index 63373dd055..c5486f6671 100644 --- a/components/esm/esm3exteriorcellrefid.cpp +++ b/components/esm/esm3exteriorcellrefid.cpp @@ -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;