Skip to content
Permalink
Browse files

TNT: start fire nodetimers for created fire nodes.

Without this patch, any fire created(placed) by tnt explosions
will remain forever on the map.
  • Loading branch information...
sofar authored and paramat committed Mar 10, 2017
1 parent b87ef5c commit 7b900445741f4fc66bf4b058ae88c7065e0dcf4e
Showing with 20 additions and 4 deletions.
  1. +20 −4 mods/tnt/init.lua
@@ -83,7 +83,10 @@ local function add_drop(drops, item)
end
end

local function destroy(drops, npos, cid, c_air, c_fire, on_blast_queue, ignore_protection, ignore_on_blast)
local basic_flame_on_construct -- cached value
local function destroy(drops, npos, cid, c_air, c_fire,
on_blast_queue, on_construct_queue,
ignore_protection, ignore_on_blast)
if not ignore_protection and minetest.is_protected(npos, "") then
return cid
end
@@ -93,9 +96,16 @@ local function destroy(drops, npos, cid, c_air, c_fire, on_blast_queue, ignore_p
if not def then
return c_air
elseif not ignore_on_blast and def.on_blast then
on_blast_queue[#on_blast_queue + 1] = {pos = vector.new(npos), on_blast = def.on_blast}
on_blast_queue[#on_blast_queue + 1] = {
pos = vector.new(npos),
on_blast = def.on_blast
}
return cid
elseif def.flammable then
on_construct_queue[#on_construct_queue + 1] = {
fn = basic_flame_on_construct,
pos = vector.new(npos)
}
return c_fire
else
local node_drops = minetest.get_node_drops(def.name, "")
@@ -306,6 +316,8 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast)

local drops = {}
local on_blast_queue = {}
local on_construct_queue = {}
basic_flame_on_construct = minetest.registered_nodes["fire:basic_flame"].on_construct

local c_fire = minetest.get_content_id("fire:basic_flame")
for z = -radius, radius do
@@ -318,8 +330,8 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast)
local p = {x = pos.x + x, y = pos.y + y, z = pos.z + z}
if cid ~= c_air then
data[vi] = destroy(drops, p, cid, c_air, c_fire,
on_blast_queue, ignore_protection,
ignore_on_blast)
on_blast_queue, on_construct_queue,
ignore_protection, ignore_on_blast)
end
end
vi = vi + 1
@@ -357,6 +369,10 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast)
end
end

for _, queued_data in pairs(on_construct_queue) do
queued_data.fn(queued_data.pos)
end

return drops, radius
end

0 comments on commit 7b90044

Please sign in to comment.
You can’t perform that action at this time.