aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-02-05 11:23:17 +0100
committerorwell96 <orwell@bleipb.de>2019-02-05 11:23:17 +0100
commite7dcee11276477294fbc9d995c4db479e7e3cfd9 (patch)
tree7c25b14fcd5645706a3809ed00f6f5edcd1ad305
parent8b8c5a2c1f196e72795d3bdb6ea717cb29b485c2 (diff)
downloadadvtrains-e7dcee11276477294fbc9d995c4db479e7e3cfd9.tar.gz
advtrains-e7dcee11276477294fbc9d995c4db479e7e3cfd9.tar.bz2
advtrains-e7dcee11276477294fbc9d995c4db479e7e3cfd9.zip
Force LZB Halt setting
-rw-r--r--advtrains/wagons.lua14
-rw-r--r--advtrains_interlocking/lzb.lua22
-rw-r--r--advtrains_interlocking/settingtypes.txt4
-rw-r--r--advtrains_luaautomation/atc_rail.lua6
4 files changed, 39 insertions, 7 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 1b1aa96..655efb4 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -861,14 +861,24 @@ function wagon:handle_bordcom_fields(pname, formname, fields)
end
if fields.line then
if fields.line~="" then
- train.line=fields.line
+ if fields.line ~= train.line then
+ train.line=fields.line
+ if advtrains.interlocking then
+ advtrains.interlocking.lzb_invalidate(train)
+ end
+ end
else
train.line=nil
end
end
if fields.routingcode then
if fields.routingcode~="" then
- train.routingcode=fields.routingcode
+ if fields.routingcode ~= train.routingcode then
+ train.routingcode=fields.routingcode
+ if advtrains.interlocking then
+ advtrains.interlocking.lzb_invalidate(train)
+ end
+ end
else
train.routingcode=nil
end
diff --git a/advtrains_interlocking/lzb.lua b/advtrains_interlocking/lzb.lua
index b309c72..eaa9808 100644
--- a/advtrains_interlocking/lzb.lua
+++ b/advtrains_interlocking/lzb.lua
@@ -1,7 +1,6 @@
-- lzb.lua
-- Enforced and/or automatic train override control, obeying signals
-
local function approach_callback(parpos, train_id, train, index)
local pos = advtrains.round_vector_floor_y(parpos)
@@ -185,11 +184,24 @@ local function apply_control(id, train)
local i = 1
while i<=#lzb.oncoming do
if lzb.oncoming[i].idx < train.index-0.5 then
- if not lzb.oncoming[i].npr then
- train.speed_restriction = lzb.oncoming[i].spd
- train.is_shunt = lzb.oncoming[i].sht
+ local ent = lzb.oncoming[i]
+ local nodelete
+ if not ent.npr then
+ if ent.spd == 0 and minetest.settings:get_bool("at_il_force_lzb_halt") then
+ atwarn(train.id,"overrun LZB 0 restriction (red signal) ",ent.pos)
+ -- Set train 1 index backward. Hope this does not lead to bugs...
+ train.index = ent.idx - 0.5
+ train.velocity = 0
+ train.ctrl.lzb = 0
+ nodelete = true
+ else
+ train.speed_restriction = ent.spd
+ train.is_shunt = ent.sht
+ end
+ end
+ if not nodelete then
+ table.remove(lzb.oncoming, i)
end
- table.remove(lzb.oncoming, i)
else
i = i + 1
end
diff --git a/advtrains_interlocking/settingtypes.txt b/advtrains_interlocking/settingtypes.txt
new file mode 100644
index 0000000..f1c22b0
--- /dev/null
+++ b/advtrains_interlocking/settingtypes.txt
@@ -0,0 +1,4 @@
+# Stop trains forcibly in front of signal when about to run over an LZB 0 restriction, instead of setting emergency halt for manual resolving
+# This prevents the need to manually restart trains that overran red signals, but is unrealistic.
+# This is a workaround to circumvent system breakages due to bugs in LZB braking curves
+at_il_force_lzb_halt (Force LZB Halt) bool true
diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua
index 04228ac..f4b3337 100644
--- a/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains_luaautomation/atc_rail.lua
@@ -58,6 +58,9 @@ function r.fire_event(pos, evtdata)
return false
end
train.line = line .. ""
+ if advtrains.interlocking then
+ advtrains.interlocking.lzb_invalidate(train)
+ end
return true
end,
get_line = function()
@@ -68,6 +71,9 @@ function r.fire_event(pos, evtdata)
return false
end
train.routingcode = rc
+ if advtrains.interlocking then
+ advtrains.interlocking.lzb_invalidate(train)
+ end
return true
end,
get_rc = function()