diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/trolly/build.cpp | 10 | ||||
-rw-r--r-- | src/ai/trolly/trolly.cpp | 2 | ||||
-rw-r--r-- | src/disaster_cmd.cpp | 2 | ||||
-rw-r--r-- | src/functions.h | 1 | ||||
-rw-r--r-- | src/industry_cmd.cpp | 2 | ||||
-rw-r--r-- | src/road_cmd.cpp | 2 | ||||
-rw-r--r-- | src/station_cmd.cpp | 12 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 2 | ||||
-rw-r--r-- | src/vehicle.cpp | 14 | ||||
-rw-r--r-- | src/water_cmd.cpp | 10 | ||||
-rw-r--r-- | src/waypoint.cpp | 4 |
11 files changed, 23 insertions, 38 deletions
diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp index 6d5e9a32f..472956bf6 100644 --- a/src/ai/trolly/build.cpp +++ b/src/ai/trolly/build.cpp @@ -185,10 +185,10 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, // Build normal road // Keep it doing till we go an other way - // EnsureNoVehicle makes sure we don't build on a tile where a vehicle is. This way + // EnsureNoVehicleOnGround makes sure we don't build on a tile where a vehicle is. This way // it will wait till the vehicle is gone.. - if (route_extra[part-1] == 0 && route_extra[part] == 0 && (flag != DC_EXEC || EnsureNoVehicle(route[part]))) { - while (route_extra[part] == 0 && (flag != DC_EXEC || EnsureNoVehicle(route[part]))) { + if (route_extra[part-1] == 0 && route_extra[part] == 0 && (flag != DC_EXEC || EnsureNoVehicleOnGround(route[part]))) { + while (route_extra[part] == 0 && (flag != DC_EXEC || EnsureNoVehicleOnGround(route[part]))) { // Get the current direction dir = AiNew_GetRoadDirection(route[part-1], route[part], route[part+1]); // Is it the same as the last one? @@ -199,7 +199,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, // Build the tile res = AI_DoCommand(route[part], dir, 0, flag | DC_NO_WATER, CMD_BUILD_ROAD); // Currently, we ignore CMD_ERRORs! - if (CmdFailed(res) && flag == DC_EXEC && !IsTileType(route[part], MP_ROAD) && !EnsureNoVehicle(route[part])) { + if (CmdFailed(res) && flag == DC_EXEC && !IsTileType(route[part], MP_ROAD) && !EnsureNoVehicleOnGround(route[part])) { // Problem.. let's just abort it all! DEBUG(ai, 0, "[BuidPath] route building failed at tile 0x%X, aborting", route[part]); p->ainew.state = AI_STATE_NOTHING; @@ -216,7 +216,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, part--; // We want to return the last position, so we go back one } - if (!EnsureNoVehicle(route[part]) && flag == DC_EXEC) part--; + if (!EnsureNoVehicleOnGround(route[part]) && flag == DC_EXEC) part--; PathFinderInfo->position = part; } diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp index c2e4f577e..2c30b682e 100644 --- a/src/ai/trolly/trolly.cpp +++ b/src/ai/trolly/trolly.cpp @@ -1111,7 +1111,7 @@ static void AiNew_State_BuildDepot(Player *p) } // There is a bus on the tile we want to build road on... idle till he is gone! (BAD PERSON! :p) - if (!EnsureNoVehicle(p->ainew.depot_tile + TileOffsByDiagDir(p->ainew.depot_direction))) + if (!EnsureNoVehicleOnGround(p->ainew.depot_tile + TileOffsByDiagDir(p->ainew.depot_direction))) return; res = AiNew_Build_Depot(p, p->ainew.depot_tile, p->ainew.depot_direction, DC_EXEC); diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index 7034a16e0..c596be9b1 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -60,7 +60,7 @@ enum DisasterSubType { static void DisasterClearSquare(TileIndex tile) { - if (!EnsureNoVehicle(tile)) return; + if (!EnsureNoVehicleOnGround(tile)) return; switch (GetTileType(tile)) { case MP_RAILWAY: diff --git a/src/functions.h b/src/functions.h index f6df7a988..4ba233d4d 100644 --- a/src/functions.h +++ b/src/functions.h @@ -132,7 +132,6 @@ bool ScrollWindowTo(int x, int y, Window *w, bool instant = false); bool ScrollMainWindowToTile(TileIndex tile, bool instant = false); bool ScrollMainWindowTo(int x, int y, bool instant = false); -bool EnsureNoVehicle(TileIndex tile); bool EnsureNoVehicleOnGround(TileIndex tile); /** diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 80d8ccc3d..f894a6349 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1221,7 +1221,7 @@ static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable return false; } } else { - if (!EnsureNoVehicle(cur_tile)) return false; + if (!EnsureNoVehicleOnGround(cur_tile)) return false; if (MayHaveBridgeAbove(cur_tile) && IsBridgeAbove(cur_tile)) return false; const IndustryTileSpec *its = GetIndustryTileSpec(gfx); diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index c057dfa37..6d3669925 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -820,7 +820,7 @@ static CommandCost RemoveRoadDepot(TileIndex tile, uint32 flags) if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR; - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (flags & DC_EXEC) { DoClearSquare(tile); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 5e83674b4..a1284248c 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1128,7 +1128,7 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1 /* Check ownership of station */ Station *st = GetStationByTile(tile2); - if (_current_player != OWNER_WATER && (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile2))) { + if (_current_player != OWNER_WATER && (!CheckOwnership(st->owner) || !EnsureNoVehicleOnGround(tile2))) { continue; } @@ -1191,7 +1191,7 @@ static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 fla do { // for nonuniform stations, only remove tiles that are actually train station tiles if (st->TileBelongsToRailStation(tile)) { - if (!EnsureNoVehicle(tile)) + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; cost.AddCost(_price.remove_rail_station); if (flags & DC_EXEC) { @@ -1425,7 +1425,7 @@ static CommandCost RemoveRoadStop(Station *st, uint32 flags, TileIndex tile) assert(cur_stop != NULL); - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (flags & DC_EXEC) { if (*primary_stop == cur_stop) { @@ -1832,7 +1832,7 @@ static CommandCost RemoveBuoy(Station *st, uint32 flags) TileIndex tile = st->dock_tile; if (CheckShipsOnBuoy(st)) return_cmd_error(STR_BUOY_IS_IN_USE); - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (flags & DC_EXEC) { st->dock_tile = 0; @@ -1980,8 +1980,8 @@ static CommandCost RemoveDock(Station *st, uint32 flags) TileIndex tile1 = st->dock_tile; TileIndex tile2 = tile1 + TileOffsByDiagDir(GetDockDirection(tile1)); - if (!EnsureNoVehicle(tile1)) return CMD_ERROR; - if (!EnsureNoVehicle(tile2)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile1)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile2)) return CMD_ERROR; if (flags & DC_EXEC) { DoClearSquare(tile1); diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 334898a7c..7eb6ec8d6 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -376,7 +376,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p switch (GetTileType(tile)) { case MP_WATER: - if (!EnsureNoVehicle(tile)) return_cmd_error(STR_980E_SHIP_IN_THE_WAY); + if (!EnsureNoVehicleOnGround(tile)) return_cmd_error(STR_980E_SHIP_IN_THE_WAY); if (!IsWater(tile) && !IsCoast(tile)) goto not_valid_below; break; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 56ce50b5d..21c8996f1 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -117,20 +117,6 @@ StringID VehicleInTheWayErrMsg(const Vehicle* v) } } -static void *EnsureNoVehicleProc(Vehicle *v, void *data) -{ - if (v->tile != *(const TileIndex*)data || v->type == VEH_DISASTER || (v->type == VEH_AIRCRAFT && v->subtype == AIR_SHADOW)) - return NULL; - - _error_message = VehicleInTheWayErrMsg(v); - return v; -} - -bool EnsureNoVehicle(TileIndex tile) -{ - return VehicleFromPos(tile, &tile, EnsureNoVehicleProc) == NULL; -} - static void *EnsureNoVehicleProcZ(Vehicle *v, void *data) { const TileInfo *ti = (const TileInfo*)data; diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index d58003fab..edaf1660a 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -105,11 +105,11 @@ static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags) if (!IsShipDepot(tile)) return CMD_ERROR; if (!CheckTileOwnership(tile)) return CMD_ERROR; - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; tile2 = GetOtherShipDepotTile(tile); - if (!EnsureNoVehicle(tile2)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile2)) return CMD_ERROR; if (flags & DC_EXEC) { /* Kill the depot, which is registered at the northernmost tile. Use that one */ @@ -172,7 +172,7 @@ static CommandCost RemoveShiplift(TileIndex tile, uint32 flags) if (!CheckTileOwnership(tile) && GetTileOwner(tile) != OWNER_NONE) return CMD_ERROR; /* make sure no vehicle is on the tile. */ - if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta)) + if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile + delta) || !EnsureNoVehicleOnGround(tile - delta)) return CMD_ERROR; if (flags & DC_EXEC) { @@ -303,7 +303,7 @@ static CommandCost ClearTile_Water(TileIndex tile, byte flags) } /* Make sure no vehicle is on the tile */ - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE && !CheckTileOwnership(tile)) return CMD_ERROR; @@ -314,7 +314,7 @@ static CommandCost ClearTile_Water(TileIndex tile, byte flags) Slope slope = GetTileSlope(tile, NULL); /* Make sure no vehicle is on the tile */ - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (flags & DC_EXEC) DoClearSquare(tile); if (slope == SLOPE_N || slope == SLOPE_E || slope == SLOPE_S || slope == SLOPE_W) { diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 34e6a7d8b..c4422f8d4 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -175,7 +175,7 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint3 } if (!CheckTileOwnership(tile)) return CMD_ERROR; - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; tileh = GetTileSlope(tile, NULL); if (tileh != SLOPE_FLAT && @@ -276,7 +276,7 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove) if (!IsTileType(tile, MP_RAILWAY) || !IsRailWaypoint(tile) || (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) || - !EnsureNoVehicle(tile)) { + !EnsureNoVehicleOnGround(tile)) { return CMD_ERROR; } |