1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-04 05:39:40 +00:00

Include Ptrs with a count of 0 in cell unloading

This commit is contained in:
Evil Eye 2025-02-12 22:07:30 +01:00
parent 63e3b8f41b
commit ad8f6e5eb6
2 changed files with 10 additions and 13 deletions

View file

@ -213,7 +213,7 @@ namespace MWWorld
/// unintended behaviour. \attention This function also lists deleted (count 0) objects! /// unintended behaviour. \attention This function also lists deleted (count 0) objects!
/// \return Iteration completed? /// \return Iteration completed?
template <class Visitor> template <class Visitor>
bool forEach(Visitor&& visitor) bool forEach(Visitor&& visitor, bool includeDeleted = false)
{ {
if (mState != State_Loaded) if (mState != State_Loaded)
return false; return false;
@ -227,7 +227,7 @@ namespace MWWorld
for (LiveCellRefBase* mergedRef : mMergedRefs) for (LiveCellRefBase* mergedRef : mMergedRefs)
{ {
if (!isAccessible(mergedRef->mData, mergedRef->mRef)) if (!includeDeleted && !isAccessible(mergedRef->mData, mergedRef->mRef))
continue; continue;
if (!visitor(MWWorld::Ptr(mergedRef, this))) if (!visitor(MWWorld::Ptr(mergedRef, this)))
@ -242,7 +242,7 @@ namespace MWWorld
/// unintended behaviour. \attention This function also lists deleted (count 0) objects! /// unintended behaviour. \attention This function also lists deleted (count 0) objects!
/// \return Iteration completed? /// \return Iteration completed?
template <class Visitor> template <class Visitor>
bool forEachConst(Visitor&& visitor) const bool forEachConst(Visitor&& visitor, bool includeDeleted = false) const
{ {
if (mState != State_Loaded) if (mState != State_Loaded)
return false; return false;
@ -252,7 +252,7 @@ namespace MWWorld
for (const LiveCellRefBase* mergedRef : mMergedRefs) for (const LiveCellRefBase* mergedRef : mMergedRefs)
{ {
if (!isAccessible(mergedRef->mData, mergedRef->mRef)) if (!includeDeleted && !isAccessible(mergedRef->mData, mergedRef->mRef))
continue; continue;
if (!visitor(MWWorld::ConstPtr(mergedRef, this))) if (!visitor(MWWorld::ConstPtr(mergedRef, this)))
@ -267,7 +267,7 @@ namespace MWWorld
/// unintended behaviour. \attention This function also lists deleted (count 0) objects! /// unintended behaviour. \attention This function also lists deleted (count 0) objects!
/// \return Iteration completed? /// \return Iteration completed?
template <class T, class Visitor> template <class T, class Visitor>
bool forEachType(Visitor&& visitor) bool forEachType(Visitor&& visitor, bool includeDeleted = false)
{ {
if (mState != State_Loaded) if (mState != State_Loaded)
return false; return false;
@ -279,16 +279,13 @@ namespace MWWorld
mHasState = true; mHasState = true;
CellRefList<T>& list = get<T>(); for (LiveCellRefBase& base : get<T>().mList)
for (typename CellRefList<T>::List::iterator it(list.mList.begin()); it != list.mList.end(); ++it)
{ {
LiveCellRefBase* base = &*it; if (mMovedToAnotherCell.contains(&base))
if (mMovedToAnotherCell.find(base) != mMovedToAnotherCell.end())
continue; continue;
if (!isAccessible(base->mData, base->mRef)) if (!includeDeleted && !isAccessible(base.mData, base.mRef))
continue; continue;
if (!visitor(MWWorld::Ptr(base, this))) if (!visitor(MWWorld::Ptr(&base, this)))
return false; return false;
} }

View file

@ -367,7 +367,7 @@ namespace MWWorld
ListAndResetObjectsVisitor visitor; ListAndResetObjectsVisitor visitor;
cell->forEach(visitor); cell->forEach(visitor, true); // Include objects being teleported by Lua
for (const auto& ptr : visitor.mObjects) for (const auto& ptr : visitor.mObjects)
{ {
if (const auto object = mPhysics->getObject(ptr)) if (const auto object = mPhysics->getObject(ptr))