mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[8465] Fixed exploit of z-axis described in http://getmangos.com/community/showthread.php?t=9652
Little code style clean up. Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
parent
bb30afb6f3
commit
bba20b92a5
4 changed files with 25 additions and 24 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -101,11 +101,12 @@ DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff,
|
|||
{
|
||||
ResetUpdate();
|
||||
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);
|
||||
|
|
@ -120,11 +121,11 @@ DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff,
|
|||
{
|
||||
ResetUpdate();
|
||||
if (!i_destSet) return true;
|
||||
float x,y,z;
|
||||
|
||||
if (!traveller.GetTraveller().hasUnitState(UNIT_STAT_MOVING | UNIT_STAT_IN_FLIGHT))
|
||||
return true;
|
||||
|
||||
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
|
||||
|
|
@ -133,7 +134,7 @@ DestinationHolder<TRAVELLER>::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);
|
||||
|
|
@ -193,11 +194,11 @@ DestinationHolder<TRAVELLER>::GetLocationNow(const Map * map, float &x, float &y
|
|||
|
||||
template<typename TRAVELLER>
|
||||
float
|
||||
DestinationHolder<TRAVELLER>::GetDistance2dFromDestSq(const WorldObject &obj) const
|
||||
DestinationHolder<TRAVELLER>::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<typename TRAVELLER>
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ TargetedMovementGenerator<T>::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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8464"
|
||||
#define REVISION_NR "8465"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue