(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
authortron
Mon, 13 Feb 2006 21:15:00 +0000
changeset 3017 915fae59d5e0
parent 3016 c63fb93fa1a0
child 3018 79f51529a689
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
console.c
economy.c
industry_gui.c
landscape.c
npf.c
openttd.h
pathfind.c
rail_cmd.c
road_cmd.c
roadveh_cmd.c
terraform_gui.c
tile.c
town_cmd.c
train_cmd.c
tree_cmd.c
tunnelbridge_cmd.c
unmovable_cmd.c
water_cmd.c
--- a/console.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/console.c	Mon Feb 13 21:15:00 2006 +0000
@@ -695,7 +695,7 @@
 {
 	const char *cmdptr;
 	char *aliases[ICON_MAX_ALIAS_LINES], aliasstream[ICON_MAX_STREAMSIZE];
-	int i;
+	uint i;
 	uint a_index, astream_i;
 
 	memset(&aliases, 0, sizeof(aliases));
@@ -758,7 +758,7 @@
 		}
 	}
 
-	for (i = 0; i <= (int)a_index; i++) IConsoleCmdExec(aliases[i]); // execute each alias in turn
+	for (i = 0; i <= a_index; i++) IConsoleCmdExec(aliases[i]); // execute each alias in turn
 }
 
 /**
--- a/economy.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/economy.c	Mon Feb 13 21:15:00 2006 +0000
@@ -1121,10 +1121,11 @@
 		if (transit_days > _cargoc.transit_days_2[cargo]) {
 			transit_days -= _cargoc.transit_days_2[cargo];
 
-			if (f < transit_days)
+			if (f < transit_days) {
 				f = 0;
-			else
+			} else {
 				f -= transit_days;
+			}
 		}
 	}
 	if (f < 31) f = 31;
@@ -1134,19 +1135,23 @@
 
 static void DeliverGoodsToIndustry(TileIndex xy, byte cargo_type, int num_pieces)
 {
-	Industry *ind, *best;
-	int t, u;
+	Industry* best = NULL;
+	Industry* ind;
+	uint u;
 
-	/* Check if there's an industry close to the station that accepts
-	 * the cargo */
-	best = NULL;
+	// Check if there's an industry close to the station that accepts the cargo
 	u = _patches.station_spread + 8;
 	FOR_ALL_INDUSTRIES(ind) {
-		if (ind->xy != 0 && (cargo_type == ind->accepts_cargo[0] || cargo_type
-				 == ind->accepts_cargo[1] || cargo_type == ind->accepts_cargo[2]) &&
-				 ind->produced_cargo[0] != CT_INVALID &&
-				 ind->produced_cargo[0] != cargo_type &&
-				 (t = DistanceManhattan(ind->xy, xy)) < 2 * u) {
+		uint t;
+
+		if (ind->xy != 0 && (
+					cargo_type == ind->accepts_cargo[0] ||
+					cargo_type == ind->accepts_cargo[1] ||
+					cargo_type == ind->accepts_cargo[2]
+				) &&
+				ind->produced_cargo[0] != CT_INVALID &&
+				ind->produced_cargo[0] != cargo_type &&
+				(t = DistanceManhattan(ind->xy, xy)) < 2 * u) {
 			u = t;
 			best = ind;
 		}
@@ -1595,7 +1600,7 @@
 				break;
 			}
 		}
-		InvalidateWindow(WC_COMPANY, (int)p1);
+		InvalidateWindow(WC_COMPANY, p1);
 	}
 	return cost;
 }
@@ -1627,7 +1632,7 @@
 		PlayerID* b = p->share_owners;
 		while (*b != _current_player) b++; /* share owners is guaranteed to contain player */
 		*b = OWNER_SPECTATOR;
-		InvalidateWindow(WC_COMPANY, (int)p1);
+		InvalidateWindow(WC_COMPANY, p1);
 	}
 	return cost;
 }
--- a/industry_gui.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/industry_gui.c	Mon Feb 13 21:15:00 2006 +0000
@@ -392,19 +392,11 @@
 		break;
 
 	case WE_ON_EDIT_TEXT:
-		if (*e->edittext.str) {
-			Industry *i;
-			int val;
-			int line;
+		if (e->edittext.str[0] != '\0') {
+			Industry* i = GetIndustry(w->window_number);
+			int line = WP(w,vp2_d).data_1;
 
-			i = GetIndustry(w->window_number);
-			line = WP(w,vp2_d).data_1;
-			val = atoi(e->edittext.str);
-			if (!IS_INT_INSIDE(val, 32, 2040)) {
-				if (val < 32) val = 32;
-				else val = 2040;
-			}
-			i->production_rate[line] = (byte)(val / 8);
+			i->production_rate[line] = clamp(atoi(e->edittext.str), 32, 2040) / 8;
 			UpdateIndustryProduction(i);
 			SetWindowDirty(w);
 		}
--- a/landscape.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/landscape.c	Mon Feb 13 21:15:00 2006 +0000
@@ -461,8 +461,8 @@
 	for (tile = 0; tile < MapSize(); ++tile) {
 		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h == 0) {
 			SetTileType(tile, MP_WATER);
+			SetTileOwner(tile, OWNER_WATER);
 			_m[tile].m5 = 0;
-			SetTileOwner(tile, OWNER_WATER);
 		}
 	}
 }
@@ -630,37 +630,48 @@
 	uint flag;
 	uint32 r;
 
-	if (_opt.landscape == LT_HILLY) {
-		for (i = ScaleByMapSize((Random() & 0x7F) + 950); i != 0; --i)
-			GenerateTerrain(2, 0);
-
-		r = Random();
-		flag = GB(r, 0, 2) | 4;
-		for (i = ScaleByMapSize(GB(r, 16, 7) + 450); i != 0; --i)
-			GenerateTerrain(4, flag);
-	} else if (_opt.landscape == LT_DESERT) {
-		for (i = ScaleByMapSize((Random()&0x7F) + 170); i != 0; --i)
-			GenerateTerrain(0, 0);
+	switch (_opt.landscape) {
+		case LT_HILLY:
+			for (i = ScaleByMapSize((Random() & 0x7F) + 950); i != 0; --i) {
+				GenerateTerrain(2, 0);
+			}
 
-		r = Random();
-		flag = GB(r, 0, 2) | 4;
-		for (i = ScaleByMapSize(GB(r, 16, 8) + 1700); i != 0; --i)
-			GenerateTerrain(0, flag);
+			r = Random();
+			flag = GB(r, 0, 2) | 4;
+			for (i = ScaleByMapSize(GB(r, 16, 7) + 450); i != 0; --i) {
+				GenerateTerrain(4, flag);
+			}
+			break;
 
-		flag ^= 2;
+		case LT_DESERT:
+			for (i = ScaleByMapSize((Random() & 0x7F) + 170); i != 0; --i) {
+				GenerateTerrain(0, 0);
+			}
 
-		for (i = ScaleByMapSize((Random() & 0x7F) + 410); i != 0; --i)
-			GenerateTerrain(3, flag);
-	} else {
-		i = ScaleByMapSize((Random() & 0x7F) + (3 - _opt.diff.quantity_sea_lakes) * 256 + 100);
-		for (; i != 0; --i)
-			GenerateTerrain(_opt.diff.terrain_type, 0);
+			r = Random();
+			flag = GB(r, 0, 2) | 4;
+			for (i = ScaleByMapSize(GB(r, 16, 8) + 1700); i != 0; --i) {
+				GenerateTerrain(0, flag);
+			}
+
+			flag ^= 2;
+
+			for (i = ScaleByMapSize((Random() & 0x7F) + 410); i != 0; --i) {
+				GenerateTerrain(3, flag);
+			}
+			break;
+
+		default:
+			i = ScaleByMapSize((Random() & 0x7F) + (3 - _opt.diff.quantity_sea_lakes) * 256 + 100);
+			for (; i != 0; --i) {
+				GenerateTerrain(_opt.diff.terrain_type, 0);
+			}
+			break;
 	}
 
 	ConvertGroundTilesIntoWaterTiles();
 
-	if (_opt.landscape == LT_DESERT)
-		CreateDesertOrRainForest();
+	if (_opt.landscape == LT_DESERT) CreateDesertOrRainForest();
 }
 
 void OnTick_Town(void);
--- a/npf.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/npf.c	Mon Feb 13 21:15:00 2006 +0000
@@ -208,25 +208,26 @@
 #ifdef NO_DEBUG_MESSAGES
 	return;
 #else
-	if (_debug_npf_level >= 1)
-		switch (GetTileType(tile)) {
-			case MP_RAILWAY:
-				/* DEBUG: mark visited tiles by mowing the grass under them
-				 * ;-) */
-				if (!IsTileDepotType(tile, TRANSPORT_RAIL)) {
-					SB(_m[tile].m2, 0, 4, 0);
-					MarkTileDirtyByTile(tile);
-				}
-				break;
-			case MP_STREET:
-				if (!IsTileDepotType(tile, TRANSPORT_ROAD)) {
-					SB(_m[tile].m4, 4, 3, 0);
-					MarkTileDirtyByTile(tile);
-				}
-				break;
-			default:
-				break;
-		}
+	if (_debug_npf_level < 1) return;
+	switch (GetTileType(tile)) {
+		case MP_RAILWAY:
+			/* DEBUG: mark visited tiles by mowing the grass under them ;-) */
+			if (!IsTileDepotType(tile, TRANSPORT_RAIL)) {
+				SB(_m[tile].m2, 0, 4, 0);
+				MarkTileDirtyByTile(tile);
+			}
+			break;
+
+		case MP_STREET:
+			if (!IsTileDepotType(tile, TRANSPORT_ROAD)) {
+				SB(_m[tile].m4, 4, 3, 0);
+				MarkTileDirtyByTile(tile);
+			}
+			break;
+
+		default:
+			break;
+	}
 #endif
 }
 
@@ -298,7 +299,7 @@
 	TileIndex tile = current->tile;
 	Trackdir trackdir = (Trackdir)current->direction;
 	int32 cost = 0;
-	/* HACK: We create a OpenListNode manualy, so we can call EndNodeCheck */
+	/* HACK: We create a OpenListNode manually, so we can call EndNodeCheck */
 	OpenListNode new_node;
 
 	/* Determine base length */
--- a/openttd.h	Sun Feb 12 14:31:33 2006 +0000
+++ b/openttd.h	Mon Feb 13 21:15:00 2006 +0000
@@ -116,7 +116,7 @@
 	 * bridges. For now, you should just not change the values for road
 	 * and rail.
 	 */
-  TRANSPORT_RAIL = 0,
+	TRANSPORT_RAIL = 0,
 	TRANSPORT_ROAD = 1,
 	TRANSPORT_WATER,	// = 2
 	TRANSPORT_END,
--- a/pathfind.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/pathfind.c	Mon Feb 13 21:15:00 2006 +0000
@@ -558,12 +558,12 @@
 		uint offs = tpf->hash_tile[hash];
 		do {
 			link = NTP_GET_LINK_PTR(tpf, offs);
-			if (tile == link->tile && (uint)(link->typelength & 0x3) == dir) {
-				if (length >= (uint)(link->typelength >> 2)) return false;
+			if (tile == link->tile && (link->typelength & 0x3U) == dir) {
+				if (length >= link->typelength >> 2) return false;
 				link->typelength = dir | (length << 2);
 				return true;
 			}
-		} while ((offs=link->next) != 0xFFFF);
+		} while ((offs = link->next) != 0xFFFF);
 	}
 
 	/* get here if we need to add a new link to link,
@@ -611,9 +611,9 @@
 	offs = tpf->hash_tile[hash];
 	for (;;) {
 		link = NTP_GET_LINK_PTR(tpf, offs);
-		if (tile == link->tile && (uint)(link->typelength & 0x3) == dir) {
-			assert( (uint)(link->typelength >> 2) <= length);
-			return length == (uint)(link->typelength >> 2);
+		if (tile == link->tile && (link->typelength & 0x3U) == dir) {
+			assert(link->typelength >> 2 <= length);
+			return length == link->typelength >> 2;
 		}
 		offs = link->next;
 		assert(offs != 0xffff);
--- a/rail_cmd.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/rail_cmd.c	Mon Feb 13 21:15:00 2006 +0000
@@ -1577,33 +1577,34 @@
 
 static bool SetSignalsEnumProc(TileIndex tile, SetSignalsData *ssd, int track, uint length, byte *state)
 {
+	if (!IsTileType(tile, MP_RAILWAY)) return false;
+
 	// the tile has signals?
-	if (IsTileType(tile, MP_RAILWAY)) {
-		if (HasSignalOnTrack(tile, TrackdirToTrack(track))) {
-			if (HasSignalOnTrackdir(tile, ReverseTrackdir(track))) {
-				// yes, add the signal to the list of signals
-				if (ssd->cur != NUM_SSD_ENTRY) {
-					ssd->tile[ssd->cur] = tile; // remember the tile index
-					ssd->bit[ssd->cur] = track; // and the controlling bit number
-					ssd->cur++;
-				}
-
-				// remember if this block has a presignal.
-				ssd->has_presignal |= (_m[tile].m4&1);
+	if (HasSignalOnTrack(tile, TrackdirToTrack(track))) {
+		if (HasSignalOnTrackdir(tile, ReverseTrackdir(track))) {
+			// yes, add the signal to the list of signals
+			if (ssd->cur != NUM_SSD_ENTRY) {
+				ssd->tile[ssd->cur] = tile; // remember the tile index
+				ssd->bit[ssd->cur] = track; // and the controlling bit number
+				ssd->cur++;
 			}
 
-			if (HasSignalOnTrackdir(tile, track) && (_m[tile].m4 & 2)) {
-				// this is an exit signal that points out from the segment
-				ssd->presignal_exits++;
-				if (GetSignalState(tile, track) != SIGNAL_STATE_RED)
-					ssd->presignal_exits_free++;
-			}
+			// remember if this block has a presignal.
+			ssd->has_presignal |= (_m[tile].m4&1);
+		}
 
-			return true;
-		} else if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
-			return true; // don't look further if the tile is a depot
+		if (HasSignalOnTrackdir(tile, track) && _m[tile].m4 & 2) {
+			// this is an exit signal that points out from the segment
+			ssd->presignal_exits++;
+			if (GetSignalState(tile, track) != SIGNAL_STATE_RED)
+				ssd->presignal_exits_free++;
 		}
+
+		return true;
+	} else if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
+		return true; // don't look further if the tile is a depot
 	}
+
 	return false;
 }
 
@@ -1806,7 +1807,7 @@
 		direction = ssd.next_dir[ssd.cur_stack];
 	}
 
-	return (bool)result;
+	return result != 0;
 }
 
 void SetSignalsOnBothDir(TileIndex tile, byte track)
@@ -1836,7 +1837,7 @@
 				// inclined foundation
 				th = _inclined_tileh[f - 15];
 			}
-		} else if ((ti->map5 & 0xC0) == 0xC0) {
+		} else if ((ti->map5 & RAIL_TILE_TYPE_MASK) == RAIL_TYPE_DEPOT_WAYPOINT) {
 			// depot or waypoint
 			return z + 8;
 		}
--- a/road_cmd.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/road_cmd.c	Mon Feb 13 21:15:00 2006 +0000
@@ -69,16 +69,13 @@
 	uint n;
 	*edge_road = true;
 
-	if (_game_mode == GM_EDITOR)
-		return true;
+	if (_game_mode == GM_EDITOR) return true;
 
 	blocks = GetRoadBitsByTile(tile);
-	if (blocks == 0)
-		return true;
+	if (blocks == 0) return true;
 
 	// Only do the special processing for actual players.
-	if (_current_player >= MAX_PLAYERS)
-		return true;
+	if (_current_player >= MAX_PLAYERS) return true;
 
 	// A railway crossing has the road owner in the map3_lo byte.
 	if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) {
@@ -92,8 +89,7 @@
 		return owner == OWNER_NONE || CheckOwnership(owner);
 	}
 
-	if (_cheats.magic_bulldozer.value)
-		return true;
+	if (_cheats.magic_bulldozer.value) return true;
 
 	// Get a bitmask of which neighbouring roads has a tile
 	n = 0;
@@ -108,8 +104,7 @@
 		Town *t;
 		*edge_road = false;
 		// you can remove all kind of roads with extra dynamite
-		if (_patches.extra_dynamite)
-			return true;
+		if (_patches.extra_dynamite) return true;
 
 		t = ClosestTownFromTile(tile, _patches.dist_local_authority);
 
@@ -164,14 +159,15 @@
 	if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) {
 		if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space)
 			t = ClosestTownFromTile(tile, _patches.dist_local_authority);
-		} else
+		} else {
 			t = GetTown(_m[tile].m2);
-	} else
+		}
+	} else {
 		t = NULL;
+	}
 
 	// allow deleting road under bridge
-	if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile))
-		return CMD_ERROR;
+	if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) return CMD_ERROR;
 
 	{
 		bool b;
@@ -336,7 +332,7 @@
 		}
 
 		// partly leveled up tile, only if there's no road on that tile
-		if ( !existing && (tileh == 1 || tileh == 2 || tileh == 4 || tileh == 8) ) {
+		if (!existing && (tileh == 1 || tileh == 2 || tileh == 4 || tileh == 8)) {
 			// force full pieces.
 			*pieces |= (*pieces & 0xC) >> 2;
 			*pieces |= (*pieces & 0x3) << 2;
@@ -383,11 +379,13 @@
 	} else if (ti.type == MP_RAILWAY) {
 		byte m5;
 
-		if (IsSteepTileh(ti.tileh)) // very steep tile
-				return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
+		if (IsSteepTileh(ti.tileh)) { // very steep tile
+			return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
+		}
 
-		if (!_valid_tileh_slopes_road[2][ti.tileh]) // prevent certain slopes
-				return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
+		if (!_valid_tileh_slopes_road[2][ti.tileh]) { // prevent certain slopes
+			return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
+		}
 
 		if (ti.map5 == 2) {
 			if (pieces & 5) goto do_clear;
@@ -395,8 +393,9 @@
 		} else if (ti.map5 == 1) {
 			if (pieces & 10) goto do_clear;
 			m5 = 0x18;
-		} else
+		} else {
 			goto do_clear;
+		}
 
 		if (flags & DC_EXEC) {
 			ModifyTile(tile,
@@ -410,26 +409,25 @@
 		}
 		return _price.build_road * 2;
 	} else if (ti.type == MP_TUNNELBRIDGE) {
-
 		/* check for flat land */
-		if (IsSteepTileh(ti.tileh)) // very steep tile
-				return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
+		if (IsSteepTileh(ti.tileh)) { // very steep tile
+			return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
+		}
 
 		/* is this middle part of a bridge? */
-		if ((ti.map5 & 0xC0) != 0xC0)
-				goto do_clear;
+		if ((ti.map5 & 0xC0) != 0xC0) goto do_clear;
 
 		/* only allow roads pertendicular to bridge */
-		if (((pieces & 5U) != 0) == ((ti.map5 & 0x01U) != 0))
-				goto do_clear;
+		if (((pieces & 5U) != 0) == ((ti.map5 & 0x01U) != 0)) goto do_clear;
 
 		/* check if clear land under bridge */
-		if ((ti.map5 & 0xF8) == 0xE8) 			/* road under bridge */
-				return_cmd_error(STR_1007_ALREADY_BUILT);
-		else if ((ti.map5 & 0xE0) == 0xE0) 	/* other transport route under bridge */
-				return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK);
-		else if ((ti.map5 & 0xF8) == 0xC8) 	/* water under bridge */
-				return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER);
+		if ((ti.map5 & 0xF8) == 0xE8) { /* road under bridge */
+			return_cmd_error(STR_1007_ALREADY_BUILT);
+		} else if ((ti.map5 & 0xE0) == 0xE0) { /* other transport route under bridge */
+			return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK);
+		} else if ((ti.map5 & 0xF8) == 0xC8) { /* water under bridge */
+			return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER);
+		}
 
 		/* all checked, can build road now! */
 		cost = _price.build_road * 2;
@@ -587,7 +585,7 @@
 		TileIndex t = start_tile;
 		start_tile = end_tile;
 		end_tile = t;
-		p2 ^= IS_INT_INSIDE(p2&3, 1, 3) ? 3 : 0;
+		p2 ^= IS_INT_INSIDE(p2 & 3, 1, 3) ? 3 : 0;
 	}
 
 	cost = 0;
@@ -735,17 +733,23 @@
 {
 	int i;
 	// normal level sloped building
-	if ((~_valid_tileh_slopes_road[1][tileh] & bits) == 0)
-		return tileh;
+	if ((~_valid_tileh_slopes_road[1][tileh] & bits) == 0) return tileh;
 
 	// inclined sloped building
-	if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) &&
-		((bits == (ROAD_SW | ROAD_NE)) || (i++, bits == (ROAD_NW | ROAD_SE))))
+	if ((
+				(i  = 0, tileh == 1) ||
+				(i += 2, tileh == 2) ||
+				(i += 2, tileh == 4) ||
+				(i += 2, tileh == 8)
+			) && (
+				(     bits == (ROAD_SW | ROAD_NE)) ||
+				(i++, bits == (ROAD_NW | ROAD_SE))
+			)) {
 		return i + 15;
+	}
 
 	// rail crossing
-	if ((bits & 0x10) && _valid_tileh_slopes_road[2][tileh])
-		return tileh;
+	if ((bits & 0x10) && _valid_tileh_slopes_road[2][tileh]) return tileh;
 
 	return 0;
 }
@@ -808,14 +812,12 @@
 	}
 
 	// Draw extra details.
-	drts = _road_display_table[ground_type][road];
-	while ((image = drts->image) != 0) {
+	for (drts = _road_display_table[ground_type][road]; drts->image != 0; drts++) {
 		int x = ti->x | drts->subcoord_x;
 		int y = ti->y | drts->subcoord_y;
 		byte z = ti->z;
 		if (ti->tileh != 0) z = GetSlopeZ(x, y);
-		AddSortableSpriteToDraw(image, x, y, 2, 2, 0x10, z);
-		drts++;
+		AddSortableSpriteToDraw(drts->image, x, y, 2, 2, 0x10, z);
 	}
 }
 
@@ -980,22 +982,23 @@
 	Town *t;
 	int grp;
 
-	if (_opt.landscape == LT_HILLY) {
-		// Fix snow style if the road is above the snowline
-		if ((_m[tile].m4 & 0x80) != ((GetTileZ(tile) > _opt.snow_line) ? 0x80 : 0x00)) {
-			_m[tile].m4 ^= 0x80;
-			MarkTileDirtyByTile(tile);
-		}
-	} else if (_opt.landscape == LT_DESERT) {
-		// Fix desert style
-		if (GetMapExtraBits(tile) == 1 && !(_m[tile].m4 & 0x80)) {
-			_m[tile].m4 |= 0x80;
-			MarkTileDirtyByTile(tile);
-		}
+	switch (_opt.landscape) {
+		case LT_HILLY:
+			if ((_m[tile].m4 & 0x80) != (GetTileZ(tile) > _opt.snow_line ? 0x80 : 0x00)) {
+				_m[tile].m4 ^= 0x80;
+				MarkTileDirtyByTile(tile);
+			}
+			break;
+
+		case LT_DESERT:
+			if (GetMapExtraBits(tile) == 1 && !(_m[tile].m4 & 0x80)) {
+				_m[tile].m4 |= 0x80;
+				MarkTileDirtyByTile(tile);
+			}
+			break;
 	}
 
-	if (_m[tile].m5 & 0xE0)
-		return;
+	if (_m[tile].m5 & 0xE0) return;
 
 	if (GB(_m[tile].m4, 4, 3) < 6) {
 		t = ClosestTownFromTile(tile, (uint)-1);
@@ -1007,8 +1010,8 @@
 			// Show an animation to indicate road work
 			if (t->road_build_months != 0 &&
 					!(DistanceManhattan(t->xy, tile) >= 8 && grp == 0) &&
-					(_m[tile].m5==5 || _m[tile].m5==10)) {
-				if (GetTileSlope(tile, NULL) == 0 && EnsureNoVehicle(tile) && CHANCE16(1,20)) {
+					(_m[tile].m5 == 5 || _m[tile].m5 == 10)) {
+				if (GetTileSlope(tile, NULL) == 0 && EnsureNoVehicle(tile) && CHANCE16(1, 20)) {
 					_m[tile].m4 |= (GB(_m[tile].m4, 4, 3) <=  2 ? 7 : 6) << 4;
 
 					SndPlayTileFx(SND_21_JACKHAMMER, tile);
@@ -1027,8 +1030,7 @@
 			const byte *p = (_opt.landscape == LT_CANDY) ? _town_road_types_2[grp] : _town_road_types[grp];
 			byte b = GB(_m[tile].m4, 4, 3);
 
-			if (b == p[0])
-				return;
+			if (b == p[0]) return;
 
 			if (b == p[1]) {
 				b = p[0];
--- a/roadveh_cmd.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/roadveh_cmd.c	Mon Feb 13 21:15:00 2006 +0000
@@ -82,7 +82,7 @@
 	if (is_custom_sprite(spritenum)) {
 		int sprite = GetCustomVehicleIcon(engine, 6);
 
-		if (sprite) {
+		if (sprite != 0) {
 			DrawSprite(sprite | image_ormod, x, y);
 			return;
 		}
@@ -263,8 +263,7 @@
 		DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 		ClearSlot(v, v->u.road.slot);
 		DeleteVehicle(v);
-		if (IsLocalPlayer())
-			InvalidateWindow(WC_REPLACE_VEHICLE, VEH_Road); // updates the replace Road window
+		if (IsLocalPlayer()) InvalidateWindow(WC_REPLACE_VEHICLE, VEH_Road);
 	}
 
 	return -(int32)v->value;
@@ -310,10 +309,11 @@
 		Trackdir trackdir = GetVehicleTrackdir(v);
 
 		ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE);
-		if (ftd.best_bird_dist == 0)
+		if (ftd.best_bird_dist == 0) {
 			return GetDepotByTile(ftd.node.tile); /* Target found */
-		else
+		} else {
 			return NULL; /* Target not found */
+		}
 		/* We do not search in two directions here, why should we? We can't reverse right now can we? */
 	} else {
 		RoadFindDepotData rfdd;
@@ -324,8 +324,7 @@
 		for (i = 0; i != 4; i++)
 			FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, i, (TPFEnumProc*)EnumRoadSignalFindDepot, NULL, &rfdd);
 
-		if (rfdd.best_length == (uint)-1)
-			return NULL;
+		if (rfdd.best_length == (uint)-1) return NULL;
 
 		return GetDepotByTile(rfdd.tile);
 	}
@@ -455,8 +454,7 @@
 	RebuildVehicleLists();
 	InvalidateWindow(WC_COMPANY, v->owner);
 
-	if (IsTileType(v->tile, MP_STATION))
-		ClearCrashedStation(v);
+	if (IsTileType(v->tile, MP_STATION)) ClearCrashedStation(v);
 
 	BeginVehicleMove(v);
 	EndVehicleMove(v);
@@ -471,7 +469,9 @@
 
 	// need this hint so it returns the right z coordinate on bridges.
 	_get_z_hint = v->z_pos;
-	new_z = GetSlopeZ(v->x_pos=x, v->y_pos=y);
+	v->x_pos = x;
+	v->y_pos = y;
+	new_z = GetSlopeZ(x, y);
 	_get_z_hint = 0;
 
 	old_z = v->z_pos;
@@ -486,7 +486,7 @@
 {
 	static const int8 _turn_prob[4] = { -1, 0, 0, 1 };
 	uint32 r = Random();
-	v->direction = (v->direction+_turn_prob[r&3])&7;
+	v->direction = (v->direction + _turn_prob[r & 3]) & 7;
 	BeginVehicleMove(v);
 	UpdateRoadVehDeltaXY(v);
 	v->cur_image = GetRoadVehImage(v, v->direction);
@@ -499,8 +499,7 @@
 	if (v->u.road.crashed_ctr == 2) {
 		CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
 	} else if (v->u.road.crashed_ctr <= 45) {
-		if ((v->tick_counter & 7) == 0)
-			RoadVehSetRandomDirection(v);
+		if ((v->tick_counter & 7) == 0) RoadVehSetRandomDirection(v);
 	} else if (v->u.road.crashed_ctr >= 2220) {
 		RoadVehDelete(v);
 	}
@@ -684,7 +683,7 @@
 	InvalidateVehicleOrder(v);
 }
 
-static void StartRoadVehSound(Vehicle *v)
+static void StartRoadVehSound(const Vehicle* v)
 {
 	SoundFx s = RoadVehInfo(v->engine_type)->sfx;
 	if (s == SND_19_BUS_START_PULL_AWAY && (v->tick_counter & 3) == 0)
@@ -693,8 +692,9 @@
 }
 
 typedef struct RoadVehFindData {
-	int x,y;
-	Vehicle *veh;
+	int x;
+	int y;
+	const Vehicle* veh;
 	byte dir;
 } RoadVehFindData;
 
@@ -727,8 +727,7 @@
 	RoadVehFindData rvf;
 	Vehicle *u;
 
-	if (v->u.road.reverse_ctr != 0)
-		return NULL;
+	if (v->u.road.reverse_ctr != 0) return NULL;
 
 	rvf.x = x;
 	rvf.y = y;
@@ -823,23 +822,22 @@
 	x = x - v->x_pos + 1;
 	y = y - v->y_pos + 1;
 
-	if ((uint)x > 2 || (uint)y > 2)
-		return v->direction;
-	return _roadveh_new_dir[y*4+x];
+	if ((uint)x > 2 || (uint)y > 2) return v->direction;
+	return _roadveh_new_dir[y * 4 + x];
 }
 
 static byte RoadVehGetSlidingDirection(Vehicle *v, int x, int y)
 {
-	byte b = RoadVehGetNewDirection(v,x,y);
+	byte b = RoadVehGetNewDirection(v, x, y);
 	byte d = v->direction;
 	if (b == d) return d;
-	d = (d+1)&7;
-	if (b==d) return d;
-	d = (d-2)&7;
-	if (b==d) return d;
-	if (b==((d-1)&7)) return d;
-	if (b==((d-2)&7)) return d;
-	return (d+2)&7;
+	d = (d + 1) & 7;
+	if (b == d) return d;
+	d = (d - 2) & 7;
+	if (b == d) return d;
+	if (b == ((d - 1) & 7)) return d;
+	if (b == ((d - 2) & 7)) return d;
+	return (d + 2) & 7;
 }
 
 typedef struct OvertakeData {
@@ -850,9 +848,9 @@
 
 static void *EnumFindVehToOvertake(Vehicle *v, OvertakeData *od)
 {
-	if (v->tile != od->tile || v->type != VEH_Road || v == od->u || v == od->v)
-		return NULL;
-	return v;
+	return
+		v->tile == od->tile && v->type == VEH_Road && v == od->u && v == od->v ?
+			v : NULL;
 }
 
 static bool FindRoadVehToOvertake(OvertakeData *od)
@@ -911,15 +909,13 @@
 
 static void RoadZPosAffectSpeed(Vehicle *v, byte old_z)
 {
-	if (old_z == v->z_pos)
-		return;
+	if (old_z == v->z_pos) return;
 
 	if (old_z < v->z_pos) {
-		v->cur_speed = v->cur_speed * 232 >> 8;
+		v->cur_speed = v->cur_speed * 232 / 256; // slow down by ~10%
 	} else {
 		uint16 spd = v->cur_speed + 2;
-		if (spd <= v->max_speed)
-			v->cur_speed = spd;
+		if (spd <= v->max_speed) v->cur_speed = spd;
 	}
 }
 
@@ -935,7 +931,7 @@
 
 	num = RandomRange(num);
 
-	for (i = 0; !((bits & 1) && ((int)--num) < 0); bits >>= 1, i++);
+	for (i = 0; !(bits & 1) || (int)--num >= 0; bits >>= 1, i++) {}
 	return i;
 }
 
@@ -973,8 +969,7 @@
 	byte m5;
 
 	{
-		uint32 r;
-		r = GetTileTrackStatus(tile, TRANSPORT_ROAD);
+		uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD);
 		signal  = GB(r, 16, 16);
 		bitmask = GB(r,  0, 16);
 	}
@@ -1100,8 +1095,7 @@
 
 found_best_track:;
 
-	if (HASBIT(signal, best_track))
-		return -1;
+	if (HASBIT(signal, best_track)) return -1;
 
 	return best_track;
 }
@@ -1147,8 +1141,7 @@
 
 	// decrease counters
 	v->tick_counter++;
-	if (v->u.road.reverse_ctr != 0)
-		v->u.road.reverse_ctr--;
+	if (v->u.road.reverse_ctr != 0) v->u.road.reverse_ctr--;
 
 	// handle crashed
 	if (v->u.road.crashed_ctr != 0) {
@@ -1277,8 +1270,8 @@
 		x = TileX(tile) * 16 + rdp[0].x;
 		y = TileY(tile) * 16 + rdp[0].y;
 
-		if (RoadVehFindCloseTo(v, x, y, newdir=RoadVehGetSlidingDirection(v, x, y)))
-			return;
+		newdir = RoadVehGetSlidingDirection(v, x, y);
+		if (RoadVehFindCloseTo(v, x, y, newdir)) return;
 
 		r = VehicleEnterTile(v, tile, x, y);
 		if (r & 8) {
@@ -1336,8 +1329,8 @@
 		x = TileX(v->tile) * 16 + rdp[1].x;
 		y = TileY(v->tile) * 16 + rdp[1].y;
 
-		if (RoadVehFindCloseTo(v, x, y, newdir=RoadVehGetSlidingDirection(v, x, y)))
-			return;
+		newdir = RoadVehGetSlidingDirection(v, x, y);
+		if (RoadVehFindCloseTo(v, x, y, newdir)) return;
 
 		r = VehicleEnterTile(v, v->tile, x, y);
 		if (r & 8) {
@@ -1365,8 +1358,7 @@
 	new_dir = RoadVehGetSlidingDirection(v, x, y);
 
 	if (!IS_BYTE_INSIDE(v->u.road.state, 0x20, 0x30) && (u=RoadVehFindCloseTo(v, x, y, new_dir)) != NULL) {
-		if (v->u.road.overtaking == 0)
-			RoadVehCheckOvertake(v, u);
+		if (v->u.road.overtaking == 0) RoadVehCheckOvertake(v, u);
 		return;
 	}
 
@@ -1449,9 +1441,7 @@
 		return;
 	}
 
-	if ((r & 4) == 0) {
-		v->u.road.frame++;
-	}
+	if ((r & 4) == 0) v->u.road.frame++;
 
 	v->cur_image = GetRoadVehImage(v, v->direction);
 	UpdateRoadVehDeltaXY(v);
@@ -1489,7 +1479,8 @@
 					STR_9016_ROAD_VEHICLE_IS_WAITING,
 					NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
 					v->index,
-					0);
+					0
+				);
 			}
 		}
 	}
@@ -1500,10 +1491,8 @@
 
 static void AgeRoadVehCargo(Vehicle *v)
 {
-	if (_age_cargo_skip_counter != 0)
-		return;
-	if (v->cargo_days != 255)
-		v->cargo_days++;
+	if (_age_cargo_skip_counter != 0) return;
+	if (v->cargo_days != 255) v->cargo_days++;
 }
 
 void RoadVeh_Tick(Vehicle *v)
@@ -1516,17 +1505,10 @@
 {
 	Depot *depot;
 
-	if (_patches.servint_roadveh == 0)
-		return;
-
-	if (!VehicleNeedsService(v))
-		return;
-
-	if (v->vehstatus & VS_STOPPED)
-		return;
-
-	if (_patches.gotodepot && VehicleHasDepotOrders(v))
-		return;
+	if (_patches.servint_roadveh == 0) return;
+	if (!VehicleNeedsService(v)) return;
+	if (v->vehstatus & VS_STOPPED) return;
+	if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
 
 	// Don't interfere with a depot visit scheduled by the user, or a
 	// depot visit by the order list.
@@ -1534,9 +1516,8 @@
 			(v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0)
 		return;
 
-	//If we already got a slot at a stop, use that FIRST, and go to a depot later
-	if (v->u.road.slot != NULL)
-		return;
+	// If we already got a slot at a stop, use that FIRST, and go to a depot later
+	if (v->u.road.slot != NULL) return;
 
 	depot = FindClosestRoadDepot(v);
 
@@ -1567,11 +1548,8 @@
 	int32 cost;
 	Station *st;
 
-	if ((++v->day_counter & 7) == 0)
-		DecreaseVehicleValue(v);
-
-	if (v->u.road.blocked_ctr == 0)
-		CheckVehicleBreakdown(v);
+	if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v);
+	if (v->u.road.blocked_ctr == 0) CheckVehicleBreakdown(v);
 
 	AgeVehicle(v);
 	CheckIfRoadVehNeedsService(v);
@@ -1653,8 +1631,7 @@
 		}
 	}
 
-	if (v->vehstatus & VS_STOPPED)
-		return;
+	if (v->vehstatus & VS_STOPPED) return;
 
 	cost = RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running / 364;
 
--- a/terraform_gui.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/terraform_gui.c	Mon Feb 13 21:15:00 2006 +0000
@@ -63,7 +63,7 @@
 	_generating_world = false;
 }
 
-/** Scenario editor command that generates desert areas */
+/** Scenario editor command that generates rocky areas */
 static void GenerateRockyArea(TileIndex end, TileIndex start)
 {
 	int size_x, size_y;
--- a/tile.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/tile.c	Mon Feb 13 21:15:00 2006 +0000
@@ -46,8 +46,7 @@
 	if ((d -= min) != 0) r += (--d << 4) + 2;
 	if ((b -= min) != 0) r += (--b << 4) + 1;
 
-	if (h != NULL)
-		*h = min * 8;
+	if (h != NULL) *h = min * 8;
 
 	return r;
 }
--- a/town_cmd.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/town_cmd.c	Mon Feb 13 21:15:00 2006 +0000
@@ -570,7 +570,7 @@
 	int a,b,rcmd;
 	TileIndex tmptile;
 	TileInfo ti;
-	int i;
+	uint i;
 	int j;
 	TileIndex tile = *tile_ptr;
 
--- a/train_cmd.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/train_cmd.c	Mon Feb 13 21:15:00 2006 +0000
@@ -305,8 +305,7 @@
 		num++;
 		drag_coeff += 3;
 
-		if (u->u.rail.track == 0x80)
-			max_speed = min(61, max_speed);
+		if (u->u.rail.track == 0x80) max_speed = min(max_speed, 61);
 
 		if (HASBIT(u->u.rail.flags, VRF_GOINGUP)) {
 			incl += u->u.rail.cached_veh_weight * 60;		//3% slope, quite a bit actually
@@ -322,8 +321,9 @@
 		resistance += 60 * num;
 		resistance += friction * mass * speed / 1000;
 		resistance += (area * drag_coeff * speed * speed) / 10000;
-	} else
+	} else {
 		resistance = (area * (drag_coeff / 2) * speed * speed) / 10000;
+	}
 	resistance += incl;
 	resistance *= 4; //[N]
 
@@ -452,13 +452,11 @@
 	bool flip_image;
 	uint i;
 
-	if (!HASBIT(rvi->callbackmask, CBM_ARTIC_ENGINE))
-		return;
+	if (!HASBIT(rvi->callbackmask, CBM_ARTIC_ENGINE)) return;
 
 	for (i = 1; i < 10; i++) {
 		callback = GetCallBackResult(CBID_TRAIN_ARTIC_ENGINE + (i << 8), v->engine_type, NULL);
-		if (callback == CALLBACK_FAILED || callback == 0xFF)
-			return;
+		if (callback == CALLBACK_FAILED || callback == 0xFF) return;
 
 		u->next = vl[i];
 		u = u->next;
@@ -632,7 +630,7 @@
 
 static int32 EstimateTrainCost(const RailVehicleInfo* rvi)
 {
-	return (rvi->base_cost * (_price.build_railvehicle >> 3)) >> 5;
+	return rvi->base_cost * (_price.build_railvehicle >> 3) >> 5;
 }
 
 static void AddRearEngineToMultiheadedTrain(Vehicle* v, Vehicle* u, bool building)
@@ -858,8 +856,7 @@
 	TileIndex tile = src->tile;
 
 	FOR_ALL_VEHICLES(dst) {
-		if (dst->type == VEH_Train && IsFreeWagon(dst) &&
-				dst->tile == tile) {
+		if (dst->type == VEH_Train && IsFreeWagon(dst) && dst->tile == tile) {
 			// check so all vehicles in the line have the same engine.
 			Vehicle *v = dst;
 
@@ -908,7 +905,6 @@
 
 		if (u == v->u.rail.other_multiheaded_part) continue;
 		AddWagonToConsist(v->u.rail.other_multiheaded_part, u);
-
 	}
 }
 
@@ -988,9 +984,7 @@
 					engine = NULL;
 				}
 				if (u == dst) {
-					if (engine != NULL) {
-					dst = engine->u.rail.other_multiheaded_part;
-					}
+					if (engine != NULL) dst = engine->u.rail.other_multiheaded_part;
 					break;
 				}
 
@@ -1052,8 +1046,7 @@
 		if (unit_num > _patches.max_trains)
 			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 
-		if (flags & DC_EXEC)
-			src->unitnumber = unit_num;
+		if (flags & DC_EXEC) src->unitnumber = unit_num;
 	}
 
 
@@ -1365,11 +1358,10 @@
 			}
 
 			/* 3. If it is still a valid train after selling, update its acceleration and cached values */
-			if ((flags & DC_EXEC) && first != NULL) {
+			if (flags & DC_EXEC && first != NULL) {
 				NormaliseTrainConsist(first);
 				TrainConsistChanged(first);
-				if (IsFrontEngine(first))
-					UpdateTrainAcceleration(first);
+				if (IsFrontEngine(first)) UpdateTrainAcceleration(first);
 				InvalidateWindow(WC_VEHICLE_DETAILS, first->index);
 				InvalidateWindow(WC_VEHICLE_REFIT, first->index);
 			}
@@ -1415,7 +1407,7 @@
 	int old = v->u.rail.last_speed;
 	if (spd != old) {
 		v->u.rail.last_speed = spd;
-		if (_patches.vehicle_speed || !old != !spd)
+		if (_patches.vehicle_speed || (old == 0) != (spd == 0))
 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 }
@@ -1702,16 +1694,23 @@
 
 			if (amount == CALLBACK_FAILED) { // callback failed or not used, use default
 				CargoID old_cid = rvi->cargo_type;
-				/* normally, the capacity depends on the cargo type, a rail vehicle
-				* can carry twice as much mail/goods as normal cargo,
-				* and four times as much passengers */
+				/* normally, the capacity depends on the cargo type, a rail vehicle can
+				 * carry twice as much mail/goods as normal cargo, and four times as
+				 * many passengers
+				 */
 				amount = rvi->capacity;
-				(old_cid == CT_PASSENGERS) ||
-				(amount <<= 1, old_cid == CT_MAIL || old_cid == CT_GOODS) ||
-				(amount <<= 1, true);
-				(new_cid == CT_PASSENGERS) ||
-				(amount >>= 1, new_cid == CT_MAIL || new_cid == CT_GOODS) ||
-				(amount >>= 1, true);
+				switch (old_cid) {
+					case CT_PASSENGERS: break;
+					case CT_MAIL:
+					case CT_GOODS: amount *= 2; break;
+					default:       amount *= 4; break;
+				}
+				switch (new_cid) {
+					case CT_PASSENGERS: break;
+					case CT_MAIL:
+					case CT_GOODS: amount /= 2; break;
+					default:       amount /= 4; break;
+				}
 			};
 
 			if (amount != 0) {
@@ -1726,7 +1725,7 @@
 				}
 			}
 		}
-	} while ( (v=v->next) != NULL );
+	} while ((v = v->next) != NULL);
 
 	_returned_refit_capacity = num;
 
@@ -1747,7 +1746,7 @@
 static bool NtpCallbFindDepot(TileIndex tile, TrainFindDepotData *tfdd, int track, uint length)
 {
 	if (IsTileType(tile, MP_RAILWAY) && IsTileOwner(tile, tfdd->owner)) {
-		if ((_m[tile].m5 & ~0x3) == 0xC0) {
+		if ((_m[tile].m5 & 0xFC) == 0xC0) {
 			tfdd->best_length = length;
 			tfdd->tile = tile;
 			return true;
@@ -1795,8 +1794,7 @@
 			* work for now :-) We can possibly change this when the old pathfinder
 			* is removed. */
 			tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH;
-			if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE))
-				tfdd.reverse = true;
+			if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) tfdd.reverse = true;
 		}
 	} else {
 		// search in the forward direction first.
@@ -1954,13 +1952,8 @@
 			SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], v);
 			break;
 
-		case RAILTYPE_MONO:
-			SndPlayVehicleFx(SND_47_MAGLEV_2, v);
-			break;
-
-		case RAILTYPE_MAGLEV:
-			SndPlayVehicleFx(SND_41_MAGLEV, v);
-			break;
+		case RAILTYPE_MONO: SndPlayVehicleFx(SND_47_MAGLEV_2, v); break;
+		case RAILTYPE_MAGLEV: SndPlayVehicleFx(SND_41_MAGLEV, v); break;
 	}
 }
 
@@ -2113,11 +2106,10 @@
 	static float f;
 #endif
 
-	assert( (trackdirbits & ~0x3F) == 0);
+	assert((trackdirbits & ~0x3F) == 0);
 
 	/* quick return in case only one possible track is available */
-	if (KILL_FIRST_BIT(trackdirbits) == 0)
-		return FIND_FIRST_BIT(trackdirbits);
+	if (KILL_FIRST_BIT(trackdirbits) == 0) return FIND_FIRST_BIT(trackdirbits);
 
 	if (_patches.new_pathfinding_all) { /* Use a new pathfinding for everything */
 		NPFFindStationOrTileData fstd;
@@ -2214,10 +2206,11 @@
 			/* We didn't find anything, just keep on going straight ahead */
 			reverse_best = false;
 		} else {
-			if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE))
+			if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) {
 				reverse_best = true;
-			else
+			} else {
 				reverse_best = false;
+			}
 		}
 	} else {
 		for (;;) {
@@ -2260,8 +2253,7 @@
 			best_track_dist = fd.best_track_dist;
 			reverse_best = reverse;
 bad:;
-			if (reverse != 0)
-				break;
+			if (reverse != 0) break;
 			reverse = 2;
 		}
 	}
@@ -2455,7 +2447,8 @@
 			STR_8801_CITIZENS_CELEBRATE_FIRST,
 			flags,
 			v->index,
-			0);
+			0
+		);
 	}
 
 	// Did we reach the final destination?
@@ -2678,8 +2671,7 @@
 {
 	Vehicle *u;
 
-	if (v->u.rail.crash_anim_pos != 0)
-		return;
+	if (v->u.rail.crash_anim_pos != 0) return;
 
 	v->u.rail.crash_anim_pos++;
 
@@ -2765,8 +2757,7 @@
 			v->tile == vasd->tile) {
 		byte diff = (v->direction - vasd->direction + 2) & 7;
 
-		if (diff == 2 || (v->cur_speed <= 5 && diff <= 4))
-			return v;
+		if (diff == 2 || (v->cur_speed <= 5 && diff <= 4)) return v;
 	}
 	return NULL;
 }
@@ -2796,8 +2787,7 @@
 				} else {
 					/* is not inside depot */
 
-					if (!TrainCheckIfLineEnds(v))
-						return;
+					if (!TrainCheckIfLineEnds(v)) return;
 
 					r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
 					if (r & 0x8) {
@@ -2831,14 +2821,15 @@
 				/* Combine the from & to directions.
 				 * Now, the lower byte contains the track status, and the byte at bit 16 contains
 				 * the signal status. */
-				tracks = ts|(ts >> 8);
+				tracks = ts | (ts >> 8);
 				bits = tracks & 0xFF;
-				if (_patches.new_pathfinding_all && _patches.forbid_90_deg && prev == NULL)
+				if (_patches.new_pathfinding_all && _patches.forbid_90_deg && prev == NULL) {
 					/* We allow wagons to make 90 deg turns, because forbid_90_deg
 					 * can be switched on halfway a turn */
 					bits &= ~TrackCrossesTracks(FIND_FIRST_BIT(v->u.rail.track));
-
-				if ( bits == 0) {
+				}
+
+				if (bits == 0) {
 					//debug("%x == 0", bits);
 					goto invalid_rail;
 				}
@@ -2878,7 +2869,7 @@
 
 				/* Call the landscape function and tell it that the vehicle entered the tile */
 				r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
-				if (r&0x8){
+				if (r & 0x8) {
 					//debug("%x & 0x8", r);
 					goto invalid_rail;
 				}
@@ -2891,17 +2882,14 @@
 					assert(v->u.rail.track);
 				}
 
-				if (IsFrontEngine(v))
-					TrainMovedChangeSignals(gp.new_tile, enterdir);
+				if (IsFrontEngine(v)) TrainMovedChangeSignals(gp.new_tile, enterdir);
 
 				/* Signals can only change when the first
 				 * (above) or the last vehicle moves. */
 				if (v->next == NULL)
 					TrainMovedChangeSignals(gp.old_tile, (enterdir) ^ 2);
 
-				if (prev == NULL) {
-					AffectSpeedByDirChange(v, chosen_dir);
-				}
+				if (prev == NULL) AffectSpeedByDirChange(v, chosen_dir);
 
 				v->direction = chosen_dir;
 			}
@@ -2951,9 +2939,8 @@
 		if (!(_m[gp.new_tile].m3 & SignalAgainstTrackdir(i))) {
 			v->cur_speed = 0;
 			v->subspeed = 0;
-			v->progress = 255-100;
-			if (++v->load_unload_time_rem < _patches.wait_oneway_signal * 20)
-				return;
+			v->progress = 255 - 100;
+			if (++v->load_unload_time_rem < _patches.wait_oneway_signal * 20) return;
 		} else if (_m[gp.new_tile].m3 & SignalAlongTrackdir(i)){
 			v->cur_speed = 0;
 			v->subspeed = 0;
@@ -2965,8 +2952,7 @@
 				vasd.direction = dir ^ 4;
 
 				/* check if a train is waiting on the other side */
-				if (VehicleFromPos(o_tile, &vasd, CheckVehicleAtSignal) == NULL)
-					return;
+				if (VehicleFromPos(o_tile, &vasd, CheckVehicleAtSignal) == NULL) return;
 			}
 		}
 	}
@@ -3016,8 +3002,7 @@
 	if (v->u.rail.track == 0x40) { // inside a tunnel
 		TileIndex endtile = CheckTunnelBusy(v->tile, NULL);
 
-		if (endtile == INVALID_TILE) // tunnel is busy (error returned)
-			return;
+		if (endtile == INVALID_TILE) return; // tunnel is busy (error returned)
 
 		switch (v->direction) {
 			case 1:
@@ -3040,7 +3025,7 @@
 
 static void ChangeTrainDirRandomly(Vehicle *v)
 {
-	static int8 _random_dir_change[4] = { -1, 0, 0, 1};
+	static const int8 _random_dir_change[4] = { -1, 0, 0, 1 };
 
 	do {
 		//I need to buffer the train direction
@@ -3052,12 +3037,12 @@
 			v->cur_image = GetTrainImage(v, v->direction);
 			AfterSetTrainPos(v, false);
 		}
-	} while ( (v=v->next) != NULL);
+	} while ((v = v->next) != NULL);
 }
 
 static void HandleCrashedTrain(Vehicle *v)
 {
-	int state = ++v->u.rail.crash_anim_pos, index;
+	int state = ++v->u.rail.crash_anim_pos;
 	uint32 r;
 	Vehicle *u;
 
@@ -3066,7 +3051,7 @@
 	}
 
 	if (state <= 200 && CHANCE16R(1, 7, r)) {
-		index = (r * 10 >> 16);
+		int index = (r * 10 >> 16);
 
 		u = v;
 		do {
@@ -3080,12 +3065,10 @@
 					EV_EXPLOSION_SMALL);
 				break;
 			}
-		} while ( (u=u->next) != NULL);
+		} while ((u = u->next) != NULL);
 	}
 
-	if (state <= 240 && !(v->tick_counter&3)) {
-		ChangeTrainDirRandomly(v);
-	}
+	if (state <= 240 && !(v->tick_counter & 3)) ChangeTrainDirRandomly(v);
 
 	if (state >= 4440 && !(v->tick_counter&0x1F)) {
 		DeleteLastWagon(v);
@@ -3174,27 +3157,13 @@
 	y = v->y_pos & 0xF;
 
 	switch (v->direction) {
-	case 0:
-		x = (~x) + (~y) + 24;
-		break;
-	case 7:
-		x = y;
-		/* fall through */
-	case 1:
-		x = (~x) + 16;
-		break;
-	case 2:
-		x = (~x) + y + 8;
-		break;
-	case 3:
-		x = y;
-		break;
-	case 4:
-		x = x + y - 8;
-		break;
-	case 6:
-		x = (~y) + x + 8;
-		break;
+		case 0: x = ~x + ~y + 24; break;
+		case 7: x = y;            /* FALLTHROUGH */
+		case 1: x = ~x + 16;      break;
+		case 2: x = ~x + y + 8;   break;
+		case 3: x = y;            break;
+		case 4: x = x + y - 8;    break;
+		case 6: x = ~y + x + 8;   break;
 	}
 
 	if (GB(ts, 0, 16) != 0) {
@@ -3227,7 +3196,7 @@
 	// slow down
 	v->vehstatus |= VS_TRAIN_SLOWING;
 	break_speed = _breakdown_speeds[x & 0xF];
-	if (!(v->direction&1)) break_speed >>= 1;
+	if (!(v->direction & 1)) break_speed >>= 1;
 	if (break_speed < v->cur_speed) v->cur_speed = break_speed;
 
 	return true;
@@ -3243,8 +3212,7 @@
 		return;
 	}
 
-	if (v->u.rail.force_proceed != 0)
-		v->u.rail.force_proceed--;
+	if (v->u.rail.force_proceed != 0) v->u.rail.force_proceed--;
 
 	/* train is broken down? */
 	if (v->breakdown_ctr != 0) {
@@ -3260,9 +3228,7 @@
 	}
 
 	/* exit if train is stopped */
-	if (v->vehstatus & VS_STOPPED && v->cur_speed == 0)
-		return;
-
+	if (v->vehstatus & VS_STOPPED && v->cur_speed == 0) return;
 
 	if (ProcessTrainOrder(v)) {
 		v->load_unload_time_rem = 0;
@@ -3274,19 +3240,16 @@
 
 	HandleTrainLoading(v, mode);
 
-	if (v->current_order.type == OT_LOADING)
-		return;
-
-	if (CheckTrainStayInDepot(v))
-		return;
+	if (v->current_order.type == OT_LOADING) return;
+
+	if (CheckTrainStayInDepot(v)) return;
 
 	if (!mode) HandleLocomotiveSmokeCloud(v);
 
 	j = UpdateTrainSpeed(v);
 	if (j == 0) {
 		// if the vehicle has speed 0, update the last_speed field.
-		if (v->cur_speed != 0)
-			return;
+		if (v->cur_speed != 0) return;
 	} else {
 		TrainCheckIfLineEnds(v);
 
@@ -3409,8 +3372,9 @@
 
 	if (v->current_order.type == OT_GOTO_DEPOT &&
 			v->current_order.station != depot->index &&
-			!CHANCE16(3,16))
+			!CHANCE16(3, 16)) {
 		return;
+	}
 
 	v->current_order.type = OT_GOTO_DEPOT;
 	v->current_order.flags = OF_NON_STOP;
@@ -3436,8 +3400,7 @@
 {
 	TileIndex tile;
 
-	if ((++v->day_counter & 7) == 0)
-		DecreaseVehicleValue(v);
+	if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v);
 
 	if (IsFrontEngine(v)) {
 		CheckVehicleBreakdown(v);
@@ -3582,46 +3545,46 @@
 			if (HASBIT(v->subtype, 7) && ((v->subtype & ~0x80) == 0 || (v->subtype & ~0x80) == 4)) {
 				Vehicle *u = v;
 
-				BEGIN_ENUM_WAGONS(u)
+				BEGIN_ENUM_WAGONS(u) {
 					const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
-				CLRBIT(u->subtype, 7);
-				switch (u->subtype) {
-					case 0:	/* TS_Front_Engine */
-						if (rvi->flags & RVI_MULTIHEAD) {
-							SetMultiheaded(u);
-						}
-						SetFrontEngine(u);
-						SetTrainEngine(u);
-						break;
-					case 1:	/* TS_Artic_Part */
-						u->subtype = 0;
-						SetArticulatedPart(u);
-						break;
-					case 2:	/* TS_Not_First */
-						u->subtype = 0;
-						if (rvi->flags & RVI_WAGON) {
-							// normal wagon
-							SetTrainWagon(u);
+
+					CLRBIT(u->subtype, 7);
+					switch (u->subtype) {
+						case 0:	/* TS_Front_Engine */
+							if (rvi->flags & RVI_MULTIHEAD) SetMultiheaded(u);
+							SetFrontEngine(u);
+							SetTrainEngine(u);
 							break;
-						}
+
+						case 1:	/* TS_Artic_Part */
+							u->subtype = 0;
+							SetArticulatedPart(u);
+							break;
+
+						case 2:	/* TS_Not_First */
+							u->subtype = 0;
+							if (rvi->flags & RVI_WAGON) {
+								// normal wagon
+								SetTrainWagon(u);
+								break;
+							}
 							if (rvi->flags & RVI_MULTIHEAD && rvi->image_index == u->spritenum - 1) {
 								// rear end of a multiheaded engine
 								SetMultiheaded(u);
 								break;
 							}
-							if (rvi->flags & RVI_MULTIHEAD) {
-								SetMultiheaded(u);
-							}
+							if (rvi->flags & RVI_MULTIHEAD) SetMultiheaded(u);
 							SetTrainEngine(u);
-						break;
-					case 4:	/* TS_Free_Car */
-						u->subtype = 0;
-						SetTrainWagon(u);
-						SetFreeWagon(u);
-						break;
-					default: NOT_REACHED(); break;
-				}
-				END_ENUM_WAGONS(u)
+							break;
+
+						case 4:	/* TS_Free_Car */
+							u->subtype = 0;
+							SetTrainWagon(u);
+							SetFreeWagon(u);
+							break;
+						default: NOT_REACHED(); break;
+					}
+				} END_ENUM_WAGONS(u)
 			}
 		}
 	}
--- a/tree_cmd.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/tree_cmd.c	Mon Feb 13 21:15:00 2006 +0000
@@ -538,7 +538,7 @@
 	uint32 r;
 	TileIndex tile;
 	ClearGround ct;
-	int tree;
+	TreeType tree;
 
 	/* place a tree at a random rainforest spot */
 	if (_opt.landscape == LT_DESERT &&
--- a/tunnelbridge_cmd.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/tunnelbridge_cmd.c	Mon Feb 13 21:15:00 2006 +0000
@@ -471,22 +471,22 @@
 	/* check if valid, and make sure that (x,y) is smaller than (x2,y2) */
 	direction = 0;
 	if (x == x2) {
-		if (y == y2)
-			return_cmd_error(STR_5008_CANNOT_START_AND_END_ON);
+		if (y == y2) return_cmd_error(STR_5008_CANNOT_START_AND_END_ON);
 		direction++;
 		if (y > y2) {
 			intswap(y,y2);
 			intswap(x,x2);
-			exc_tile|=2;
+			exc_tile |= 2;
 		}
 	} else if (y == y2) {
 		if (x > x2) {
 			intswap(y,y2);
 			intswap(x,x2);
-			exc_tile|=2;
+			exc_tile |= 2;
 		}
-	} else
+	} else {
 		return_cmd_error(STR_500A_START_AND_END_MUST_BE_IN);
+	}
 
 	cost = 0;
 
@@ -829,7 +829,6 @@
 
 		SetSignalsOnBothDir(tile, direction);
 		SetSignalsOnBothDir(endtile, direction);
-
 	}
 
 	if (direction) {
@@ -845,11 +844,9 @@
 
 	if ((m5 & 0xF0) == 0) {
 		if (flags & DC_AUTO) return_cmd_error(STR_5006_MUST_DEMOLISH_TUNNEL_FIRST);
-
 		return DoClearTunnel(tile, flags);
 	} else if (m5 & 0x80) {
 		if (flags & DC_AUTO) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
-
 		return DoClearBridge(tile, flags);
 	}
 
@@ -1023,13 +1020,20 @@
 {
 	int i;
 	// normal level sloped building (7, 11, 13, 14)
-	if (BRIDGE_FULL_LEVELED_FOUNDATION & (1 << tileh))
-		return tileh;
+	if (BRIDGE_FULL_LEVELED_FOUNDATION & (1 << tileh)) return tileh;
 
 	// inclined sloped building
-	if (	((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) &&
-				( direction == 0 || (i++, direction == 1)) )
+	if ((
+				(i  = 0, tileh == 1) ||
+				(i += 2, tileh == 2) ||
+				(i += 2, tileh == 4) ||
+				(i += 2, tileh == 8)
+			) && (
+				direction == 0 ||
+				(i++, direction == 1)
+			)) {
 		return i + 15;
+	}
 
 	return 0;
 }
@@ -1132,10 +1136,11 @@
 				// draw land under bridge
 				if (ice) image += 2;
 
-				if (image != 1 || ti->tileh == 0)
+				if (image != 1 || ti->tileh == 0) {
 					DrawGroundSprite(_bridge_land_below[image] + _tileh_to_sprite[ti->tileh]);
-				else
+				} else {
 					DrawGroundSprite(_water_shore_sprites[ti->tileh]);
+				}
 
 				// draw canal water?
 				if (ti->map5 & 8 && ti->z != 0) DrawCanalWater(ti->tile);
@@ -1185,7 +1190,7 @@
 			if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
 
 			// draw roof, the component of the bridge which is logically between the vehicle and the camera
-			if (ti->map5&1) {
+			if (ti->map5 & 1) {
 				x += 12;
 				if (image & SPRITE_MASK) AddSortableSpriteToDraw(image, x,y, 1, 16, 0x28, z);
 			} else {
@@ -1193,10 +1198,10 @@
 				if (image & SPRITE_MASK) AddSortableSpriteToDraw(image, x,y, 16, 1, 0x28, z);
 			}
 
-			if (ti->z + 5 == z ) {
+			if (ti->z + 5 == z) {
 				// draw poles below for small bridges
 				image = b[2];
-				if (image) {
+				if (image != 0) {
 					if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
 					DrawGroundSpriteAt(image, x, y, z);
 				}
@@ -1235,10 +1240,10 @@
 					return z + 8;
 				} else if (!(ti->map5 & 0x20)) { // northern / southern ending
 					// ramp
-					return (z + (x>>1) + 1);
+					return z + (x >> 1) + 1;
 				} else {
 					// ramp in opposite dir
-					return (z + ((x^0xF)>>1));
+					return z + ((x ^ 0xF) >> 1);
 				}
 
 			// bridge middle part
@@ -1351,23 +1356,27 @@
 
 static void TileLoop_TunnelBridge(TileIndex tile)
 {
-	if (_opt.landscape == LT_HILLY) {
-		if (GetTileZ(tile) > _opt.snow_line) {
-			if (!(_m[tile].m4 & 0x80)) {
+	switch (_opt.landscape) {
+		case LT_HILLY:
+			if (GetTileZ(tile) > _opt.snow_line) {
+				if (!(_m[tile].m4 & 0x80)) {
+					_m[tile].m4 |= 0x80;
+					MarkTileDirtyByTile(tile);
+				}
+			} else {
+				if (_m[tile].m4 & 0x80) {
+					_m[tile].m4 &= ~0x80;
+					MarkTileDirtyByTile(tile);
+				}
+			}
+			break;
+
+		case LT_DESERT:
+			if (GetMapExtraBits(tile) == 1 && !(_m[tile].m4 & 0x80)) {
 				_m[tile].m4 |= 0x80;
 				MarkTileDirtyByTile(tile);
 			}
-		} else {
-			if (_m[tile].m4 & 0x80) {
-				_m[tile].m4 &= ~0x80;
-				MarkTileDirtyByTile(tile);
-			}
-		}
-	} else if (_opt.landscape == LT_DESERT) {
-		if (GetMapExtraBits(tile) == 1 && !(_m[tile].m4&0x80)) {
-			_m[tile].m4 |= 0x80;
-			MarkTileDirtyByTile(tile);
-		}
+			break;
 	}
 
 	// if it's a bridge with water below, call tileloop_water on it.
@@ -1537,14 +1546,14 @@
 		if (v->type == VEH_Road || (v->type == VEH_Train && IsFrontEngine(v))) {
 			uint h;
 
-			if (GetTileSlope(tile, &h) != 0)
-				h += 8; // Compensate for possible foundation
+			// Compensate for possible foundation
+			if (GetTileSlope(tile, &h) != 0) h += 8;
 			if (!(_m[tile].m5 & 0x40) || // start/end tile of bridge
 					myabs(h - v->z_pos) > 2) { // high above the ground -> on the bridge
 				/* modify speed of vehicle */
 				uint16 spd = _bridge[GetBridgeType(tile)].speed;
 				if (v->type == VEH_Road) spd *= 2;
-				if (spd < v->cur_speed) v->cur_speed = spd;
+				if (v->cur_speed > spd) v->cur_speed = spd;
 			}
 		}
 	}
--- a/unmovable_cmd.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/unmovable_cmd.c	Mon Feb 13 21:15:00 2006 +0000
@@ -51,7 +51,7 @@
 			DoClearSquare(p->location_of_house + TileDiffXY(1, 0));
 			DoClearSquare(p->location_of_house + TileDiffXY(1, 1));
 			p->location_of_house = 0; // reset HQ position
-			InvalidateWindow(WC_COMPANY, (int)p->index);
+			InvalidateWindow(WC_COMPANY, p->index);
 		}
 
 	// cost of relocating company is 1% of company value
@@ -91,7 +91,7 @@
 		ModifyTile(tile + TileDiffXY(1, 0), MP_SETTYPE(MP_UNMOVABLE) | MP_MAPOWNER_CURRENT | MP_MAP5, 0x82);
 		ModifyTile(tile + TileDiffXY(1, 1), MP_SETTYPE(MP_UNMOVABLE) | MP_MAPOWNER_CURRENT | MP_MAP5, 0x83);
 		UpdatePlayerHouse(p, score);
-		InvalidateWindow(WC_COMPANY, (int)p->index);
+		InvalidateWindow(WC_COMPANY, p->index);
 	}
 
 	return cost;
@@ -346,8 +346,8 @@
 		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) {
 			if (!checkRadioTowerNearby(tile)) continue;
 			SetTileType(tile, MP_UNMOVABLE);
+			SetTileOwner(tile, OWNER_NONE);
 			_m[tile].m5 = 0;
-			SetTileOwner(tile, OWNER_NONE);
 			if (--j == 0) break;
 		}
 	} while (--i);
@@ -375,8 +375,8 @@
 		assert(tile == TILE_MASK(tile));
 
 		SetTileType(tile, MP_UNMOVABLE);
+		SetTileOwner(tile, OWNER_NONE);
 		_m[tile].m5 = 1;
-		SetTileOwner(tile, OWNER_NONE);
 	} while (--i);
 }
 
--- a/water_cmd.c	Sun Feb 12 14:31:33 2006 +0000
+++ b/water_cmd.c	Mon Feb 13 21:15:00 2006 +0000
@@ -274,7 +274,6 @@
 static int32 ClearTile_Water(TileIndex tile, byte flags)
 {
 	byte m5 = _m[tile].m5;
-	uint slope;
 
 	if (m5 <= 1) { // water and shore
 		// Allow building on water? It's ok to build on shores.
@@ -285,25 +284,26 @@
 		if (!EnsureNoVehicle(tile)) return CMD_ERROR;
 
 		// Make sure it's not an edge tile.
-		if (!(IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) &&
-				IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)))
+		if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) ||
+				!IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) {
 			return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
+		}
 
 		if (m5 == 0) {
 			if (flags & DC_EXEC) DoClearSquare(tile);
 			return _price.clear_water;
 		} else if (m5 == 1) {
-			slope = GetTileSlope(tile,NULL);
+			uint slope = GetTileSlope(tile,NULL);
+
+			if (flags & DC_EXEC) DoClearSquare(tile);
 			if (slope == 8 || slope == 4 || slope == 2 || slope == 1) {
-				if (flags & DC_EXEC)
-					DoClearSquare(tile);
 				return _price.clear_water;
+			} else {
+				return _price.purchase_land;
 			}
-			if (flags & DC_EXEC)
-				DoClearSquare(tile);
-			return _price.purchase_land;
-		} else
+		} else {
 			return CMD_ERROR;
+		}
 	} else if ((m5 & 0x10) == 0x10) {
 		// shiplift