diff options
| author | Shauren <shauren.trinity@gmail.com> | 2013-11-10 18:52:20 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2013-11-10 18:52:20 +0100 |
| commit | 1966a78b9f0d0f56de6b611e7ede99464a3a6ea5 (patch) | |
| tree | 6c4bf83ea9e0960b09f3be01b83239a42d49794f /src/server/game/Entities/Unit | |
| parent | 8332cee0522b9166bd73903b85a3220a84b57a5f (diff) | |
Core/Movement: Backported spline stop fix from 4.3.4 branch - use Stop spline type for stopping movement instead of starting movement that ends in creature's current position
Diffstat (limited to 'src/server/game/Entities/Unit')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 49 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 1 |
2 files changed, 27 insertions, 23 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index b9b4b7ebd83..2cb767a6b4d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -385,8 +385,6 @@ void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed, bool gen void Unit::UpdateSplineMovement(uint32 t_diff) { - uint32 const positionUpdateDelay = 400; - if (movespline->Finalized()) return; @@ -398,27 +396,32 @@ void Unit::UpdateSplineMovement(uint32 t_diff) m_movesplineTimer.Update(t_diff); if (m_movesplineTimer.Passed() || arrived) - { - m_movesplineTimer.Reset(positionUpdateDelay); - Movement::Location loc = movespline->ComputePosition(); + UpdateSplinePosition(); +} - if (HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT)) - { - Position& pos = m_movementInfo.transport.pos; - pos.m_positionX = loc.x; - pos.m_positionY = loc.y; - pos.m_positionZ = loc.z; - pos.m_orientation = loc.orientation; +void Unit::UpdateSplinePosition() +{ + static uint32 const positionUpdateDelay = 400; - if (TransportBase* transport = GetDirectTransport()) - transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, &loc.orientation); - } + m_movesplineTimer.Reset(positionUpdateDelay); + Movement::Location loc = movespline->ComputePosition(); - if (HasUnitState(UNIT_STATE_CANNOT_TURN)) - loc.orientation = GetOrientation(); + if (HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT)) + { + Position& pos = m_movementInfo.transport.pos; + pos.m_positionX = loc.x; + pos.m_positionY = loc.y; + pos.m_positionZ = loc.z; + pos.m_orientation = loc.orientation; - UpdatePosition(loc.x, loc.y, loc.z, loc.orientation); + if (TransportBase* transport = GetDirectTransport()) + transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, &loc.orientation); } + + if (HasUnitState(UNIT_STATE_CANNOT_TURN)) + loc.orientation = GetOrientation(); + + UpdatePosition(loc.x, loc.y, loc.z, loc.orientation); } void Unit::DisableSpline() @@ -14413,14 +14416,14 @@ void Unit::StopMoving() { ClearUnitState(UNIT_STATE_MOVING); - // not need send any packets if not in world - if (!IsInWorld()) + // not need send any packets if not in world or not moving + if (!IsInWorld() || movespline->Finalized()) return; + // Update position now since Stop does not start a new movement that can be updated later + UpdateSplinePosition(); Movement::MoveSplineInit init(this); - init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZMinusOffset(), false); - init.SetFacing(GetOrientation()); - init.Launch(); + init.Stop(); } void Unit::SendMovementFlagUpdate(bool self /* = false */) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index f8d5964beca..4091ea15662 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2214,6 +2214,7 @@ class Unit : public WorldObject bool HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura); void UpdateSplineMovement(uint32 t_diff); + void UpdateSplinePosition(); // player or player's pet float GetCombatRatingReduction(CombatRating cr) const; |
