*[8465] Fixed exploit of z-axis described in http://getmangos.com/community/showthread.php?t=9652 Author: elecyb
Note: mostly just code cleanup, parts of this already seemed to be implemented, and some code that was updated in MaNGOS doesn't even exist in our code. --HG-- branch : trunk
This commit is contained in:
@@ -56,7 +56,7 @@ class TRINITY_DLL_DECL DestinationHolder
|
|||||||
uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true);
|
uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true);
|
||||||
void GetLocationNow(const Map * map, float &x, float &y, float &z, bool is3D = false) const;
|
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
|
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:
|
private:
|
||||||
void _findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y);
|
void _findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y);
|
||||||
|
|||||||
@@ -107,24 +107,24 @@ DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff,
|
|||||||
if(!i_destSet) return true;
|
if(!i_destSet) return true;
|
||||||
|
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
if(!micro_movement)
|
if (!micro_movement)
|
||||||
{
|
{
|
||||||
GetLocationNowNoMicroMovement(x, y, z);
|
GetLocationNowNoMicroMovement(x, y, z);
|
||||||
|
|
||||||
if( x == -431602080 )
|
if (x == -431602080)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!traveller.GetTraveller().hasUnitState(UNIT_STAT_MOVING | UNIT_STAT_IN_FLIGHT))
|
if (!traveller.GetTraveller().hasUnitState(UNIT_STAT_MOVING | UNIT_STAT_IN_FLIGHT))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(traveller.GetTraveller().hasUnitState(UNIT_STAT_IN_FLIGHT))
|
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
|
GetLocationNow(traveller.GetTraveller().GetBaseMap() ,x, y, z, true); // Should reposition Object with right Coord, so I can bypass some Grid Relocation
|
||||||
else
|
else
|
||||||
GetLocationNow(traveller.GetTraveller().GetBaseMap(), x, y, z, false);
|
GetLocationNow(traveller.GetTraveller().GetBaseMap(), x, y, z, false);
|
||||||
|
|
||||||
if( x == -431602080 )
|
if (x == -431602080)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Change movement computation to micro movement based on last tick coords, this makes system work
|
// Change movement computation to micro movement based on last tick coords, this makes system work
|
||||||
@@ -142,7 +142,7 @@ DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff,
|
|||||||
i_fromZ = z;
|
i_fromZ = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y || traveller.GetTraveller().GetPositionZ() != z)
|
if (traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y || traveller.GetTraveller().GetPositionZ() != z)
|
||||||
{
|
{
|
||||||
float ori = traveller.GetTraveller().GetAngle(x, y);
|
float ori = traveller.GetTraveller().GetAngle(x, y);
|
||||||
traveller.Relocation(x, y, z, ori);
|
traveller.Relocation(x, y, z, ori);
|
||||||
@@ -155,13 +155,13 @@ template<typename TRAVELLER>
|
|||||||
void
|
void
|
||||||
DestinationHolder<TRAVELLER>::GetLocationNow(const Map * map, float &x, float &y, float &z, bool is3D) const
|
DestinationHolder<TRAVELLER>::GetLocationNow(const Map * map, float &x, float &y, float &z, bool is3D) const
|
||||||
{
|
{
|
||||||
if( HasArrived() )
|
if (HasArrived())
|
||||||
{
|
{
|
||||||
x = i_destX;
|
x = i_destX;
|
||||||
y = i_destY;
|
y = i_destY;
|
||||||
z = i_destZ;
|
z = i_destZ;
|
||||||
}
|
}
|
||||||
else if(HasDestination())
|
else if (HasDestination())
|
||||||
{
|
{
|
||||||
double percent_passed = (double)i_timeElapsed / (double)i_totalTravelTime;
|
double percent_passed = (double)i_timeElapsed / (double)i_totalTravelTime;
|
||||||
const float distanceX = ((i_destX - i_fromX) * percent_passed);
|
const float distanceX = ((i_destX - i_fromX) * percent_passed);
|
||||||
@@ -171,7 +171,7 @@ DestinationHolder<TRAVELLER>::GetLocationNow(const Map * map, float &x, float &y
|
|||||||
y = i_fromY + distanceY;
|
y = i_fromY + distanceY;
|
||||||
float z2 = i_fromZ + distanceZ;
|
float z2 = i_fromZ + distanceZ;
|
||||||
// All that is not finished but previous code neither... Traveller need be able to swim.
|
// All that is not finished but previous code neither... Traveller need be able to swim.
|
||||||
if(is3D)
|
if (is3D)
|
||||||
z = z2;
|
z = z2;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -188,11 +188,11 @@ DestinationHolder<TRAVELLER>::GetLocationNow(const Map * map, float &x, float &y
|
|||||||
|
|
||||||
template<typename TRAVELLER>
|
template<typename TRAVELLER>
|
||||||
float
|
float
|
||||||
DestinationHolder<TRAVELLER>::GetDistance2dFromDestSq(const WorldObject &obj) const
|
DestinationHolder<TRAVELLER>::GetDistance3dFromDestSq(const WorldObject &obj) const
|
||||||
{
|
{
|
||||||
float x,y,z;
|
float x,y,z;
|
||||||
obj.GetPosition(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<typename TRAVELLER>
|
template<typename TRAVELLER>
|
||||||
|
|||||||
@@ -182,14 +182,14 @@ TargetedMovementGenerator<T>::Update(T &owner, const uint32 & time_diff)
|
|||||||
if (!i_target.isValid() || !i_target->IsInWorld())
|
if (!i_target.isValid() || !i_target->IsInWorld())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( !&owner || !owner.isAlive())
|
if (!&owner || !owner.isAlive())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DISTRACTED) )
|
if (owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DISTRACTED))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// prevent movement while casting spells with cast time or channel time
|
// prevent movement while casting spells with cast time or channel time
|
||||||
if(owner.hasUnitState(UNIT_STAT_CASTING))
|
if (owner.hasUnitState(UNIT_STAT_CASTING))
|
||||||
{
|
{
|
||||||
if (!owner.IsStopped())
|
if (!owner.IsStopped())
|
||||||
owner.StopMoving();
|
owner.StopMoving();
|
||||||
@@ -202,9 +202,9 @@ TargetedMovementGenerator<T>::Update(T &owner, const uint32 & time_diff)
|
|||||||
|
|
||||||
Traveller<T> traveller(owner);
|
Traveller<T> traveller(owner);
|
||||||
|
|
||||||
if( !i_destinationHolder.HasDestination() )
|
if (!i_destinationHolder.HasDestination())
|
||||||
_setTargetLocation(owner);
|
_setTargetLocation(owner);
|
||||||
else if( owner.IsStopped() && !i_destinationHolder.HasArrived() )
|
else if (owner.IsStopped() && !i_destinationHolder.HasArrived())
|
||||||
{
|
{
|
||||||
owner.addUnitState(UNIT_STAT_CHASE);
|
owner.addUnitState(UNIT_STAT_CHASE);
|
||||||
i_destinationHolder.StartTravel(traveller);
|
i_destinationHolder.StartTravel(traveller);
|
||||||
@@ -218,7 +218,7 @@ TargetedMovementGenerator<T>::Update(T &owner, const uint32 & time_diff)
|
|||||||
//i_destinationHolder.ResetUpdate(50);
|
//i_destinationHolder.ResetUpdate(50);
|
||||||
|
|
||||||
// target moved
|
// target moved
|
||||||
if(i_targetX != i_target->GetPositionX() || i_targetY != i_target->GetPositionY()
|
if (i_targetX != i_target->GetPositionX() || i_targetY != i_target->GetPositionY()
|
||||||
|| i_targetZ != i_target->GetPositionZ())
|
|| i_targetZ != i_target->GetPositionZ())
|
||||||
{
|
{
|
||||||
if(_setTargetLocation(owner) || !owner.hasUnitState(UNIT_STAT_FOLLOW))
|
if(_setTargetLocation(owner) || !owner.hasUnitState(UNIT_STAT_FOLLOW))
|
||||||
@@ -226,7 +226,7 @@ TargetedMovementGenerator<T>::Update(T &owner, const uint32 & time_diff)
|
|||||||
i_target->GetPosition(i_targetX, i_targetY, i_targetZ);
|
i_target->GetPosition(i_targetX, i_targetY, i_targetZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(( owner.IsStopped() && !i_destinationHolder.HasArrived() ) || i_recalculateTravel )
|
if ((owner.IsStopped() && !i_destinationHolder.HasArrived()) || i_recalculateTravel)
|
||||||
{
|
{
|
||||||
i_recalculateTravel = false;
|
i_recalculateTravel = false;
|
||||||
//Angle update will take place into owner.StopMoving()
|
//Angle update will take place into owner.StopMoving()
|
||||||
|
|||||||
Reference in New Issue
Block a user