[11920] Fix possible crash when trying to add playerto group who is not in world

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
cyberium 2012-02-07 11:41:36 +01:00 committed by Schmoozerd
parent 6c8000705f
commit b984d3f787
5 changed files with 25 additions and 18 deletions

View file

@ -73,21 +73,19 @@ Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid)
return ret;
}
Player*
ObjectAccessor::FindPlayer(ObjectGuid guid)
Player* ObjectAccessor::FindPlayer(ObjectGuid guid, bool inWorld /*= true*/)
{
if (!guid)
return NULL;
Player * plr = HashMapHolder<Player>::Find(guid);;
if (!plr || !plr->IsInWorld())
Player* plr = HashMapHolder<Player>::Find(guid);;
if (!plr || (!plr->IsInWorld() && inWorld))
return NULL;
return plr;
}
Player*
ObjectAccessor::FindPlayerByName(const char *name)
Player* ObjectAccessor::FindPlayerByName(const char *name)
{
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();