# HG changeset patch # User rubidium # Date 1192834015 0 # Node ID 17ad53748c7b5b00cdb1c21c56303c6d08920489 # Parent 3e63b119a5bf64f0978918f516fa091e17e108c8 (svn r11303) -Fix: EnsureNoVehicle and EnsureNoVehicleOnGround were both used to check whether there was no vehicle on the ground, except that the former didn't take care of aircraft shadows. So now we only use EnsureNoVehicleOnGround. diff -r 3e63b119a5bf -r 17ad53748c7b src/ai/trolly/build.cpp --- a/src/ai/trolly/build.cpp Fri Oct 19 21:14:38 2007 +0000 +++ b/src/ai/trolly/build.cpp Fri Oct 19 22:46:55 2007 +0000 @@ -185,10 +185,10 @@ // 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 @@ // 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 @@ 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 -r 3e63b119a5bf -r 17ad53748c7b src/ai/trolly/trolly.cpp --- a/src/ai/trolly/trolly.cpp Fri Oct 19 21:14:38 2007 +0000 +++ b/src/ai/trolly/trolly.cpp Fri Oct 19 22:46:55 2007 +0000 @@ -1111,7 +1111,7 @@ } // 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 -r 3e63b119a5bf -r 17ad53748c7b src/disaster_cmd.cpp --- a/src/disaster_cmd.cpp Fri Oct 19 21:14:38 2007 +0000 +++ b/src/disaster_cmd.cpp Fri Oct 19 22:46:55 2007 +0000 @@ -60,7 +60,7 @@ static void DisasterClearSquare(TileIndex tile) { - if (!EnsureNoVehicle(tile)) return; + if (!EnsureNoVehicleOnGround(tile)) return; switch (GetTileType(tile)) { case MP_RAILWAY: diff -r 3e63b119a5bf -r 17ad53748c7b src/functions.h --- a/src/functions.h Fri Oct 19 21:14:38 2007 +0000 +++ b/src/functions.h Fri Oct 19 22:46:55 2007 +0000 @@ -132,7 +132,6 @@ 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 -r 3e63b119a5bf -r 17ad53748c7b src/industry_cmd.cpp --- a/src/industry_cmd.cpp Fri Oct 19 21:14:38 2007 +0000 +++ b/src/industry_cmd.cpp Fri Oct 19 22:46:55 2007 +0000 @@ -1221,7 +1221,7 @@ 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 -r 3e63b119a5bf -r 17ad53748c7b src/road_cmd.cpp --- a/src/road_cmd.cpp Fri Oct 19 21:14:38 2007 +0000 +++ b/src/road_cmd.cpp Fri Oct 19 22:46:55 2007 +0000 @@ -820,7 +820,7 @@ 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 -r 3e63b119a5bf -r 17ad53748c7b src/station_cmd.cpp --- a/src/station_cmd.cpp Fri Oct 19 21:14:38 2007 +0000 +++ b/src/station_cmd.cpp Fri Oct 19 22:46:55 2007 +0000 @@ -1128,7 +1128,7 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 -r 3e63b119a5bf -r 17ad53748c7b src/tunnelbridge_cmd.cpp --- a/src/tunnelbridge_cmd.cpp Fri Oct 19 21:14:38 2007 +0000 +++ b/src/tunnelbridge_cmd.cpp Fri Oct 19 22:46:55 2007 +0000 @@ -376,7 +376,7 @@ 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 -r 3e63b119a5bf -r 17ad53748c7b src/vehicle.cpp --- a/src/vehicle.cpp Fri Oct 19 21:14:38 2007 +0000 +++ b/src/vehicle.cpp Fri Oct 19 22:46:55 2007 +0000 @@ -117,20 +117,6 @@ } } -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 -r 3e63b119a5bf -r 17ad53748c7b src/water_cmd.cpp --- a/src/water_cmd.cpp Fri Oct 19 21:14:38 2007 +0000 +++ b/src/water_cmd.cpp Fri Oct 19 22:46:55 2007 +0000 @@ -105,11 +105,11 @@ 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 @@ 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 @@ } /* 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 @@ 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 -r 3e63b119a5bf -r 17ad53748c7b src/waypoint.cpp --- a/src/waypoint.cpp Fri Oct 19 21:14:38 2007 +0000 +++ b/src/waypoint.cpp Fri Oct 19 22:46:55 2007 +0000 @@ -175,7 +175,7 @@ } 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 @@ if (!IsTileType(tile, MP_RAILWAY) || !IsRailWaypoint(tile) || (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) || - !EnsureNoVehicle(tile)) { + !EnsureNoVehicleOnGround(tile)) { return CMD_ERROR; }