summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-09-21 11:24:51 +0000
committerrubidium <rubidium@openttd.org>2014-09-21 11:24:51 +0000
commit9daf7e749ccb00873443e2261379bf31999664d9 (patch)
treec6121f8173938736242b84b2830058d330f1da9a
parent982f5a6aa2f600106f9bd292ebefcef52e6e65e6 (diff)
downloadopenttd-9daf7e749ccb00873443e2261379bf31999664d9.tar.xz
(svn r26879) -Codechange: remove most MayHaveBridgeAbove calls since the data is now always accessible
-rw-r--r--src/bridge_map.h12
-rw-r--r--src/elrail.cpp4
-rw-r--r--src/industry_cmd.cpp2
-rw-r--r--src/object_cmd.cpp2
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/road_cmd.cpp6
-rw-r--r--src/saveload/afterload.cpp12
-rw-r--r--src/station_cmd.cpp6
-rw-r--r--src/terraform_cmd.cpp2
-rw-r--r--src/town_cmd.cpp6
-rw-r--r--src/tunnelbridge_cmd.cpp14
-rw-r--r--src/vehicle.cpp2
-rw-r--r--src/water_cmd.cpp7
-rw-r--r--src/waypoint_cmd.cpp4
14 files changed, 38 insertions, 43 deletions
diff --git a/src/bridge_map.h b/src/bridge_map.h
index be10ab8c7..74c6974db 100644
--- a/src/bridge_map.h
+++ b/src/bridge_map.h
@@ -38,18 +38,6 @@ static inline bool IsBridgeTile(TileIndex t)
}
/**
- * checks for the possibility that a bridge may be on this tile
- * These are in fact all the tile types on which a bridge can be found
- * @param t The tile to analyze
- * @return true if a bridge might be present
- */
-static inline bool MayHaveBridgeAbove(TileIndex t)
-{
- return IsTileType(t, MP_CLEAR) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_ROAD) ||
- IsTileType(t, MP_WATER) || IsTileType(t, MP_TUNNELBRIDGE) || IsTileType(t, MP_OBJECT);
-}
-
-/**
* checks if a bridge is set above the ground of this tile
* @param t The tile to analyze
* @return true if a bridge is detected above
diff --git a/src/elrail.cpp b/src/elrail.cpp
index 8116bff2c..1927be03e 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -407,7 +407,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
* Remove those (simply by ANDing with allowed, since these markers are never allowed) */
if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i];
- if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) {
+ if (IsBridgeAbove(ti->tile)) {
Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y;
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
@@ -446,7 +446,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
if (IsTunnelTile(ti->tile)) return;
/* Don't draw a wire under a low bridge */
- if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BRIDGES)) {
+ if (IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BRIDGES)) {
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
if (height <= GetTileMaxZ(ti->tile) + 1) return;
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 34bf1ffcb..5971964fd 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1390,7 +1390,7 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
} else {
CommandCost ret = EnsureNoVehicleOnGround(cur_tile);
if (ret.Failed()) return ret;
- if (MayHaveBridgeAbove(cur_tile) && IsBridgeAbove(cur_tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
+ if (IsBridgeAbove(cur_tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
const IndustryTileSpec *its = GetIndustryTileSpec(gfx);
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 4038288d0..b5b992152 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -295,7 +295,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
/* Finally do a check for bridges. */
TILE_AREA_LOOP(t, ta) {
- if (MayHaveBridgeAbove(t) && IsBridgeAbove(t) && (
+ if (IsBridgeAbove(t) && (
!(spec->flags & OBJECT_FLAG_ALLOW_UNDER_BRIDGE) ||
(GetTileMaxZ(t) + spec->height >= GetBridgeHeight(GetSouthernBridgeEnd(t))))) {
return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index c4b2b9f43..2ba00d790 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -953,7 +953,7 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u
CommandCost cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (cost.Failed()) return cost;
- if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
+ if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
if (!Depot::CanAllocateItem()) return CMD_ERROR;
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index d20bdcfb4..46a074968 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -1015,7 +1015,7 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
CommandCost cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (cost.Failed()) return cost;
- if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
+ if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
if (!Depot::CanAllocateItem()) return CMD_ERROR;
@@ -1185,7 +1185,7 @@ void DrawTramCatenary(const TileInfo *ti, RoadBits tram)
if (IsInvisibilitySet(TO_CATENARY)) return;
/* Don't draw the catenary under a low bridge */
- if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) {
+ if (IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) {
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
if (height <= GetTileMaxZ(ti->tile) + 1) return;
@@ -1292,7 +1292,7 @@ static void DrawRoadBits(TileInfo *ti)
if (!HasBit(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom > ZOOM_LVL_DETAIL) return;
/* Do not draw details (street lights, trees) under low bridge */
- if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && (roadside == ROADSIDE_TREES || roadside == ROADSIDE_STREET_LIGHTS)) {
+ if (IsBridgeAbove(ti->tile) && (roadside == ROADSIDE_TREES || roadside == ROADSIDE_STREET_LIGHTS)) {
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
int minz = GetTileMaxZ(ti->tile) + 2;
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 514f29465..cb3eae472 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -506,6 +506,18 @@ static uint FixVehicleInclination(Vehicle *v, Direction dir)
}
/**
+ * Checks for the possibility that a bridge may be on this tile
+ * These are in fact all the tile types on which a bridge can be found
+ * @param t The tile to analyze
+ * @return True if a bridge might have been present prior to savegame 194.
+ */
+static inline bool MayHaveBridgeAbove(TileIndex t)
+{
+ return IsTileType(t, MP_CLEAR) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_ROAD) ||
+ IsTileType(t, MP_WATER) || IsTileType(t, MP_TUNNELBRIDGE) || IsTileType(t, MP_OBJECT);
+}
+
+/**
* Perform a (large) amount of savegame conversion *magic* in order to
* load older savegames and to fill the caches for various purposes.
* @return True iff conversion went without a problem.
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 91d65ad87..eb3e5de6a 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -721,7 +721,7 @@ CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags);
*/
CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z, bool allow_steep, bool check_bridge = true)
{
- if (check_bridge && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) {
+ if (check_bridge && IsBridgeAbove(tile)) {
return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
}
@@ -2489,7 +2489,7 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags);
if (ret.Failed()) return ret;
- if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
+ if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) return ret;
@@ -2500,7 +2500,7 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
}
- if (MayHaveBridgeAbove(tile_cur) && IsBridgeAbove(tile_cur)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
+ if (IsBridgeAbove(tile_cur)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
/* Get the water class of the water tile before it is cleared.*/
WaterClass wc = GetWaterClass(tile_cur);
diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp
index ce871a407..50ae42f6b 100644
--- a/src/terraform_cmd.cpp
+++ b/src/terraform_cmd.cpp
@@ -254,7 +254,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (pass == 0) {
/* Check if bridge would take damage */
- if (direction == 1 && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) &&
+ if (direction == 1 && IsBridgeAbove(tile) &&
GetBridgeHeight(GetSouthernBridgeEnd(tile)) <= z_max) {
_terraform_err_tile = tile; // highlight the tile under the bridge
return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 1c6a01eae..8c86475ef 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -868,7 +868,7 @@ static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir)
if (DistanceFromEdge(tile) == 0) return false;
/* Prevent towns from building roads under bridges along the bridge. Looks silly. */
- if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) && GetBridgeAxis(tile) == DiagDirToAxis(dir)) return false;
+ if (IsBridgeAbove(tile) && GetBridgeAxis(tile) == DiagDirToAxis(dir)) return false;
/* Check if there already is a road at this point? */
if (GetTownRoadBits(tile) == ROAD_NONE) {
@@ -2018,7 +2018,7 @@ static inline bool CanBuildHouseHere(TileIndex tile, TownID town, bool noslope)
if ((noslope && slope != SLOPE_FLAT) || IsSteepSlope(slope)) return false;
/* building under a bridge? */
- if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
+ if (IsBridgeAbove(tile)) return false;
/* do not try to build over house owned by another town */
if (IsTileType(tile, MP_HOUSE) && GetTownIndex(tile) != town) return false;
@@ -2790,7 +2790,7 @@ static bool SearchTileForStatue(TileIndex tile, void *user_data)
/* Statues can be build on slopes, just like houses. Only the steep slopes is a no go. */
if (IsSteepSlope(GetTileSlope(tile))) return false;
/* Don't build statues under bridges. */
- if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
+ if (IsBridgeAbove(tile)) return false;
/* A clear-able open space is always preferred. */
if ((IsTileType(tile, MP_CLEAR) || IsTileType(tile, MP_TREES)) && TryClearTile(tile)) {
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 9bb96538d..49b987d0a 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -376,15 +376,13 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
const TileIndex heads[] = {tile_start, tile_end};
for (int i = 0; i < 2; i++) {
- if (MayHaveBridgeAbove(heads[i])) {
- if (IsBridgeAbove(heads[i])) {
- TileIndex north_head = GetNorthernBridgeEnd(heads[i]);
+ if (IsBridgeAbove(heads[i])) {
+ TileIndex north_head = GetNorthernBridgeEnd(heads[i]);
- if (direction == GetBridgeAxis(heads[i])) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
+ if (direction == GetBridgeAxis(heads[i])) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
- if (z_start + 1 == GetBridgeHeight(north_head)) {
- return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
- }
+ if (z_start + 1 == GetBridgeHeight(north_head)) {
+ return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
}
}
}
@@ -393,7 +391,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
for (TileIndex tile = tile_start + delta; tile != tile_end; tile += delta) {
if (GetTileMaxZ(tile) > z_start) return_cmd_error(STR_ERROR_BRIDGE_TOO_LOW_FOR_TERRAIN);
- if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) {
+ if (IsBridgeAbove(tile)) {
/* Disallow crossing bridges for the time being */
return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 118ceed27..3b570ab27 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2460,7 +2460,7 @@ void Vehicle::ShowVisualEffect() const
* - The vehicle is a train engine that is currently unpowered */
if (effect_model == VESM_NONE ||
v->vehstatus & VS_HIDDEN ||
- (MayHaveBridgeAbove(v->tile) && IsBridgeAbove(v->tile)) ||
+ IsBridgeAbove(v->tile) ||
IsDepotTile(v->tile) ||
IsTunnelTile(v->tile) ||
(v->type == VEH_TRAIN &&
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 7b5272a41..7b74363be 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -109,8 +109,7 @@ CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
return_cmd_error(STR_ERROR_MUST_BE_BUILT_ON_WATER);
}
- if ((MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) ||
- (MayHaveBridgeAbove(tile2) && IsBridgeAbove(tile2))) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
+ if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
if (!IsTileFlat(tile) || !IsTileFlat(tile2)) {
/* Prevent depots on rapids */
@@ -289,9 +288,7 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
}
- if ((MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) ||
- (MayHaveBridgeAbove(tile - delta) && IsBridgeAbove(tile - delta)) ||
- (MayHaveBridgeAbove(tile + delta) && IsBridgeAbove(tile + delta))) {
+ if (IsBridgeAbove(tile) || IsBridgeAbove(tile - delta) || IsBridgeAbove(tile + delta)) {
return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
}
diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp
index 3c2701270..efa48003f 100644
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -133,7 +133,7 @@ static CommandCost IsValidTileForWaypoint(TileIndex tile, Axis axis, StationID *
return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
}
- if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
+ if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
return CommandCost();
}
@@ -289,7 +289,7 @@ CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint
CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
if (tile == 0 || !HasTileWaterGround(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
- if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
+ if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
if (!IsTileFlat(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);