diff options
-rw-r--r-- | src/roadveh_cmd.cpp | 32 | ||||
-rw-r--r-- | src/table/roadveh_movement.h | 2 |
2 files changed, 22 insertions, 12 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 315499eb9..3739aa8ce 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1082,10 +1082,20 @@ static Trackdir RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection ent } 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)) { diff --git a/src/table/roadveh_movement.h b/src/table/roadveh_movement.h index a6f3e543a..76c94beae 100644 --- a/src/table/roadveh_movement.h +++ b/src/table/roadveh_movement.h @@ -1259,7 +1259,7 @@ static const RoadDriveEntry _roadveh_tram_turn_sw_0[] = { {15, 7}, {15, 6}, {15, 5}, - {RDE_TURNED | DIAGDIR_SW, 0}, + {RDE_TURNED | DIAGDIR_NE, 0}, {14, 5}, {13, 5}, {12, 5}, |