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
commit273533d4c705f98a15e1376a77f34a5978ec55f6 (patch)
treee2311e3c6295b3d9db10baea067278eaaa657869 /bridge_map.h
parentb1cc36da3a828c496b82d5055b5e0214d0699081 (diff)
downloadopenttd-273533d4c705f98a15e1376a77f34a5978ec55f6.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);