From 1e0c3bfdec40f84d8f7a73c9b54f9cb72609b550 Mon Sep 17 00:00:00 2001 From: "florent.teppe" Date: Wed, 1 Mar 2023 17:27:35 +0100 Subject: [PATCH] fixes integration tests we still want to be able to write using old formats --- apps/openmw/mwworld/store.cpp | 2 +- components/esm3/esmwriter.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 712ec95d1a..d12e53eefe 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -793,12 +793,12 @@ namespace MWWorld } ESM::Cell* Store::insert(const ESM::Cell& cell) { - ESM::Cell* insertedCell = &mCells.emplace(cell.mId, cell).first->second; if (search(cell) != nullptr) { const std::string cellType = (cell.isExterior()) ? "exterior" : "interior"; throw std::runtime_error("Failed to create " + cellType + " cell"); } + ESM::Cell* insertedCell = &mCells.emplace(cell.mId, cell).first->second; if (cell.isExterior()) { std::pair key(cell.getGridX(), cell.getGridY()); diff --git a/components/esm3/esmwriter.cpp b/components/esm3/esmwriter.cpp index af92a7bec9..6af0341a3b 100644 --- a/components/esm3/esmwriter.cpp +++ b/components/esm3/esmwriter.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -238,7 +239,13 @@ namespace ESM void ESMWriter::writeCellId(const ESM::RefId& cellId) { - writeHNRefId("NAME", cellId); + if (mHeader.mFormatVersion <= ESM::MaxUseEsmCellId) + { + ESM::CellId generatedCellid = ESM::CellId::extractFromRefId(cellId); + generatedCellid.save(*this); + } + else + writeHNRefId("NAME", cellId); } void ESMWriter::writeMaybeFixedSizeString(const std::string& data, std::size_t size)