Changeset - r10174:6f7dce48683a
[Not reviewed]
master
0 2 0
rubidium - 16 years ago 2008-09-21 11:26:50
rubidium@openttd.org
(svn r14368) -Fix [FS#1852]: trams jumping when reversing on a single trambit (like caused during road construction reworks) or when (manually) reversing in a corner.
2 files changed with 22 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1082,10 +1082,20 @@ static Trackdir RoadFindPathToDest(Vehic
 
	}
 

	
 
	if (v->u.road.reverse_ctr != 0) {
 
		/* What happens here?? */
 
		v->u.road.reverse_ctr = 0;
 
		if (v->tile != tile) {
 
			return_track(_road_reverse_table[enterdir]);
 
		bool reverse = true;
 
		if (v->u.road.roadtype == ROADTYPE_TRAM) {
 
			/* Trams may only reverse on a tile if it contains at least the straight
 
			 * trackbits or when it is a valid turning tile (i.e. one roadbit) */
 
			RoadBits rb = GetAnyRoadBits(tile, ROADTYPE_TRAM);
 
			RoadBits straight = AxisToRoadBits(DiagDirToAxis(enterdir));
 
			reverse = ((rb & straight) == straight) ||
 
			          (rb == DiagDirToRoadBits(enterdir));
 
		}
 
		if (reverse) {
 
			v->u.road.reverse_ctr = 0;
 
			if (v->tile != tile) {
 
				return_track(_road_reverse_table[enterdir]);
 
			}
 
		}
 
	}
 

	
 
@@ -1219,7 +1229,7 @@ enum {
 
	RVC_DEFAULT_START_FRAME                =  0,
 
	RVC_TURN_AROUND_START_FRAME            =  1,
 
	RVC_DEPOT_START_FRAME                  =  6,
 
	RVC_START_FRAME_AFTER_LONG_TRAM        = 22,
 
	RVC_START_FRAME_AFTER_LONG_TRAM        = 21,
 
	RVC_TURN_AROUND_START_FRAME_SHORT_TRAM = 16,
 
	/* Stop frame for a vehicle in a drive-through stop */
 
	RVC_DRIVE_THROUGH_STOP_FRAME           =  7
 
@@ -1477,7 +1487,7 @@ again:
 
					 *   going to cause the tram to split up.
 
					 * - Or the front of the tram can drive over the next tile.
 
					 */
 
				} else if (!IsRoadVehFront(v) || !CanBuildTramTrackOnTile(v->owner, tile, needed)) {
 
				} else if (!IsRoadVehFront(v) || !CanBuildTramTrackOnTile(v->owner, tile, needed) || ((~needed & GetRoadBits(v->tile, ROADTYPE_TRAM)) == ROAD_NONE)) {
 
					/*
 
					 * Taking the 'small' corner for trams only happens when:
 
					 * - We are not the from vehicle of an articulated tram.
 
@@ -1587,12 +1597,12 @@ again:
 
			 * going to be properly shown.
 
			 */
 
			turn_around_start_frame = RVC_START_FRAME_AFTER_LONG_TRAM;
 
			switch (tram) {
 
			switch (rd.x & 0x3) {
 
				default: NOT_REACHED();
 
				case ROAD_SW: dir = TRACKDIR_RVREV_NE; break;
 
				case ROAD_NW: dir = TRACKDIR_RVREV_SE; break;
 
				case ROAD_NE: dir = TRACKDIR_RVREV_SW; break;
 
				case ROAD_SE: dir = TRACKDIR_RVREV_NW; break;
 
				case DIAGDIR_NW: dir = TRACKDIR_RVREV_SE; break;
 
				case DIAGDIR_NE: dir = TRACKDIR_RVREV_SW; break;
 
				case DIAGDIR_SE: dir = TRACKDIR_RVREV_NW; break;
 
				case DIAGDIR_SW: dir = TRACKDIR_RVREV_NE; break;
 
			}
 
		} else {
 
			if (IsRoadVehFront(v)) {
src/table/roadveh_movement.h
Show inline comments
 
@@ -1259,7 +1259,7 @@ static const RoadDriveEntry _roadveh_tra
 
	{15, 7},
 
	{15, 6},
 
	{15, 5},
 
	{RDE_TURNED | DIAGDIR_SW, 0},
 
	{RDE_TURNED | DIAGDIR_NE, 0},
 
	{14, 5},
 
	{13, 5},
 
	{12, 5},
0 comments (0 inline, 0 general)