# HG changeset patch # User tron # Date 1110112267 0 # Node ID 68847f67a4129b04096641f30e7b7491c57054a1 # Parent ae1a7e41277be9e97fcb2515743f844fe873cc72 (svn r1934) Small cleanup (uint -> TileIndex, (uint)-1 -> INVALID_TILE and similar stuff) diff -r ae1a7e41277b -r 68847f67a412 train_cmd.c --- a/train_cmd.c Sun Mar 06 12:26:38 2005 +0000 +++ b/train_cmd.c Sun Mar 06 12:31:07 2005 +0000 @@ -2597,7 +2597,7 @@ } -extern uint CheckTunnelBusy(uint tile, int *length); +extern TileIndex CheckTunnelBusy(TileIndex tile, uint *length); /** * Deletes/Clears the last wagon of a crashed train. It takes the engine of the @@ -2635,10 +2635,9 @@ DisableTrainCrossing(v->tile); if (v->u.rail.track == 0x40) { // inside a tunnel - int length; - TileIndex endtile = CheckTunnelBusy(v->tile, &length); - - if (endtile == (uint)-1) // tunnel is busy (error returned) + TileIndex endtile = CheckTunnelBusy(v->tile, NULL); + + if (endtile == INVALID_TILE) // tunnel is busy (error returned) return; if ((v->direction == 1) || (v->direction == 5) ) diff -r ae1a7e41277b -r 68847f67a412 tunnelbridge_cmd.c --- a/tunnelbridge_cmd.c Sun Mar 06 12:26:38 2005 +0000 +++ b/tunnelbridge_cmd.c Sun Mar 06 12:31:07 2005 +0000 @@ -585,12 +585,12 @@ static const byte _updsignals_tunnel_dir[4] = { 5, 7, 1, 3}; -uint CheckTunnelBusy(uint tile, int *length) +TileIndex CheckTunnelBusy(TileIndex tile, uint *length) { uint z = GetTileZ(tile); byte m5 = _map5[tile]; int delta = TileOffsByDir(m5 & 3); - int len = 0; + uint len = 0; uint starttile = tile; Vehicle *v; @@ -604,13 +604,14 @@ GetTileZ(tile) != z ); - if ((v=FindVehicleBetween(starttile, tile, z)) != NULL) { - _error_message = v->type == VEH_Train ? STR_5000_TRAIN_IN_TUNNEL : STR_5001_ROAD_VEHICLE_IN_TUNNEL; - return (uint)-1; + v = FindVehicleBetween(starttile, tile, z); + if (v != NULL) { + _error_message = v->type == VEH_Train ? + STR_5000_TRAIN_IN_TUNNEL : STR_5001_ROAD_VEHICLE_IN_TUNNEL; + return INVALID_TILE; } - if (length != NULL) - *length = len; + if (length != NULL) *length = len; return tile; } @@ -618,7 +619,7 @@ { Town *t; uint endtile; - int length; + uint length; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -629,7 +630,7 @@ } endtile = CheckTunnelBusy(tile, &length); - if (endtile == (uint)-1) return CMD_ERROR; + if (endtile == INVALID_TILE) return CMD_ERROR; _build_tunnel_endtile = endtile; @@ -828,7 +829,7 @@ int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec) { uint endtile; - int length; + uint length; Vehicle *v; if ((_map5[tile] & 0xFC) == 0x00) { @@ -838,7 +839,7 @@ if ( (uint)(_map3_lo[tile] & 0xF) == totype) return CMD_ERROR; endtile = CheckTunnelBusy(tile, &length); - if (endtile == (uint)-1) return CMD_ERROR; + if (endtile == INVALID_TILE) return CMD_ERROR; if (exec) { _map3_lo[tile] = (_map3_lo[tile] & 0xF0) + totype;