comparison Main.lua @ 482:f924bec6cf5e

Prevent out of bounds coordinates from being recorded for whatever reason.
author MMOSimca <mmosimca@gmail.com>
date Fri, 12 Aug 2016 12:32:50 -0400
parents 6f689ac680bd
children 271132f4fa77
comparison
equal deleted inserted replaced
481:274776fa70c8 482:f924bec6cf5e
324 324
325 -- Put coordinates into expected format (as integers, they don't get a billion decimals output in the SavedVariables) 325 -- Put coordinates into expected format (as integers, they don't get a billion decimals output in the SavedVariables)
326 local x_int = nil 326 local x_int = nil
327 if (x and type(x) == "number") then 327 if (x and type(x) == "number") then
328 x_int = _G.floor(x * 1000) 328 x_int = _G.floor(x * 1000)
329
330 -- Limit precision to 0.2
329 if x_int % 2 ~= 0 then 331 if x_int % 2 ~= 0 then
330 x_int = x_int + 1 332 x_int = x_int + 1
333 end
334
335 -- Prevent out of bounds coordinates
336 if (x_int < 0 or x_int > 1000) then
337 x_int = nil
331 end 338 end
332 end 339 end
333 local y_int = nil 340 local y_int = nil
334 if (y and type(y) == "number") then 341 if (y and type(y) == "number") then
335 y_int = _G.floor(y * 1000) 342 y_int = _G.floor(y * 1000)
343
344 -- Limit precision to 0.2
336 if y_int % 2 ~= 0 then 345 if y_int % 2 ~= 0 then
337 y_int = y_int + 1 346 y_int = y_int + 1
347 end
348
349 -- Prevent out of bounds coordinates
350 if (y_int < 0 or y_int > 1000) then
351 y_int = nil
338 end 352 end
339 end 353 end
340 354
341 return zone_name, current_area_id, x_int, y_int, map_level, InstanceDifficultyToken() 355 return zone_name, current_area_id, x_int, y_int, map_level, InstanceDifficultyToken()
342 end 356 end