Mercurial > hg > openttd
changeset 7758:013f54f32e5e draft
(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.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Fri, 19 Oct 2007 22:46:55 +0000 |
parents | 47c2afb5b9ff |
children | b9b3e3b75b92 |
files | src/ai/trolly/build.cpp src/ai/trolly/trolly.cpp src/disaster_cmd.cpp src/functions.h src/industry_cmd.cpp src/road_cmd.cpp src/station_cmd.cpp src/tunnelbridge_cmd.cpp src/vehicle.cpp src/water_cmd.cpp src/waypoint.cpp |
diffstat | 11 files changed, 23 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ai/trolly/build.cpp +++ b/src/ai/trolly/build.cpp @@ -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; }
--- a/src/ai/trolly/trolly.cpp +++ b/src/ai/trolly/trolly.cpp @@ -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);
--- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -60,7 +60,7 @@ static void DisasterClearSquare(TileIndex tile) { - if (!EnsureNoVehicle(tile)) return; + if (!EnsureNoVehicleOnGround(tile)) return; switch (GetTileType(tile)) { case MP_RAILWAY:
--- a/src/functions.h +++ b/src/functions.h @@ -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); /**
--- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -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);
--- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -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);
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -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);
--- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -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;
--- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -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;
--- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -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) {
--- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -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; }