*Set seer back when it is removed to prevent crash.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-19 08:59:15 -06:00
parent 2f9688bb07
commit 4877009098
5 changed files with 22 additions and 34 deletions
+2 -2
View File
@@ -1442,8 +1442,8 @@ void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data )
_player->SetSeer(_player);
break;
case 1:
sLog.outDebug("Added FarSight " I64FMT " to player %u", _player->GetFarSightGUID(), _player->GetGUIDLow());
if(WorldObject *target = _player->GetFarsightTarget())
sLog.outDebug("Added FarSight " I64FMT " to player %u", _player->GetUInt64Value(PLAYER_FARSIGHT), _player->GetGUIDLow());
if(WorldObject *target = _player->GetViewpoint())
_player->SetSeer(target);
else
sLog.outError("Player %s requests non-existing seer", _player->GetName());
+14 -22
View File
@@ -20191,46 +20191,31 @@ void Player::HandleFallUnderMap()
}
}
/*void Player::SetViewport(uint64 guid, bool moveable)
{
WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, 8+1);
data.appendPackGUID(guid); // Packed guid of object to set client's view to
data << (moveable ? uint8(0x01) : uint8(0x00)); // 0 - can't move; 1 - can move
m_session->SendPacket(&data);
sLog.outDetail("Viewport for "I64FMT" (%s) changed to "I64FMT, GetGUID(), GetName(), guid);
}*/
WorldObject* Player::GetFarsightTarget() const
{
// Players can have in farsight field another player's guid, a creature's guid, or a dynamic object's guid
if(uint64 guid = GetFarSightGUID())
return (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_SEER);
return NULL;
}
void Player::StopCastingBindSight()
{
if (WorldObject* target = GetFarsightTarget())
if(WorldObject* target = GetViewpoint())
{
if (target->isType(TYPEMASK_UNIT))
if(target->isType(TYPEMASK_UNIT))
((Unit*)target)->RemoveAuraTypeByCaster(SPELL_AURA_BIND_SIGHT, GetGUID());
}
}
void Player::CreateSeer(WorldObject* target)
void Player::CreateViewpoint(WorldObject* target)
{
if(!target || target == this) // remove seer
{
sLog.outDebug("Player::CreateSeer: Player %s remove seer", GetName());
sLog.outDebug("Player::CreateViewpoint: Player %s remove seer", GetName());
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;
}
else
{
sLog.outDebug("Player::CreateSeer: 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();
SetUInt64Value(PLAYER_FARSIGHT, target->GetGUID());
if(target->isType(TYPEMASK_UNIT))
@@ -20238,6 +20223,13 @@ void Player::CreateSeer(WorldObject* target)
}
}
WorldObject* Player::GetViewpoint() const
{
if(uint64 guid = GetUInt64Value(PLAYER_FARSIGHT))
return (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_SEER);
return NULL;
}
bool Player::CanUseBattleGroundObject()
{
return ( //InBattleGround() && // in battleground - not need, check in other cases
+3 -7
View File
@@ -2057,16 +2057,12 @@ class TRINITY_DLL_SPEC Player : public Unit
void EnterVehicle(Vehicle *vehicle);
void ExitVehicle(Vehicle *vehicle);
void SetMover(Unit* target) { CreateSeer(target); m_mover = target; }
void CreateSeer(WorldObject *target);
void SetMover(Unit* target) { CreateViewpoint(target); m_mover = target; }
void SetSeer(WorldObject *target) { m_seer = target; }
void CreateViewpoint(WorldObject *target);
WorldObject* GetViewpoint() const;
void StopCastingCharm() { Uncharm(); }
void StopCastingBindSight();
uint64 GetFarSightGUID() const { return GetUInt64Value(PLAYER_FARSIGHT); }
WorldObject* GetFarsightTarget() const;
// Controls if vision is currently on farsight object, updated in FAR_SIGHT opcode
void SetFarsightVision(bool apply) { m_farsightVision = apply; }
bool HasFarsightVision() const { return m_farsightVision; }
// Transports
Transport * GetTransport() const { return m_transport; }
+2 -2
View File
@@ -2001,7 +2001,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
if( m_target->GetTypeId() == TYPEID_PLAYER && GetSpellProto()->Effect[0]==72 )
{
// spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
((Player*)m_target)->CreateSeer(NULL);
((Player*)m_target)->CreateViewpoint(NULL);
return;
}
@@ -2949,7 +2949,7 @@ void Aura::HandleBindSight(bool apply, bool Real)
if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
return;
((Player*)caster)->CreateSeer(apply ? m_target : NULL);
((Player*)caster)->CreateViewpoint(apply ? m_target : NULL);
}
void Aura::HandleFarSight(bool apply, bool Real)
+1 -1
View File
@@ -3657,7 +3657,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)->CreateSeer(dynObj);
((Player*)m_caster)->CreateViewpoint(dynObj);
//((Player*)m_caster)->UpdateVisibilityOf(dynObj);
}