Skip to content

Commit 3b05ec0

Browse files
committed
Merge branch 'countteleportula' into 'master'
Include Ptrs with a count of 0 in cell unloading Closes #8311 See merge request OpenMW/openmw!4536
2 parents 63e3b8f + ad8f6e5 commit 3b05ec0

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

apps/openmw/mwworld/cellstore.hpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ namespace MWWorld
213213
/// unintended behaviour. \attention This function also lists deleted (count 0) objects!
214214
/// \return Iteration completed?
215215
template <class Visitor>
216-
bool forEach(Visitor&& visitor)
216+
bool forEach(Visitor&& visitor, bool includeDeleted = false)
217217
{
218218
if (mState != State_Loaded)
219219
return false;
@@ -227,7 +227,7 @@ namespace MWWorld
227227

228228
for (LiveCellRefBase* mergedRef : mMergedRefs)
229229
{
230-
if (!isAccessible(mergedRef->mData, mergedRef->mRef))
230+
if (!includeDeleted && !isAccessible(mergedRef->mData, mergedRef->mRef))
231231
continue;
232232

233233
if (!visitor(MWWorld::Ptr(mergedRef, this)))
@@ -242,7 +242,7 @@ namespace MWWorld
242242
/// unintended behaviour. \attention This function also lists deleted (count 0) objects!
243243
/// \return Iteration completed?
244244
template <class Visitor>
245-
bool forEachConst(Visitor&& visitor) const
245+
bool forEachConst(Visitor&& visitor, bool includeDeleted = false) const
246246
{
247247
if (mState != State_Loaded)
248248
return false;
@@ -252,7 +252,7 @@ namespace MWWorld
252252

253253
for (const LiveCellRefBase* mergedRef : mMergedRefs)
254254
{
255-
if (!isAccessible(mergedRef->mData, mergedRef->mRef))
255+
if (!includeDeleted && !isAccessible(mergedRef->mData, mergedRef->mRef))
256256
continue;
257257

258258
if (!visitor(MWWorld::ConstPtr(mergedRef, this)))
@@ -267,7 +267,7 @@ namespace MWWorld
267267
/// unintended behaviour. \attention This function also lists deleted (count 0) objects!
268268
/// \return Iteration completed?
269269
template <class T, class Visitor>
270-
bool forEachType(Visitor&& visitor)
270+
bool forEachType(Visitor&& visitor, bool includeDeleted = false)
271271
{
272272
if (mState != State_Loaded)
273273
return false;
@@ -279,16 +279,13 @@ namespace MWWorld
279279

280280
mHasState = true;
281281

282-
CellRefList<T>& list = get<T>();
283-
284-
for (typename CellRefList<T>::List::iterator it(list.mList.begin()); it != list.mList.end(); ++it)
282+
for (LiveCellRefBase& base : get<T>().mList)
285283
{
286-
LiveCellRefBase* base = &*it;
287-
if (mMovedToAnotherCell.find(base) != mMovedToAnotherCell.end())
284+
if (mMovedToAnotherCell.contains(&base))
288285
continue;
289-
if (!isAccessible(base->mData, base->mRef))
286+
if (!includeDeleted && !isAccessible(base.mData, base.mRef))
290287
continue;
291-
if (!visitor(MWWorld::Ptr(base, this)))
288+
if (!visitor(MWWorld::Ptr(&base, this)))
292289
return false;
293290
}
294291

apps/openmw/mwworld/scene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ namespace MWWorld
367367

368368
ListAndResetObjectsVisitor visitor;
369369

370-
cell->forEach(visitor);
370+
cell->forEach(visitor, true); // Include objects being teleported by Lua
371371
for (const auto& ptr : visitor.mObjects)
372372
{
373373
if (const auto object = mPhysics->getObject(ptr))

0 commit comments

Comments
 (0)