aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2019-08-03 18:12:53 +0200
committerccrs <ccrs@users.noreply.github.com>2019-08-03 18:12:53 +0200
commit8e88f4501d8e3b537e96fa56ad7dd25a61dff968 (patch)
tree17909062ba80576343787227e527538cb2445c6e /src
parent5ec856d81d764729cd0ad7ac31ac504b4cb7082a (diff)
Core/Creature: add a const spell-focus-check method and remove a nasty const_cast from IsMovementPreventedByCasting()
closes #23670 maybe #22857 ?
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp2
-rw-r--r--src/server/game/Entities/Creature/Creature.h1
-rw-r--r--src/server/game/Entities/Unit/Unit.h1
3 files changed, 3 insertions, 1 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index e0ef6a70e27..819d19b4f09 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -3184,7 +3184,7 @@ bool Creature::IsMovementPreventedByCasting() const
return false;
}
- if (const_cast<Creature*>(this)->HandleSpellFocus(nullptr, true))
+ if (HasSpellFocusTarget())
return true;
if (HasUnitState(UNIT_STATE_CASTING))
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 96832971515..41170334aac 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -351,6 +351,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
void SetSpellFocusTarget(Spell const* focusSpell, WorldObject const* target);
bool HandleSpellFocus(Spell const* focusSpell = nullptr, bool withDelay = false) override;
void ReleaseSpellFocus(Spell const* focusSpell = nullptr, bool withDelay = true);
+ bool HasSpellFocusTarget() const override { return IsAlive() && (_focusSpell || _spellFocusDelay); }
bool IsMovementPreventedByCasting() const override;
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 36542083450..4b8a1da607a 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1358,6 +1358,7 @@ class TC_GAME_API Unit : public WorldObject
int32 GetCurrentSpellCastTime(uint32 spell_id) const;
virtual bool HandleSpellFocus(Spell const* /*focusSpell*/ = nullptr, bool /*withDelay*/ = false) { return false; }
+ virtual bool HasSpellFocusTarget() const { return false; }
virtual bool IsMovementPreventedByCasting() const;
SpellHistory* GetSpellHistory() { return m_spellHistory; }