aboutsummaryrefslogtreecommitdiff
path: root/advtrains/path.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-05-17 21:37:01 +0200
committerorwell96 <orwell@bleipb.de>2018-06-14 17:39:42 +0200
commit24b0639c5f057ccb0fccc3c65be923bee1b571db (patch)
treebe7ece8c6c70701dc02ee68cf86998f310efd2ec /advtrains/path.lua
parent5dca1553333b8267de72ebf8788afbb928251ebf (diff)
downloadadvtrains-24b0639c5f057ccb0fccc3c65be923bee1b571db.tar.gz
advtrains-24b0639c5f057ccb0fccc3c65be923bee1b571db.tar.bz2
advtrains-24b0639c5f057ccb0fccc3c65be923bee1b571db.zip
Mainly make collisions and coupling work
Missing: ATC stuff, yaw problems
Diffstat (limited to 'advtrains/path.lua')
-rw-r--r--advtrains/path.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/advtrains/path.lua b/advtrains/path.lua
index d1d7ad9..d810fd7 100644
--- a/advtrains/path.lua
+++ b/advtrains/path.lua
@@ -137,7 +137,7 @@ function advtrains.path_setrestore(train, invert)
idx = train.end_index
end
- local pos, connid, frac = advtrains.path_getrestore(train, idx, invert)
+ local pos, connid, frac = advtrains.path_getrestore(train, idx, invert, true)
train.last_pos = pos
train.last_connid = connid
@@ -145,23 +145,25 @@ function advtrains.path_setrestore(train, invert)
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 = train.index
+function advtrains.path_getrestore(train, index, invert, tmp)
+ local idx = index
local cns = train.path_cn
if invert then
- idx = train.end_index
cns = train.path_cp
end
- fli = atfloor(train.index)
+ 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
-
+ if not tmp then
+ atdebug ("getrestore ",atround(train.index),"calc",atround(index),fli)
+ end
return advtrains.path_get(train, fli),
cns[fli],
(idx - fli) * (invert and -1 or 1)
@@ -359,7 +361,7 @@ function advtrains.path_clear_unused(train)
train.path_cp[i] = nil
train.path_cn[i] = nil
train.path_dir[i+1] = nil
- train.path_ext_b = i - 1
+ train.path_ext_f = i - 1
end
train.path_req_f = math.ceil(train.index)