diff --git a/train_cmd.c b/train_cmd.c index ac39e4b1a0..645a84e6c3 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -2597,7 +2597,7 @@ reverse_train_direction: } -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 @@ static void DeleteLastWagon(Vehicle *v) DisableTrainCrossing(v->tile); if (v->u.rail.track == 0x40) { // inside a tunnel - int length; - TileIndex endtile = CheckTunnelBusy(v->tile, &length); + TileIndex endtile = CheckTunnelBusy(v->tile, NULL); - if (endtile == (uint)-1) // tunnel is busy (error returned) + if (endtile == INVALID_TILE) // tunnel is busy (error returned) return; if ((v->direction == 1) || (v->direction == 5) ) diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index 29e218d3ee..92c59b6b3c 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -585,12 +585,12 @@ int32 CmdBuildTunnel(int x, int y, uint32 flags, uint32 p1, uint32 p2) 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 @@ uint CheckTunnelBusy(uint tile, int *length) 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 @@ static int32 DoClearTunnel(uint tile, uint32 flags) { Town *t; uint endtile; - int length; + uint length; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -629,7 +630,7 @@ static int32 DoClearTunnel(uint tile, uint32 flags) } 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 @@ static int32 ClearTile_TunnelBridge(uint tile, byte flags) { 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 @@ int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec) 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;