(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.

pull/155/head
rubidium 16 years ago
parent a4fd962adf
commit 0f56f52080

@ -1082,10 +1082,20 @@ static Trackdir RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection ent
} }
if (v->u.road.reverse_ctr != 0) { if (v->u.road.reverse_ctr != 0) {
/* What happens here?? */ bool reverse = true;
v->u.road.reverse_ctr = 0; if (v->u.road.roadtype == ROADTYPE_TRAM) {
if (v->tile != tile) { /* Trams may only reverse on a tile if it contains at least the straight
return_track(_road_reverse_table[enterdir]); * 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_DEFAULT_START_FRAME = 0,
RVC_TURN_AROUND_START_FRAME = 1, RVC_TURN_AROUND_START_FRAME = 1,
RVC_DEPOT_START_FRAME = 6, 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, RVC_TURN_AROUND_START_FRAME_SHORT_TRAM = 16,
/* Stop frame for a vehicle in a drive-through stop */ /* Stop frame for a vehicle in a drive-through stop */
RVC_DRIVE_THROUGH_STOP_FRAME = 7 RVC_DRIVE_THROUGH_STOP_FRAME = 7
@ -1477,7 +1487,7 @@ again:
* going to cause the tram to split up. * going to cause the tram to split up.
* - Or the front of the tram can drive over the next tile. * - 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: * Taking the 'small' corner for trams only happens when:
* - We are not the from vehicle of an articulated tram. * - We are not the from vehicle of an articulated tram.
@ -1587,12 +1597,12 @@ again:
* going to be properly shown. * going to be properly shown.
*/ */
turn_around_start_frame = RVC_START_FRAME_AFTER_LONG_TRAM; turn_around_start_frame = RVC_START_FRAME_AFTER_LONG_TRAM;
switch (tram) { switch (rd.x & 0x3) {
default: NOT_REACHED(); default: NOT_REACHED();
case ROAD_SW: dir = TRACKDIR_RVREV_NE; break; case DIAGDIR_NW: dir = TRACKDIR_RVREV_SE; break;
case ROAD_NW: dir = TRACKDIR_RVREV_SE; break; case DIAGDIR_NE: dir = TRACKDIR_RVREV_SW; break;
case ROAD_NE: dir = TRACKDIR_RVREV_SW; break; case DIAGDIR_SE: dir = TRACKDIR_RVREV_NW; break;
case ROAD_SE: dir = TRACKDIR_RVREV_NW; break; case DIAGDIR_SW: dir = TRACKDIR_RVREV_NE; break;
} }
} else { } else {
if (IsRoadVehFront(v)) { if (IsRoadVehFront(v)) {

@ -1259,7 +1259,7 @@ static const RoadDriveEntry _roadveh_tram_turn_sw_0[] = {
{15, 7}, {15, 7},
{15, 6}, {15, 6},
{15, 5}, {15, 5},
{RDE_TURNED | DIAGDIR_SW, 0}, {RDE_TURNED | DIAGDIR_NE, 0},
{14, 5}, {14, 5},
{13, 5}, {13, 5},
{12, 5}, {12, 5},

Loading…
Cancel
Save