mirror of https://github.com/OpenTTD/OpenTTD
(svn r1934) Small cleanup (uint -> TileIndex, (uint)-1 -> INVALID_TILE and similar stuff)
parent
4c9b6b44d5
commit
a747e2bb97
|
@ -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
|
* 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);
|
DisableTrainCrossing(v->tile);
|
||||||
|
|
||||||
if (v->u.rail.track == 0x40) { // inside a tunnel
|
if (v->u.rail.track == 0x40) { // inside a tunnel
|
||||||
int length;
|
TileIndex endtile = CheckTunnelBusy(v->tile, NULL);
|
||||||
TileIndex endtile = CheckTunnelBusy(v->tile, &length);
|
|
||||||
|
|
||||||
if (endtile == (uint)-1) // tunnel is busy (error returned)
|
if (endtile == INVALID_TILE) // tunnel is busy (error returned)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((v->direction == 1) || (v->direction == 5) )
|
if ((v->direction == 1) || (v->direction == 5) )
|
||||||
|
|
|
@ -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};
|
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);
|
uint z = GetTileZ(tile);
|
||||||
byte m5 = _map5[tile];
|
byte m5 = _map5[tile];
|
||||||
int delta = TileOffsByDir(m5 & 3);
|
int delta = TileOffsByDir(m5 & 3);
|
||||||
int len = 0;
|
uint len = 0;
|
||||||
uint starttile = tile;
|
uint starttile = tile;
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
|
|
||||||
|
@ -604,13 +604,14 @@ uint CheckTunnelBusy(uint tile, int *length)
|
||||||
GetTileZ(tile) != z
|
GetTileZ(tile) != z
|
||||||
);
|
);
|
||||||
|
|
||||||
if ((v=FindVehicleBetween(starttile, tile, z)) != NULL) {
|
v = FindVehicleBetween(starttile, tile, z);
|
||||||
_error_message = v->type == VEH_Train ? STR_5000_TRAIN_IN_TUNNEL : STR_5001_ROAD_VEHICLE_IN_TUNNEL;
|
if (v != NULL) {
|
||||||
return (uint)-1;
|
_error_message = v->type == VEH_Train ?
|
||||||
|
STR_5000_TRAIN_IN_TUNNEL : STR_5001_ROAD_VEHICLE_IN_TUNNEL;
|
||||||
|
return INVALID_TILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length != NULL)
|
if (length != NULL) *length = len;
|
||||||
*length = len;
|
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,7 +619,7 @@ static int32 DoClearTunnel(uint tile, uint32 flags)
|
||||||
{
|
{
|
||||||
Town *t;
|
Town *t;
|
||||||
uint endtile;
|
uint endtile;
|
||||||
int length;
|
uint length;
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
|
@ -629,7 +630,7 @@ static int32 DoClearTunnel(uint tile, uint32 flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
endtile = CheckTunnelBusy(tile, &length);
|
endtile = CheckTunnelBusy(tile, &length);
|
||||||
if (endtile == (uint)-1) return CMD_ERROR;
|
if (endtile == INVALID_TILE) return CMD_ERROR;
|
||||||
|
|
||||||
_build_tunnel_endtile = endtile;
|
_build_tunnel_endtile = endtile;
|
||||||
|
|
||||||
|
@ -828,7 +829,7 @@ static int32 ClearTile_TunnelBridge(uint tile, byte flags) {
|
||||||
int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec)
|
int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec)
|
||||||
{
|
{
|
||||||
uint endtile;
|
uint endtile;
|
||||||
int length;
|
uint length;
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
|
|
||||||
if ((_map5[tile] & 0xFC) == 0x00) {
|
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;
|
if ( (uint)(_map3_lo[tile] & 0xF) == totype) return CMD_ERROR;
|
||||||
|
|
||||||
endtile = CheckTunnelBusy(tile, &length);
|
endtile = CheckTunnelBusy(tile, &length);
|
||||||
if (endtile == (uint)-1) return CMD_ERROR;
|
if (endtile == INVALID_TILE) return CMD_ERROR;
|
||||||
|
|
||||||
if (exec) {
|
if (exec) {
|
||||||
_map3_lo[tile] = (_map3_lo[tile] & 0xF0) + totype;
|
_map3_lo[tile] = (_map3_lo[tile] & 0xF0) + totype;
|
||||||
|
|
Loading…
Reference in New Issue