Fix deadlock in Foliage::GetFoliageTypeInstancesCount

#1724
This commit is contained in:
Wojtek Figat
2023-10-17 23:20:30 +02:00
parent 387e30a1dc
commit 2d0eabc8be
2 changed files with 5 additions and 12 deletions

View File

@@ -133,18 +133,16 @@ public:
return _chunkIndex * ChunkSize + _index;
}
public:
bool IsEnd() const
FORCE_INLINE bool IsEnd() const
{
return Index() == _collection->Count();
return (_chunkIndex * ChunkSize + _index) == _collection->_count;
}
bool IsNotEnd() const
FORCE_INLINE bool IsNotEnd() const
{
return Index() != _collection->Count();
return (_chunkIndex * ChunkSize + _index) != _collection->_count;
}
public:
FORCE_INLINE T& operator*() const
{
return _collection->_chunks[_chunkIndex]->At(_index);
@@ -155,7 +153,6 @@ public:
return &_collection->_chunks[_chunkIndex]->At(_index);
}
public:
FORCE_INLINE bool operator==(const Iterator& v) const
{
return _collection == v._collection && _chunkIndex == v._chunkIndex && _index == v._index;
@@ -166,7 +163,6 @@ public:
return _collection != v._collection || _chunkIndex != v._chunkIndex || _index != v._index;
}
public:
Iterator& operator++()
{
// Check if it is not at end

View File

@@ -634,15 +634,12 @@ void Foliage::RemoveFoliageType(int32 index)
int32 Foliage::GetFoliageTypeInstancesCount(int32 index) const
{
PROFILE_CPU();
int32 result = 0;
for (auto i = Instances.Begin(); i.IsNotEnd(); i++)
for (auto i = Instances.Begin(); i.IsNotEnd(); ++i)
{
if (i->Type == index)
result++;
}
return result;
}