aboutsummaryrefslogtreecommitdiff
path: root/src/game/Player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r--src/game/Player.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index f5577198dd1..a9b0b95307c 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -1394,8 +1394,8 @@ void Player::Update( uint32 p_time )
SendUpdateToOutOfRangeGroupMembers();
Pet* pet = GetPet();
- if (pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE) && !pet->isPossessed())
- //if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID())))
+ if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && !pet->isPossessed())
+ //if(pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID())))
RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true);
//we should execute delayed teleports only for alive(!) players
@@ -1748,7 +1748,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();
}
@@ -19302,12 +19302,27 @@ inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, Player* target, std
v.insert(target);
}
+template<class T>
+inline void BeforeVisibilityDestroy(T* /*t*/, Player* /*p*/)
+{
+}
+
+template<>
+inline void BeforeVisibilityDestroy<Creature>(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* target)
{
if(HaveAtClient(target))
{
if(!target->isVisibleForInState(this, true))
{
+ if (target->GetTypeId()==TYPEID_UNIT)
+ BeforeVisibilityDestroy<Creature>((Creature*)target,this);
+
target->DestroyForPlayer(this);
m_clientGUIDs.erase(target->GetGUID());
@@ -19359,6 +19374,8 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& vi
{
if(!target->isVisibleForInState(this,true))
{
+ BeforeVisibilityDestroy<T>(target,this);
+
target->BuildOutOfRangeUpdateBlock(&data);
m_clientGUIDs.erase(target->GetGUID());