diff --git a/src/game/DestinationHolder.h b/src/game/DestinationHolder.h index 5e4dc9dca..7c8b6ba2b 100644 --- a/src/game/DestinationHolder.h +++ b/src/game/DestinationHolder.h @@ -54,7 +54,7 @@ class MANGOS_DLL_DECL DestinationHolder uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true); void GetLocationNow(const Map * map, float &x, float &y, float &z, bool is3D = false) const; void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement - float GetDistance2dFromDestSq(const WorldObject &obj) const; + float GetDistance3dFromDestSq(const WorldObject &obj) const; private: void _findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y); diff --git a/src/game/DestinationHolderImp.h b/src/game/DestinationHolderImp.h index bb8f54829..a5c42ebc4 100644 --- a/src/game/DestinationHolderImp.h +++ b/src/game/DestinationHolderImp.h @@ -93,19 +93,20 @@ template bool DestinationHolder::UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update, bool micro_movement) { - if(!micro_movement) + if (!micro_movement) { i_tracker.Update(diff); i_timeElapsed += diff; - if( i_tracker.Passed() || force_update ) + if (i_tracker.Passed() || force_update) { ResetUpdate(); - if(!i_destSet) return true; + if (!i_destSet) return true; + float x,y,z; GetLocationNowNoMicroMovement(x, y, z); if( x == -431602080 ) return false; - if( traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y ) + if (traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y || traveller.GetTraveller().GetPositionZ() != z) { float ori = traveller.GetTraveller().GetAngle(x, y); traveller.Relocation(x, y, z, ori); @@ -116,16 +117,16 @@ DestinationHolder::UpdateTraveller(TRAVELLER &traveller, uint32 diff, } i_tracker.Update(diff); i_timeElapsed += diff; - if( i_tracker.Passed() || force_update ) + if (i_tracker.Passed() || force_update) { ResetUpdate(); - if(!i_destSet) return true; - float x,y,z; + if (!i_destSet) return true; - if(!traveller.GetTraveller().hasUnitState(UNIT_STAT_MOVING | UNIT_STAT_IN_FLIGHT)) + if (!traveller.GetTraveller().hasUnitState(UNIT_STAT_MOVING | UNIT_STAT_IN_FLIGHT)) return true; - if(traveller.GetTraveller().hasUnitState(UNIT_STAT_IN_FLIGHT)) + float x,y,z; + if (traveller.GetTraveller().hasUnitState(UNIT_STAT_IN_FLIGHT)) GetLocationNow(traveller.GetTraveller().GetBaseMap() ,x, y, z, true); // Should reposition Object with right Coord, so I can bypass some Grid Relocation else GetLocationNow(traveller.GetTraveller().GetBaseMap(), x, y, z, false); @@ -133,7 +134,7 @@ DestinationHolder::UpdateTraveller(TRAVELLER &traveller, uint32 diff, if( x == -431602080 ) return false; - if( traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y ) + if (traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y || traveller.GetTraveller().GetPositionZ() != z) { float ori = traveller.GetTraveller().GetAngle(x, y); traveller.Relocation(x, y, z, ori); @@ -160,13 +161,13 @@ template void DestinationHolder::GetLocationNow(const Map * map, float &x, float &y, float &z, bool is3D) const { - if( HasArrived() ) + if (HasArrived()) { x = i_destX; y = i_destY; z = i_destZ; } - else if(HasDestination()) + else if (HasDestination()) { double percent_passed = (double)i_timeElapsed / (double)i_totalTravelTime; const float distanceX = ((i_destX - i_fromX) * percent_passed); @@ -176,7 +177,7 @@ DestinationHolder::GetLocationNow(const Map * map, float &x, float &y y = i_fromY + distanceY; float z2 = i_fromZ + distanceZ; // All that is not finished but previous code neither... Traveller need be able to swim. - if(is3D) + if (is3D) z = z2; else { @@ -193,11 +194,11 @@ DestinationHolder::GetLocationNow(const Map * map, float &x, float &y template float -DestinationHolder::GetDistance2dFromDestSq(const WorldObject &obj) const +DestinationHolder::GetDistance3dFromDestSq(const WorldObject &obj) const { float x,y,z; obj.GetPosition(x,y,z); - return (i_destX-x)*(i_destX-x)+(i_destY-y)*(i_destY-y); + return (i_destX-x)*(i_destX-x)+(i_destY-y)*(i_destY-y)+(i_destZ-z)*(i_destZ-z); } template @@ -211,7 +212,7 @@ template void DestinationHolder::GetLocationNowNoMicroMovement(float &x, float &y, float &z) const { - if( HasArrived() ) + if (HasArrived()) { x = i_destX; y = i_destY; diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index 9ec7ece76..11b1bbdfa 100644 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -136,7 +136,7 @@ TargetedMovementGenerator::Update(T &owner, const uint32 & time_diff) return true; // prevent movement while casting spells with cast time or channel time - if ( owner.IsNonMeleeSpellCasted(false, false, true)) + if (owner.IsNonMeleeSpellCasted(false, false, true)) { if (!owner.IsStopped()) owner.StopMoving(); @@ -149,9 +149,9 @@ TargetedMovementGenerator::Update(T &owner, const uint32 & time_diff) Traveller traveller(owner); - if( !i_destinationHolder.HasDestination() ) + if (!i_destinationHolder.HasDestination()) _setTargetLocation(owner); - if( owner.IsStopped() && !i_destinationHolder.HasArrived() ) + if (owner.IsStopped() && !i_destinationHolder.HasArrived()) { owner.addUnitState(UNIT_STAT_CHASE); if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly()) @@ -172,16 +172,16 @@ TargetedMovementGenerator::Update(T &owner, const uint32 & time_diff) //More distance let have better performance, less distance let have more sensitive reaction at target move. // try to counter precision differences - if( i_destinationHolder.GetDistance2dFromDestSq(*i_target.getTarget()) >= dist * dist) + if (i_destinationHolder.GetDistance3dFromDestSq(*i_target.getTarget()) >= dist * dist) { owner.SetInFront(i_target.getTarget()); // Set new Angle For Map:: _setTargetLocation(owner); //Calculate New Dest and Send data To Player } // Update the Angle of the target only for Map::, no need to send packet for player - else if ( !i_angle && !owner.HasInArc( 0.01f, i_target.getTarget() ) ) + else if (!i_angle && !owner.HasInArc(0.01f, i_target.getTarget())) owner.SetInFront(i_target.getTarget()); - if(( owner.IsStopped() && !i_destinationHolder.HasArrived() ) || i_recalculateTravel ) + if ((owner.IsStopped() && !i_destinationHolder.HasArrived()) || i_recalculateTravel) { i_recalculateTravel = false; //Angle update will take place into owner.StopMoving() diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 0bcdf8911..aa87337c8 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8464" + #define REVISION_NR "8465" #endif // __REVISION_NR_H__