diff options
| author | Shauren <shauren.trinity@gmail.com> | 2012-08-11 20:18:00 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2012-08-11 20:18:00 +0200 |
| commit | e7590abce7ac42a3bb21fd353e4338f64253d792 (patch) | |
| tree | 170354d4ff756b7bb951bcd4e3545d071e7aff6e /src/server/game/Entities/Unit | |
| parent | c3e1443a13340efe7a1ffe99f72b1e7edb9ae7b0 (diff) | |
Core/Movement: Use MonsterMoveStop spline type to stop movement instead of sending movement to current position
Diffstat (limited to 'src/server/game/Entities/Unit')
| -rwxr-xr-x | src/server/game/Entities/Unit/Unit.cpp | 62 | ||||
| -rwxr-xr-x | src/server/game/Entities/Unit/Unit.h | 1 |
2 files changed, 33 insertions, 30 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 9d924230a76..06b082de155 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -376,12 +376,13 @@ void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed) init.Launch(); } -void Unit::UpdateSplineMovement(uint32 t_diff) +enum MovementIntervals { - enum{ - POSITION_UPDATE_DELAY = 400, - }; + POSITION_UPDATE_DELAY = 400, +}; +void Unit::UpdateSplineMovement(uint32 t_diff) +{ if (movespline->Finalized()) return; @@ -393,30 +394,32 @@ void Unit::UpdateSplineMovement(uint32 t_diff) m_movesplineTimer.Update(t_diff); if (m_movesplineTimer.Passed() || arrived) - { - m_movesplineTimer.Reset(POSITION_UPDATE_DELAY); - Movement::Location loc = movespline->ComputePosition(); + UpdateSplinePosition(); +} - if (GetTransGUID()) +void Unit::UpdateSplinePosition() +{ + m_movesplineTimer.Reset(POSITION_UPDATE_DELAY); + Movement::Location loc = movespline->ComputePosition(); + if (GetTransGUID()) + { + Position& pos = m_movementInfo.t_pos; + pos.m_positionX = loc.x; + pos.m_positionY = loc.y; + pos.m_positionZ = loc.z; + pos.m_orientation = loc.orientation; + if (Unit* vehicle = GetVehicleBase()) { - Position& pos = m_movementInfo.t_pos; - pos.m_positionX = loc.x; - pos.m_positionY = loc.y; - pos.m_positionZ = loc.z; - pos.m_orientation = loc.orientation; - if (Unit* vehicle = GetVehicleBase()) - { - loc.x += vehicle->GetPositionX(); - loc.y += vehicle->GetPositionY(); - loc.z += vehicle->GetPositionZMinusOffset(); - loc.orientation = vehicle->GetOrientation(); - } - else if (Transport* trans = GetTransport()) - trans->CalculatePassengerPosition(loc.x, loc.y, loc.z, loc.orientation); + loc.x += vehicle->GetPositionX(); + loc.y += vehicle->GetPositionY(); + loc.z += vehicle->GetPositionZMinusOffset(); + loc.orientation = vehicle->GetOrientation(); } - - UpdatePosition(loc.x, loc.y, loc.z, loc.orientation); + else if (Transport* trans = GetTransport()) + trans->CalculatePassengerPosition(loc.x, loc.y, loc.z, loc.orientation); } + + UpdatePosition(loc.x, loc.y, loc.z, loc.orientation); } void Unit::DisableSpline() @@ -15180,14 +15183,13 @@ 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; - Movement::MoveSplineInit init(*this); - init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZMinusOffset()); - init.SetFacing(GetOrientation()); - init.Launch(); + // Update position using old spline + UpdateSplinePosition(); + Movement::MoveSplineInit(*this).Stop(); } void Unit::SendMovementFlagUpdate() diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 7a0b97b90ef..96ee32274ef 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2326,6 +2326,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; |
