summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-04-18 13:43:05 +0000
committerrubidium <rubidium@openttd.org>2009-04-18 13:43:05 +0000
commit06a8a8ce8d32f8a71bd595aee3e7dc84ee2e9902 (patch)
tree9d53b2900547de998110d77c9cab1391734c1951 /src/train_cmd.cpp
parent523a92493db441c6bda816f3cdd6cbd4dcc5c1cd (diff)
downloadopenttd-06a8a8ce8d32f8a71bd595aee3e7dc84ee2e9902.tar.xz
(svn r16079) -Fix [FS#2824]: insanely fast trains would not stop in time for stations
-Fix: insanely fast trains would sometimes 'jump' over waypoints/via stations within a tick, which would cause the order not to be processed causing the train to go in loops until (with luck) it 'hit' the tile
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index d32c2ec25..1839b3c47 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -4375,10 +4375,25 @@ static void TrainLocoHandler(Vehicle *v, bool mode)
do {
j -= adv_spd;
TrainController(v, NULL);
- /* Don't continue to move if the train crashed. */
- if (CheckTrainCollision(v)) break;
+
/* 192 spd used for going straight, 256 for going diagonally. */
adv_spd = (v->direction & 1) ? 192 : 256;
+
+ if (j >= adv_spd) {
+ /* Don't continue to move if the train crashed or isn't moving. */
+ if (CheckTrainCollision(v) || v->cur_speed == 0) break;
+
+ OrderType order_type = v->current_order.GetType();
+ /* Do not skip waypoints (incl. 'via' stations) when passing through at full speed. */
+ if ((order_type == OT_GOTO_WAYPOINT &&
+ v->dest_tile == v->tile) ||
+ (order_type == OT_GOTO_STATION &&
+ (v->current_order.GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) &&
+ IsTileType(v->tile, MP_STATION) &&
+ v->current_order.GetDestination() == GetStationIndex(v->tile))) {
+ ProcessOrders(v);
+ }
+ }
} while (j >= adv_spd);
SetLastSpeed(v, v->cur_speed);
}