Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

Commit b8145c5

Browse files
committed
[mobs] Avoid server crash with nan vector values
1 parent 96dea33 commit b8145c5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mods/mobs/api.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,15 @@ do_jump = function(self)
476476
end
477477

478478
function calc_velocity(pos1, pos2, old_vel, power) --MFF we use this function
479+
-- If the two positions are equal the vector will contain nan and crash the game
480+
if (pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z) then
481+
return {
482+
x = 0,
483+
y = 0,
484+
z = 0
485+
}
486+
end
487+
479488
local vel = vector.direction(pos1, pos2)
480489
vel = vector.normalize(vel)
481490
vel = vector.multiply(vel, power)

0 commit comments

Comments
 (0)