aboutsummaryrefslogtreecommitdiff
path: root/advtrains/models/advtrains_platform_diag_low.b3d
blob: 5a8054b9400dfdd30670092cf991e3ed6f8f691c (plain)
ofshex dumpascii
0000 42 42 33 44 b6 07 00 00 01 00 00 00 42 52 55 53 67 00 00 00 01 00 00 00 4d 61 69 6e 20 54 65 78 BB3D........BRUSg.......Main.Tex
0020 74 75 72 65 2e 30 30 32 00 cd cc 4c 3f cd cc 4c 3f cd cc 4c 3f 00 00 80 3f 00 00 00 00 01 00 00 ture.002...L?..L?..L?...?.......
0040 00 00 00 00 00 ff ff ff ff 50 6c 61 74 66 6f 72 6d 20 45 64 67 65 2e 30 30 32 00 cd cc 4c 3f cd .........Platform.Edge.002...L?.
0060 cc 4c 3f cd cc 4c 3f 00 00 80 3f 00 00 00 00 01 00 00 00 00 00 00 00 ff ff ff ff 4e 4f 44 45 3b .L?..L?...?................NODE;
0080 07 00 00 44 69 61 67 6f 6e 61 6c 20 50 6c 61 74 66 6f 72 6d 20 4e 6f 64 65 20 4c 6f 77 00 56 22 ...Diagonal.Platform.Node.Low.V"
00a0 d0 b9 00 00 00 bf da b3 25 bd 00 00 80 3f 00 00 80 3f 00 00 80 3f e5 f2 34 3f 00 00 00 00 01 17 ........%....?...?...?..4?......
00c0 35 bf 00 00 00 00 4d 45 53 48 f0 06 00 00 ff ff ff ff 56 52 54 53 ac 05 00 00 00 00 00 00 01 00 5.....MESH........VRTS..........
00e0 00 00 02 00 00 00 70 3d 0a bf 00 00 80 33 02 00 00 bf 00 00 00 00 00 00 80 3f 20 85 eb 3e 00 00 ......p=.....3...........?...>..
0100 00 3f fa ff ff be 00 00 80 3f 00 00 00 3f 70 3d 0a bf 00 00 00 3f 01 00 00 bf 00 00 00 00 00 00 .?.......?...?p=.....?..........
0120 00 3f 20 85 eb 3e 00 00 00 3f fa ff ff be 00 00 c0 3e 00 00 00 00 94 c2 75 be fe ff ff 3e cd cc .?...>...?.......>......u....>..
0140 4c 3f 00 00 00 00 00 00 80 3f 72 3d 0a bf 00 00 00 3f 00 00 00 3f 00 00 c0 3e 00 00 80 3f 70 3d L?.......?r=.....?...?...>...?p=
0160 0a bf 00 00 80 33 02 00 00 bf 00 00 00 80 00 00 80 3f 72 3d 0a bf 00 00 00 00 fe ff ff 3e 00 00 .....3...........?r=.........>..
0180 00 00 00 00 00 00 20 85 eb 3e 00 00 80 33 fc ff ff be 00 00 80 3f 00 00 80 3f 70 3d 0a bf 00 00 .........>...3.......?...?p=....
01a0 00 3f 01 00 00 bf 00 00 80 3f 00 00 00 00 20 85 eb 3e 00 00 00 3f fa ff ff be 00 00 00 00 00 00 .?.......?.......>...?..........
01c0 00 00 72 3d 0a bf 00 00 00 3f 00 00 00 3f 00 00 80 3f 00 00 80 3f 20 85 eb 3e 00 00 80 33 fc ff ..r=.....?...?...?...?...>...3..
01e0 ff be 00 00 c0 3e 00 00 80 3f 10 34 9f be 00 00 00 00 6a a3 3a 3f 00 00 00 00 00 00 00 00 f8 65 .....>...?.4......j.:?.........e
0200 30 3f cc 27 f2 31 27 b9 8a be 00 00 00 00 00 00 80 3f 5b 8f 42 3f 9a 99 99 3e c0 cc 4c be 00 00 0?.'.1'..........?[.B?...>..L...
0220 00 00 00 00 54 3e 94 c2 75 be fe ff ff 3e cd cc 4c 3f 00 00 80 3f 00 00 00 00 5b 8f 42 3f 00 00 ....T>..u....>..L?...?....[.B?..
0240 00 3f c0 cc 4c be 00 00 00 00 00 00 00 00 94 c2 75 be 98 99 99 3e cd cc 4c 3f 00 00 80 3f 00 00 .?..L...........u....>..L?...?..
0260 2e 3e f8 65 30 3f 9a 99 99 3e 26 b9 8a be 00 00 00 80 00 00 80 3d 10 34 9f be 98 99 99 3e 6a a3 .>.e0?...>&..........=.4.....>j.
0280 3a 3f 00 00 80 3f 00 00 80 3d 10 34 9f be 00 00 00 00 6a a3 3a 3f d5 ff 7f 3f 00 00 80 3f f8 65 :?...?...=.4......j.:?...?...?.e
02a0 30 3f 9a 99 99 3e 26 b9 8a be 00 00 30 32 92 54 3a 3f f8 65 30 3f cc 27 f2 31 27 b9 8a be 00 00 0?...>&.....02.T:?.e0?.'.1'.....
02c0 00 00 07 a9 7f 3f 94 c2 75 be fe ff ff 3e cd cc 4c 3f 00 00 10 3f 00 00 00 3f 94 c2 75 be 98 99 .....?..u....>..L?...?...?..u...
02e0 99 3e cd cc 4c 3f 00 00 10 3f 00 00 30 3f 10 34 9f be 98 99 99 3e 6a a3 3a 3f 00 00 30 3f 00 00 .>..L?...?..0?.4.....>j.:?..0?..
0300 30 3f 72 3d 0a bf 00 00 00 00 fe ff ff 3e 00 00 00 00 00 00 00 00 70 3d 0a bf 00 00 00 3f 01 00 0?r=.........>........p=.....?..
0320 00 bf 00 00 80 3f 00 00 00 3f 72 3d 0a bf 00 00 00 3f 00 00 00 3f 00 00 00 00 00 00 00 3f 20 85 .....?...?r=.....?...?.......?..
0340 eb 3e 00 00 00 3f fa ff ff be 00 00 00 00 01 00 00 3f 20 85 eb 3e 00 00 80 33 fc ff ff be 00 00 .>...?...........?...>...3......
0360 00 00 00 00 80 3f f8 65 30 3f 9a 99 99 3e 26 b9 8a be 00 00 a0 3e 00 00 30 3f 70 3d 0a bf 00 00 .....?.e0?...>&......>..0?p=....
0380 80 33 02 00 00 bf 00 00 00 00 00 00 80 3f 20 85 eb 3e 00 00 80 33 fc ff ff be 00 00 80 3f 00 00 .3...........?...>...3.......?..
03a0 80 3f 20 85 eb 3e 00 00 00 3f fa ff ff be 00 00 80 3f 00 00 00 3f 20 85 eb 3e 00 00 00 3f fa ff .?...>...?.......?...?...>...?..
03c0 ff be 00 00 c0 3e 00 00 00 00 5b 8f 42 3f 00 00 00 3f c0 cc 4c be 00 00 00 00 00 00 00 00 94 c2 .....>....[.B?...?..L...........
03e0 75 be fe ff ff 3e cd cc 4c 3f 00 00 00 00 00 00 80 3f 20 85 eb 3e 00 00 80 33 fc ff ff be 00 00 u....>..L?.......?...>...3......
0400 c0 3e 00 00 80 3f 72 3d 0a bf 00 00 00 00 fe ff ff 3e 00 00 c0 3e 00 00 00 00 10 34 9f be 00 00 .>...?r=.........>...>.....4....
0420 00 00 6a a3 3a 3f 00 00 00 00 00 00 00 00 5b 8f 42 3f 9a 99 99 3e c0 cc 4c be 00 00 00 00 00 00 ..j.:?........[.B?...>..L.......
0440 54 3e 94 c2 75 be 98 99 99 3e cd cc 4c 3f 00 00 80 3f 00 00 54 3e 94 c2 75 be fe ff ff 3e cd cc T>..u....>..L?...?..T>..u....>..
0460 4c 3f 00 00 80 3f 00 00 00 00 94 c2 75 be 98 99 99 3e cd cc 4c 3f 00 00 80 3f 00 00 2e 3e 5b 8f L?...?......u....>..L?...?...>[.
0480 42 3f 9a 99 99 3e c0 cc 4c be 00 00 00 00 00 00 2e 3e f8 65 30 3f 9a 99 99 3e 26 b9 8a be 00 00 B?...>..L........>.e0?...>&.....
04a0 00 80 00 00 80 3d 10 34 9f be 00 00 00 00 6a a3 3a 3f d5 ff 7f 3f 00 00 80 3f 10 34 9f be 98 99 .....=.4......j.:?...?...?.4....
04c0 99 3e 6a a3 3a 3f 00 00 80 3f 92 54 3a 3f f8 65 30 3f 9a 99 99 3e 26 b9 8a be 00 00 30 32 92 54 .>j.:?...?.T:?.e0?...>&.....02.T
04e0 3a 3f 10 34 9f be 98 99 99 3e 6a a3 3a 3f 00 00 30 3f 00 00 30 3f 10 34 9f be 00 00 00 00 6a a3 :?.4.....>j.:?..0?..0?.4......j.
0500 3a 3f 00 00 30 3f 00 00 80 3f 72 3d 0a bf 00 00 00 00 fe ff ff 3e 00 00 80 3f 00 00 80 3f 72 3d :?..0?...?r=.........>...?...?r=
0520 0a bf 00 00 00 00 fe ff ff 3e 00 00 80 3f 00 00 80 3f 72 3d 0a bf 00 00 00 3f 00 00 00 3f 00 00 .........>...?...?r=.....?...?..
0540 80 3f 00 00 00 3f 10 34 9f be 98 99 99 3e 6a a3 3a 3f 00 00 30 3f 00 00 30 3f 72 3d 0a bf 00 00 .?...?.4.....>j.:?..0?..0?r=....
0560 00 3f 00 00 00 3f 00 00 80 3f 00 00 00 3f 94 c2 75 be fe ff ff 3e cd cc 4c 3f 00 00 10 3f 00 00 .?...?...?...?..u....>..L?...?..
0580 00 3f 10 34 9f be 98 99 99 3e 6a a3 3a 3f 00 00 30 3f 00 00 30 3f 72 3d 0a bf 00 00 00 00 fe ff .?.4.....>j.:?..0?..0?r=........
05a0 ff 3e 00 00 00 00 00 00 00 00 70 3d 0a bf 00 00 80 33 02 00 00 bf 00 00 80 3f 00 00 00 00 70 3d .>........p=.....3.......?....p=
05c0 0a bf 00 00 00 3f 01 00 00 bf 00 00 80 3f 00 00 00 3f 20 85 eb 3e 00 00 80 33 fc ff ff be 00 00 .....?.......?...?...>...3......
05e0 00 00 00 00 80 3f f8 65 30 3f cc 27 f2 31 27 b9 8a be 00 00 a0 3e 00 00 80 3f f8 65 30 3f 9a 99 .....?.e0?.'.1'......>...?.e0?..
0600 99 3e 26 b9 8a be 00 00 a0 3e 00 00 30 3f f8 65 30 3f 9a 99 99 3e 26 b9 8a be 00 00 a0 3e 00 00 .>&......>..0?.e0?...>&......>..
0620 30 3f 5b 8f 42 3f 9a 99 99 3e c0 cc 4c be 00 00 e0 3e 00 00 30 3f 5b 8f 42 3f 00 00 00 3f c0 cc 0?[.B?...>..L....>..0?[.B?...?..
0640 4c be 00 00 e0 3e 00 00 00 3f 5b 8f 42 3f 00 00 00 3f c0 cc 4c be 00 00 e0 3e 00 00 00 3f 20 85 L....>...?[.B?...?..L....>...?..
0660 eb 3e 00 00 00 3f fa ff ff be 00 00 00 00 01 00 00 3f f8 65 30 3f 9a 99 99 3e 26 b9 8a be 00 00 .>...?...........?.e0?...>&.....
0680 a0 3e 00 00 30 3f 54 52 49 53 0c 01 00 00 00 00 00 00 02 00 00 00 01 00 00 00 00 00 00 00 08 00 .>..0?TRIS......................
06a0 00 00 07 00 00 00 06 00 00 00 0b 00 00 00 0a 00 00 00 09 00 00 00 0e 00 00 00 0d 00 00 00 0c 00 ................................
06c0 00 00 11 00 00 00 10 00 00 00 0f 00 00 00 14 00 00 00 13 00 00 00 12 00 00 00 17 00 00 00 16 00 ................................
06e0 00 00 15 00 00 00 1a 00 00 00 19 00 00 00 18 00 00 00 1d 00 00 00 1c 00 00 00 1b 00 00 00 20 00 ................................
0700 00 00 1f 00 00 00 1e 00 00 00 23 00 00 00 22 00 00 00 21 00 00 00 29 00 00 00 28 00 00 00 27 00 ..........#..."...!...)...(...'.
0720 00 00 2c 00 00 00 2b 00 00 00 2a 00 00 00 2f 00 00 00 2e 00 00 00 2d 00 00 00 32 00 00 00 31 00 ..,...+...*.../.......-...2...1.
0740 00 00 30 00 00 00 35 00 00 00 34 00 00 00 33 00 00 00 38 00 00 00 37 00 00 00 36 00 00 00 3b 00 ..0...5...4...3...8...7...6...;.
0760 00 00 3a 00 00 00 39 00 00 00 3e 00 00 00 3d 00 00 00 3c 00 00 00 41 00 00 00 40 00 00 00 3f 00 ..:...9...>...=...<...A...@...?.
0780 00 00 44 00 00 00 43 00 00 00 42 00 00 00 47 00 00 00 46 00 00 00 45 00 00 00 54 52 49 53 1c 00 ..D...C...B...G...F...E...TRIS..
07a0 00 00 01 00 00 00 05 00 00 00 04 00 00 00 03 00 00 00 26 00 00 00 25 00 00 00 24 00 00 00 ..................&...%...$...
#n423'>423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
-- path.lua
-- Functions for pathpredicting, put in a separate file. 

-- Naming conventions:
-- 'index' - An index of the train.path table.
-- 'offset' - A value in meters that determines how far on the path to walk relative to a certain index
-- 'n' - Referring or pointing towards the 'next' path item, the one with index+1
-- 'p' - Referring or pointing towards the 'prev' path item, the one with index-1
-- 'f' - Referring to the positive end of the path (the end with the higher index)
-- 'b' - Referring to the negative end of the path (the end with the lower index)

-- New path structure of trains:
--Tables:
-- path      - path positions. 'indices' are relative to this. At the moment, at.round_vector_floor_y(path[i])
--              is the node this item corresponds to, however, this will change in the future.
-- path_node - (reserved)
-- path_cn   - Connid of the current node that points towards path[i+1]
-- path_cp   - Connid of the current node that points towards path[i-1]
--     When the day comes on that path!=node, these will only be set if this index represents a transition between rail nodes
-- path_dist - The total distance of this path element from path element 0
-- path_dir  - The direction of this path item's transition to the next path item, which is the angle of conns[path_cn[i]].c
-- path_speed- Populated by the LZB system. The maximum speed (velocity) permitted in the moment this path item is passed.
--             (this saves brake distance calculations every step to determine LZB control). nil means no limit.
--Variables:
-- path_ext_f/b - how far path[i] is set
-- path_trk_f/b - how far the path extends along a track. beyond those values, paths are generated in a straight line.
-- path_req_f/b - how far path items were requested in the last step
--
--Distance and index:
-- There is an important difference between the path index and the actual distance on the track: The distance between two path items can be larger than 1,
-- but the corresponding index increment is still 1.
-- Indexes in advtrains can be fractional values. If they are, it means that the actual position is interpolated between the 2 adjacent path items.
-- If you need to proceed along the path by a specific actual distance, it does NOT work to simply add it to the index. You should use the path_get_index_by_offset() function.

-- creates the path data structure, reconstructing the train from a position and a connid
-- Important! train.drives_on must exist while calling this method
-- returns: true - successful
--           nil - node not yet available/unloaded, please wait
--         false - node definitely gone, remove train
function advtrains.path_create(train, pos, connid, rel_index)
	local posr = advtrains.round_vector_floor_y(pos)
	local node_ok, conns, rhe = advtrains.get_rail_info_at(pos, train.drives_on)
	if not node_ok then
		return node_ok
	end
	local mconnid = advtrains.get_matching_conn(connid, #conns)
	train.index = rel_index
	train.path = { [0] = { x=posr.x, y=posr.y+rhe, z=posr.z } }
	train.path_cn = { [0] = connid }
	train.path_cp = { [0] = mconnid }
	train.path_dist = { [0] = 0 }
	
	train.path_dir = {
		[0] = advtrains.conn_angle_median(conns[mconnid].c, conns[connid].c)
	}
	
	train.path_speed = { }
	
	train.path_ext_f=0
	train.path_ext_b=0
	train.path_trk_f=0
	train.path_trk_b=0
	train.path_req_f=0
	train.path_req_b=0
	
	advtrains.occ.set_item(train.id, posr, 0)
	return true
end

-- Sets position and connid to properly restore after a crash, e.g. in order
-- to save the train or to invalidate its path
-- Assumes that the train is in clean state
-- if invert ist true, setrestore will use the end index
function advtrains.path_setrestore(train, invert)
	local idx = train.index
	if invert then
		idx = train.end_index
	end
	
	local pos, connid, frac = advtrains.path_getrestore(train, idx, invert, true)
	
	train.last_pos = pos
	train.last_connid = connid
	train.last_frac = frac
end
-- Get restore position, connid and frac (in this order) for a train that will originate at the passed index
-- If invert is set, it will return path_cp and multiply frac by -1, in order to reverse the train there.
function advtrains.path_getrestore(train, index, invert)
	local idx = index
	local cns = train.path_cn
	
	if invert then
		cns = train.path_cp
	end
	
	local fli = atfloor(index)
	advtrains.path_get(train, fli)
	if fli > train.path_trk_f then
		fli = train.path_trk_f
	end
	if fli < train.path_trk_b then
		fli = train.path_trk_b
	end
	return advtrains.path_get(train, fli),
			cns[fli],
			(idx - fli) * (invert and -1 or 1)
end

-- Invalidates a path
-- this is supposed to clear stuff from the occupation tables
-- This function throws a warning whenever any code calls it while the train steps are run, since that must not happen.
-- The ignore_lock parameter can be used to ignore this, however, it should then be accompanied by a call to train_ensure_init
-- before returning from the calling function.
function advtrains.path_invalidate(train, ignore_lock)
	if advtrains.lock_path_inval and not ignore_lock then
		atwarn("Train ",train.train_id,": Illegal path invalidation has occured during train step:")
		atwarn(debug.traceback())
	end

	if train.path then
		for i,p in pairs(train.path) do
			advtrains.occ.clear_item(train.id, advtrains.round_vector_floor_y(p))
		end
	end
	train.path = nil
	train.path_dist = nil
	train.path_cp = nil
	train.path_cn = nil
	train.path_dir = nil
	train.path_speed = nil
	train.path_ext_f=0
	train.path_ext_b=0
	train.path_trk_f=0
	train.path_trk_b=0
	train.path_req_f=0
	train.path_req_b=0
	
	train.dirty = true
	--atdebug(train.id, "Path invalidated")
end

-- Keeps the path intact, but invalidates all path nodes from the specified index (inclusive)
-- onwards. This has the advantage that we don't need to recalculate the whole path, and we can do it synchronously.
function advtrains.path_invalidate_ahead(train, start_idx, ignore_when_passed)
	if not train.path then
		-- the path wasn't even initialized. Nothing to do
		return
	end

	local idx = atfloor(start_idx)
	--atdebug("Invalidate_ahead:",train.id,"start_index",start_idx,"cur_idx",train.index)
	
	if(idx <= train.index - 0.5) then
		if ignore_when_passed then
			--atdebug("ignored passed")
			return
		end
		advtrains.path_print(train, atwarn)
		error("Train "+train.id+": Cannot path_invalidate_ahead start_idx="+idx+" as train has already passed!")
	end
	
	-- leave current node in path, it won't change. What might change is the path onward from here (e.g. switch)
	local i = idx + 1
	while train.path[i] do
		advtrains.occ.clear_item(train.id, advtrains.round_vector_floor_y(train.path[i]))
		i = i+1
	end
	train.path_ext_f=idx
	train.path_trk_f=math.min(idx, train.path_trk_f)
	
	-- callbacks called anyway for current node, because of LZB
	advtrains.run_callbacks_invahead(train.id, train, idx)
end

-- Prints a path using the passed print function
-- This function should be 'atprint', 'atlog', 'atwarn' or 'atdebug', because it needs to use print_concat_table
function advtrains.path_print(train, printf)
	printf("path_print: tid =",train.id," index =",train.index," end_index =",train.end_index," vel =",train.velocity)
	if not train.path then
		printf("path_print: Path is invalidated/inexistant.")
		return
	end
	printf("i:	CP	Position	Dir				CN		Dist		Speed")
	for i = train.path_ext_b, train.path_ext_f do
		if i==train.path_trk_b then
			printf("--Back on-track border here--")
		end
		printf(i,":	",train.path_cp[i],"	",train.path[i],"	",train.path_dir[i],"	",train.path_cn[i],"		",train.path_dist[i],"		",train.path_speed[i])
		if i==train.path_trk_f then
			printf("--Front on-track border here--")		
		end
	end
end

-- Function to get path entry at a position. This function will automatically calculate more of the path when required.
-- returns: pos, on_track
function advtrains.path_get(train, index)
	if not train.path then
		error("For train "..train.id..": path_get called but there's no path set yet!")
	end
	if index ~= atfloor(index) then
		error("For train "..train.id..": Called path_get() but index="..index.." is not a round number")
	end
	
	local pef = train.path_ext_f
	-- generate forward (front of train, positive)
	while index > pef do
		local pos = train.path[pef]
		local connid = train.path_cn[pef]
		local node_ok, this_conns, adj_pos, adj_connid, conn_idx, nextrail_y, next_conns
		if pef == train.path_trk_f then
			node_ok, this_conns = advtrains.get_rail_info_at(pos)
			if not node_ok then error("For train "..train.id..": Path item "..pef.." on-track but not a valid node!") end
			adj_pos, adj_connid, conn_idx, nextrail_y, next_conns = advtrains.get_adjacent_rail(pos, this_conns, connid, train.drives_on)
		end
		pef = pef + 1
		if adj_pos then
			advtrains.occ.set_item(train.id, adj_pos, pef)
		
			-- If we have split points, notify accordingly
			local mconnid = advtrains.get_matching_conn(adj_connid, #next_conns)
			if #next_conns==3 and adj_connid==1 and train.points_split and train.points_split[advtrains.encode_pos(adj_pos)] then
				--atdebug(id,"has split points restored at",adj_pos)
				mconnid = 3
			end
		
			adj_pos.y = adj_pos.y + nextrail_y
			train.path_cp[pef] = adj_connid
			train.path_cn[pef] = mconnid
			train.path_dir[pef] = advtrains.conn_angle_median(next_conns[adj_connid].c, next_conns[mconnid].c)
			train.path_trk_f = pef
		else
			-- off-track fallback behavior
			adj_pos = advtrains.pos_add_angle(pos, train.path_dir[pef-1])
			--atdebug("Offtrack overgenerating(front) at",adj_pos,"index",peb,"trkf",train.path_trk_f)
			train.path_dir[pef] = train.path_dir[pef-1]
		end
		train.path[pef] = adj_pos
		train.path_dist[pef] = train.path_dist[pef-1] + vector.distance(pos, adj_pos)
	end
	train.path_ext_f = pef
	
	
	local peb = train.path_ext_b
	-- generate backward (back of train, negative)
	while index < peb do
		local pos = train.path[peb]
		local connid = train.path_cp[peb]
		local node_ok, this_conns, adj_pos, adj_connid, conn_idx, nextrail_y, next_conns
		if peb == train.path_trk_b then
			node_ok, this_conns = advtrains.get_rail_info_at(pos)
			if not node_ok then error("For train "..train.id..": Path item "..peb.." on-track but not a valid node!") end
			adj_pos, adj_connid, conn_idx, nextrail_y, next_conns = advtrains.get_adjacent_rail(pos, this_conns, connid, train.drives_on)
		end
		peb = peb - 1
		if adj_pos then
			advtrains.occ.set_item(train.id, adj_pos, peb)
			
			-- If we have split points, notify accordingly
			local mconnid = advtrains.get_matching_conn(adj_connid, #next_conns)
			if #next_conns==3 and adj_connid==1 and train.points_split and train.points_split[advtrains.encode_pos(adj_pos)] then
				-- atdebug(id,"has split points restored at",adj_pos)
				mconnid = 3
			end
			
			adj_pos.y = adj_pos.y + nextrail_y
			train.path_cn[peb] = adj_connid
			train.path_cp[peb] = mconnid
			train.path_dir[peb] = advtrains.conn_angle_median(next_conns[mconnid].c, next_conns[adj_connid].c)
			train.path_trk_b = peb
		else
			-- off-track fallback behavior
			adj_pos = advtrains.pos_add_angle(pos, train.path_dir[peb+1] + math.pi)
			--atdebug("Offtrack overgenerating(back) at",adj_pos,"index",peb,"trkb",train.path_trk_b)
			train.path_dir[peb] = train.path_dir[peb+1]
		end
		train.path[peb] = adj_pos
		train.path_dist[peb] = train.path_dist[peb+1] - vector.distance(pos, adj_pos)
	end
	train.path_ext_b = peb