summaryrefslogtreecommitdiff
path: root/src/direction_func.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-04-24 13:05:51 +0000
committersmatz <smatz@openttd.org>2008-04-24 13:05:51 +0000
commit345f160978ada62ad59cb8f9d34c135a536ccbb1 (patch)
tree4aeca38f1ed816119df449a6876e357e9df79dbd /src/direction_func.h
parent5ac07a2c3454ca3cb932ac7cf1f0083368640322 (diff)
downloadopenttd-345f160978ada62ad59cb8f9d34c135a536ccbb1.tar.xz
(svn r12870) -Codechange: remove some magic numbers from u.ship.state handling
Diffstat (limited to 'src/direction_func.h')
-rw-r--r--src/direction_func.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/direction_func.h b/src/direction_func.h
index 2cfe99534..8b0790483 100644
--- a/src/direction_func.h
+++ b/src/direction_func.h
@@ -168,6 +168,22 @@ static inline DiagDirection AxisToDiagDir(Axis a)
}
/**
+ * Converts an Axis to a Direction
+ *
+ * This function returns the Direction which
+ * belongs to the axis. As 2 directions are mapped to an axis
+ * this function returns the one which points to south,
+ * either south-west (on X axis) or south-east (on Y axis)
+ *
+ * @param a The axis
+ * @return The direction pointed to south
+ */
+static inline Direction AxisToDirection(Axis a)
+{
+ return (Direction)(5 - 2 * a);
+}
+
+/**
* Convert an axis and a flag for north/south into a DiagDirection
* @param xy axis to convert
* @param ns north -> 0, south -> 1