diff options
author | tenplus1 <tenplus1@users.noreply.github.com> | 2015-05-14 11:35:24 +0100 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-05-15 00:15:25 +0200 |
commit | be18bd6a8cafdc2c452da39dd8cc428d8dbf62e6 (patch) | |
tree | 1fe9ac5f1d1425c7a937874ea2944e9e9888329b /builtin | |
parent | 178f536f082fd586a13d03ec9aa0775f1c009d5e (diff) | |
download | minetest-be18bd6a8cafdc2c452da39dd8cc428d8dbf62e6.tar.gz minetest-be18bd6a8cafdc2c452da39dd8cc428d8dbf62e6.tar.bz2 minetest-be18bd6a8cafdc2c452da39dd8cc428d8dbf62e6.zip |
Don't crash if an item gets dropped into unloaded space
Items dropped into unloaded map space will crash game so here's a fix...
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/game/item_entity.lua | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua index d848fd855..6425a10aa 100644 --- a/builtin/game/item_entity.lua +++ b/builtin/game/item_entity.lua @@ -155,7 +155,17 @@ core.register_entity(":__builtin:item", { end local p = self.object:getpos() p.y = p.y - 0.5 - local nn = core.get_node(p).name + local node = core.get_node_or_nil(p) + local in_unloaded = (node == nil) + if in_unloaded then + -- Don't infinetly fall into unloaded map + self.object:setvelocity({x = 0, y = 0, z = 0}) + self.object:setacceleration({x = 0, y = 0, z = 0}) + self.physical_state = false + self.object:set_properties({physical = false}) + return + end + local nn = node.name -- If node is not registered or node is walkably solid and resting on nodebox local v = self.object:getvelocity() if not core.registered_nodes[nn] or core.registered_nodes[nn].walkable and v.y == 0 then |