From 1f40c574efc1d47f6168f84b1e3df43c92f06c1f Mon Sep 17 00:00:00 2001 From: Vinolentus <655ff4c91d8e57f5@gmail.com> Date: Sat, 24 Sep 2011 06:35:01 +0400 Subject: [PATCH] [2292] Restore ScriptedPetAI's eysight. Merge pull request #4 Also make the interface between ScriptedPetAI and MaNGOS safer. Signed-off-by: Schmoozerd --- base/pet_ai.cpp | 6 ++++++ base/pet_ai.h | 14 ++++++++------ sd2_revision_nr.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/base/pet_ai.cpp b/base/pet_ai.cpp index 040484359..a73a47a2f 100644 --- a/base/pet_ai.cpp +++ b/base/pet_ai.cpp @@ -15,6 +15,12 @@ EndScriptData */ ScriptedPetAI::ScriptedPetAI(Creature* pCreature) : CreatureAI(pCreature) {} +bool ScriptedPetAI::IsVisible(Unit* pWho) const +{ + return pWho && m_creature->IsWithinDist(pWho, VISIBLE_RANGE) + && pWho->isVisibleForOrDetect(m_creature, m_creature, true); +} + void ScriptedPetAI::MoveInLineOfSight(Unit* pWho) { if (m_creature->getVictim()) diff --git a/base/pet_ai.h b/base/pet_ai.h index 8665f488a..d5f4d4567 100644 --- a/base/pet_ai.h +++ b/base/pet_ai.h @@ -12,17 +12,19 @@ class MANGOS_DLL_DECL ScriptedPetAI : public CreatureAI explicit ScriptedPetAI(Creature* pCreature); ~ScriptedPetAI() {} - void MoveInLineOfSight(Unit* /*pWho*/); + void MoveInLineOfSight(Unit* /*pWho*/) override; - void AttackStart(Unit* /*pWho*/); + void AttackStart(Unit* /*pWho*/) override; - void AttackedBy(Unit* /*pAttacker*/); + void AttackedBy(Unit* /*pAttacker*/) override; - void KilledUnit(Unit* /*pVictim*/) {} + bool IsVisible(Unit* /*pWho*/) const override; - void OwnerKilledUnit(Unit* /*pVictim*/) {} + void KilledUnit(Unit* /*pVictim*/) override {} - void UpdateAI(const uint32 uiDiff); + void OwnerKilledUnit(Unit* /*pVictim*/) override {} + + void UpdateAI(const uint32 uiDiff) override; virtual void Reset() {} diff --git a/sd2_revision_nr.h b/sd2_revision_nr.h index 28978ffc7..b59d14c81 100644 --- a/sd2_revision_nr.h +++ b/sd2_revision_nr.h @@ -1,4 +1,4 @@ #ifndef __SD2_REVISION_NR_H__ #define __SD2_REVISION_NR_H__ - #define SD2_REVISION_NR "2291" + #define SD2_REVISION_NR "2292" #endif // __SD2_REVISION_NR_H__