aboutsummaryrefslogtreecommitdiff
path: root/assets/lyx_img/Bildschirmfoto_2018-08-30_14-28-32.png
diff options
context:
space:
mode:
Diffstat (limited to 'assets/lyx_img/Bildschirmfoto_2018-08-30_14-28-32.png')
0 files changed, 0 insertions, 0 deletions
href='#n66'>66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
-- Interlocking counterpart of LZB, which has been moved into the core...
-- Registers LZB callback for signal management.

--[[
usage of lzbdata:
{
	travsht = boolean indicating whether the train will be a shunt move at "trav"
	travspd = speed restriction at end of traverser
	travwspd = warning speed res.t
}
]]

local SHUNT_SPEED_MAX = advtrains.SHUNT_SPEED_MAX

local il = advtrains.interlocking

local function get_over_function(speed, shunt)
	return function(pos, id, train, index, speed, lzbdata)
		if speed == 0 and minetest.settings:get_bool("at_il_force_lzb_halt") then
			atwarn(id,"overrun LZB 0 restriction (red signal) ",pos)
			-- Set train 1 index backward. Hope this does not lead to bugs...
			--train.index = index - 0.5
			train.speed_restriction = 0
			
			--TODO temporary
			--advtrains.drb_dump(id)
			--error("Debug: "..id.." triggered LZB-0")
		else
			train.speed_restriction = speed
			train.is_shunt = shunt
		end
		--atdebug("train drove over IP: speed=",speed,"shunt=",shunt)
	end
end

advtrains.tnc_register_on_approach(function(pos, id, train, index, has_entered, lzbdata)

	--atdebug(id,"IL ApprC",pos,index,lzbdata)
	--train.debug = advtrains.print_concat_table({train.is_shunt,"|",index,"|",lzbdata})

	local pts = advtrains.roundfloorpts(pos)
	local cn  = train.path_cn[index]
	local travsht = lzbdata.il_shunt
	
	local travspd = lzbdata.il_speed
	
	if travsht==nil then
		-- lzbdata has reset
		travspd = train.speed_restriction
		travsht = train.is_shunt or false
	end
	
	
	
	-- check for signal
	local asp, spos = il.db.get_ip_signal_asp(pts, cn)
	
	-- do ARS if needed
	local ars_enabled = not train.ars_disable
	-- Note on ars_disable:
	-- Theoretically, the ars_disable flag would need to behave like the speed restriction field: it should be
	-- stored in lzbdata and updated once the train drives over. However, for the sake of simplicity, it is simply
	-- a value in the train. In this case, this is sufficient because once a train triggers ARS for the first time,