--- a/src/slope.h Sat Oct 20 10:14:05 2007 +0000
+++ b/src/slope.h Sat Oct 20 10:42:28 2007 +0000
@@ -48,9 +48,21 @@
CORNER_S = 1,
CORNER_E = 2,
CORNER_N = 3,
+ CORNER_END
};
/**
+ * Rangecheck for Corner enumeration.
+ *
+ * @param corner A #Corner.
+ * @return true iff corner is in a valid range.
+ */
+static inline bool IsValidCorner(Corner corner)
+{
+ return IS_INT_INSIDE(corner, 0, CORNER_END);
+}
+
+/**
* Checks if a slope is steep.
*
* @param s The given #Slope.
@@ -79,6 +91,17 @@
}
/**
+ * Tests if a slope has a highest corner (i.e. one corner raised or a steep slope).
+ *
+ * @param s The #Slope.
+ * @return true iff the slope has a highest corner.
+ */
+static inline bool HasSlopeHighestCorner(Slope s)
+{
+ return IsSteepSlope(s) || (s == SLOPE_W) || (s == SLOPE_S) || (s == SLOPE_E) || (s == SLOPE_N);
+}
+
+/**
* Returns the highest corner of a slope (one corner raised or a steep slope).
*
* @pre The slope must be a slope with one corner raised or a steep slope.
@@ -132,7 +155,7 @@
*/
static inline Slope SlopeWithOneCornerRaised(Corner corner)
{
- assert(IS_INT_INSIDE(corner, 0, 4));
+ assert(IsValidCorner(corner));
return (Slope)(1 << corner);
}
@@ -158,6 +181,8 @@
FOUNDATION_INCLINED_Y, ///< The tile has an along Y-axis inclined foundation.
FOUNDATION_STEEP_LOWER, ///< The tile has a steep slope. The lowerst corner is raised by a foundation to allow building railroad on the lower halftile.
FOUNDATION_STEEP_HIGHER, ///< The tile has a steep slope. Three corners are raised by a foundation to allow building railroad on the higher halftile.
+
+ FOUNDATION_INVALID = 0xFF ///< Used inside "rail_cmd.cpp" to indicate invalid slope/track combination.
};
/**