mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r14526) -Fix [FS#2379]: make sure trains stop at the end of a station; a 3/8th length train did stop 2/8th of it's length too early causing a 63/8th long train not to fit in a 4 tile station.
This commit is contained in:
parent
e3e65e8f2b
commit
7588513003
|
@ -2548,10 +2548,6 @@ static void ClickTile_Station(TileIndex tile)
|
|||
}
|
||||
}
|
||||
|
||||
static const byte _enter_station_speedtable[12] = {
|
||||
215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0
|
||||
};
|
||||
|
||||
static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
|
||||
{
|
||||
StationID station_id = GetStationIndex(tile);
|
||||
|
@ -2568,12 +2564,13 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i
|
|||
if (DiagDirToAxis(dir) != AXIS_X) Swap(x, y);
|
||||
if (y == TILE_SIZE / 2) {
|
||||
if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x;
|
||||
if (x == 12) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); /* enter station */
|
||||
if (x < 12) {
|
||||
int stop = TILE_SIZE - (v->u.rail.cached_veh_length + 1) / 2;
|
||||
if (x == stop) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); /* enter station */
|
||||
if (x < stop) {
|
||||
uint16 spd;
|
||||
|
||||
v->vehstatus |= VS_TRAIN_SLOWING;
|
||||
spd = _enter_station_speedtable[x];
|
||||
spd = max(0, (stop - x) * 20 - 15);
|
||||
if (spd < v->cur_speed) v->cur_speed = spd;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4104,7 +4104,7 @@ static bool TrainApproachingLineEnd(Vehicle *v, bool signal)
|
|||
}
|
||||
|
||||
/* do not reverse when approaching red signal */
|
||||
if (!signal && x + 4 >= TILE_SIZE) {
|
||||
if (!signal && x + (v->u.rail.cached_veh_length + 1) / 2 >= TILE_SIZE) {
|
||||
/* we are too near the tile end, reverse now */
|
||||
v->cur_speed = 0;
|
||||
ReverseTrainDirection(v);
|
||||
|
|
Loading…
Reference in New Issue