Changeset - r2667:abe745331f35
[Not reviewed]
master
0 1 0
peter1138 - 19 years ago 2005-11-16 14:30:24
peter1138@openttd.org
(svn r3209) In TileLoop_Track(), use names based on function rather than their place in the map array.
1 file changed with 18 insertions and 18 deletions:
rail_cmd.c
18
18
0 comments (0 inline, 0 general)
rail_cmd.c
Show inline comments
 
@@ -1970,23 +1970,23 @@ static void AnimateTile_Track(TileIndex 
 

	
 
static void TileLoop_Track(TileIndex tile)
 
{
 
	byte a2;
 
	byte rail;
 
	uint16 m2;
 
	byte old_ground;
 
	byte new_ground;
 
	TrackBits rail;
 

	
 
	m2 = GB(_m[tile].m2, 0, 4);
 
	old_ground = GB(_m[tile].m2, 0, 4);
 

	
 
	switch (_opt.landscape) {
 
		case LT_HILLY:
 
			if (GetTileZ(tile) > _opt.snow_line) { /* convert into snow? */
 
				a2 = RAIL_GROUND_ICE_DESERT;
 
				new_ground = RAIL_GROUND_ICE_DESERT;
 
				goto modify_me;
 
			}
 
			break;
 

	
 
		case LT_DESERT:
 
			if (GetMapExtraBits(tile) == 1) { /* convert into desert? */
 
				a2 = RAIL_GROUND_ICE_DESERT;
 
				new_ground = RAIL_GROUND_ICE_DESERT;
 
				goto modify_me;
 
			}
 
			break;
 
@@ -1995,20 +1995,20 @@ static void TileLoop_Track(TileIndex til
 
	// Don't continue tile loop for depots
 
	if (_m[tile].m5 & RAIL_TYPE_SPECIAL) return;
 

	
 
	a2 = RAIL_GROUND_GREEN;
 
	new_ground = RAIL_GROUND_GREEN;
 

	
 
	if (m2 != RAIL_GROUND_BROWN) { /* wait until bottom is green */
 
	if (old_ground != RAIL_GROUND_BROWN) { /* wait until bottom is green */
 
		/* determine direction of fence */
 
		rail = _m[tile].m5 & TRACK_BIT_MASK;
 

	
 
		if (rail == TRACK_BIT_UPPER) {
 
			a2 = RAIL_GROUND_FENCE_HORIZ1;
 
			new_ground = RAIL_GROUND_FENCE_HORIZ1;
 
		} else if (rail == TRACK_BIT_LOWER) {
 
			a2 = RAIL_GROUND_FENCE_HORIZ2;
 
			new_ground = RAIL_GROUND_FENCE_HORIZ2;
 
		} else if (rail == TRACK_BIT_LEFT) {
 
			a2 = RAIL_GROUND_FENCE_VERT1;
 
			new_ground = RAIL_GROUND_FENCE_VERT1;
 
		} else if (rail == TRACK_BIT_RIGHT) {
 
			a2 = RAIL_GROUND_FENCE_VERT2;
 
			new_ground = RAIL_GROUND_FENCE_VERT2;
 
		} else {
 
			PlayerID owner = GetTileOwner(tile);
 

	
 
@@ -2016,36 +2016,36 @@ static void TileLoop_Track(TileIndex til
 
				if (!IsTileType(tile + TileDiffXY(0, -1), MP_RAILWAY) ||
 
						!IsTileOwner(tile + TileDiffXY(0, -1), owner) ||
 
						(_m[tile + TileDiffXY(0, -1)].m5 == TRACK_BIT_UPPER || _m[tile + TileDiffXY(0, -1)].m5 == TRACK_BIT_LEFT))
 
							a2 = RAIL_GROUND_FENCE_NW;
 
							new_ground = RAIL_GROUND_FENCE_NW;
 
			}
 

	
 
			if ( (!(rail&(TRACK_BIT_DIAG2|TRACK_BIT_LOWER|TRACK_BIT_RIGHT)) && (rail&TRACK_BIT_DIAG1)) || rail==(TRACK_BIT_UPPER|TRACK_BIT_LEFT)) {
 
				if (!IsTileType(tile + TileDiffXY(0, 1), MP_RAILWAY) ||
 
						!IsTileOwner(tile + TileDiffXY(0, 1), owner) ||
 
						(_m[tile + TileDiffXY(0, 1)].m5 == TRACK_BIT_LOWER || _m[tile + TileDiffXY(0, 1)].m5 == TRACK_BIT_RIGHT))
 
							a2 = (a2 == RAIL_GROUND_FENCE_NW) ? RAIL_GROUND_FENCE_SENW : RAIL_GROUND_FENCE_SE;
 
							new_ground = (new_ground == RAIL_GROUND_FENCE_NW) ? RAIL_GROUND_FENCE_SENW : RAIL_GROUND_FENCE_SE;
 
			}
 

	
 
			if ( (!(rail&(TRACK_BIT_DIAG1|TRACK_BIT_UPPER|TRACK_BIT_RIGHT)) && (rail&TRACK_BIT_DIAG2)) || rail==(TRACK_BIT_LOWER|TRACK_BIT_LEFT)) {
 
				if (!IsTileType(tile + TileDiffXY(-1, 0), MP_RAILWAY) ||
 
						!IsTileOwner(tile + TileDiffXY(-1, 0), owner) ||
 
						(_m[tile + TileDiffXY(-1, 0)].m5 == TRACK_BIT_UPPER || _m[tile + TileDiffXY(-1, 0)].m5 == TRACK_BIT_RIGHT))
 
							a2 = RAIL_GROUND_FENCE_NE;
 
							new_ground = RAIL_GROUND_FENCE_NE;
 
			}
 

	
 
			if ( (!(rail&(TRACK_BIT_DIAG1|TRACK_BIT_LOWER|TRACK_BIT_LEFT)) && (rail&TRACK_BIT_DIAG2)) || rail==(TRACK_BIT_UPPER|TRACK_BIT_RIGHT)) {
 
				if (!IsTileType(tile + TileDiffXY(1, 0), MP_RAILWAY) ||
 
						!IsTileOwner(tile + TileDiffXY(1, 0), owner) ||
 
						(_m[tile + TileDiffXY(1, 0)].m5 == TRACK_BIT_LOWER || _m[tile + TileDiffXY(1, 0)].m5 == TRACK_BIT_LEFT))
 
							a2 = (a2 == RAIL_GROUND_FENCE_NE) ? RAIL_GROUND_FENCE_NESW : RAIL_GROUND_FENCE_SW;
 
							new_ground = (new_ground == RAIL_GROUND_FENCE_NE) ? RAIL_GROUND_FENCE_NESW : RAIL_GROUND_FENCE_SW;
 
			}
 
		}
 
	}
 

	
 
modify_me:;
 
	/* tile changed? */
 
	if (m2 != a2) {
 
		SB(_m[tile].m2, 0, 4, a2);
 
	if (old_ground != new_ground) {
 
		SB(_m[tile].m2, 0, 4, new_ground);
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
0 comments (0 inline, 0 general)