(svn r2643) Get rid of some unnecessary casts
authortron
Tue, 19 Jul 2005 21:49:35 +0000
changeset 2133 d7f582b7001d
parent 2132 2e7f4c2e479b
child 2134 50fafe90c9f0
(svn r2643) Get rid of some unnecessary casts
aircraft_cmd.c
bridge_gui.c
graph_gui.c
industry_cmd.c
music_gui.c
rail.c
road_cmd.c
station_cmd.c
tunnelbridge_cmd.c
--- a/aircraft_cmd.c	Tue Jul 19 21:28:15 2005 +0000
+++ b/aircraft_cmd.c	Tue Jul 19 21:49:35 2005 +0000
@@ -909,7 +909,7 @@
 	dist = myabs(x + amd->x - v->x_pos) +  myabs(y + amd->y - v->y_pos);
 
 	// Need exact position?
-	if (!(amd->flag & AMED_EXACTPOS) && dist <= (uint)((amd->flag&AMED_SLOWTURN)?8:4))
+	if (!(amd->flag & AMED_EXACTPOS) && dist <= (amd->flag & AMED_SLOWTURN ? 8 : 4))
 		return true;
 
 	// At final pos?
--- a/bridge_gui.c	Tue Jul 19 21:28:15 2005 +0000
+++ b/bridge_gui.c	Tue Jul 19 21:49:35 2005 +0000
@@ -10,7 +10,7 @@
 #include "sound.h"
 
 static struct BridgeData {
-	int count;
+	uint count;
 	TileIndex start_tile;
 	TileIndex end_tile;
 	byte type;
@@ -40,11 +40,11 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		int i;
+		uint i;
 
 		DrawWindowWidgets(w);
 
-		for(i=0; i < 4 && i + w->vscroll.pos < _bridge.count; i++) {
+		for (i = 0; i < 4 && i + w->vscroll.pos < _bridge.count; i++) {
 			int ind = _bridge.indexes[i + w->vscroll.pos];
 
 			SetDParam(2, _bridge.costs[i + w->vscroll.pos]);
@@ -58,7 +58,7 @@
 
 	case WE_KEYPRESS: {
 		uint i = e->keypress.keycode - '1';
-		if (i < 9 && i < (uint)_bridge.count) {
+		if (i < 9 && i < _bridge.count) {
 			e->keypress.cont = false;
 			BuildBridge(w, i);
 		}
@@ -69,7 +69,7 @@
 	case WE_CLICK:
 	 if (e->click.widget == 2) {
 			uint ind = ((int)e->click.pt.y - 14) / 22;
-			if (ind < 4 && (ind += w->vscroll.pos) < (uint)_bridge.count)
+			if (ind < 4 && (ind += w->vscroll.pos) < _bridge.count)
 				BuildBridge(w, ind);
 		}
 		break;
@@ -112,7 +112,7 @@
 
 void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
 {
-	int j = 0;
+	uint j = 0;
 	int32 ret;
 	uint16 errmsg;
 
--- a/graph_gui.c	Tue Jul 19 21:28:15 2005 +0000
+++ b/graph_gui.c	Tue Jul 19 21:49:35 2005 +0000
@@ -1171,8 +1171,7 @@
 			SignStruct *ss;
 
 			/* Start drawing the signs */
-			i = 0;
-			for (i = w->vscroll.pos; i < (uint)w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) {
+			for (i = w->vscroll.pos; i < w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) {
 				ss = GetSign(_sign_sort[i]);
 
 				if (ss->owner != OWNER_NONE)
--- a/industry_cmd.c	Tue Jul 19 21:28:15 2005 +0000
+++ b/industry_cmd.c	Tue Jul 19 21:49:35 2005 +0000
@@ -948,7 +948,7 @@
 {
 	uint size_x, size_y;
 	uint32 r;
-	int count;
+	uint count;
 	int type, type2;
 
 	if (_opt.landscape == LT_HILLY) {
@@ -971,8 +971,7 @@
 		cur_tile = TILE_MASK(cur_tile);
 		count += IsBadFarmFieldTile(cur_tile);
 	END_TILE_LOOP(cur_tile, size_x, size_y, tile)
-	if ((uint)(count * 2) >= size_x * size_y)
-		return;
+	if (count * 2 >= size_x * size_y) return;
 
 	/* determine type of field */
 	r = Random();
--- a/music_gui.c	Tue Jul 19 21:28:15 2005 +0000
+++ b/music_gui.c	Tue Jul 19 21:49:35 2005 +0000
@@ -197,7 +197,8 @@
 {
 	switch(e->event) {
 	case WE_PAINT: {
-		int y,i;
+		uint i;
+		int y;
 		byte *p;
 
 		w->disabled_state = (msf.playlist  <= 3) ? (1 << 11) : 0;
@@ -212,7 +213,7 @@
 		SetDParam(0, STR_01D5_ALL + msf.playlist);
 		DrawStringCentered(340, 15, STR_01EF_PROGRAM, 0);
 
-		for(i=1; (uint)i <= NUM_SONGS_AVAILABLE; i++) {
+		for (i = 1; i <= NUM_SONGS_AVAILABLE; i++) {
 			SetDParam(0, i);
 			SetDParam(2, i);
 			SetDParam(1, SPECSTR_SONGNAME);
--- a/rail.c	Tue Jul 19 21:28:15 2005 +0000
+++ b/rail.c	Tue Jul 19 21:49:35 2005 +0000
@@ -133,7 +133,7 @@
 			if ((_m[tile].m5 & 0xC6) == 0xC0 && ((DiagDirection)(_m[tile].m5 & 0x1)) == (exitdir & 0x1))
 				type = (_m[tile].m3 >> 4) & RAILTYPE_MASK;
 			/* under bridge (any type) */
-			if ((_m[tile].m5 & 0xC0) == 0xC0 && ((uint)_m[tile].m5 & 0x1) != (exitdir & 0x1))
+			if ((_m[tile].m5 & 0xC0) == 0xC0 && (_m[tile].m5 & 0x1U) != (exitdir & 0x1))
 				type = _m[tile].m3 & RAILTYPE_MASK;
 			break;
 		default:
--- a/road_cmd.c	Tue Jul 19 21:28:15 2005 +0000
+++ b/road_cmd.c	Tue Jul 19 21:49:35 2005 +0000
@@ -496,7 +496,7 @@
 	if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
 
 	// tile is already of requested type?
-	if ( (uint)(_m[tile].m4 & 0xF) == totype) return CMD_ERROR;
+	if ((_m[tile].m4 & 0xFU) == totype) return CMD_ERROR;
 
 	if (exec) {
 		// change type.
--- a/station_cmd.c	Tue Jul 19 21:28:15 2005 +0000
+++ b/station_cmd.c	Tue Jul 19 21:49:35 2005 +0000
@@ -529,7 +529,7 @@
 	int x1,y1,x2,y2;
 	int xc,yc;
 
-	memset(produced, 0, NUM_CARGO * sizeof(uint));
+	memset(produced, 0, sizeof(AcceptedCargo));
 
 	x = TileX(tile);
 	y = TileY(tile);
@@ -1428,7 +1428,7 @@
 	if (_m[tile].m5 >= 8) return CMD_ERROR;
 
 	// tile is already of requested type?
-	if ( (uint)(_m[tile].m3 & 0xF) == totype) return CMD_ERROR;
+	if ((_m[tile].m3 & 0xFU) == totype) return CMD_ERROR;
 
 	if (exec) {
 		// change type.
--- a/tunnelbridge_cmd.c	Tue Jul 19 21:28:15 2005 +0000
+++ b/tunnelbridge_cmd.c	Tue Jul 19 21:49:35 2005 +0000
@@ -845,7 +845,7 @@
 		// railway tunnel
 		if (!CheckTileOwnership(tile)) return CMD_ERROR;
 
-		if ( (uint)(_m[tile].m3 & 0xF) == totype) return CMD_ERROR;
+		if ((_m[tile].m3 & 0xFU) == totype) return CMD_ERROR;
 
 		endtile = CheckTunnelBusy(tile, &length);
 		if (endtile == INVALID_TILE) return CMD_ERROR;
@@ -864,7 +864,7 @@
 			return CMD_ERROR;
 
 		// tile is already of requested type?
-		if ( (uint)(_m[tile].m3 & 0xF) == totype) return CMD_ERROR;
+		if ((_m[tile].m3 & 0xFU) == totype) return CMD_ERROR;
 		// change type.
 		if (exec) {
 			_m[tile].m3 = (_m[tile].m3 & 0xF0) + totype;
@@ -893,7 +893,7 @@
 			return CMD_ERROR;
 		}
 
-		if ( (uint)(_m[tile].m3 & 0xF) == totype) return CMD_ERROR;
+		if ((_m[tile].m3 & 0xFU) == totype) return CMD_ERROR;
 		cost = 0;
 		do {
 			if (exec) {