summaryrefslogtreecommitdiff
path: root/depot.h
diff options
context:
space:
mode:
authormatthijs <matthijs@openttd.org>2005-04-05 22:06:02 +0000
committermatthijs <matthijs@openttd.org>2005-04-05 22:06:02 +0000
commit92fe22382a8f0ea362fb35b28b8eb228c1e2e339 (patch)
tree9387c6b7a02c7f86fc41be8000d1b75c947560f9 /depot.h
parentdfe6c34bf1e872d76c4c3d9468684117e52e0020 (diff)
downloadopenttd-92fe22382a8f0ea362fb35b28b8eb228c1e2e339.tar.xz
(svn r2154) - Fix: [NPF] Vehicles should no longer try to drive through the back of depots and road stations.
- Add: GetDepotDirection() wrapper function. - Fix: [NPF] Ships can now actually reach buoys.
Diffstat (limited to 'depot.h')
-rw-r--r--depot.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/depot.h b/depot.h
index 11f47401a..7f0d6acac 100644
--- a/depot.h
+++ b/depot.h
@@ -71,6 +71,32 @@ static inline bool IsTileDepotType(TileIndex tile, TransportType type)
}
}
+/**
+ * Returns the direction the exit of the depot on the given tile is facing.
+ */
+static inline uint GetDepotDirection(TileIndex tile, TransportType type)
+{
+ assert(IsTileDepotType(tile, type));
+
+ switch (type)
+ {
+ case TRANSPORT_RAIL:
+ case TRANSPORT_ROAD:
+ /* Rail and road store a diagonal direction in bits 0 and 1 */
+ return _map5[tile] & 3;
+ case TRANSPORT_WATER:
+ /* Water is stubborn, it stores the directions in a different order. */
+ switch (_map5[tile] & 3) {
+ case 0: return 0;
+ case 1: return 2;
+ case 2: return 3;
+ case 3: return 1;
+ }
+ default:
+ return 0; /* Not reached */
+ }
+}
+
Depot *GetDepotByTile(uint tile);
void InitializeDepot(void);
Depot *AllocateDepot(void);