You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My server has been shutting down at random occasions due to an obscure problem I have not been able to solve myself. The short of it is that it appears that player:getpos() can return an invalid vector, which if passed to minetest.get_objects_inside_radius(), will provoke a shutdown. I thought that perhaps I should NOT be getting the positions of dead players, so I added a check for player health. Unfortunately the problem still happens.
Here's the actual error message:
2017-02-14 08:07:13: ERROR[Main]: ServerError: AsyncErr: environment_Step: Runtime error from mod 'itempickup' in callback environment_Step(): Invalid float vector dimension range 'x' (expected -2.14748e+06 < x < 2.14748e+06 got -2.14748e+06).
2017-02-14 08:07:13: ERROR[Main]: stack traceback:
2017-02-14 08:07:13: ERROR[Main]: [C]: in function 'get_objects_inside_radius'
2017-02-14 08:07:13: ERROR[Main]: ...t_home/.minetest/games/musttest/mods/itempickup/init.lua:26: in function 'update'
2017-02-14 08:07:13: ERROR[Main]: ...t_home/.minetest/games/musttest/mods/itempickup/init.lua:51: in function <...t_home/.minetest/games/musttest/mods/itempickup/init.lua:51>
2017-02-14 08:07:13: ERROR[Main]: /usr/local/share/minetest/builtin/game/register.lua:412: in function </usr/local/share/minetest/builtin/game/register.lua:392>
And here's the offending code (with comments):
itempickup.update = function(dtime)
local players = minetest.get_connected_players()
for k, v in ipairs(players) do
if v:is_player() and v:get_hp() > 0 then
local pos = v:getpos() -- Getting the player's position. The vector should always be valid, no?
local items = minetest.get_objects_inside_radius(pos, 1.2) -- The offending line. It fails here.
local inv = v:get_inventory()
for m, n in ipairs(items) do
-- Ensure object found is an item-drop.
if not n:is_player() and n:get_luaentity() and n:get_luaentity().name == "__builtin:item" then
local name = n:get_luaentity().itemstring
local item = ItemStack(name)
-- Ensure player's inventory has enough room.
if inv and inv:room_for_item("main", item) then
inv:add_item("main", item)
if name ~= "" then itempickup.sound(pos) end
n:get_luaentity().itemstring = "" -- Prevents item duplication.
n:remove()
end
end
end
end
end
end
If this should happen to not be a problem in the engine, what should I be doing to avoid the error?
Thanks in advance!
The text was updated successfully, but these errors were encountered:
My server has been shutting down at random occasions due to an obscure problem I have not been able to solve myself. The short of it is that it appears that
player:getpos()
can return an invalid vector, which if passed tominetest.get_objects_inside_radius()
, will provoke a shutdown. I thought that perhaps I should NOT be getting the positions of dead players, so I added a check for player health. Unfortunately the problem still happens.Here's the actual error message:
And here's the offending code (with comments):
If this should happen to not be a problem in the engine, what should I be doing to avoid the error?
Thanks in advance!
The text was updated successfully, but these errors were encountered: