diff --git a/SilentPatchSA/GeneralSA.cpp b/SilentPatchSA/GeneralSA.cpp index 2e07328..86728fc 100644 --- a/SilentPatchSA/GeneralSA.cpp +++ b/SilentPatchSA/GeneralSA.cpp @@ -116,21 +116,20 @@ std::tuple CObject::TryOrFreeUpTempObjects( int numObjects, bool force int numProcessed = 0, numFreed = 0; auto& pool = CPools::GetObjectPool(); - for ( auto& obj : pool ) + for ( auto obj : pool ) { if ( numFreed >= numObjects ) break; - CObject* const objPtr = &obj; - if ( pool.IsValidPtr( objPtr ) ) + if ( pool.IsValidPtr( obj ) ) { - if ( objPtr->m_objectCreatedBy == TEMP_OBJECT ) + if ( obj->m_objectCreatedBy == TEMP_OBJECT ) { numProcessed++; - if ( force || !objPtr->IsVisible() ) + if ( force || !obj->IsVisible() ) { numFreed++; - WorldRemove( objPtr ); - delete objPtr; + WorldRemove( obj ); + delete obj; } } } diff --git a/SilentPatchSA/PoolsSA.h b/SilentPatchSA/PoolsSA.h index 106aca7..ac45c4d 100644 --- a/SilentPatchSA/PoolsSA.h +++ b/SilentPatchSA/PoolsSA.h @@ -53,9 +53,15 @@ public: return !GetIsFree( index ); } - class iterator : public std::iterator + class iterator { public: + using iterator_category = std::random_access_iterator_tag; + using value_type = ReturnType*; + using difference_type = ptrdiff_t; + using pointer = ReturnType* const *; + using reference = ReturnType*; + iterator() : m_ptr(nullptr) { } @@ -64,8 +70,8 @@ public: { } - reference operator* () const { return *reinterpret_cast(m_ptr); } - pointer operator->() const { return reinterpret_cast(m_ptr); } + reference operator* () const { return reinterpret_cast(m_ptr); } + pointer operator->() const { return &reinterpret_cast(m_ptr); } iterator& operator ++ () { ++m_ptr; return *this; } bool operator == ( const iterator& rhs ) const { return m_ptr == rhs.m_ptr; }