aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/database.lua16
-rw-r--r--advtrains_interlocking/demosignals.lua3
2 files changed, 18 insertions, 1 deletions
diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua
index 68d4138..a35d446 100644
--- a/advtrains_interlocking/database.lua
+++ b/advtrains_interlocking/database.lua
@@ -562,9 +562,23 @@ function ildb.set_sigd_for_signal(pos, sigd)
end
-- 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)
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
end
return false
diff --git a/advtrains_interlocking/demosignals.lua b/advtrains_interlocking/demosignals.lua
index fe60a73..cba1f30 100644
--- a/advtrains_interlocking/demosignals.lua
+++ b/advtrains_interlocking/demosignals.lua
@@ -51,6 +51,7 @@ minetest.register_node("advtrains_interlocking:ds_danger", {
},
on_rightclick = advtrains.interlocking.signal_rc_handler,
can_dig = advtrains.interlocking.signal_can_dig,
+ after_dig_node = advtrains.interlocking.signal_after_dig,
})
minetest.register_node("advtrains_interlocking:ds_free", {
description = "Demo signal at Free",
@@ -72,6 +73,7 @@ minetest.register_node("advtrains_interlocking:ds_free", {
},
on_rightclick = advtrains.interlocking.signal_rc_handler,
can_dig = advtrains.interlocking.signal_can_dig,
+ after_dig_node = advtrains.interlocking.signal_after_dig,
})
minetest.register_node("advtrains_interlocking:ds_slow", {
description = "Demo signal at Slow",
@@ -93,5 +95,6 @@ minetest.register_node("advtrains_interlocking:ds_slow", {
},
on_rightclick = advtrains.interlocking.signal_rc_handler,
can_dig = advtrains.interlocking.signal_can_dig,
+ after_dig_node = advtrains.interlocking.signal_after_dig,
})