Fixed a possible bug in CObjectManager::GetObjectByRank (might fix #611)
parent
b058a6986b
commit
0a59f0a907
|
@ -124,10 +124,11 @@ CObject* CObjectManager::GetObjectById(unsigned int id)
|
|||
|
||||
CObject* CObjectManager::GetObjectByRank(unsigned int id)
|
||||
{
|
||||
if (id >= m_objects.size()) return nullptr;
|
||||
auto it = m_objects.begin();
|
||||
for (unsigned int i = 0; i < id; i++, ++it);
|
||||
return it->second.get();
|
||||
auto objects = GetAllObjects();
|
||||
auto it = objects.begin();
|
||||
for (unsigned int i = 0; i < id && it != objects.end(); i++, ++it);
|
||||
if (it == objects.end()) return nullptr;
|
||||
return *it;
|
||||
}
|
||||
|
||||
CObject* CObjectManager::CreateObject(ObjectCreateParams params)
|
||||
|
|
|
@ -94,6 +94,11 @@ public:
|
|||
while (m_currentIt != m_endIt && m_currentIt->second == nullptr);
|
||||
}
|
||||
|
||||
bool operator==(const CObjectIteratorProxy& other)
|
||||
{
|
||||
return m_currentIt == other.m_currentIt;
|
||||
}
|
||||
|
||||
bool operator!=(const CObjectIteratorProxy& other)
|
||||
{
|
||||
return m_currentIt != other.m_currentIt;
|
||||
|
|
Loading…
Reference in New Issue