From ae7a8a09718115b291d18929c098c5082ee0fda8 Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 22 Mar 2009 11:35:25 -0600 Subject: *Do not set another viewpoint when the old one cannot be removed. --HG-- branch : trunk --- src/game/Player.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/game/Player.cpp') diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 367baf29d6a..050ae12b818 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -20079,21 +20079,32 @@ void Player::StopCastingBindSight() 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()); + + if(WorldObject *viewpoint = GetViewpoint()) + if(viewpoint->isType(TYPEMASK_UNIT)) + ((Unit*)viewpoint)->RemovePlayerFromVision(this); 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 m_seer = this; + + //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(GetUInt64Value(PLAYER_FARSIGHT)) + { + sLog.outError("Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName()); + return; + } + SetUInt64Value(PLAYER_FARSIGHT, target->GetGUID()); if(target->isType(TYPEMASK_UNIT)) ((Unit*)target)->AddPlayerToVision(this); -- cgit v1.2.3