From 2f2a859e08dfb26831b3f187e4793bdcef692c2c Mon Sep 17 00:00:00 2001 From: orwell96 Date: Mon, 15 May 2017 12:44:13 +0200 Subject: 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) --- advtrains/advtrains/trainlogic.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index 1b862c9..8614c79 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -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 -- cgit v1.2.3