*Do not set another viewpoint when the old one cannot be removed.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-22 11:35:25 -06:00
parent bb201e6bd4
commit ae7a8a0971
+16 -5
View File
@@ -20079,21 +20079,32 @@ void Player::StopCastingBindSight()
void Player::CreateViewpoint(WorldObject* target) void Player::CreateViewpoint(WorldObject* target)
{ {
if(!target || target == this) // remove seer if(!target || target == this) // remove viewpoint
{ {
sLog.outDebug("Player::CreateViewpoint: Player %s remove seer", GetName()); 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); SetUInt64Value(PLAYER_FARSIGHT, 0);
//WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
//GetSession()->SendPacket(&data);
if(m_seer != this && m_seer->isType(TYPEMASK_UNIT))
((Unit*)m_seer)->RemovePlayerFromVision(this);
//must immediately set seer back otherwise may crash //must immediately set seer back otherwise may crash
m_seer = this; m_seer = this;
//WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
//GetSession()->SendPacket(&data);
} }
else else
{ {
sLog.outDebug("Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName(), target->GetEntry(), target->GetTypeId()); sLog.outDebug("Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName(), target->GetEntry(), target->GetTypeId());
StopCastingBindSight(); StopCastingBindSight();
if(GetUInt64Value(PLAYER_FARSIGHT))
{
sLog.outError("Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName());
return;
}
SetUInt64Value(PLAYER_FARSIGHT, target->GetGUID()); SetUInt64Value(PLAYER_FARSIGHT, target->GetGUID());
if(target->isType(TYPEMASK_UNIT)) if(target->isType(TYPEMASK_UNIT))
((Unit*)target)->AddPlayerToVision(this); ((Unit*)target)->AddPlayerToVision(this);