Changeset - r20480:93a50078f0bb
[Not reviewed]
master
0 1 0
rubidium - 11 years ago 2013-06-28 18:09:07
rubidium@openttd.org
(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
1 file changed with 6 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -3121,32 +3121,29 @@ static VehicleEnterTileStatus VehicleEnt
 
		int stop = GetTrainStopLocation(station_id, tile, Train::From(v), &station_ahead, &station_length);
 

	
 
		/* Stop whenever that amount of station ahead + the distance from the
 
		 * 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);
 

	
 
		x &= 0xF;
 
		y &= 0xF;
 

	
 
		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;
 
			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;
 

	
 
				v->vehstatus |= VS_TRAIN_SLOWING;
 
				spd = max(0, (stop - x) * 20 - 15);
 
				if (spd < v->cur_speed) v->cur_speed = spd;
 
			}
 
			if (x >= stop) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); // enter station
 

	
 
			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);
 
		if (rv->state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)rv->state) && rv->frame == 0) {
 
			if (IsRoadStop(tile) && rv->IsFrontEngine()) {
 
				/* Attempt to allocate a parking bay in a road stop */
0 comments (0 inline, 0 general)