aboutsummaryrefslogtreecommitdiff
path: root/advtrains/trainlogic.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-12-06 10:41:51 +0100
committerorwell96 <orwell@bleipb.de>2019-12-09 11:00:21 +0100
commita8ae0a5332934d61739edddeefb6d9184cfce529 (patch)
treec36798b9d90a0652e59505c8d239f1e74089d101 /advtrains/trainlogic.lua
parent9c1d3565058799f21b6985c100ccf1abe045d3da (diff)
downloadadvtrains-a8ae0a5332934d61739edddeefb6d9184cfce529.tar.gz
advtrains-a8ae0a5332934d61739edddeefb6d9184cfce529.tar.bz2
advtrains-a8ae0a5332934d61739edddeefb6d9184cfce529.zip
Simplify and optimize path_get_index_by_offset (cherrypicked)
Diffstat (limited to 'advtrains/trainlogic.lua')
-rw-r--r--advtrains/trainlogic.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index bc24feb..3c0d02e 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -474,7 +474,8 @@ function advtrains.train_step_b(id, train, dtime)
--- 4. move train ---
- local pdist = train.path_dist[math.floor(train.index)] or 1
+ local idx_floor = math.floor(train.index)
+ local pdist = (train.path_dist[idx_floor+1] - train.path_dist[idx_floor])
local distance = (train.velocity*dtime) / pdist
--debugging code