mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[8870] Fix problem with max pet distance from owner.
* Avoid use hardcoded and different max distance from owner for pet (more at contienets and less in instances) Use instaed max visibility for map as expected. * Explicitly pet remove at move pet to non-visible distance for player owner. Original patch provided by Lightguard.
This commit is contained in:
parent
e636d63fdb
commit
663038c7c7
5 changed files with 25 additions and 10 deletions
|
|
@ -499,7 +499,7 @@ void Pet::Update(uint32 diff)
|
||||||
{
|
{
|
||||||
// unsummon pet that lost owner
|
// unsummon pet that lost owner
|
||||||
Unit* owner = GetOwner();
|
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);
|
Remove(PET_SAVE_NOT_IN_SLOT, true);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -116,8 +116,6 @@ typedef std::vector<uint32> AutoSpellList;
|
||||||
|
|
||||||
#define ACTIVE_SPELLS_MAX 4
|
#define ACTIVE_SPELLS_MAX 4
|
||||||
|
|
||||||
#define OWNER_MAX_DISTANCE 100.0f
|
|
||||||
|
|
||||||
#define PET_FOLLOW_DIST 1
|
#define PET_FOLLOW_DIST 1
|
||||||
#define PET_FOLLOW_ANGLE (M_PI/2)
|
#define PET_FOLLOW_ANGLE (M_PI/2)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1335,7 +1335,7 @@ void Player::Update( uint32 p_time )
|
||||||
SendUpdateToOutOfRangeGroupMembers();
|
SendUpdateToOutOfRangeGroupMembers();
|
||||||
|
|
||||||
Pet* pet = GetPet();
|
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);
|
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))
|
if (!(options & TELE_TO_NOT_UNSUMMON_PET))
|
||||||
{
|
{
|
||||||
//same map, only remove pet if out of range for new position
|
//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();
|
UnsummonPetTemporaryIfAny();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -18095,12 +18095,27 @@ bool Player::IsVisibleGloballyFor( Player* u ) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 const* viewPoint, WorldObject* target)
|
void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* target)
|
||||||
{
|
{
|
||||||
if(HaveAtClient(target))
|
if(HaveAtClient(target))
|
||||||
{
|
{
|
||||||
if(!target->isVisibleForInState(this, viewPoint, true))
|
if(!target->isVisibleForInState(this, viewPoint, true))
|
||||||
{
|
{
|
||||||
|
if (target->GetTypeId()==TYPEID_UNIT)
|
||||||
|
BeforeVisibilityDestroy<Creature>((Creature*)target,this);
|
||||||
|
|
||||||
target->DestroyForPlayer(this);
|
target->DestroyForPlayer(this);
|
||||||
m_clientGUIDs.erase(target->GetGUID());
|
m_clientGUIDs.erase(target->GetGUID());
|
||||||
|
|
||||||
|
|
@ -18154,6 +18169,8 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateD
|
||||||
{
|
{
|
||||||
if(!target->isVisibleForInState(this,viewPoint,true))
|
if(!target->isVisibleForInState(this,viewPoint,true))
|
||||||
{
|
{
|
||||||
|
BeforeVisibilityDestroy<T>(target,this);
|
||||||
|
|
||||||
target->BuildOutOfRangeUpdateBlock(&data);
|
target->BuildOutOfRangeUpdateBlock(&data);
|
||||||
m_clientGUIDs.erase(target->GetGUID());
|
m_clientGUIDs.erase(target->GetGUID());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9848,10 +9848,6 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// always seen by owner
|
|
||||||
if (GetCharmerOrOwnerGUID()==u->GetGUID())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// always seen by far sight caster
|
// always seen by far sight caster
|
||||||
if (u->GetTypeId()==TYPEID_PLAYER && ((Player*)u)->GetFarSight()==GetGUID())
|
if (u->GetTypeId()==TYPEID_PLAYER && ((Player*)u)->GetFarSight()==GetGUID())
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -9896,6 +9892,10 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// always seen by owner
|
||||||
|
if (GetCharmerOrOwnerGUID()==u->GetGUID())
|
||||||
|
return true;
|
||||||
|
|
||||||
// isInvisibleForAlive() those units can only be seen by dead or if other
|
// isInvisibleForAlive() those units can only be seen by dead or if other
|
||||||
// unit is also invisible for alive.. if an isinvisibleforalive unit dies we
|
// unit is also invisible for alive.. if an isinvisibleforalive unit dies we
|
||||||
// should be able to see it too
|
// should be able to see it too
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8869"
|
#define REVISION_NR "8870"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue