ts2 / ts2-sim-server

TS2 SimServer, the core of the TS2 Simulator
https://ts2.github.io
GNU General Public License v2.0
5 stars 9 forks source link

MaxSpeed: Use full length of train. Implement Place MaxSpeed #47

Closed hklang10 closed 4 years ago

hklang10 commented 4 years ago

This patch implements two features:

  1. When calculating MaxSpeed, the full length of the train is used, before only trainhead was used.
  2. If a TrackItem is linked to a Place, the maximum speed for the place is now also used.

The impact of this change is that trains do not accelerate until they are 100% clear of low speed areas (crossovers or station platform places for example).

Be aware that this patch now causes trains to operate very slowly in Liverpool Street, Wheler Street Junction and Bethnal Green TrackItems, because these Places are low-speed. [[ EDIT: No longer an issue in the latest push ]]

Feedback welcome, I am not a go programmer !

codecov[bot] commented 4 years ago

Codecov Report

Merging #47 into master will decrease coverage by 0.04%. The diff coverage is 86.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #47      +/-   ##
==========================================
- Coverage   76.23%   76.19%   -0.05%     
==========================================
  Files          38       38              
  Lines        2588     2600      +12     
==========================================
+ Hits         1973     1981       +8     
- Misses        492      496       +4     
  Partials      123      123
Impacted Files Coverage Δ
plugins/trains/trains.go 75% <100%> (ø) :arrow_up:
simulation/trains.go 60.86% <100%> (+0.92%) :arrow_up:
simulation/track_items.go 77.94% <66.66%> (-1.64%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 02b6bd9...53bf88d. Read the comment docs.

hklang10 commented 4 years ago

Logic modified: will now use a) TrackItem b) Place (if not blank) and c) Default max speed.

If there is a maxspeed in TrackItem and Place, the TrackItem will always be used.

This now fixes the issue where trains run slowly through Bow Junction, Bethnal Green and Wheler Street junction.

npiganeau commented 4 years ago

Perfect for me.