*Make sure the a player can only have one viewpoint.
--HG-- branch : trunk
This commit is contained in:
+29
-24
@@ -1901,10 +1901,10 @@ void Player::RemoveFromWorld()
|
||||
|
||||
if(m_uint32Values)
|
||||
{
|
||||
if(GetUInt64Value(PLAYER_FARSIGHT))
|
||||
if(WorldObject *viewpoint = GetViewpoint())
|
||||
{
|
||||
sLog.outCrash("Player %s has viewpoint when removed from world", GetName());
|
||||
CreateViewpoint(NULL);
|
||||
sLog.outCrash("Player %s has viewpoint %u %u when removed from world", GetName(), viewpoint->GetEntry(), viewpoint->GetTypeId());
|
||||
SetViewpoint(viewpoint, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20088,16 +20088,33 @@ void Player::StopCastingBindSight()
|
||||
}
|
||||
}
|
||||
|
||||
void Player::CreateViewpoint(WorldObject* target)
|
||||
void Player::SetViewpoint(WorldObject* target, bool apply)
|
||||
{
|
||||
if(!target || target == this) // remove viewpoint
|
||||
if(apply)
|
||||
{
|
||||
sLog.outDebug("Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName(), target->GetEntry(), target->GetTypeId());
|
||||
|
||||
if(!AddUInt64Value(PLAYER_FARSIGHT, target->GetGUID()))
|
||||
{
|
||||
sLog.outCrash("Player::CreateViewpoint: Player %s cannot add new viewpoint!", GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
if(target->isType(TYPEMASK_UNIT))
|
||||
((Unit*)target)->AddPlayerToVision(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog.outDebug("Player::CreateViewpoint: Player %s remove seer", GetName());
|
||||
|
||||
if(WorldObject *viewpoint = GetViewpoint())
|
||||
if(viewpoint->isType(TYPEMASK_UNIT))
|
||||
((Unit*)viewpoint)->RemovePlayerFromVision(this);
|
||||
SetUInt64Value(PLAYER_FARSIGHT, 0);
|
||||
if(!RemoveUInt64Value(PLAYER_FARSIGHT, target->GetGUID()))
|
||||
{
|
||||
sLog.outCrash("Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
if(target->isType(TYPEMASK_UNIT))
|
||||
((Unit*)target)->RemovePlayerFromVision(this);
|
||||
|
||||
//must immediately set seer back otherwise may crash
|
||||
m_seer = this;
|
||||
@@ -20105,20 +20122,6 @@ void Player::CreateViewpoint(WorldObject* target)
|
||||
//WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
|
||||
//GetSession()->SendPacket(&data);
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog.outDebug("Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName(), target->GetEntry(), target->GetTypeId());
|
||||
|
||||
StopCastingBindSight();
|
||||
if(!AddUInt64Value(PLAYER_FARSIGHT, target->GetGUID()))
|
||||
{
|
||||
sLog.outError("Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
if(target->isType(TYPEMASK_UNIT))
|
||||
((Unit*)target)->AddPlayerToVision(this);
|
||||
}
|
||||
}
|
||||
|
||||
WorldObject* Player::GetViewpoint() const
|
||||
@@ -20224,7 +20227,8 @@ void Player::EnterVehicle(Vehicle *vehicle)
|
||||
|
||||
StopCastingCharm();
|
||||
StopCastingBindSight();
|
||||
SetCharm(vehicle, true); // charm
|
||||
SetCharm(vehicle, true);
|
||||
SetViewpoint(vehicle, true);
|
||||
SetMover(vehicle);
|
||||
|
||||
SetClientControl(vehicle, 1); // redirect controls to vehicle
|
||||
@@ -20264,6 +20268,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
|
||||
vehicle->setFaction((GetTeam() == ALLIANCE) ? vehicle->GetCreatureInfo()->faction_A : vehicle->GetCreatureInfo()->faction_H);
|
||||
|
||||
SetCharm(vehicle, false);
|
||||
SetViewpoint(vehicle, false);
|
||||
SetMover(this);
|
||||
|
||||
SetClientControl(vehicle, 0);
|
||||
|
||||
+2
-2
@@ -1982,9 +1982,9 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
void EnterVehicle(Vehicle *vehicle);
|
||||
void ExitVehicle(Vehicle *vehicle);
|
||||
|
||||
void SetMover(Unit* target) { CreateViewpoint(target); m_mover = target; }
|
||||
void SetMover(Unit* target) { m_mover = target; }
|
||||
void SetSeer(WorldObject *target) { m_seer = target; }
|
||||
void CreateViewpoint(WorldObject *target);
|
||||
void SetViewpoint(WorldObject *target, bool apply);
|
||||
WorldObject* GetViewpoint() const;
|
||||
void StopCastingCharm();
|
||||
void StopCastingBindSight();
|
||||
|
||||
@@ -2048,10 +2048,15 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
|
||||
// AT REMOVE
|
||||
else
|
||||
{
|
||||
if( m_target->GetTypeId() == TYPEID_PLAYER && GetSpellProto()->Effect[0]==72 )
|
||||
if(GetSpellProto()->Effect[0]==72 )
|
||||
{
|
||||
// spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
|
||||
((Player*)m_target)->CreateViewpoint(NULL);
|
||||
if(DynamicObject* dynObj = m_target->GetDynObject(GetId(), 0))
|
||||
{
|
||||
if(m_target->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)m_target)->SetViewpoint(dynObj, false);
|
||||
m_target->RemoveDynObject(GetId());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3007,7 +3012,7 @@ void Aura::HandleBindSight(bool apply, bool Real)
|
||||
if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
((Player*)caster)->CreateViewpoint(apply ? m_target : NULL);
|
||||
((Player*)caster)->SetViewpoint(m_target, apply);
|
||||
}
|
||||
|
||||
void Aura::HandleFarSight(bool apply, bool Real)
|
||||
|
||||
@@ -3620,7 +3620,7 @@ void Spell::EffectAddFarsight(uint32 i)
|
||||
dynObj->GetMap()->Add(dynObj); //grid will also be loaded
|
||||
|
||||
// Need to update visibility of object for client to accept farsight guid
|
||||
((Player*)m_caster)->CreateViewpoint(dynObj);
|
||||
((Player*)m_caster)->SetViewpoint(dynObj, true);
|
||||
//((Player*)m_caster)->UpdateVisibilityOf(dynObj);
|
||||
}
|
||||
|
||||
|
||||
@@ -13141,6 +13141,7 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess)
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
|
||||
((Player*)charmer)->SetClientControl(this, 1);
|
||||
((Player*)charmer)->SetMover(this);
|
||||
((Player*)charmer)->SetViewpoint(this, true);
|
||||
charmer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
|
||||
}
|
||||
// Charm demon
|
||||
@@ -13223,6 +13224,7 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer)
|
||||
{
|
||||
((Player*)charmer)->SetClientControl(charmer, 1);
|
||||
((Player*)charmer)->SetMover(charmer);
|
||||
((Player*)charmer)->SetViewpoint(this, false);
|
||||
charmer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
|
||||
}
|
||||
// restore UNIT_FIELD_BYTES_0
|
||||
|
||||
Reference in New Issue
Block a user