diff --git a/src/game/Group.cpp b/src/game/Group.cpp index b8ae12046..b433d52e6 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -310,7 +310,7 @@ bool Group::AddMember(ObjectGuid guid, const char* name) SendUpdate(); - if (Player *player = sObjectMgr.GetPlayer(guid)) + if (Player* player = sObjectMgr.GetPlayer(guid)) { if (!IsLeader(player->GetObjectGuid()) && !isBGGroup()) { @@ -1155,20 +1155,26 @@ bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant) bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant, uint8 group) { - if(IsFull()) + if (IsFull()) return false; 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); @@ -1180,16 +1186,19 @@ bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant, uint if (player->GetGroup() && isBGGroup()) player->SetBattleGroundRaid(this, group); //if player is in bg raid and we are adding him to normal group, then call SetOriginalGroup() - else if ( player->GetGroup() ) + else if (player->GetGroup()) player->SetOriginalGroup(this, group); //if player is not in group, then call set group else player->SetGroup(this, group); - // 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 (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 diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 5197b8a57..d098d253c 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -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::Find(guid);; - if (!plr || !plr->IsInWorld()) + Player* plr = HashMapHolder::Find(guid);; + if (!plr || (!plr->IsInWorld() && inWorld)) return NULL; return plr; } -Player* -ObjectAccessor::FindPlayerByName(const char *name) +Player* ObjectAccessor::FindPlayerByName(const char *name) { HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index cc0883655..f35296219 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -100,7 +100,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton 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(id); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8103cb48a..b13d5d289 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11919" + #define REVISION_NR "11920" #endif // __REVISION_NR_H__