Got rid of dangerous GetEntity(), not using DoWithEntity()

git-svn-id: http://mc-server.googlecode.com/svn/trunk@278 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
faketruth
2012-02-16 17:20:28 +00:00
parent 415d4eaa68
commit 008addf5d7
6 changed files with 31 additions and 55 deletions
+4 -5
View File
@@ -1168,18 +1168,17 @@ void cWorld::SendPlayerList(cPlayer * a_DestPlayer)
// TODO: This interface is dangerous!
cEntity * cWorld::GetEntity( int a_UniqueID )
bool cWorld::DoWithEntity( int a_UniqueID, cEntityCallback & a_Callback )
{
cCSLock Lock(m_CSEntities);
for (cEntityList::iterator itr = m_AllEntities.begin(); itr != m_AllEntities.end(); ++itr )
{
if( (*itr)->GetUniqueID() == a_UniqueID )
{
return *itr;
return a_Callback.Item(*itr);
}
}
return NULL;
} // for itr - m_AllEntities[]
return false;
}