# HG changeset patch # User glx # Date 1224716796 0 # Node ID ce00edcf11122bdc2f5c4152e3a9448f4b6da023 # Parent 6f45e8b392d1de3d90a401c21d2d3d6c24853c92 (svn r14521) -Fix [FS#2378]: fast trains could continue to move after a crash diff -r 6f45e8b392d1 -r ce00edcf1112 src/train_cmd.cpp --- a/src/train_cmd.cpp Wed Oct 22 22:07:43 2008 +0000 +++ b/src/train_cmd.cpp Wed Oct 22 23:06:36 2008 +0000 @@ -3572,10 +3572,10 @@ * 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 @@ } /* 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 @@ 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 @@ 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);