diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index db5f6eb36..b828c984c 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -499,7 +499,7 @@ void Pet::Update(uint32 diff) { // unsummon pet that lost owner Unit* owner = GetOwner(); - if(!owner || (!IsWithinDistInMap(owner, OWNER_MAX_DISTANCE) && (owner->GetCharmGUID() && (owner->GetCharmGUID() != GetGUID()))) || (isControlled() && !owner->GetPetGUID())) + if(!owner || (!IsWithinDistInMap(owner, GetMap()->GetVisibilityDistance()) && (owner->GetCharmGUID() && (owner->GetCharmGUID() != GetGUID()))) || (isControlled() && !owner->GetPetGUID())) { Remove(PET_SAVE_NOT_IN_SLOT, true); return; diff --git a/src/game/Pet.h b/src/game/Pet.h index 303d3ba50..600a1d535 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -116,8 +116,6 @@ typedef std::vector AutoSpellList; #define ACTIVE_SPELLS_MAX 4 -#define OWNER_MAX_DISTANCE 100.0f - #define PET_FOLLOW_DIST 1 #define PET_FOLLOW_ANGLE (M_PI/2) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 038cc3846..2b62149f2 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1335,7 +1335,7 @@ void Player::Update( uint32 p_time ) SendUpdateToOutOfRangeGroupMembers(); Pet* pet = GetPet(); - if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID()))) + if(pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID()))) { RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true); } @@ -1651,7 +1651,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (!(options & TELE_TO_NOT_UNSUMMON_PET)) { //same map, only remove pet if out of range for new position - if(pet && !pet->IsWithinDist3d(x,y,z, OWNER_MAX_DISTANCE)) + if(pet && !pet->IsWithinDist3d(x,y,z,GetMap()->GetVisibilityDistance())) UnsummonPetTemporaryIfAny(); } @@ -18095,12 +18095,27 @@ bool Player::IsVisibleGloballyFor( Player* u ) const return true; } +template +inline void BeforeVisibilityDestroy(T* /*t*/, Player* /*p*/) +{ +} + +template<> +inline void BeforeVisibilityDestroy(Creature* t, Player* p) +{ + if (p->GetPetGUID()==t->GetGUID() && ((Creature*)t)->isPet()) + ((Pet*)t)->Remove(PET_SAVE_NOT_IN_SLOT, true); +} + void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* target) { if(HaveAtClient(target)) { if(!target->isVisibleForInState(this, viewPoint, true)) { + if (target->GetTypeId()==TYPEID_UNIT) + BeforeVisibilityDestroy((Creature*)target,this); + target->DestroyForPlayer(this); m_clientGUIDs.erase(target->GetGUID()); @@ -18154,6 +18169,8 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateD { if(!target->isVisibleForInState(this,viewPoint,true)) { + BeforeVisibilityDestroy(target,this); + target->BuildOutOfRangeUpdateBlock(&data); m_clientGUIDs.erase(target->GetGUID()); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 83e839cc5..ec27cf548 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9848,10 +9848,6 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo return false; } - // always seen by owner - if (GetCharmerOrOwnerGUID()==u->GetGUID()) - return true; - // always seen by far sight caster if (u->GetTypeId()==TYPEID_PLAYER && ((Player*)u)->GetFarSight()==GetGUID()) return true; @@ -9896,6 +9892,10 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo return false; } + // always seen by owner + if (GetCharmerOrOwnerGUID()==u->GetGUID()) + return true; + // isInvisibleForAlive() those units can only be seen by dead or if other // unit is also invisible for alive.. if an isinvisibleforalive unit dies we // should be able to see it too diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ae1d376b5..e2b6c5250 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 "8869" + #define REVISION_NR "8870" #endif // __REVISION_NR_H__