diff options
author | Subv <s.v.h21@hotmail.com> | 2012-09-08 15:24:59 -0500 |
---|---|---|
committer | Subv <s.v.h21@hotmail.com> | 2012-09-08 15:24:59 -0500 |
commit | 7dbc20626e06d6f1d42bf4983f7f21c76b1eb787 (patch) | |
tree | edbbb22920bbdd4a40e91318615dd9b8fcc5809a | |
parent | 158a86cf11ed6b5d7e5be592cc00bc4aa51e59c2 (diff) |
Core/Entities: Fixed GameObject::FindNearestX for objects with the same coordinates.
closes #4581
-rwxr-xr-x | src/server/game/Entities/GameObject/GameObject.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 808cbd9a5e4..c28ff21bfa5 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1707,6 +1707,11 @@ bool GameObject::IsInRange(float x, float y, float z, float radius) const float dy = y - GetPositionY(); float dz = z - GetPositionZ(); float dist = sqrt(dx*dx + dy*dy); + //! Check if the distance between the 2 objects is 0, can happen if both objects are on the same position. + //! The code below this check wont crash if dist is 0 because 0/0 in float operations is valid, and returns infinite + if (G3D::fuzzyEq(dist, 0.0f)) + return true; + float sinB = dx / dist; float cosB = dy / dist; dx = dist * (cosA * cosB + sinA * sinB); |