aboutsummaryrefslogtreecommitdiff
path: root/advtrains/trainlogic.lua
diff options
context:
space:
mode:
authorywang <yw05@forksworld.de>2019-12-07 16:48:19 +0100
committerywang <yw05@forksworld.de>2020-04-12 16:07:16 +0200
commitad0713547c45930254473d8dc2b198b0587183d2 (patch)
treebfa91c2b303542a814e92ff32bd28cc65b0b217f /advtrains/trainlogic.lua
parenta86677b42fc37c59c9297baa567a7e1d68660d4f (diff)
downloadadvtrains-ad0713547c45930254473d8dc2b198b0587183d2.tar.gz
advtrains-ad0713547c45930254473d8dc2b198b0587183d2.tar.bz2
advtrains-ad0713547c45930254473d8dc2b198b0587183d2.zip
Improved quadratic function solver; added wrapper for math.sqrt()
Diffstat (limited to 'advtrains/trainlogic.lua')
-rw-r--r--advtrains/trainlogic.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 7e9a613..c0c3888 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -434,7 +434,7 @@ function advtrains.train_step_b(id, train, dtime)
else s = (v1*v1 - v0*v0)/2/a
end
train.ctrl.lzb = nil
- if lzblimit.velocity and lzblimit.velocity < train.velocity then
+ if lzblimit.velocity and lzblimit.lever < train.lever then
tmp_lever = lzblimit.lever
while (lzbmap[tmp_lever].t > dtime) do
tmp_lever = tmp_lever - 1
@@ -457,7 +457,7 @@ function advtrains.train_step_b(id, train, dtime)
a = (v1 - train.velocity)/dtime
--- 4b. Move train and update train properties ---
local pdist = train.path_dist[math.floor(train.index)] or 1
- local distance = s / pdist
+ local distance = pdist == 0 and s or s / pdist
train.lever = tmp_lever
train.velocity = v1
train.acceleration = a