@@ -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
0 commit comments