Fixed a possible bug in CObjectManager::GetObjectByRank (might fix #611)

master
krzys-h 2015-09-07 20:38:25 +02:00
parent b058a6986b
commit 0a59f0a907
2 changed files with 10 additions and 4 deletions

View File

@ -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)

View File

@ -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;