diff options
author | rubidium <rubidium@openttd.org> | 2013-06-28 18:09:07 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2013-06-28 18:09:07 +0000 |
commit | d3ccc7c1948e9a4b91c97bf8a430be19ffba1c43 (patch) | |
tree | b3b09ee09ff5042f24747de8df780190f4cd6fd3 /src | |
parent | 6e8f2f29f55f74d1b4964b828fb32784ec960411 (diff) | |
download | openttd-d3ccc7c1948e9a4b91c97bf8a430be19ffba1c43.tar.xz |
(svn r25495) -Fix [FS#5553]: when addings bits to a (train) station, the train trying to stop there could overshoot the (new) stop location and not stop at all
Diffstat (limited to 'src')
-rw-r--r-- | src/station_cmd.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 4b3daba5b..c57e4382d 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3124,7 +3124,7 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i * begin of the platform to the stop location is longer than the length * of the platform. Station ahead 'includes' the current tile where the * vehicle is on, so we need to subtract that. */ - if (!IsInsideBS(stop + station_ahead, station_length, TILE_SIZE)) return VETSB_CONTINUE; + if (stop + station_ahead - (int)TILE_SIZE >= station_length) return VETSB_CONTINUE; DiagDirection dir = DirToDiagDir(v->direction); @@ -3136,14 +3136,11 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x; stop &= TILE_SIZE - 1; - if (x == stop) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); // enter station - if (x < stop) { - uint16 spd; + if (x >= stop) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); // enter station - v->vehstatus |= VS_TRAIN_SLOWING; - spd = max(0, (stop - x) * 20 - 15); - if (spd < v->cur_speed) v->cur_speed = spd; - } + v->vehstatus |= VS_TRAIN_SLOWING; + uint16 spd = max(0, (stop - x) * 20 - 15); + if (spd < v->cur_speed) v->cur_speed = spd; } } else if (v->type == VEH_ROAD) { RoadVehicle *rv = RoadVehicle::From(v); |