aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-03-19 08:59:15 -0600
committermegamage <none@none>2009-03-19 08:59:15 -0600
commit4877009098c7399ee880f2374b08bf9f1c87d55d (patch)
treebba3785bc5ab04e029aeecc6dbed87082725184d
parent2f9688bb07a59f10ef25f20c53e94c67e4c0e254 (diff)
*Set seer back when it is removed to prevent crash.
--HG-- branch : trunk
-rw-r--r--src/game/MiscHandler.cpp4
-rw-r--r--src/game/Player.cpp36
-rw-r--r--src/game/Player.h10
-rw-r--r--src/game/SpellAuras.cpp4
-rw-r--r--src/game/SpellEffects.cpp2
5 files changed, 22 insertions, 34 deletions
diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index 9cfbcdf091d..446a7331615 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -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());
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 00966d24407..14565e74411 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -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
diff --git a/src/game/Player.h b/src/game/Player.h
index 58f766d677e..b96753b6175 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -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; }
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index e3e2cc1e572..6415638169f 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -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)
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 4c717ba924c..8645d1ab7d4 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -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);
}