(svn r2492) Remove some pointless casts and fix some nearby indentation

This commit is contained in:
tron 2005-06-27 06:57:24 +00:00
parent 78fed52627
commit ab7b8b50e3
10 changed files with 59 additions and 95 deletions

View File

@ -641,7 +641,7 @@ static void DrawAircraftDepotWindow(Window *w)
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 @@ static void DrawAircraftDepotWindow(Window *w)
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 @@ static int GetVehicleFromAircraftDepotWndPt(Window *w, int x, int y, Vehicle **v
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 */
}

View File

@ -167,13 +167,12 @@ static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height
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;

View File

@ -22,12 +22,12 @@ static bool TPFSetTileBit(TrackPathFinder *tpf, TileIndex tile, int dir)
/* 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 @@ static bool TPFSetTileBit(TrackPathFinder *tpf, TileIndex tile, int dir)
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 @@ static bool TPFSetTileBit(TrackPathFinder *tpf, TileIndex tile, int dir)
/* 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 @@ static bool NtpVisit(NewTrackPathFinder *tpf, TileIndex tile, uint dir, uint len
}
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 @@ static bool NtpVisit(NewTrackPathFinder *tpf, TileIndex tile, uint dir, uint len
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 @@ static bool NtpVisit(NewTrackPathFinder *tpf, TileIndex tile, uint dir, uint len
/* 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 @@ static bool NtpCheck(NewTrackPathFinder *tpf, TileIndex tile, uint dir, uint len
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);
}

View File

@ -663,8 +663,7 @@ int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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) |

View File

@ -644,8 +644,7 @@ int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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;

View File

@ -907,11 +907,8 @@ typedef struct OvertakeData {
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 @@ static int RoadFindPathToDest(Vehicle *v, TileIndex tile, int enterdir)
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]);
}
}

View File

@ -540,9 +540,8 @@ static void DrawRoadDepotWindow(Window *w)
/* 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 @@ static void DrawRoadDepotWindow(Window *w)
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 @@ static int GetVehicleFromRoadDepotWndPt(Window *w, int x, int y, Vehicle **veh)
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 */

View File

@ -616,9 +616,8 @@ static void DrawShipDepotWindow(Window *w)
/* 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 @@ static void DrawShipDepotWindow(Window *w)
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 @@ static int GetVehicleFromShipDepotWndPt(Window *w, int x, int y, Vehicle **veh)
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 */

View File

@ -445,7 +445,7 @@ static int32 CmdBuildRailWagon(uint engine, TileIndex tile, uint32 flags)
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 @@ static int32 CmdBuildRailWagon(uint engine, TileIndex tile, uint32 flags)
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 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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]);

View File

@ -370,17 +370,17 @@ static void DrawTrainDepotWindow(Window *w)
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 @@ static void DrawTrainDepotWindow(Window *w)
// 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 @@ static void DrawTrainDepotWindow(Window *w)
// 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);