aboutsummaryrefslogtreecommitdiff
path: root/src/server/collision/Maps/MapTree.cpp
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2013-08-30 21:27:04 +0100
committerNay <dnpd.dd@gmail.com>2013-08-30 21:27:04 +0100
commitbe7d82ba8de464d0d0a817bb4adbfa81930e68d0 (patch)
tree7fb1397c19401aec454fe8dc3505adeaacfb3231 /src/server/collision/Maps/MapTree.cpp
parentdd7802c0ec7e42cf6943140b86f7687eb2e730cf (diff)
Core/Maps: Fix Spline triggered assert
Fix an assert triggered by float to int32 cast overflowing to -1, now it replaces -1 with max int32 value. Fix another assert triggered by Vector3 magnitude float overflow to max/infinity in StaticMapTree::isInLineOfSight(), in this case return false. Both asserts can be reproduced by casting Mind Control to a NPC, tele to z: 1.0e+38 using client hack tools, move to allow the server to register the new position and stop Mind Control. Closes #8970 Closes #10578 Closes #10355 Closes #10673
Diffstat (limited to 'src/server/collision/Maps/MapTree.cpp')
-rw-r--r--src/server/collision/Maps/MapTree.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/server/collision/Maps/MapTree.cpp b/src/server/collision/Maps/MapTree.cpp
index dc12bb68e0d..436f30eed10 100644
--- a/src/server/collision/Maps/MapTree.cpp
+++ b/src/server/collision/Maps/MapTree.cpp
@@ -156,6 +156,11 @@ namespace VMAP
bool StaticMapTree::isInLineOfSight(const Vector3& pos1, const Vector3& pos2) const
{
float maxDist = (pos2 - pos1).magnitude();
+ // return false if distance is over max float, in case of cheater teleporting to the end of the universe
+ if (maxDist == std::numeric_limits<float>::max() ||
+ maxDist == std::numeric_limits<float>::infinity())
+ return false;
+
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too
ASSERT(maxDist < std::numeric_limits<float>::max());
// prevent NaN values which can cause BIH intersection to enter infinite loop