[7123] Cleanup in using STD's containers erase method.

Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
Balrok 2009-01-20 20:04:12 +01:00 committed by ApoC
parent 8171c9c61a
commit ce384c5278
9 changed files with 23 additions and 69 deletions

View file

@ -57,9 +57,7 @@ class HashMapHolder
static void Remove(T* o)
{
Guard guard(i_lock);
typename MapType::iterator itr = m_objectMap.find(o->GetGUID());
if (itr != m_objectMap.end())
m_objectMap.erase(itr);
m_objectMap.erase(o->GetGUID());
}
static T* Find(uint64 guid)
@ -174,16 +172,22 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
HashMapHolder<Player>::Remove(pl);
Guard guard(i_updateGuard);
std::set<Object *>::iterator iter2 = std::find(i_objects.begin(), i_objects.end(), (Object *)pl);
if( iter2 != i_objects.end() )
i_objects.erase(iter2);
i_objects.erase((Object *)pl);
}
void SaveAllPlayers();
void AddUpdateObject(Object *obj);
void RemoveUpdateObject(Object *obj);
void AddUpdateObject(Object *obj)
{
Guard guard(i_updateGuard);
i_objects.insert(obj);
}
void RemoveUpdateObject(Object *obj)
{
Guard guard(i_updateGuard);
i_objects.erase( obj );
}
void Update(uint32 diff);
void UpdatePlayers(uint32 diff);