summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-07-09 12:14:02 +0000
committeralberth <alberth@openttd.org>2010-07-09 12:14:02 +0000
commit82fc340a0a608eb1edf8c079b4585cf0880733df (patch)
treee197cefb0566f9017e59dbe5c802b9f2301776aa
parent72bfda4634fa599479c7fcd8026642362c58ef58 (diff)
downloadopenttd-82fc340a0a608eb1edf8c079b4585cf0880733df.tar.xz
(svn r20097) -Codechange: Share constant bitset of safe level crossing slopes.
-rw-r--r--src/rail_cmd.cpp6
-rw-r--r--src/road_cmd.cpp5
-rw-r--r--src/slope_type.h5
3 files changed, 6 insertions, 10 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index c61503fe6..2eb8b056f 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -408,12 +408,8 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
}
case MP_ROAD: {
-#define M(x) (1 << (x))
/* Level crossings may only be built on these slopes */
- if (!HasBit(M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT), tileh)) {
- return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
- }
-#undef M
+ if (!HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh)) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
CommandCost ret = EnsureNoVehicleOnGround(tile);
if (ret.Failed()) return ret;
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 515237f38..41ef5b0d6 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -52,11 +52,6 @@ bool RoadVehiclesAreBuilt()
return false;
}
-#define M(x) (1 << (x))
-/* Level crossings may only be built on these slopes */
-static const uint32 VALID_LEVEL_CROSSING_SLOPES = (M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT));
-#undef M
-
/* Invalid RoadBits on slopes */
static const RoadBits _invalid_tileh_slopes_road[2][15] = {
/* The inverse of the mixable RoadBits on a leveled slope */
diff --git a/src/slope_type.h b/src/slope_type.h
index 0098eedf6..5eb7a7a20 100644
--- a/src/slope_type.h
+++ b/src/slope_type.h
@@ -79,6 +79,11 @@ enum Slope {
};
DECLARE_ENUM_AS_BIT_SET(Slope)
+#define M(x) (1 << (x))
+/** Constant bitset with safe slopes for building a level crossing. */
+static const uint32 VALID_LEVEL_CROSSING_SLOPES = M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT);
+#undef M
+
/**
* Enumeration for Foundations.