1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-04 03:40:14 +00:00

fixes integration tests

we still want to be able to write using old formats
This commit is contained in:
florent.teppe 2023-03-01 17:27:35 +01:00
parent f99e65843a
commit 1e0c3bfdec
2 changed files with 9 additions and 2 deletions

View File

@ -793,12 +793,12 @@ namespace MWWorld
} }
ESM::Cell* Store<ESM::Cell>::insert(const ESM::Cell& cell) ESM::Cell* Store<ESM::Cell>::insert(const ESM::Cell& cell)
{ {
ESM::Cell* insertedCell = &mCells.emplace(cell.mId, cell).first->second;
if (search(cell) != nullptr) if (search(cell) != nullptr)
{ {
const std::string cellType = (cell.isExterior()) ? "exterior" : "interior"; const std::string cellType = (cell.isExterior()) ? "exterior" : "interior";
throw std::runtime_error("Failed to create " + cellType + " cell"); throw std::runtime_error("Failed to create " + cellType + " cell");
} }
ESM::Cell* insertedCell = &mCells.emplace(cell.mId, cell).first->second;
if (cell.isExterior()) if (cell.isExterior())
{ {
std::pair<int, int> key(cell.getGridX(), cell.getGridY()); std::pair<int, int> key(cell.getGridX(), cell.getGridY());

View File

@ -4,6 +4,7 @@
#include <fstream> #include <fstream>
#include <stdexcept> #include <stdexcept>
#include <components/esm3/cellid.hpp>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/misc/notnullptr.hpp> #include <components/misc/notnullptr.hpp>
#include <components/to_utf8/to_utf8.hpp> #include <components/to_utf8/to_utf8.hpp>
@ -238,7 +239,13 @@ namespace ESM
void ESMWriter::writeCellId(const ESM::RefId& cellId) 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) void ESMWriter::writeMaybeFixedSizeString(const std::string& data, std::size_t size)