diff options
author | smatz <smatz@openttd.org> | 2008-09-09 12:26:25 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-09-09 12:26:25 +0000 |
commit | f503c7c99e5322ea68336d9fa48c208722df9668 (patch) | |
tree | 6bd21c91c8943ef78a3129350c28c9e50daccb89 /src | |
parent | a527d237aa3af230dd95447916822985ae1c1e11 (diff) | |
download | openttd-f503c7c99e5322ea68336d9fa48c208722df9668.tar.xz |
(svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_station.cpp | 5 | ||||
-rw-r--r-- | src/openttd.cpp | 3 | ||||
-rw-r--r-- | src/order_gui.cpp | 5 | ||||
-rw-r--r-- | src/rail_map.h | 11 | ||||
-rw-r--r-- | src/waypoint.cpp | 3 | ||||
-rw-r--r-- | src/waypoint.h | 2 |
6 files changed, 17 insertions, 12 deletions
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 87e98ef91..f90ae845c 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -244,8 +244,7 @@ static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool ch TileIndex new_tile = TILE_ADD(tile, delta); if (waypoint) { - if (!IsTileType(new_tile, MP_RAILWAY)) break; - if (!IsRailWaypoint(new_tile)) break; + if (!IsRailWaypointTile(new_tile)) break; if (check_axis && GetWaypointAxis(new_tile) != orig_axis) break; } else { if (!IsRailwayStationTile(new_tile)) break; @@ -407,7 +406,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by case 0x42: return GetTerrainType(tile) | (GetRailType(tile) << 8); case 0x43: return st->owner; // Station owner case 0x44: - if (IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile)) { + if (IsRailWaypointTile(tile)) { return GetDepotWaypointReservation(tile) ? 7 : 4; } else { return GetRailwayStationReservation(tile) ? 7 : 4; // PBS status diff --git a/src/openttd.cpp b/src/openttd.cpp index 73589937c..e37e60627 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2539,9 +2539,8 @@ bool AfterLoadGame() /* Give owners to waypoints, based on rail tracks it is sitting on. * If none is available, specify OWNER_NONE */ Waypoint *wp; - Owner owner; FOR_ALL_WAYPOINTS(wp) { - owner = (IsTileType(wp->xy, MP_RAILWAY) && IsRailWaypoint(wp->xy) ? GetTileOwner(wp->xy) : OWNER_NONE); + Owner owner = (IsRailWaypointTile(wp->xy) ? GetTileOwner(wp->xy) : OWNER_NONE); wp->owner = IsValidPlayerID(owner) ? owner : OWNER_NONE; } } diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 9b840ffbf..32c4abd51 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -318,10 +318,9 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) } /* check waypoint */ - if (IsTileType(tile, MP_RAILWAY) && + if (IsRailWaypointTile(tile) && v->type == VEH_TRAIN && - IsTileOwner(tile, _local_player) && - IsRailWaypoint(tile)) { + IsTileOwner(tile, _local_player)) { order.MakeGoToWaypoint(GetWaypointByTile(tile)->index); if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); return order; diff --git a/src/rail_map.h b/src/rail_map.h index 0937da730..a6077cf0d 100644 --- a/src/rail_map.h +++ b/src/rail_map.h @@ -83,6 +83,16 @@ static inline bool IsRailWaypoint(TileIndex t) } /** + * Is this tile rail tile and a rail waypoint? + * @param t the tile to get the information from + * @return true if and only if the tile is a rail waypoint + */ +static inline bool IsRailWaypointTile(TileIndex t) +{ + return IsTileType(t, MP_RAILWAY) && IsRailWaypoint(t); +} + +/** * Is this rail tile a rail depot? * @param t the tile to get the information from * @pre IsTileType(t, MP_RAILWAY) @@ -96,7 +106,6 @@ static inline bool IsRailDepot(TileIndex t) /** * Is this tile rail tile and a rail depot? * @param t the tile to get the information from - * @pre IsTileType(t, MP_RAILWAY) * @return true if and only if the tile is a rail depot */ static inline bool IsRailDepotTile(TileIndex t) diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 3d6ed983e..e36668db6 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -309,8 +309,7 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove) Waypoint *wp; /* Make sure it's a waypoint */ - if (!IsTileType(tile, MP_RAILWAY) || - !IsRailWaypoint(tile) || + if (!IsRailWaypointTile(tile) || (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) || !EnsureNoVehicleOnGround(tile)) { return CMD_ERROR; diff --git a/src/waypoint.h b/src/waypoint.h index a0742940e..2692ad5ea 100644 --- a/src/waypoint.h +++ b/src/waypoint.h @@ -55,7 +55,7 @@ static inline bool IsValidWaypointID(WaypointID index) */ static inline Waypoint *GetWaypointByTile(TileIndex tile) { - assert(IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile)); + assert(IsRailWaypointTile(tile)); return GetWaypoint(GetWaypointIndex(tile)); } |