mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +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)
|
if (!guid)
|
||||||
return false;
|
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;
|
MemberSlot member;
|
||||||
member.guid = guid;
|
member.guid = guid;
|
||||||
member.name = name;
|
member.name = name;
|
||||||
member.group = group;
|
member.group = group;
|
||||||
member.assistant = isAssistant;
|
member.assistant = isAssistant;
|
||||||
member.lastMap = player->GetMapId();
|
member.lastMap = lastMap;
|
||||||
m_memberSlots.push_back(member);
|
m_memberSlots.push_back(member);
|
||||||
|
|
||||||
SubGroupCounterIncrease(group);
|
SubGroupCounterIncrease(group);
|
||||||
|
|
@ -1186,11 +1192,14 @@ bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant, uint
|
||||||
else
|
else
|
||||||
player->SetGroup(this, group);
|
player->SetGroup(this, group);
|
||||||
|
|
||||||
|
if (player->IsInWorld())
|
||||||
|
{
|
||||||
// if the same group invites the player back, cancel the homebind timer
|
// if the same group invites the player back, cancel the homebind timer
|
||||||
if (InstanceGroupBind* bind = GetBoundInstance(player->GetMapId(), player))
|
if (InstanceGroupBind* bind = GetBoundInstance(player->GetMapId(), player))
|
||||||
if (bind->state->GetInstanceId() == player->GetInstanceId())
|
if (bind->state->GetInstanceId() == player->GetInstanceId())
|
||||||
player->m_InstanceValid = true;
|
player->m_InstanceValid = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isRaidGroup()) // reset targetIcons for non-raid-groups
|
if (!isRaidGroup()) // reset targetIcons for non-raid-groups
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -73,21 +73,19 @@ Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player*
|
Player* ObjectAccessor::FindPlayer(ObjectGuid guid, bool inWorld /*= true*/)
|
||||||
ObjectAccessor::FindPlayer(ObjectGuid guid)
|
|
||||||
{
|
{
|
||||||
if (!guid)
|
if (!guid)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Player* plr = HashMapHolder<Player>::Find(guid);;
|
Player* plr = HashMapHolder<Player>::Find(guid);;
|
||||||
if (!plr || !plr->IsInWorld())
|
if (!plr || (!plr->IsInWorld() && inWorld))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return plr;
|
return plr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player*
|
Player* ObjectAccessor::FindPlayerByName(const char *name)
|
||||||
ObjectAccessor::FindPlayerByName(const char *name)
|
|
||||||
{
|
{
|
||||||
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
|
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
|
||||||
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
|
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);
|
static Unit* GetUnit(WorldObject const& obj, ObjectGuid guid);
|
||||||
|
|
||||||
// Player access
|
// 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 Player* FindPlayerByName(const char *name);
|
||||||
static void KickPlayer(ObjectGuid guid);
|
static void KickPlayer(ObjectGuid guid);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -472,7 +472,7 @@ class ObjectMgr
|
||||||
typedef UNORDERED_MAP<uint32, WeatherZoneChances> WeatherZoneMap;
|
typedef UNORDERED_MAP<uint32, WeatherZoneChances> WeatherZoneMap;
|
||||||
|
|
||||||
static Player* GetPlayer(const char* name) { return ObjectAccessor::FindPlayerByName(name);}
|
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); }
|
static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry<GameObjectInfo>(id); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11919"
|
#define REVISION_NR "11920"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue