Don't invoke conway on a path item that has been over-generated

This breaks ATC systems that are based on wronly switched switches, but fixes a series of bugs (esp. setting train recovery positions at a place where no tracks are)
master
orwell96 2017-05-15 12:44:13 +02:00
parent 3e67f3c66a
commit 2f2a859e08
1 changed files with 10 additions and 4 deletions

View File

@ -482,8 +482,11 @@ function advtrains.pathpredict(id, train, regular)
local maxn=train.path_extent_max or 0
while maxn < gen_front do--pregenerate
atprint("maxn conway for ",maxn,train.path[maxn],maxn-1,train.path[maxn-1])
local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.drives_on)
local conway
if train.max_index_on_track == train.path_extent_max then
atprint("maxn conway for ",maxn,train.path[maxn],maxn-1,train.path[maxn-1])
conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.drives_on)
end
if conway then
train.path[maxn+1]=conway
train.max_index_on_track=maxn
@ -500,8 +503,11 @@ function advtrains.pathpredict(id, train, regular)
local minn=train.path_extent_min or -1
while minn > gen_back do
atprint("minn conway for ",minn,train.path[minn],minn+1,train.path[minn+1])
local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.drives_on)
local conway
if train.min_index_on_track == train.path_extent_min then
atprint("minn conway for ",minn,train.path[minn],minn+1,train.path[minn+1])
conway=advtrains.conway(train.path[minn], train.path[minn+1], train.drives_on)
end
if conway then
train.path[minn-1]=conway
train.min_index_on_track=minn