(svn r2492) Remove some pointless casts and fix some nearby indentation
authortron
Mon, 27 Jun 2005 06:57:24 +0000
changeset 1986 5dd3db2b86d7
parent 1985 c4ec1653a337
child 1987 9de61844bc60
(svn r2492) Remove some pointless casts and fix some nearby indentation
aircraft_gui.c
clear_cmd.c
pathfind.c
rail_cmd.c
road_cmd.c
roadveh_cmd.c
roadveh_gui.c
ship_gui.c
train_cmd.c
train_gui.c
--- a/aircraft_gui.c	Sun Jun 26 21:59:21 2005 +0000
+++ b/aircraft_gui.c	Mon Jun 27 06:57:24 2005 +0000
@@ -641,7 +641,7 @@
 	num = 0;
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_Aircraft && v->subtype <= 2 && v->vehstatus&VS_HIDDEN &&
-				v->tile == (TileIndex)tile)
+				v->tile == tile)
 					num++;
 	}
 	SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
@@ -657,7 +657,7 @@
 		if (v->type == VEH_Aircraft &&
 				v->subtype <= 2 &&
 				v->vehstatus&VS_HIDDEN &&
-				v->tile == (TileIndex)tile &&
+				v->tile == tile &&
 				--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) {
 
 			DrawAircraftImage(v, x+12, y, WP(w,traindepot_d).sel);
@@ -695,20 +695,14 @@
 
 	tile = w->window_number;
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Aircraft &&
-				v->subtype <= 2 &&
-				v->vehstatus&VS_HIDDEN &&
-				v->tile == (TileIndex)tile &&
+		if (v->type == VEH_Aircraft && v->subtype <= 2 &&
+				v->vehstatus & VS_HIDDEN && v->tile == tile &&
 				--pos < 0) {
-					*veh = v;
-					if (xm >= 12)
-						return 0;
-
-					if (ym <= 12)
-						return -1; /* show window */
-
-					return -2; /* start stop */
-				}
+			*veh = v;
+			if (xm >= 12) return 0;
+			if (ym <= 12) return -1; /* show window */
+			return -2; /* start stop */
+		}
 	}
 	return 1; /* outside */
 }
--- a/clear_cmd.c	Sun Jun 26 21:59:21 2005 +0000
+++ b/clear_cmd.c	Mon Jun 27 06:57:24 2005 +0000
@@ -167,13 +167,12 @@
 			ts->modheight_count++;
 			break;
 		}
-		if (mod->tile == (TileIndex)tile)
-			break;
+		if (mod->tile == tile) break;
 		mod++;
 		count--;
 	}
 
-	mod->tile = (TileIndex)tile;
+	mod->tile = tile;
 	mod->height = (byte)height;
 
 	ts->cost += _price.terraform;
--- a/pathfind.c	Sun Jun 26 21:59:21 2005 +0000
+++ b/pathfind.c	Mon Jun 27 06:57:24 2005 +0000
@@ -22,12 +22,12 @@
 		/* unused hash entry, set the appropriate bit in it and return true
 		 * to indicate that a bit was set. */
 		tpf->hash_head[hash] = bits;
-		tpf->hash_tile[hash] = (TileIndex)tile;
+		tpf->hash_tile[hash] = tile;
 		return true;
 	} else if (!(val & 0x8000)) {
 		/* single tile */
 
-		if ( (TileIndex)tile == tpf->hash_tile[hash] ) {
+		if (tile == tpf->hash_tile[hash]) {
 			/* found another bit for the same tile,
 			 * check if this bit is already set, if so, return false */
 			if (val & bits)
@@ -65,7 +65,7 @@
 		offs = tpf->hash_tile[hash];
 		do {
 			link = PATHFIND_GET_LINK_PTR(tpf, offs);
-			if ( (TileIndex)tile == link->tile) {
+			if (tile == link->tile) {
 				/* found the tile in the link list,
 				 * check if the bit was alrady set, if so return false to indicate that the
 				 * bit was already set */
@@ -86,7 +86,7 @@
 
 	/* then fill the link with the new info, and establish a ptr from the old
 	 * link to the new one */
-	new_link->tile = (TileIndex)tile;
+	new_link->tile = tile;
 	new_link->flags = bits;
 	new_link->next = 0xFFFF;
 
@@ -531,7 +531,7 @@
 	}
 
 	if (head != 0xffff) {
-		if ( (TileIndex)tile == tpf->hash_tile[hash] && (head & 0x3) == dir ) {
+		if (tile == tpf->hash_tile[hash] && (head & 0x3) == dir) {
 
 			// longer length
 			if (length >= (head >> 2)) return false;
@@ -563,7 +563,7 @@
 		uint offs = tpf->hash_tile[hash];
 		do {
 			link = NTP_GET_LINK_PTR(tpf, offs);
-			if ( (TileIndex)tile == link->tile && (uint)(link->typelength & 0x3) == dir) {
+			if (tile == link->tile && (uint)(link->typelength & 0x3) == dir) {
 				if (length >= (uint)(link->typelength >> 2)) return false;
 				link->typelength = dir | (length << 2);
 				return true;
@@ -580,7 +580,7 @@
 
 	/* then fill the link with the new info, and establish a ptr from the old
 	 * link to the new one */
-	new_link->tile = (TileIndex)tile;
+	new_link->tile = tile;
 	new_link->typelength = dir | (length << 2);
 	new_link->next = 0xFFFF;
 
@@ -607,7 +607,7 @@
 	offs = tpf->hash_tile[hash];
 	for(;;) {
 		link = NTP_GET_LINK_PTR(tpf, offs);
-		if ( (TileIndex)tile == link->tile && (uint)(link->typelength & 0x3) == dir) {
+		if (tile == link->tile && (uint)(link->typelength & 0x3) == dir) {
 			assert( (uint)(link->typelength >> 2) <= length);
 			return length == (uint)(link->typelength >> 2);
 		}
--- a/rail_cmd.c	Sun Jun 26 21:59:21 2005 +0000
+++ b/rail_cmd.c	Mon Jun 27 06:57:24 2005 +0000
@@ -663,8 +663,7 @@
 		return CMD_ERROR;
 
 	if (flags & DC_EXEC) {
-		if (_current_player == _local_player)
-			_last_built_train_depot_tile = (TileIndex)tile;
+		if (_current_player == _local_player) _last_built_train_depot_tile = tile;
 
 		ModifyTile(tile,
 			MP_SETTYPE(MP_RAILWAY) |
--- a/road_cmd.c	Sun Jun 26 21:59:21 2005 +0000
+++ b/road_cmd.c	Mon Jun 27 06:57:24 2005 +0000
@@ -644,8 +644,7 @@
 		return CMD_ERROR;
 
 	if (flags & DC_EXEC) {
-		if (_current_player == _local_player)
-			_last_built_road_depot_tile = (TileIndex)tile;
+		if (_current_player == _local_player) _last_built_road_depot_tile = tile;
 
 		dep->xy = tile;
 		dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
--- a/roadveh_cmd.c	Sun Jun 26 21:59:21 2005 +0000
+++ b/roadveh_cmd.c	Mon Jun 27 06:57:24 2005 +0000
@@ -907,11 +907,8 @@
 
 static void *EnumFindVehToOvertake(Vehicle *v, OvertakeData *od)
 {
-	if (v->tile != (TileIndex)od->tile ||
-			v->type != VEH_Road ||
-			v == od->u ||
-			v == od->v)
-				return NULL;
+	if (v->tile != od->tile || v->type != VEH_Road || v == od->u || v == od->v)
+		return NULL;
 	return v;
 }
 
@@ -1079,7 +1076,7 @@
 	if (v->u.road.reverse_ctr != 0) {
 		/* What happens here?? */
 		v->u.road.reverse_ctr = 0;
-		if (v->tile != (TileIndex)tile) {
+		if (v->tile != tile) {
 			return_track(_road_reverse_table[enterdir]);
 		}
 	}
--- a/roadveh_gui.c	Sun Jun 26 21:59:21 2005 +0000
+++ b/roadveh_gui.c	Mon Jun 27 06:57:24 2005 +0000
@@ -540,9 +540,8 @@
 	/* determine amount of items for scroller */
 	num = 0;
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Road && v->u.road.state == 254 &&
-				v->tile == (TileIndex)tile)
-					num++;
+		if (v->type == VEH_Road && v->u.road.state == 254 && v->tile == tile)
+			num++;
 	}
 	SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
 
@@ -558,11 +557,8 @@
 	num = w->vscroll.pos * w->hscroll.cap;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Road &&
-				v->u.road.state == 254 &&
-				v->tile == (TileIndex)tile &&
+		if (v->type == VEH_Road && v->u.road.state == 254 && v->tile == tile &&
 				--num < 0 && num >=	-w->vscroll.cap * w->hscroll.cap) {
-
 			DrawRoadVehImage(v, x+24, y, WP(w,traindepot_d).sel);
 
 			SetDParam(0, v->unitnumber);
@@ -598,19 +594,13 @@
 
 	tile = w->window_number;
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Road &&
-				v->u.road.state == 254 &&
-				v->tile == (TileIndex)tile &&
+		if (v->type == VEH_Road && v->u.road.state == 254 && v->tile == tile &&
 				--pos < 0) {
-					*veh = v;
-					if (xm >= 24)
-						return 0;
-
-					if (xm <= 16)
-						return -1; /* show window */
-
-					return -2; /* start stop */
-				}
+			*veh = v;
+			if (xm >= 24) return 0;
+			if (xm <= 16) return -1; /* show window */
+			return -2; /* start stop */
+		}
 	}
 
 	return 1; /* outside */
--- a/ship_gui.c	Sun Jun 26 21:59:21 2005 +0000
+++ b/ship_gui.c	Mon Jun 27 06:57:24 2005 +0000
@@ -616,9 +616,8 @@
 	/* determine amount of items for scroller */
 	num = 0;
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Ship && v->u.ship.state == 0x80 &&
-				v->tile == (TileIndex)tile)
-					num++;
+		if (v->type == VEH_Ship && v->u.ship.state == 0x80 && v->tile == tile)
+			num++;
 	}
 	SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
 
@@ -634,11 +633,8 @@
 	num = w->vscroll.pos * w->hscroll.cap;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Ship &&
-				v->u.ship.state == 0x80 &&
-				v->tile == (TileIndex)tile &&
+		if (v->type == VEH_Ship && v->u.ship.state == 0x80 && v->tile == tile &&
 				--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) {
-
 			DrawShipImage(v, x+19, y, WP(w,traindepot_d).sel);
 
 			SetDParam(0, v->unitnumber);
@@ -675,17 +671,13 @@
 
 	tile = w->window_number;
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Ship &&
-				v->vehstatus&VS_HIDDEN &&
-				v->tile == (TileIndex)tile &&
+		if (v->type == VEH_Ship && v->vehstatus & VS_HIDDEN && v->tile == tile &&
 				--pos < 0) {
-					*veh = v;
-					if (xm >= 19)
-						return 0;
-					if (ym <= 10)
-						return -1; /* show window */
-					return -2; /* start stop */
-				}
+			*veh = v;
+			if (xm >= 19) return 0;
+			if (ym <= 10) return -1; /* show window */
+			return -2; /* start stop */
+		}
 	}
 
 	return 1; /* outside */
--- a/train_cmd.c	Sun Jun 26 21:59:21 2005 +0000
+++ b/train_cmd.c	Mon Jun 27 06:57:24 2005 +0000
@@ -445,7 +445,7 @@
 			u = NULL;
 
 			FOR_ALL_VEHICLES(w) {
-				if (w->type == VEH_Train && w->tile == (TileIndex)tile &&
+				if (w->type == VEH_Train && w->tile == tile &&
 				    w->subtype == TS_Free_Car && w->engine_type == engine) {
 					u = GetLastVehicleInChain(w);
 					break;
@@ -457,7 +457,7 @@
 			dir = _map5[tile] & 3;
 
 			v->direction = (byte)(dir*2+1);
-			v->tile = (TileIndex)tile;
+			v->tile = tile;
 
 			x = TileX(tile) * TILE_SIZE | _vehicle_initial_x_fract[dir];
 			y = TileY(tile) * TILE_SIZE | _vehicle_initial_y_fract[dir];
@@ -633,7 +633,7 @@
 			dir = _map5[tile] & 3;
 
 			v->direction = (byte)(dir*2+1);
-			v->tile = (TileIndex)tile;
+			v->tile = tile;
 			v->owner = _current_player;
 			v->x_pos = (x |= _vehicle_initial_x_fract[dir]);
 			v->y_pos = (y |= _vehicle_initial_y_fract[dir]);
--- a/train_gui.c	Sun Jun 26 21:59:21 2005 +0000
+++ b/train_gui.c	Mon Jun 27 06:57:24 2005 +0000
@@ -370,17 +370,17 @@
 	hnum = 1;
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_Train &&
-				  (v->subtype == TS_Front_Engine || v->subtype == TS_Free_Car) &&
-				v->tile == (TileIndex)tile &&
+			  (v->subtype == TS_Front_Engine || v->subtype == TS_Free_Car) &&
+				v->tile == tile &&
 				v->u.rail.track == 0x80) {
-					num++;
-					// determine number of items in the X direction.
-					if (v->subtype == TS_Front_Engine) {
-						i = 0;
-						u = v;
-						do i++; while ( (u=u->next) != NULL);
-						if (i > hnum) hnum = i;
-					}
+			num++;
+			// determine number of items in the X direction.
+			if (v->subtype == TS_Front_Engine) {
+				i = 0;
+				u = v;
+				do i++; while ((u = u->next) != NULL);
+				if (i > hnum) hnum = i;
+			}
 		}
 	}
 
@@ -403,12 +403,9 @@
 
 	// draw all trains
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Train &&
-				v->subtype == TS_Front_Engine &&
-				v->tile == (TileIndex)tile &&
-				v->u.rail.track == 0x80 &&
+		if (v->type == VEH_Train && v->subtype == TS_Front_Engine &&
+				v->tile == tile && v->u.rail.track == 0x80 &&
 				--num < 0 && num >= -w->vscroll.cap) {
-
 			DrawTrainImage(v, x+21, y, w->hscroll.cap, w->hscroll.pos, WP(w,traindepot_d).sel);
 			/* Draw the train number */
 			SetDParam(0, v->unitnumber);
@@ -433,12 +430,9 @@
 
 	// draw all remaining vehicles
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Train &&
-				v->subtype == TS_Free_Car &&
-				v->tile == (TileIndex)tile &&
-				v->u.rail.track == 0x80 &&
+		if (v->type == VEH_Train && v->subtype == TS_Free_Car &&
+				v->tile == tile && v->u.rail.track == 0x80 &&
 				--num < 0 && num >= -w->vscroll.cap) {
-
 			DrawTrainImage(v, x+50, y, w->hscroll.cap - 1, 0, WP(w,traindepot_d).sel);
 			DrawString(x, y+2, STR_8816, 0);