summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-10-22 23:06:36 +0000
committerglx <glx@openttd.org>2008-10-22 23:06:36 +0000
commiteb0464071d41224770dcb34240b602ee97d5764e (patch)
tree61e109c859f045c5707f267386963fb9c357207e
parenta7ff1920f9680bd57340a41eca8838168a35f10f (diff)
downloadopenttd-eb0464071d41224770dcb34240b602ee97d5764e.tar.xz
(svn r14521) -Fix [FS#2378]: fast trains could continue to move after a crash
-rw-r--r--src/train_cmd.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index be41cf556..527b35019 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -3572,10 +3572,10 @@ static Vehicle *FindTrainCollideEnum(Vehicle *v, void *data)
* Reports the incident in a flashy news item, modifies station ratings and
* plays a sound.
*/
-static void CheckTrainCollision(Vehicle *v)
+static bool CheckTrainCollision(Vehicle *v)
{
/* can't collide in depot */
- if (v->u.rail.track == TRACK_BIT_DEPOT) return;
+ if (v->u.rail.track == TRACK_BIT_DEPOT) return false;
assert(v->u.rail.track == TRACK_BIT_WORMHOLE || TileVirtXY(v->x_pos, v->y_pos) == v->tile);
@@ -3592,7 +3592,7 @@ static void CheckTrainCollision(Vehicle *v)
}
/* any dead -> no crash */
- if (tcc.num == 0) return;
+ if (tcc.num == 0) return false;
SetDParam(0, tcc.num);
AddNewsItem(STR_8868_TRAIN_CRASH_DIE_IN_FIREBALL,
@@ -3603,6 +3603,7 @@ static void CheckTrainCollision(Vehicle *v)
ModifyStationRatingAround(v->tile, v->owner, -160, 30);
SndPlayVehicleFx(SND_13_BIG_CRASH, v);
+ return true;
}
static Vehicle *CheckVehicleAtSignal(Vehicle *v, void *data)
@@ -4332,7 +4333,8 @@ static void TrainLocoHandler(Vehicle *v, bool mode)
do {
j -= adv_spd;
TrainController(v, NULL, true);
- CheckTrainCollision(v);
+ /* 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;
} while (j >= adv_spd);