mirror of https://github.com/OpenTTD/OpenTTD
(svn r20097) -Codechange: Share constant bitset of safe level crossing slopes.
parent
72bfda4634
commit
82fc340a0a
|
@ -408,12 +408,8 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||||
}
|
}
|
||||||
|
|
||||||
case MP_ROAD: {
|
case MP_ROAD: {
|
||||||
#define M(x) (1 << (x))
|
|
||||||
/* Level crossings may only be built on these slopes */
|
/* 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)) {
|
if (!HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh)) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||||
return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
|
||||||
}
|
|
||||||
#undef M
|
|
||||||
|
|
||||||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
|
|
|
@ -52,11 +52,6 @@ bool RoadVehiclesAreBuilt()
|
||||||
return false;
|
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 */
|
/* Invalid RoadBits on slopes */
|
||||||
static const RoadBits _invalid_tileh_slopes_road[2][15] = {
|
static const RoadBits _invalid_tileh_slopes_road[2][15] = {
|
||||||
/* The inverse of the mixable RoadBits on a leveled slope */
|
/* The inverse of the mixable RoadBits on a leveled slope */
|
||||||
|
|
|
@ -79,6 +79,11 @@ enum Slope {
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(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.
|
* Enumeration for Foundations.
|
||||||
|
|
Loading…
Reference in New Issue