Signal influence points: Make sure to clear on removal of signal, clear orphaned when digging rail
This commit is contained in:
parent
2dcf60dec6
commit
b2d7bbb2c5
@ -9,6 +9,12 @@ local function can_dig_func(pos)
|
|||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
local function after_dig_func(pos)
|
||||||
|
if advtrains.interlocking then
|
||||||
|
return advtrains.interlocking.signal_after_dig(pos)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
local function aspect(b)
|
local function aspect(b)
|
||||||
return {
|
return {
|
||||||
@ -97,6 +103,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||||||
supported_aspects = suppasp,
|
supported_aspects = suppasp,
|
||||||
},
|
},
|
||||||
can_dig = can_dig_func,
|
can_dig = can_dig_func,
|
||||||
|
after_dig_node = after_dig_func,
|
||||||
})
|
})
|
||||||
advtrains.trackplacer.add_worked("advtrains:retrosignal", r, rotation, nil)
|
advtrains.trackplacer.add_worked("advtrains:retrosignal", r, rotation, nil)
|
||||||
|
|
||||||
@ -163,6 +170,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
can_dig = can_dig_func,
|
can_dig = can_dig_func,
|
||||||
|
after_dig_node = after_dig_func,
|
||||||
})
|
})
|
||||||
advtrains.trackplacer.add_worked("advtrains:signal", r, rotation, nil)
|
advtrains.trackplacer.add_worked("advtrains:signal", r, rotation, nil)
|
||||||
end
|
end
|
||||||
@ -232,6 +240,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
can_dig = can_dig_func,
|
can_dig = can_dig_func,
|
||||||
|
after_dig_node = after_dig_func,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -622,7 +622,7 @@ function advtrains.can_dig_or_modify_track(pos)
|
|||||||
return false, attrans("There's a Track Circuit Break here.")
|
return false, attrans("There's a Track Circuit Break here.")
|
||||||
end
|
end
|
||||||
-- signal ip?
|
-- signal ip?
|
||||||
if advtrains.interlocking.db.is_ip_at(pos) then
|
if advtrains.interlocking.db.is_ip_at(pos, true) then -- is_ip_at with purge parameter
|
||||||
return false, attrans("There's a Signal Influence Point here.")
|
return false, attrans("There's a Signal Influence Point here.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -562,9 +562,23 @@ function ildb.set_sigd_for_signal(pos, sigd)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- checks if there's any influence point set to this position
|
-- checks if there's any influence point set to this position
|
||||||
function ildb.is_ip_at(pos)
|
-- if purge is true, checks whether the associated signal still exists
|
||||||
|
-- and deletes the ip if not.
|
||||||
|
function ildb.is_ip_at(pos, purge)
|
||||||
local pts = advtrains.roundfloorpts(pos)
|
local pts = advtrains.roundfloorpts(pos)
|
||||||
if influence_points[pts] then
|
if influence_points[pts] then
|
||||||
|
if purge then
|
||||||
|
-- is there still a signal assigned to it?
|
||||||
|
for connid, sigpos in pairs(influence_points[pts]) do
|
||||||
|
local asp = advtrains.interlocking.signal_get_aspect(sigpos)
|
||||||
|
if not asp then
|
||||||
|
atlog("Clearing orphaned signal influence point", pts, "/", connid)
|
||||||
|
ildb.clear_ip_signal(pts, connid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- if there's no side left after purging, return false
|
||||||
|
if not influence_points[pts] then return false end
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
@ -51,6 +51,7 @@ minetest.register_node("advtrains_interlocking:ds_danger", {
|
|||||||
},
|
},
|
||||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||||
can_dig = advtrains.interlocking.signal_can_dig,
|
can_dig = advtrains.interlocking.signal_can_dig,
|
||||||
|
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||||
})
|
})
|
||||||
minetest.register_node("advtrains_interlocking:ds_free", {
|
minetest.register_node("advtrains_interlocking:ds_free", {
|
||||||
description = "Demo signal at Free",
|
description = "Demo signal at Free",
|
||||||
@ -72,6 +73,7 @@ minetest.register_node("advtrains_interlocking:ds_free", {
|
|||||||
},
|
},
|
||||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||||
can_dig = advtrains.interlocking.signal_can_dig,
|
can_dig = advtrains.interlocking.signal_can_dig,
|
||||||
|
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||||
})
|
})
|
||||||
minetest.register_node("advtrains_interlocking:ds_slow", {
|
minetest.register_node("advtrains_interlocking:ds_slow", {
|
||||||
description = "Demo signal at Slow",
|
description = "Demo signal at Slow",
|
||||||
@ -93,5 +95,6 @@ minetest.register_node("advtrains_interlocking:ds_slow", {
|
|||||||
},
|
},
|
||||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||||
can_dig = advtrains.interlocking.signal_can_dig,
|
can_dig = advtrains.interlocking.signal_can_dig,
|
||||||
|
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ for _, rtab in ipairs({
|
|||||||
},
|
},
|
||||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||||
can_dig = advtrains.interlocking.signal_can_dig,
|
can_dig = advtrains.interlocking.signal_can_dig,
|
||||||
|
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||||
})
|
})
|
||||||
-- rotatable by trackworker
|
-- rotatable by trackworker
|
||||||
advtrains.trackplacer.add_worked("advtrains_signals_ks:hs", typ, "_"..rot, prts.n)
|
advtrains.trackplacer.add_worked("advtrains_signals_ks:hs", typ, "_"..rot, prts.n)
|
||||||
@ -160,6 +161,7 @@ for _, rtab in ipairs({
|
|||||||
},
|
},
|
||||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||||
can_dig = advtrains.interlocking.signal_can_dig,
|
can_dig = advtrains.interlocking.signal_can_dig,
|
||||||
|
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||||
})
|
})
|
||||||
-- rotatable by trackworker
|
-- rotatable by trackworker
|
||||||
advtrains.trackplacer.add_worked("advtrains_signals_ks:ra", typ, "_"..rot, prts.n)
|
advtrains.trackplacer.add_worked("advtrains_signals_ks:ra", typ, "_"..rot, prts.n)
|
||||||
@ -210,6 +212,7 @@ for _, rtab in ipairs({
|
|||||||
},
|
},
|
||||||
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
||||||
can_dig = advtrains.interlocking.signal_can_dig,
|
can_dig = advtrains.interlocking.signal_can_dig,
|
||||||
|
after_dig_node = advtrains.interlocking.signal_after_dig,
|
||||||
})
|
})
|
||||||
-- rotatable by trackworker
|
-- rotatable by trackworker
|
||||||
advtrains.trackplacer.add_worked("advtrains_signals_ks:sign", typ, "_"..rot, prts.n)
|
advtrains.trackplacer.add_worked("advtrains_signals_ks:sign", typ, "_"..rot, prts.n)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user