mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[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:
parent
6c8000705f
commit
b984d3f787
5 changed files with 25 additions and 18 deletions
|
|
@ -1161,14 +1161,20 @@ bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant, uint
|
|||
if (!guid)
|
||||
return false;
|
||||
|
||||
Player *player = sObjectMgr.GetPlayer(guid);
|
||||
Player* player = sObjectMgr.GetPlayer(guid, false);
|
||||
|
||||
uint32 lastMap = 0;
|
||||
if (player && player->IsInWorld())
|
||||
player->GetMapId();
|
||||
else if (player && player->IsBeingTeleported())
|
||||
player->GetTeleportDest().mapid;
|
||||
|
||||
MemberSlot member;
|
||||
member.guid = guid;
|
||||
member.name = name;
|
||||
member.group = group;
|
||||
member.assistant = isAssistant;
|
||||
member.lastMap = player->GetMapId();
|
||||
member.lastMap = lastMap;
|
||||
m_memberSlots.push_back(member);
|
||||
|
||||
SubGroupCounterIncrease(group);
|
||||
|
|
@ -1186,11 +1192,14 @@ bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant, uint
|
|||
else
|
||||
player->SetGroup(this, group);
|
||||
|
||||
if (player->IsInWorld())
|
||||
{
|
||||
// if the same group invites the player back, cancel the homebind timer
|
||||
if (InstanceGroupBind* bind = GetBoundInstance(player->GetMapId(), player))
|
||||
if (bind->state->GetInstanceId() == player->GetInstanceId())
|
||||
player->m_InstanceValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isRaidGroup()) // reset targetIcons for non-raid-groups
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
|
|||
static Unit* GetUnit(WorldObject const& obj, ObjectGuid guid);
|
||||
|
||||
// Player access
|
||||
static Player* FindPlayer(ObjectGuid guid); // if need player at specific map better use Map::GetPlayer
|
||||
static Player* FindPlayer(ObjectGuid guid, bool inWorld = true);// if need player at specific map better use Map::GetPlayer
|
||||
static Player* FindPlayerByName(const char *name);
|
||||
static void KickPlayer(ObjectGuid guid);
|
||||
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ class ObjectMgr
|
|||
typedef UNORDERED_MAP<uint32, WeatherZoneChances> WeatherZoneMap;
|
||||
|
||||
static Player* GetPlayer(const char* name) { return ObjectAccessor::FindPlayerByName(name);}
|
||||
static Player* GetPlayer(ObjectGuid guid) { return ObjectAccessor::FindPlayer(guid); }
|
||||
static Player* GetPlayer(ObjectGuid guid, bool inWorld = true) { return ObjectAccessor::FindPlayer(guid, inWorld); }
|
||||
|
||||
static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry<GameObjectInfo>(id); }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11919"
|
||||
#define REVISION_NR "11920"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue