diff options
author | ccrs <ccrs@users.noreply.github.com> | 2019-08-03 18:12:53 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-18 00:35:14 +0100 |
commit | 44e9572a77061a8ddf04940f8e76f6585ad4ca05 (patch) | |
tree | 261a39046dc6515dca4c4d5c65ff02b593c94e34 /src | |
parent | 8446f4fe0437dc0e2b0fa19a00dcbbf5c5eb5cc0 (diff) |
Core/Creature: add a const spell-focus-check method and remove a nasty const_cast from IsMovementPreventedByCasting()
closes #23670
maybe #22857 ?
(cherry picked from commit 8e88f4501d8e3b537e96fa56ad7dd25a61dff968)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 1 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 1 |
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 489320de190..468f2d81f0f 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -3345,7 +3345,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 14b5db8f242..9cc915d3e63 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -359,6 +359,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 cd7d690e989..23624766dbb 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1504,6 +1504,7 @@ class TC_GAME_API Unit : public WorldObject uint32 GetCastSpellXSpellVisualId(SpellInfo const* spellInfo) const override; virtual bool HandleSpellFocus(Spell const* /*focusSpell*/ = nullptr, bool /*withDelay*/ = false) { return false; } + virtual bool HasSpellFocusTarget() const { return false; } virtual bool IsMovementPreventedByCasting() const; bool CanCastSpellWhileMoving(SpellInfo const* spellInfo) const; |