mirror of https://github.com/OpenTTD/OpenTTD
(svn r9542) -Fix(FS# 712): When checking if a vehicle is on a given tile, and you are working on the ground tile, do not take aircrafts into account, as they do not pose any danger for the construction/destruction/conversion itself. Z stuff, in other words
parent
191ea4b1ba
commit
65bc46082e
|
@ -254,7 +254,7 @@ int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (!CheckTrackCombination(tile, trackbit, flags) ||
|
if (!CheckTrackCombination(tile, trackbit, flags) ||
|
||||||
!EnsureNoVehicle(tile)) {
|
!EnsureNoVehicleOnGround(tile)) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
if (!IsTileOwner(tile, _current_player) ||
|
if (!IsTileOwner(tile, _current_player) ||
|
||||||
|
@ -289,7 +289,7 @@ int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
#undef M
|
#undef M
|
||||||
|
|
||||||
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
|
if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
|
||||||
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
|
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
|
||||||
|
@ -352,7 +352,7 @@ int32 CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
if (!IsLevelCrossing(tile) ||
|
if (!IsLevelCrossing(tile) ||
|
||||||
GetCrossingRailBits(tile) != trackbit ||
|
GetCrossingRailBits(tile) != trackbit ||
|
||||||
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
|
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
|
||||||
!EnsureNoVehicle(tile)) {
|
!EnsureNoVehicleOnGround(tile)) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ int32 CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (!IsPlainRailTile(tile) ||
|
if (!IsPlainRailTile(tile) ||
|
||||||
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
|
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
|
||||||
!EnsureNoVehicle(tile)) {
|
!EnsureNoVehicleOnGround(tile)) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ int32 CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
SignalVariant sigvar = (pre_signal ^ HASBIT(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC;
|
SignalVariant sigvar = (pre_signal ^ HASBIT(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC;
|
||||||
int32 cost;
|
int32 cost;
|
||||||
|
|
||||||
if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicle(tile))
|
if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicleOnGround(tile))
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
|
||||||
/* Protect against invalid signal copying */
|
/* Protect against invalid signal copying */
|
||||||
|
@ -810,7 +810,7 @@ int32 CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (!ValParamTrackOrientation(track) ||
|
if (!ValParamTrackOrientation(track) ||
|
||||||
!IsTileType(tile, MP_RAILWAY) ||
|
!IsTileType(tile, MP_RAILWAY) ||
|
||||||
!EnsureNoVehicle(tile) ||
|
!EnsureNoVehicleOnGround(tile) ||
|
||||||
!HasSignalOnTrack(tile, track)) {
|
!HasSignalOnTrack(tile, track)) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -867,7 +867,7 @@ static int32 DoConvertRail(TileIndex tile, RailType totype, bool exec)
|
||||||
|
|
||||||
if (GetRailType(tile) == totype) return CMD_ERROR;
|
if (GetRailType(tile) == totype) return CMD_ERROR;
|
||||||
|
|
||||||
if (!EnsureNoVehicle(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR;
|
if (!EnsureNoVehicleOnGround(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR;
|
||||||
|
|
||||||
// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
|
// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
|
||||||
if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
|
if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
|
||||||
|
@ -971,7 +971,7 @@ static int32 RemoveTrainDepot(TileIndex tile, uint32 flags)
|
||||||
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
|
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
|
||||||
if (!EnsureNoVehicle(tile))
|
if (!EnsureNoVehicleOnGround(tile))
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
|
|
@ -120,7 +120,7 @@ int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (!CheckAllowRemoveRoad(tile, pieces, &edge_road)) return CMD_ERROR;
|
if (!CheckAllowRemoveRoad(tile, pieces, &edge_road)) return CMD_ERROR;
|
||||||
|
|
||||||
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
/* check if you're allowed to remove the street owned by a town
|
/* check if you're allowed to remove the street owned by a town
|
||||||
* removal allowance depends on difficulty setting */
|
* removal allowance depends on difficulty setting */
|
||||||
|
@ -281,7 +281,7 @@ int32 CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
if ((existing & pieces) == pieces) {
|
if ((existing & pieces) == pieces) {
|
||||||
return_cmd_error(STR_1007_ALREADY_BUILT);
|
return_cmd_error(STR_1007_ALREADY_BUILT);
|
||||||
}
|
}
|
||||||
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROAD_TILE_CROSSING:
|
case ROAD_TILE_CROSSING:
|
||||||
|
@ -325,7 +325,7 @@ int32 CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
default: goto do_clear;
|
default: goto do_clear;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
|
YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
|
||||||
|
@ -383,7 +383,7 @@ int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
|
||||||
if (!IsLevelCrossing(tile)) return CMD_ERROR;
|
if (!IsLevelCrossing(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
/* not owned by me? */
|
/* not owned by me? */
|
||||||
if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
|
if (!CheckTileOwnership(tile) || !EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
if (GetRailType(tile) == totype) return CMD_ERROR;
|
if (GetRailType(tile) == totype) return CMD_ERROR;
|
||||||
|
|
||||||
|
@ -902,7 +902,7 @@ static void TileLoop_Road(TileIndex tile)
|
||||||
if (t->road_build_months != 0 &&
|
if (t->road_build_months != 0 &&
|
||||||
(DistanceManhattan(t->xy, tile) < 8 || grp != 0) &&
|
(DistanceManhattan(t->xy, tile) < 8 || grp != 0) &&
|
||||||
GetRoadTileType(tile) == ROAD_TILE_NORMAL && (GetRoadBits(tile) == ROAD_X || GetRoadBits(tile) == ROAD_Y)) {
|
GetRoadTileType(tile) == ROAD_TILE_NORMAL && (GetRoadBits(tile) == ROAD_X || GetRoadBits(tile) == ROAD_Y)) {
|
||||||
if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicle(tile) && CHANCE16(1, 20)) {
|
if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && CHANCE16(1, 20)) {
|
||||||
StartRoadWorks(tile);
|
StartRoadWorks(tile);
|
||||||
|
|
||||||
SndPlayTileFx(SND_21_JACKHAMMER, tile);
|
SndPlayTileFx(SND_21_JACKHAMMER, tile);
|
||||||
|
|
|
@ -637,8 +637,8 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
|
||||||
|
|
||||||
endtile = GetOtherBridgeEnd(tile);
|
endtile = GetOtherBridgeEnd(tile);
|
||||||
|
|
||||||
if (!EnsureNoVehicle(tile) ||
|
if (!EnsureNoVehicleOnGround(tile) ||
|
||||||
!EnsureNoVehicle(endtile) ||
|
!EnsureNoVehicleOnGround(endtile) ||
|
||||||
IsVehicleOnBridge(tile, endtile, GetBridgeHeight(tile))) {
|
IsVehicleOnBridge(tile, endtile, GetBridgeHeight(tile))) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -741,8 +741,8 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||||
|
|
||||||
endtile = GetOtherBridgeEnd(tile);
|
endtile = GetOtherBridgeEnd(tile);
|
||||||
|
|
||||||
if (!EnsureNoVehicle(tile) ||
|
if (!EnsureNoVehicleOnGround(tile) ||
|
||||||
!EnsureNoVehicle(endtile) ||
|
!EnsureNoVehicleOnGround(endtile) ||
|
||||||
IsVehicleOnBridge(tile, endtile, GetBridgeHeight(tile))) {
|
IsVehicleOnBridge(tile, endtile, GetBridgeHeight(tile))) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue