diff options
author | orwell <orwell@bleipb.de> | 2025-10-05 16:02:10 +0200 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2025-10-05 16:02:10 +0200 |
commit | 7a2eaad050fb75058fca67a01f0b0c122a0c513b (patch) | |
tree | 87e15e59d0d918dd42abdde4118a23bcc2f65b22 /advtrains_interlocking | |
parent | f7d757b9a5a02ac06e1168c5591fc5fb62f2cbc3 (diff) | |
download | advtrains-7a2eaad050fb75058fca67a01f0b0c122a0c513b.tar.gz advtrains-7a2eaad050fb75058fca67a01f0b0c122a0c513b.tar.bz2 advtrains-7a2eaad050fb75058fca67a01f0b0c122a0c513b.zip |
signal_api: Fix errors caused by missing nodedef
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r-- | advtrains_interlocking/signal_api.lua | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/advtrains_interlocking/signal_api.lua b/advtrains_interlocking/signal_api.lua index e7c2248..53f8c9c 100644 --- a/advtrains_interlocking/signal_api.lua +++ b/advtrains_interlocking/signal_api.lua @@ -307,7 +307,7 @@ function signal.get_aspect_internal(pos, aspt) -- oh, no main aspect, nevermind return signal.MASP_HALT, nil, node, ndef end - local ndefat = ndef.advtrains or {} + local ndefat = ndef and ndef.advtrains or {} local masp = aspt.main or signal.MASP_HALT if type(masp) == "string" then @@ -317,12 +317,16 @@ function signal.get_aspect_internal(pos, aspt) -- case is fine, distant only signal masp = signal.MASP_DEFAULT else - assert(ndefat.main_aspects, "With named aspects, node "..node.name.." needs advtrains.main_aspects table!") - -- resolve the main aspect from the mainaspects table - if not ndefat.main_aspects_lookup then - cache_mainaspects(ndefat) + if not ndefat.main_aspects then + atwarn(pos, "With named aspects, node", node and node.name, "needs advtrains.main_aspects table! Fix the aspect on the signal!") + masp = signal.MASP_HALT + else + -- resolve the main aspect from the mainaspects table + if not ndefat.main_aspects_lookup then + cache_mainaspects(ndefat) + end + masp = ndefat.main_aspects_lookup[aspt.main] or signal.MASP_DEFAULT end - masp = ndefat.main_aspects_lookup[aspt.main] or signal.MASP_DEFAULT end end -- return whatever the main aspect is @@ -385,7 +389,7 @@ function signal.reapply_aspect(pts) end -- call into ndef --atdebug("applying to",pos,": main_asp",masp,"rem_masp",rem_masp,"rem_aspi",rem_aspi) - if ndef.advtrains and ndef.advtrains.apply_aspect then + if ndef and ndef.advtrains and ndef.advtrains.apply_aspect then ndef.advtrains.apply_aspect(pos, node, masp, rem_masp, rem_aspi) end -- notify trains |