diff options
author | orwell96 <orwell@bleipb.de> | 2021-03-12 17:56:07 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2021-03-12 17:56:07 +0100 |
commit | b2d7bbb2c577a2b28cdaf421daf9b143f4376c8a (patch) | |
tree | 49d7ec4e1a3c4b6cf64180978fdc6bd5a8486606 /advtrains_interlocking/database.lua | |
parent | 2dcf60dec6304abc910dea82c6f9a5904bbf365b (diff) | |
download | advtrains-b2d7bbb2c577a2b28cdaf421daf9b143f4376c8a.tar.gz advtrains-b2d7bbb2c577a2b28cdaf421daf9b143f4376c8a.tar.bz2 advtrains-b2d7bbb2c577a2b28cdaf421daf9b143f4376c8a.zip |
Signal influence points: Make sure to clear on removal of signal, clear orphaned when digging rail
Diffstat (limited to 'advtrains_interlocking/database.lua')
-rw-r--r-- | advtrains_interlocking/database.lua | 16 |
1 files changed, 15 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 |