diff options
author | orwell96 <orwell@bleipb.de> | 2021-04-25 22:07:44 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2021-04-25 22:07:44 +0200 |
commit | 571a5cd19b5f9ea1feebbfdef678865039b71370 (patch) | |
tree | 60c9bfa922f0f84612dcbffa7e3fe38b9b475b67 /advtrains | |
parent | 09bba2c57fcf3907d9e761d15526f1d9a9a91a13 (diff) | |
download | advtrains-571a5cd19b5f9ea1feebbfdef678865039b71370.tar.gz advtrains-571a5cd19b5f9ea1feebbfdef678865039b71370.tar.bz2 advtrains-571a5cd19b5f9ea1feebbfdef678865039b71370.zip |
Prevent splitting trains when they're off track (fixes #178)
Diffstat (limited to 'advtrains')
-rw-r--r-- | advtrains/trainlogic.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index c812ff7..499144b 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -1079,6 +1079,12 @@ function advtrains.split_train_at_index(train, index) atwarn("Train",train_id,"is not initialized! Operation aborted!") return end + + -- make sure that the train is fully on track before splitting. May cause problems otherwise + if train.index > train.path_trk_f or train.end_index < train.path_trk_b then + atwarn("Train",train_id,": cannot split train because it is off track!") + return + end local p_index=advtrains.path_get_index_by_offset(train, train.index, - data.pos_in_train + wagon.wagon_span) local pos, connid, frac = advtrains.path_getrestore(train, p_index) |