Commit be0d2a5a authored by BlockMen's avatar BlockMen
Browse files

Fix crashes by unknown nodes

parent 4cd14d9f
Minetest mod "Torches" Minetest mod "Torches"
======================= =======================
version: 1.3.1 version: 1.3.2
License of source code and textures: WTFPL License of source code and textures: WTFPL
----------------------------------------- -----------------------------------------
...@@ -35,3 +35,6 @@ Changelog: ...@@ -35,3 +35,6 @@ Changelog:
1.3.1: 1.3.1:
- fix dropping torches when digging a block next to it - fix dropping torches when digging a block next to it
- all torches attached to a block get droped when dug - all torches attached to a block get droped when dug
1.3.2:
- fix crashes by unknown nodes
local VIEW_DISTANCE = 13 -- if player is near that distance flames are shown local VIEW_DISTANCE = 13 -- if player is near that distance flames are shown
local null = {x=0, y=0, z=0} local null = {x=0, y=0, z=0}
local dirs = {{-1,0,-1},{-1,0,0},{0,0,-1},
{1,0,1},{1,0,0},{0,0,1},{0,1,0}}
--fire_particles --fire_particles
local function add_fire(pos) local function add_fire(pos)
pos.y = pos.y+0.19 pos.y = pos.y+0.19
...@@ -119,9 +123,11 @@ minetest.register_craftitem(":default:torch", { ...@@ -119,9 +123,11 @@ minetest.register_craftitem(":default:torch", {
local under = pointed_thing.under local under = pointed_thing.under
local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}) local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z})
local u_n = minetest.get_node(under) local u_n = minetest.get_node(under)
if u_n and not minetest.registered_nodes[u_n.name].walkable then above = under end local udef = minetest.registered_nodes[u_n.name]
local u_n = minetest.get_node(above) if u_n and udef and not udef.walkable then above = under end
if u_n and minetest.registered_nodes[u_n.name].walkable then return itemstack end u_n = minetest.get_node(above)
udef = minetest.registered_nodes[u_n.name]
if u_n and udef and udef.walkable then return itemstack end
if wdir == 1 then if wdir == 1 then
minetest.env:add_node(above, {name = "torches:floor"}) minetest.env:add_node(above, {name = "torches:floor"})
else else
...@@ -219,17 +225,16 @@ minetest.register_node("torches:wand", { ...@@ -219,17 +225,16 @@ minetest.register_node("torches:wand", {
}) })
minetest.register_on_dignode(function(pos, oldnode, digger) minetest.register_on_dignode(function(pos, oldnode, digger)
for ix=-1,1 do if minetest.find_node_near(pos, 1, {"group:torch"}) == nil then return end
for iz=-1,1 do for i=1,#dirs do
for iy=0,1 do local v = dirs[i]
if ix ~=0 and iz ~= 0 then iy=0 end local p = {x=pos.x+v[1],y=pos.y+v[2],z=pos.z+v[3]}
local p = {x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}
local n = minetest.get_node_or_nil(p) local n = minetest.get_node_or_nil(p)
local fd = minetest.registered_nodes[n.name].update or nil if n and n.name then
if fd ~= nil then local def = minetest.registered_nodes[n.name]
fd(p, n, pos) if def and def.update then
def.update(p, n, pos)
end
end end
end end
end
end
end) end)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment