summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-05-13 10:58:41 +0000
committerrubidium <rubidium@openttd.org>2009-05-13 10:58:41 +0000
commitaa0459309cef7773c5ad493abfcf4a60414275a6 (patch)
treea9b19c9a47541e15e9cc63170b3ce5573911b87b /src
parent111e62bba64bca75e6fd878136b8db371e7902d8 (diff)
downloadopenttd-aa0459309cef7773c5ad493abfcf4a60414275a6.tar.xz
(svn r16291) -Fix [FS#2893]: RVs were unable to find a depot when turning around (in some cases), causing 'nearest depot' orders to be occasionally lost.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 5dda6a93d..4e4572815 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1219,13 +1219,12 @@ Trackdir GetVehicleTrackdir(const Vehicle *v)
if (IsStandardRoadStopTile(v->tile)) // We'll assume the road vehicle is facing outwards
return DiagDirToDiagTrackdir(GetRoadStopDir(v->tile)); // Road vehicle in a station
- if (IsDriveThroughStopTile(v->tile)) return DiagDirToDiagTrackdir(DirToDiagDir(v->direction));
+ /* Drive through road stops / wormholes (tunnels) */
+ if (v->u.road.state > RVSB_TRACKDIR_MASK) return DiagDirToDiagTrackdir(DirToDiagDir(v->direction));
- /* If vehicle's state is a valid track direction (vehicle is not turning around) return it */
- if (!IsReversingRoadTrackdir((Trackdir)v->u.road.state)) return (Trackdir)v->u.road.state;
-
- /* Vehicle is turning around, get the direction from vehicle's direction */
- return DiagDirToDiagTrackdir(DirToDiagDir(v->direction));
+ /* If vehicle's state is a valid track direction (vehicle is not turning around) return it,
+ * otherwise transform it into a valid track direction */
+ return (Trackdir)((IsReversingRoadTrackdir((Trackdir)v->u.road.state)) ? (v->u.road.state - 6) : v->u.road.state);
/* case VEH_AIRCRAFT: case VEH_EFFECT: case VEH_DISASTER: */
default: return INVALID_TRACKDIR;