aboutsummaryrefslogtreecommitdiff
path: root/serialize_lib/api.md
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2023-07-01 22:37:09 +0200
committerorwell96 <orwell@bleipb.de>2023-07-01 22:37:09 +0200
commit8b5903a7293491901b555f720d5f79bbac681c1b (patch)
treeef4ca50ae3e15944b80b8dec15f672c687c6f72c /serialize_lib/api.md
parent21ed1d23b5a71c962a47b5bc1f67a2833cd8f5ca (diff)
downloadadvtrains-8b5903a7293491901b555f720d5f79bbac681c1b.tar.gz
advtrains-8b5903a7293491901b555f720d5f79bbac681c1b.tar.bz2
advtrains-8b5903a7293491901b555f720d5f79bbac681c1b.zip
Fix path_invalidate_ahead after recent commit
Diffstat (limited to 'serialize_lib/api.md')
0 files changed, 0 insertions, 0 deletions
#n104'>104 105 106 107 108 109 110 111 112 113
-- 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.velocity = 0
			train.ctrl.lzb = 0
			minetest.after(0, advtrains.invalidate_path, id)
		else
			train.speed_restriction = speed
			train.is_shunt = shunt
		end
	end
end

advtrains.tnc_register_on_approach(function(pos, id, train, index, 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.travsht
	
	if travsht==nil then
		travsht = train.is_shunt
	end
	
	local travspd = lzbdata.travspd
	local travwspd = lzbdata.travwspd
	
	-- check for signal
	local asp, spos = il.db.get_ip_signal_asp(pts, cn)
	
	-- do ARS if needed
	if spos then
		--atdebug(id,"IL Spos (ARS)",spos,asp)
		local sigd = il.db.get_sigd_for_signal(spos)
		if sigd then
			il.ars_check(sigd, train)
		end
	end
	--atdebug("trav: ",pos, cn, asp, spos, "travsht=", lzb.travsht)
	local lspd
	if asp then
		--atdebug(id,"IL Signal",spos,asp)
		local nspd = 0