Fix ATC rail reversing

This commit is contained in:
orwell96 2018-08-12 16:36:20 +02:00
parent d7e2918009
commit 0ec89364c0
2 changed files with 7 additions and 4 deletions

View File

@ -194,9 +194,9 @@ local matchptn={
return #match+1 return #match+1
end, end,
["R"]=function(id, train) ["R"]=function(id, train)
if train.velocity<=0 then --TODO this code still uses movedir if train.velocity<=0 then
train.movedir=train.movedir*-1 advtrains.invert_train(id)
train.atc_arrow = not train.atc_arrow advtrains.train_ensure_init(id, train)
else else
atwarn(sid(id), attrans("ATC Reverse command warning: didn't reverse train, train moving!")) atwarn(sid(id), attrans("ATC Reverse command warning: didn't reverse train, train moving!"))
end end
@ -205,7 +205,7 @@ local matchptn={
["O([LRC])"]=function(id, train, match) ["O([LRC])"]=function(id, train, match)
local tt={L=-1, R=1, C=0} local tt={L=-1, R=1, C=0}
local arr=train.atc_arrow and 1 or -1 local arr=train.atc_arrow and 1 or -1
train.door_open = tt[match]*arr*train.movedir train.door_open = tt[match]*arr
return 2 return 2
end, end,
} }

View File

@ -956,6 +956,9 @@ function advtrains.invert_train(train_id)
if train.door_open then if train.door_open then
train.door_open = - train.door_open train.door_open = - train.door_open
end end
if train.atc_command then
train.atc_arrow = not train.atc_arrow
end
advtrains.path_invalidate(train) advtrains.path_invalidate(train)
advtrains.couple_invalidate(train) advtrains.couple_invalidate(train)