aboutsummaryrefslogtreecommitdiff
path: root/advtrains/trainlogic.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-07-07 22:58:10 +0200
committerorwell96 <orwell@bleipb.de>2021-07-07 22:58:10 +0200
commit4989da3663cbc91ccd283a20f40bb4031687aacf (patch)
tree64ccc1012a2c621e3108d2c65d9462eea0400116 /advtrains/trainlogic.lua
parent1f3a4c3bfc2a462ff51bd6b391be0d39a6a6c944 (diff)
downloadadvtrains-4989da3663cbc91ccd283a20f40bb4031687aacf.tar.gz
advtrains-4989da3663cbc91ccd283a20f40bb4031687aacf.tar.bz2
advtrains-4989da3663cbc91ccd283a20f40bb4031687aacf.zip
Disable position-based collision and coupling system for very short trains (such as single minecarts) to solve #155
Diffstat (limited to 'advtrains/trainlogic.lua')
-rw-r--r--advtrains/trainlogic.lua20
1 files changed, 12 insertions, 8 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 442d6bf..00c04bf 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -705,6 +705,7 @@ function advtrains.train_step_c(id, train, dtime)
end
local train_moves=(train.velocity~=0)
+ local very_short_train = train.trainlen < 3
--- On-track collision handling - detected in train_step_b, but handled here so all other train movements have already happened.
if train.ontrack_collision_info then
@@ -726,7 +727,9 @@ function advtrains.train_step_c(id, train, dtime)
if train_moves then
train.couples_up_to_date = nil
elseif not train.couples_up_to_date then
- advtrains.train_check_couples(train) -- no guarantee for train order here
+ if not very_short_train then -- old coupling system is buggy for short trains
+ advtrains.train_check_couples(train) -- no guarantee for train order here
+ end
train.couples_up_to_date = true
end
@@ -746,13 +749,14 @@ function advtrains.train_step_c(id, train, dtime)
local testpos=vector.add(rcollpos, {x=x, y=0, z=z})
--- 8a Check collision ---
if not collided then
-
- local col_tr = advtrains.occ.check_collision(testpos, id)
- if col_tr then
- train.velocity = 0
- train.acceleration = 0
- advtrains.atc.train_reset_command(train)
- collided = true
+ if not very_short_train then -- position collision system is buggy for short trains
+ local col_tr = advtrains.occ.check_collision(testpos, id)
+ if col_tr then
+ train.velocity = 0
+ train.acceleration = 0
+ advtrains.atc.train_reset_command(train)
+ collided = true
+ end
end
--- 8b damage players ---