summaryrefslogtreecommitdiff
path: root/src/tunnelbridge.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-01-23 22:34:04 +0000
committersmatz <smatz@openttd.org>2008-01-23 22:34:04 +0000
commit5a7c9037709772e4678ee57d9b42f5332bd66f97 (patch)
treeae76a3390a465cf3bfc011e2b32d53d5ae55c298 /src/tunnelbridge.h
parentb5641ae0f2ca3723af7fe7f68c4ac45e113e8421 (diff)
downloadopenttd-5a7c9037709772e4678ee57d9b42f5332bd66f97.tar.xz
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
Diffstat (limited to 'src/tunnelbridge.h')
-rw-r--r--src/tunnelbridge.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/tunnelbridge.h b/src/tunnelbridge.h
new file mode 100644
index 000000000..758ba59a5
--- /dev/null
+++ b/src/tunnelbridge.h
@@ -0,0 +1,26 @@
+/* $Id$ */
+
+/** @file tunnelbridge.h Header file for things common for tunnels and bridges */
+
+#ifndef TUNNELBRIDGE_H
+#define TUNNELBRIDGE_H
+
+#include "tile_type.h"
+#include "map_func.h"
+#include "tunnelbridge_map.h"
+
+/**
+ * Calculates the length of a tunnel or a bridge (without end tiles)
+ * @return length of bridge/tunnel middle
+ */
+static inline uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
+{
+ int x1 = TileX(begin);
+ int y1 = TileY(begin);
+ int x2 = TileX(end);
+ int y2 = TileY(end);
+
+ return abs(x2 + y2 - x1 - y1) - 1;
+}
+
+#endif /* TUNNELBRIDGE_H */