aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-03-10 15:26:17 -0600
committermegamage <none@none>2009-03-10 15:26:17 -0600
commit167ca565d044915f01ead4b189754ab1c44cc981 (patch)
tree84fce28796ad726f1a0d629444741c7ff8ffb4cf /src
parentfec6be8a7428cdf3328f0480f6b85a56f283b79d (diff)
*Update bind sight spells code.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/Corpse.cpp2
-rw-r--r--src/game/DynamicObject.cpp3
-rw-r--r--src/game/GameObject.cpp2
-rw-r--r--src/game/MiscHandler.cpp12
-rw-r--r--src/game/Object.h4
-rw-r--r--src/game/Player.cpp60
-rw-r--r--src/game/Player.h6
-rw-r--r--src/game/SpellAuras.cpp12
-rw-r--r--src/game/SpellEffects.cpp4
-rw-r--r--src/game/Unit.cpp8
-rw-r--r--src/game/Unit.h2
11 files changed, 56 insertions, 59 deletions
diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp
index 63d156583af..43025958224 100644
--- a/src/game/Corpse.cpp
+++ b/src/game/Corpse.cpp
@@ -220,6 +220,6 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields)
bool Corpse::isVisibleForInState(Player const* u, bool inVisibleList) const
{
- return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
+ return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(u->m_seer,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp
index ba903568733..4667b7c91a5 100644
--- a/src/game/DynamicObject.cpp
+++ b/src/game/DynamicObject.cpp
@@ -142,7 +142,6 @@ void DynamicObject::Delay(int32 delaytime)
bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const
{
return IsInWorld() && u->IsInWorld()
- && (IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false)
- || GetCasterGUID() == u->GetGUID());
+ && (IsWithinDistInMap(u->m_seer,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false));
}
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 8f620638b01..f967bb50dfc 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -754,7 +754,7 @@ bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const
}
// check distance
- return IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject() +
+ return IsWithinDistInMap(u->m_seer,World::GetMaxVisibleDistanceForObject() +
(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index d176c19baf7..93659bd6e0a 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -1433,21 +1433,15 @@ void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data )
uint8 apply;
recv_data >> apply;
- CellPair pair;
switch(apply)
{
case 0:
- _player->SetFarsightVision(false);
- pair = Trinity::ComputeCellPair(_player->GetPositionX(), _player->GetPositionY());
- sLog.outDebug("Player %u set vision to himself", _player->GetGUIDLow());
+ _player->SetSeer(_player);
+ sLog.outDebug("Player %u set vision to self", _player->GetGUIDLow());
break;
case 1:
- _player->SetFarsightVision(true);
- if (WorldObject* obj = _player->GetFarsightTarget())
- pair = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
- else
- return;
+ _player->SetSeer(_player->GetFarsightTarget());
sLog.outDebug("Added FarSight " I64FMT " to player %u", _player->GetFarSightGUID(), _player->GetGUIDLow());
break;
default:
diff --git a/src/game/Object.h b/src/game/Object.h
index f98c32d46d3..93cde906468 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -50,14 +50,14 @@ enum TypeMask
TYPEMASK_OBJECT = 0x0001,
TYPEMASK_ITEM = 0x0002,
TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004
- TYPEMASK_UNIT = 0x0008,
+ TYPEMASK_UNIT = 0x0008, //creature or player
TYPEMASK_PLAYER = 0x0010,
TYPEMASK_GAMEOBJECT = 0x0020,
TYPEMASK_DYNAMICOBJECT = 0x0040,
TYPEMASK_CORPSE = 0x0080,
TYPEMASK_AIGROUP = 0x0100,
TYPEMASK_AREATRIGGER = 0x0200,
- TYPEMASK_FARSIGHTOBJ = TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
+ TYPEMASK_SEER = TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
};
enum TypeID
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 7ad1be5a478..9571f415ac7 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -455,7 +455,8 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this)
//Default movement to run mode
m_unit_movement_flags = 0;
- m_mover = NULL;
+ m_mover = this;
+ m_seer = this;
m_miniPet = 0;
m_bgAfkReportedTimer = 0;
@@ -14936,14 +14937,13 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
// clear charm/summon related fields
SetCharm(NULL);
- SetMover(NULL);
+ SetMover(this);
SetPet(NULL);
SetCharmerGUID(0);
SetOwnerGUID(0);
SetCreatorGUID(0);
// reset some aura modifiers before aura apply
- SetFarSightGUID(0);
SetUInt32Value(PLAYER_TRACK_CREATURES, 0 );
SetUInt32Value(PLAYER_TRACK_RESOURCES, 0 );
@@ -18571,9 +18571,9 @@ bool Player::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList, bool
return false;
// If the player is currently channeling vision, update visibility from the target unit's location
- const WorldObject* target = GetFarsightTarget();
- if (!target || !HasFarsightVision()) // Vision needs to be on the farsight target
- target = this;
+ const WorldObject* target = m_seer;
+ //if (!target || !HasFarsightVision()) // Vision needs to be on the farsight target
+ // target = this;
// different visible distance checks
if(isInFlight()) // what see player in flight
@@ -18973,6 +18973,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
m_mover = this;
+ m_seer = this;
}
void Player::SendInitialPacketsAfterAddToMap()
@@ -20141,7 +20142,7 @@ 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_FARSIGHTOBJ);
+ return (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_SEER);
return NULL;
}
@@ -20149,30 +20150,39 @@ void Player::StopCastingBindSight()
{
if (WorldObject* target = GetFarsightTarget())
{
- if (target->isType(TYPEMASK_PLAYER | TYPEMASK_UNIT))
+ if (target->isType(TYPEMASK_UNIT))
((Unit*)target)->RemoveSpellsCausingAura(SPELL_AURA_BIND_SIGHT);
}
}
-void Player::ClearFarsight()
-{
- if(GetFarSightGUID())
- {
- SetFarSightGUID(0);
- WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
- GetSession()->SendPacket(&data);
- }
-}
-
-void Player::SetFarsightTarget(WorldObject* obj)
+void Player::SetSeer(WorldObject* target)
{
- if (!obj || !obj->isType(TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT))
+ if(target == m_seer)
return;
- // Remove the current target if there is one
- StopCastingBindSight();
+ sLog.outDebug("Player::SetSeer: Player %s set object %u (TypeId: %u) as seer.", GetName(), target->GetEntry(), target->GetTypeId());
+
+ if(target == this)
+ {
+ if(GetFarSightGUID())
+ {
+ SetFarSightGUID(0);
+ WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
+ GetSession()->SendPacket(&data);
+ }
+
+ if(m_seer->isType(TYPEMASK_UNIT))
+ ((Unit*)m_seer)->RemovePlayerFromVision(this);
+ }
+ else if(target->isType(TYPEMASK_SEER))
+ {
+ StopCastingBindSight();
+ SetFarSightGUID(target->GetGUID());
- SetFarSightGUID(obj->GetGUID());
+ if(target->isType(TYPEMASK_UNIT))
+ ((Unit*)target)->AddPlayerToVision(this);
+ }
+ m_seer = target;
}
bool Player::CanUseBattleGroundObject()
@@ -20270,7 +20280,6 @@ void Player::EnterVehicle(Vehicle *vehicle)
SetCharm(vehicle); // charm
SetMover(vehicle);
- SetFarSightGUID(vehicle->GetGUID()); // set view
SetClientControl(vehicle, 1); // redirect controls to vehicle
@@ -20321,8 +20330,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
vehicle->setFaction((GetTeam() == ALLIANCE) ? vehicle->GetCreatureInfo()->faction_A : vehicle->GetCreatureInfo()->faction_H);
SetCharm(NULL);
- SetMover(NULL);
- SetFarSightGUID(0);
+ SetMover(this);
SetClientControl(vehicle, 0);
diff --git a/src/game/Player.h b/src/game/Player.h
index 196c3e6fcfa..686dc86d5e9 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -2030,6 +2030,7 @@ class TRINITY_DLL_SPEC Player : public Unit
uint32 m_lastFallTime;
float m_lastFallZ;
Unit *m_mover;
+ WorldObject *m_seer;
void SetFallInformation(uint32 time, float z)
{
m_lastFallTime = time;
@@ -2051,14 +2052,13 @@ class TRINITY_DLL_SPEC Player : public Unit
void EnterVehicle(Vehicle *vehicle);
void ExitVehicle(Vehicle *vehicle);
- void SetMover(Unit* target) { m_mover = target ? target : this; }
+ void SetMover(Unit* target) { SetSeer(target); m_mover = target; }
+ void SetSeer(WorldObject *target);
void StopCastingCharm() { Uncharm(); }
void StopCastingBindSight();
uint64 GetFarSightGUID() const { return GetUInt64Value(PLAYER_FARSIGHT); }
void SetFarSightGUID(uint64 guid) { SetUInt64Value(PLAYER_FARSIGHT, guid); }
WorldObject* GetFarsightTarget() const;
- void ClearFarsight();
- void SetFarsightTarget(WorldObject* target);
// 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; }
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index fb0a943bc3d..0f93e915adb 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -1918,7 +1918,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)->ClearFarsight();
+ ((Player*)m_target)->SetSeer(m_target);
return;
}
@@ -2819,19 +2819,17 @@ void Aura::HandleBindSight(bool apply, bool Real)
if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
return;
- if(apply)
- m_target->AddPlayerToVision((Player*)caster);
- else
- m_target->RemovePlayerFromVision((Player*)caster);
+ ((Player*)caster)->SetSeer(apply ? m_target : caster);
}
void Aura::HandleFarSight(bool apply, bool Real)
{
- Unit* caster = GetCaster();
+ //Handled by client
+ /*Unit* caster = GetCaster();
if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
return;
- ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
+ ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);*/
}
void Aura::HandleAuraTrackCreatures(bool apply, bool Real)
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 2e4e6cdecb4..aac198d088e 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -3648,8 +3648,8 @@ 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)->UpdateVisibilityOf(dynObj);
- ((Player*)m_caster)->SetFarsightTarget(dynObj);
+ ((Player*)m_caster)->SetSeer(dynObj);
+ //((Player*)m_caster)->UpdateVisibilityOf(dynObj);
}
void Spell::EffectSummonWild(uint32 i)
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index fb1da20d39a..5adf109e2a8 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -8136,6 +8136,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
return nearMembers[randTarget];
}
+//only called in Player::SetSeer
void Unit::AddPlayerToVision(Player* plr)
{
if(m_sharedVision.empty())
@@ -8144,9 +8145,9 @@ void Unit::AddPlayerToVision(Player* plr)
SetWorldObject(true);
}
m_sharedVision.push_back(plr);
- plr->SetFarsightTarget(this);
}
+//only called in Player::SetSeer
void Unit::RemovePlayerFromVision(Player* plr)
{
m_sharedVision.remove(plr);
@@ -8155,7 +8156,6 @@ void Unit::RemovePlayerFromVision(Player* plr)
setActive(false);
SetWorldObject(false);
}
- plr->ClearFarsight();
}
void Unit::RemoveBindSightAuras()
@@ -10765,7 +10765,7 @@ Unit* Unit::GetUnit(WorldObject& object, uint64 guid)
bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const
{
- return isVisibleForOrDetect(u, false, inVisibleList, false);
+ return u->canSeeOrDetect(this, false, inVisibleList, false);
}
uint32 Unit::GetCreatureType() const
@@ -13018,7 +13018,6 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess)
{
addUnitState(UNIT_STAT_POSSESSED);
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
- AddPlayerToVision((Player*)charmer);
((Player*)charmer)->SetClientControl(this, 1);
((Player*)charmer)->SetMover(this);
charmer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
@@ -13101,7 +13100,6 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer)
charmer->SetCharm(0);
if(possess)
{
- RemovePlayerFromVision((Player*)charmer);
((Player*)charmer)->SetClientControl(charmer, 1);
((Player*)charmer)->SetMover(charmer);
charmer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
diff --git a/src/game/Unit.h b/src/game/Unit.h
index fa5faa4452a..c6f9c4d17c9 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1344,7 +1344,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void DestroyForNearbyPlayers();
// common function for visibility checks for player/creatures with detection code
- virtual bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
+ virtual bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const = 0;
bool isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
bool canDetectInvisibilityOf(Unit const* u) const;
bool canDetectStealthOf(Unit const* u, float distance) const;