diff options
author | Ovah <dreadkiller@gmx.de> | 2020-01-22 13:32:38 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-20 23:47:23 +0100 |
commit | 43a7091e8a86179e195e2bc021133ce751d48d48 (patch) | |
tree | 89e1537a0539a2b22dcc5a4406fe9e684f16f459 /src | |
parent | 95b8d0fcf44ea037cf5a177ba5ca94b1f02c64f4 (diff) |
Core/Movement: properly fix aura interrupts during movement (#24068)
We want our movement to be fully updated before even thinking about interrupting anything. The old logic was updating positions, interrupting stuff and afterwards updating movement generators. This way we were ending up with false interrupts.
properly fixes #22908
(cherry picked from commit 02daf1bf3afc570c26e8e9f431866fcb3720174a)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 28 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 19 | ||||
-rw-r--r-- | src/server/game/Miscellaneous/SharedDefines.h | 17 |
3 files changed, 47 insertions, 17 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 1f16f9789b1..556b6f5ac74 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -479,6 +479,12 @@ void Unit::Update(uint32 p_time) UpdateSplineMovement(p_time); i_motionMaster->Update(p_time); + // Wait with the aura interrupts until we have updated our movement generators and position + if (GetTypeId() == TYPEID_PLAYER) + InterruptMovementBasedAuras(); + else if (!movespline->Finalized()) + InterruptMovementBasedAuras(); + if (!GetAI() && (GetTypeId() != TYPEID_PLAYER || (IsCharmed() && GetCharmerGUID().IsCreature()))) UpdateCharmAI(); RefreshAI(); @@ -543,6 +549,16 @@ void Unit::UpdateSplinePosition() UpdatePosition(loc.x, loc.y, loc.z, loc.orientation); } +void Unit::InterruptMovementBasedAuras() +{ + // TODO: Check if orientation transport offset changed instead of only global orientation + if (_positionUpdateInfo.Turned) + RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Turning); + + if (_positionUpdateInfo.Relocated && !GetVehicle()) + RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Moving); +} + void Unit::DisableSpline() { m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_FORWARD); @@ -9999,6 +10015,8 @@ void Unit::UpdateReactives(uint32 p_time) if (HasAuraState(AURA_STATE_DEFENSIVE_2)) ModifyAuraState(AURA_STATE_DEFENSIVE_2, false); break; + default: + break; } } else @@ -12003,15 +12021,8 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel std::fabs(GetPositionY() - y) > 0.001f || std::fabs(GetPositionZ() - z) > 0.001f); - // TODO: Check if orientation transport offset changed instead of only global orientation - if (turn) - RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Turning); - if (relocated) { - if (!GetVehicle()) - RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Moving); - // move and update visible state if need if (GetTypeId() == TYPEID_PLAYER) GetMap()->PlayerRelocation(ToPlayer(), x, y, z, orientation); @@ -12023,6 +12034,9 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel UpdatePositionData(); + _positionUpdateInfo.Relocated = relocated; + _positionUpdateInfo.Turned = turn; + bool isInWater = IsInWater(); if (!IsFalling() || isInWater || IsFlying()) RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags2::Ground); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 1708a6b8a6d..d1a21e06538 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -717,18 +717,15 @@ struct TC_GAME_API CharmInfo enum ReactiveType { REACTIVE_DEFENSE = 0, - REACTIVE_DEFENSE_2 = 1 + REACTIVE_DEFENSE_2 = 1, + MAX_REACTIVE }; -#define MAX_REACTIVE 2 -#define SUMMON_SLOT_PET 0 -#define SUMMON_SLOT_TOTEM 1 -#define MAX_TOTEM_SLOT 5 -#define SUMMON_SLOT_MINIPET 5 -#define SUMMON_SLOT_QUEST 6 -#define MAX_SUMMON_SLOT 7 - -#define MAX_GAMEOBJECT_SLOT 4 +struct PositionUpdateInfo +{ + bool Relocated = false; + bool Turned = false; +}; // delay time next attack to prevent client attack animation problems #define ATTACK_DISPLAY_DELAY 200 @@ -1953,6 +1950,7 @@ class TC_GAME_API Unit : public WorldObject void UpdateSplineMovement(uint32 t_diff); void UpdateSplinePosition(); + void InterruptMovementBasedAuras(); // player or player's pet float GetCombatRatingReduction(CombatRating cr) const; @@ -2006,6 +2004,7 @@ class TC_GAME_API Unit : public WorldObject SpellHistory* _spellHistory; std::unique_ptr<MovementForces> _movementForces; + PositionUpdateInfo _positionUpdateInfo; }; namespace Trinity diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 3da7ec97af4..211f13f17be 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -5855,6 +5855,23 @@ enum class SummonTitle : int32 ServantOfNZoth = 44 }; +enum SummonSlot : int32 +{ + SUMMON_SLOT_ANY_TOTEM = -1, + SUMMON_SLOT_PET = 0, + SUMMON_SLOT_TOTEM = 1, + SUMMON_SLOT_TOTEM_2 = 2, + SUMMON_SLOT_TOTEM_3 = 3, + SUMMON_SLOT_TOTEM_4 = 4, + SUMMON_SLOT_MINIPET = 5, + SUMMON_SLOT_QUEST = 6, + + MAX_SUMMON_SLOT +}; + +#define MAX_TOTEM_SLOT 5 +#define MAX_GAMEOBJECT_SLOT 4 + enum EventId { EVENT_CHARGE = 1003, |