[mobs] Avoid server crash with nan vector values

This commit is contained in:
LeMagnesium 2016-12-04 14:04:54 +01:00
parent 96dea33e89
commit b8145c5471
No known key found for this signature in database
GPG Key ID: A54DDB5272C51E8B
1 changed files with 9 additions and 0 deletions

View File

@ -476,6 +476,15 @@ do_jump = function(self)
end
function calc_velocity(pos1, pos2, old_vel, power) --MFF we use this function
-- If the two positions are equal the vector will contain nan and crash the game
if (pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z) then
return {
x = 0,
y = 0,
z = 0
}
end
local vel = vector.direction(pos1, pos2)
vel = vector.normalize(vel)
vel = vector.multiply(vel, power)