summaryrefslogtreecommitdiff
path: root/bridge_map.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-14 12:00:11 +0000
committertron <tron@openttd.org>2006-03-14 12:00:11 +0000
commit42d1731cc1a795f7067c1fd92e337a41480d5589 (patch)
treee2311e3c6295b3d9db10baea067278eaaa657869 /bridge_map.h
parentb2412f7472335fdaee34b355643f0ab77ae381bd (diff)
downloadopenttd-42d1731cc1a795f7067c1fd92e337a41480d5589.tar.xz
(svn r3857) Add and use GetBridgeRampDirection()
Note: This slightly changes the behavior of GetAnyRoadBits() to only return a road piece for the start of the bridge ramp instead of a full ROAD_[XY]
Diffstat (limited to 'bridge_map.h')
-rw-r--r--bridge_map.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/bridge_map.h b/bridge_map.h
index ba8e71d50..f1e12db59 100644
--- a/bridge_map.h
+++ b/bridge_map.h
@@ -3,12 +3,25 @@
#ifndef BRIDGE_MAP_H
#define BRIDGE_MAP_H
+#include "direction.h"
#include "macros.h"
#include "map.h"
#include "rail.h"
#include "tile.h"
+/**
+ * Get the direction pointing onto the bridge
+ */
+static inline DiagDirection GetBridgeRampDirection(TileIndex t)
+{
+ /* Heavy wizardry to convert the X/Y (bit 0) + N/S (bit 5) encoding of
+ * bridges to a DiagDirection
+ */
+ return (DiagDirection)((6 - (_m[t].m5 >> 4 & 2) - (_m[t].m5 & 1)) % 4);
+}
+
+
static inline void SetClearUnderBridge(TileIndex t)
{
SetTileOwner(t, OWNER_NONE);