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

View file

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