Changeset - r15438:0fdaf92abff1
[Not reviewed]
master
0 3 0
alberth - 14 years ago 2010-07-09 12:14:02
alberth@openttd.org
(svn r20097) -Codechange: Share constant bitset of safe level crossing slopes.
3 files changed with 6 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/rail_cmd.cpp
Show inline comments
 
@@ -405,18 +405,14 @@ CommandCost CmdBuildSingleRail(TileIndex
 
				SetTrackBits(tile, GetTrackBits(tile) | trackbit);
 
			}
 
			break;
 
		}
 

	
 
		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;
 

	
 
			if (IsNormalRoad(tile)) {
 
				if (HasRoadWorks(tile)) return_cmd_error(STR_ERROR_ROAD_WORKS_IN_PROGRESS);
src/road_cmd.cpp
Show inline comments
 
@@ -49,17 +49,12 @@ bool RoadVehiclesAreBuilt()
 
	const RoadVehicle *rv;
 
	FOR_ALL_ROADVEHICLES(rv) return true;
 

	
 
	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 */
 
	{
 
		ROAD_NONE,         // SLOPE_FLAT
 
		ROAD_NE | ROAD_SE, // SLOPE_W
src/slope_type.h
Show inline comments
 
@@ -76,12 +76,17 @@ enum Slope {
 
	SLOPE_HALFTILE_S = SLOPE_HALFTILE | (CORNER_S << 6),    ///< the south halftile is leveled (non continuous slope)
 
	SLOPE_HALFTILE_E = SLOPE_HALFTILE | (CORNER_E << 6),    ///< the east halftile is leveled (non continuous slope)
 
	SLOPE_HALFTILE_N = SLOPE_HALFTILE | (CORNER_N << 6),    ///< the north halftile is leveled (non continuous 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.
 
 */
 
enum Foundation {
 
	FOUNDATION_NONE,             ///< The tile has no foundation, the slope remains unchanged.
0 comments (0 inline, 0 general)