Changeset - r3878:ed9ca5d7fcba
[Not reviewed]
master
0 3 0
tron - 19 years ago 2006-05-20 18:03:22
tron@openttd.org
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
3 files changed with 39 insertions and 44 deletions:
0 comments (0 inline, 0 general)
rail_cmd.c
Show inline comments
 
@@ -153,27 +153,24 @@ const TrackBits _valid_tileh_slopes[2][1
 

	
 
uint GetRailFoundation(Slope tileh, TrackBits bits)
 
{
 
	int i;
 
	uint i;
 

	
 
	if ((~_valid_tileh_slopes[0][tileh] & bits) == 0)
 
		return 0;
 

	
 
	if ((~_valid_tileh_slopes[1][tileh] & bits) == 0)
 
		return tileh;
 
	if ((~_valid_tileh_slopes[0][tileh] & bits) == 0) return 0;
 
	if ((~_valid_tileh_slopes[1][tileh] & bits) == 0) return tileh;
 

	
 
	if ((
 
				(i  = 0, tileh == SLOPE_W) ||
 
				(i += 2, tileh == SLOPE_S) ||
 
				(i += 2, tileh == SLOPE_E) ||
 
				(i += 2, tileh == SLOPE_N)
 
			) && (
 
				bits == TRACK_BIT_X ||
 
				(i++, bits == TRACK_BIT_Y)
 
			)) {
 
		return i + 15;
 
	} else {
 
		return 0;
 
	switch (bits) {
 
		case TRACK_BIT_X: i = 0; break;
 
		case TRACK_BIT_Y: i = 1; break;
 
		default:          return 0;
 
	}
 
	switch (tileh) {
 
		case SLOPE_W: i += 0; break;
 
		case SLOPE_S: i += 2; break;
 
		case SLOPE_E: i += 4; break;
 
		case SLOPE_N: i += 6; break;
 
		default:      return 0;
 
	}
 
	return i + 15;
 
}
 

	
 

	
road_cmd.c
Show inline comments
 
@@ -659,24 +659,25 @@ typedef struct DrawRoadSeqStruct {
 

	
 
uint GetRoadFoundation(Slope tileh, RoadBits bits)
 
{
 
	int i;
 
	uint i;
 

	
 
	// normal level sloped building
 
	if ((~_valid_tileh_slopes_road[1][tileh] & bits) == 0) return tileh;
 

	
 
	// inclined sloped building
 
	if ((
 
				(i  = 0, tileh == SLOPE_W) ||
 
				(i += 2, tileh == SLOPE_S) ||
 
				(i += 2, tileh == SLOPE_E) ||
 
				(i += 2, tileh == SLOPE_N)
 
			) && (
 
				(     bits == ROAD_X) ||
 
				(i++, bits == ROAD_Y)
 
			)) {
 
		return i + 15;
 
	switch (bits) {
 
		case ROAD_X: i = 0; break;
 
		case ROAD_Y: i = 1; break;
 
		default:     return 0;
 
	}
 

	
 
	return 0;
 
	switch (tileh) {
 
		case SLOPE_W: i += 0; break;
 
		case SLOPE_S: i += 2; break;
 
		case SLOPE_E: i += 4; break;
 
		case SLOPE_N: i += 6; break;
 
		default:      return 0;
 
	}
 
	return i + 15;
 
}
 

	
 
const byte _road_sloped_sprites[14] = {
tunnelbridge_cmd.c
Show inline comments
 
@@ -858,23 +858,20 @@ static void DrawBridgePillars(PalSpriteI
 

	
 
uint GetBridgeFoundation(Slope tileh, Axis axis)
 
{
 
	int i;
 
	uint i;
 

	
 
	if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) return tileh;
 

	
 
	// inclined sloped building
 
	if ((
 
				(i  = 0, tileh == SLOPE_W) ||
 
				(i += 2, tileh == SLOPE_S) ||
 
				(i += 2, tileh == SLOPE_E) ||
 
				(i += 2, tileh == SLOPE_N)
 
			) && (
 
				      axis == AXIS_X ||
 
				(i++, axis == AXIS_Y)
 
			)) {
 
		return i + 15;
 
	switch (tileh) {
 
		case SLOPE_W: i = 0; break;
 
		case SLOPE_S: i = 2; break;
 
		case SLOPE_E: i = 4; break;
 
		case SLOPE_N: i = 6; break;
 
		default:      return 0;
 
	}
 

	
 
	return 0;
 
	if (axis != AXIS_X) ++i;
 
	return i + 15;
 
}
 

	
 
/**
0 comments (0 inline, 0 general)