diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 16bc188e83..7fbbb0c695 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -1116,25 +1116,29 @@ namespace MWWorld ESM4::Cell* Store::insert(const ESM4::Cell& item, bool overrideOnly) { auto cellPtr = TypedDynamicStore::insert(item, overrideOnly); - if (!cellPtr->mEditorId.empty()) - mCellNameIndex[cellPtr->mEditorId] = cellPtr; - if (cellPtr->isExterior()) - { - mExteriors[{ cellPtr->mX, cellPtr->mY, cellPtr->mParent }] = cellPtr; - } - + insertCell(cellPtr); return cellPtr; } ESM4::Cell* Store::insertStatic(const ESM4::Cell& item) { auto cellPtr = TypedDynamicStore::insertStatic(item); + insertCell(cellPtr); + return cellPtr; + } + + void Store::insertCell(ESM4::Cell* cellPtr) + { if (!cellPtr->mEditorId.empty()) mCellNameIndex[cellPtr->mEditorId] = cellPtr; if (cellPtr->isExterior()) - mExteriors[{ cellPtr->mX, cellPtr->mY, cellPtr->mParent }] = cellPtr; - - return cellPtr; + { + ESM::ExteriorCellIndex cellindex = { cellPtr->mX, cellPtr->mY, cellPtr->mParent }; + if (cellPtr->mCellFlags & ESM4::Rec_Persistent) + mPersistentExteriors[cellindex] = cellPtr; + else + mExteriors[cellindex] = cellPtr; + } } void Store::clearDynamic() diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index e21c85d850..45706dc793 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -286,12 +286,14 @@ namespace MWWorld mCellNameIndex; std::unordered_map mExteriors; + std::unordered_map mPersistentExteriors; public: const ESM4::Cell* searchCellName(std::string_view) const; const ESM4::Cell* searchExterior(ESM::ExteriorCellIndex cellIndex) const; ESM4::Cell* insert(const ESM4::Cell& item, bool overrideOnly = false); ESM4::Cell* insertStatic(const ESM4::Cell& item); + void insertCell(ESM4::Cell* cell); void clearDynamic() override; };