Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid float vector dimension range. #5235

Closed
BluebirdGreycoat opened this issue Feb 14, 2017 · 1 comment
Closed

Invalid float vector dimension range. #5235

BluebirdGreycoat opened this issue Feb 14, 2017 · 1 comment

Comments

@BluebirdGreycoat
Copy link
Contributor

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!

@sfan5
Copy link
Member

sfan5 commented Feb 15, 2017

duplicate of #5135

@sfan5 sfan5 closed this as completed Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants