mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-28 08:37:12 +00:00
crashfix dynamic exterior cells
This commit is contained in:
parent
a62e75fd19
commit
81d9686541
@ -1127,7 +1127,8 @@ namespace MWWorld
|
|||||||
ESM4::Cell* Store<ESM4::Cell>::insert(const ESM4::Cell& item, bool overrideOnly)
|
ESM4::Cell* Store<ESM4::Cell>::insert(const ESM4::Cell& item, bool overrideOnly)
|
||||||
{
|
{
|
||||||
auto cellPtr = TypedDynamicStore<ESM4::Cell>::insert(item, overrideOnly);
|
auto cellPtr = TypedDynamicStore<ESM4::Cell>::insert(item, overrideOnly);
|
||||||
mCellNameIndex[cellPtr->mEditorId] = cellPtr;
|
if (!cellPtr->mEditorId.empty())
|
||||||
|
mCellNameIndex[cellPtr->mEditorId] = cellPtr;
|
||||||
if (cellPtr->isExterior())
|
if (cellPtr->isExterior())
|
||||||
mExteriors[cellPtr->mParent][std::make_pair(cellPtr->getGridX(), cellPtr->getGridY())] = cellPtr;
|
mExteriors[cellPtr->mParent][std::make_pair(cellPtr->getGridX(), cellPtr->getGridY())] = cellPtr;
|
||||||
|
|
||||||
@ -1137,12 +1138,28 @@ namespace MWWorld
|
|||||||
ESM4::Cell* Store<ESM4::Cell>::insertStatic(const ESM4::Cell& item)
|
ESM4::Cell* Store<ESM4::Cell>::insertStatic(const ESM4::Cell& item)
|
||||||
{
|
{
|
||||||
auto cellPtr = TypedDynamicStore<ESM4::Cell>::insertStatic(item);
|
auto cellPtr = TypedDynamicStore<ESM4::Cell>::insertStatic(item);
|
||||||
mCellNameIndex[cellPtr->mEditorId] = cellPtr;
|
if (!cellPtr->mEditorId.empty())
|
||||||
|
mCellNameIndex[cellPtr->mEditorId] = cellPtr;
|
||||||
if (cellPtr->isExterior())
|
if (cellPtr->isExterior())
|
||||||
mExteriors[cellPtr->mParent][std::make_pair(cellPtr->getGridX(), cellPtr->getGridY())] = cellPtr;
|
mExteriors[cellPtr->mParent][std::make_pair(cellPtr->getGridX(), cellPtr->getGridY())] = cellPtr;
|
||||||
|
|
||||||
return cellPtr;
|
return cellPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Store<ESM4::Cell>::clearDynamic()
|
||||||
|
{
|
||||||
|
for (auto& cellToDeleteIt : mDynamic)
|
||||||
|
{
|
||||||
|
ESM4::Cell& cellToDelete = cellToDeleteIt.second;
|
||||||
|
if (cellToDelete.isExterior())
|
||||||
|
{
|
||||||
|
mExteriors[cellToDelete.mParent].erase(std::make_pair(cellToDelete.mX, cellToDelete.mY));
|
||||||
|
}
|
||||||
|
if (!cellToDelete.mEditorId.empty())
|
||||||
|
mCellNameIndex.erase(cellToDelete.mEditorId);
|
||||||
|
}
|
||||||
|
MWWorld::TypedDynamicStore<ESM4::Cell>::clearDynamic();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template class MWWorld::TypedDynamicStore<ESM::Activator>;
|
template class MWWorld::TypedDynamicStore<ESM::Activator>;
|
||||||
|
@ -177,6 +177,7 @@ namespace MWWorld
|
|||||||
template <class T, class Id = ESM::RefId>
|
template <class T, class Id = ESM::RefId>
|
||||||
class TypedDynamicStore : public DynamicStoreBase<Id>
|
class TypedDynamicStore : public DynamicStoreBase<Id>
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
typedef std::unordered_map<Id, T> Static;
|
typedef std::unordered_map<Id, T> Static;
|
||||||
Static mStatic;
|
Static mStatic;
|
||||||
/// @par mShared usually preserves the record order as it came from the content files (this
|
/// @par mShared usually preserves the record order as it came from the content files (this
|
||||||
@ -290,6 +291,7 @@ namespace MWWorld
|
|||||||
bool exteriorExists(ESM::RefId worldspace) const;
|
bool exteriorExists(ESM::RefId worldspace) const;
|
||||||
ESM4::Cell* insert(const ESM4::Cell& item, bool overrideOnly = false);
|
ESM4::Cell* insert(const ESM4::Cell& item, bool overrideOnly = false);
|
||||||
ESM4::Cell* insertStatic(const ESM4::Cell& item);
|
ESM4::Cell* insertStatic(const ESM4::Cell& item);
|
||||||
|
void clearDynamic() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user