aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-05-15 12:44:13 +0200
committerorwell96 <mono96.mml@gmail.com>2017-05-15 12:46:58 +0200
commit2f2a859e08dfb26831b3f187e4793bdcef692c2c (patch)
tree0346095b47d72a5a75cc3ab2e0bb5ef764ba010f
parent3e67f3c66af627ee189cf77cbc30f8f49a73f03f (diff)
downloadadvtrains-2f2a859e08dfb26831b3f187e4793bdcef692c2c.tar.gz
advtrains-2f2a859e08dfb26831b3f187e4793bdcef692c2c.tar.bz2
advtrains-2f2a859e08dfb26831b3f187e4793bdcef692c2c.zip
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)
-rw-r--r--advtrains/advtrains/trainlogic.lua14
1 files 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