depot.h
changeset 1650 4a5141e10b72
parent 1330 5d76a0522a11
child 1718 96d76767ea93
--- a/depot.h	Tue Apr 05 21:09:36 2005 +0000
+++ b/depot.h	Tue Apr 05 22:06:02 2005 +0000
@@ -71,6 +71,32 @@
 	}
 }
 
+/**
+ * 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);