summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-04-19 04:36:53 +0000
committerrubidium <rubidium@openttd.org>2009-04-19 04:36:53 +0000
commit2a2b40461d478406aef9d12093e07ed8ae5b987f (patch)
treeaeab1a836169f7cf60ce1b4dc888367a12e57c7d
parentb66783afabf6ca4702d372526b8eb3d64f30caa7 (diff)
downloadopenttd-2a2b40461d478406aef9d12093e07ed8ae5b987f.tar.xz
(svn r16087) -Fix (r16079): slow trains wouldn't crash into eachother anymore
-rw-r--r--src/train_cmd.cpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 1839b3c47..9ce55ece8 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -4372,29 +4372,28 @@ static void TrainLocoHandler(Vehicle *v, bool mode)
} else {
TrainCheckIfLineEnds(v);
/* Loop until the train has finished moving. */
- do {
+ for (;;) {
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);
- }
+ /* No more moving this tick */
+ if (j < adv_spd || 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);
}