summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-24 11:15:11 +0000
committerrubidium <rubidium@openttd.org>2009-07-24 11:15:11 +0000
commit2c6b5237f68b1ce444f35eef6e31e7c0ff49d7cc (patch)
treea327b740ebd6f71336780c857326fe41fbe56683
parent07447a1766145231e97b39993ec55d01e9be7bca (diff)
downloadopenttd-2c6b5237f68b1ce444f35eef6e31e7c0ff49d7cc.tar.xz
(svn r16938) -Codechange: introduce helper function to tell whether a tile is either a rail station or rail waypoint tile
-rw-r--r--src/ai/api/ai_rail.cpp2
-rw-r--r--src/elrail.cpp2
-rw-r--r--src/newgrf_commons.cpp2
-rw-r--r--src/newgrf_station.cpp4
-rw-r--r--src/npf.cpp2
-rw-r--r--src/pbs.cpp6
-rw-r--r--src/rail.cpp2
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/rail_gui.cpp2
-rw-r--r--src/saveload/afterload.cpp2
-rw-r--r--src/signal.cpp2
-rw-r--r--src/station_map.h22
12 files changed, 36 insertions, 14 deletions
diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp
index 05dad3fb3..766c23d53 100644
--- a/src/ai/api/ai_rail.cpp
+++ b/src/ai/api/ai_rail.cpp
@@ -17,7 +17,7 @@
if (!::IsValidTile(tile)) return false;
return (::IsTileType(tile, MP_RAILWAY) && !::IsRailDepot(tile)) ||
- (::IsRailwayStationTile(tile) && !::IsStationTileBlocked(tile)) || ::IsLevelCrossingTile(tile);
+ (::HasStationTileRail(tile) && !::IsStationTileBlocked(tile)) || ::IsLevelCrossingTile(tile);
}
/* static */ bool AIRail::IsLevelCrossingTile(TileIndex tile)
diff --git a/src/elrail.cpp b/src/elrail.cpp
index 8c6dffffe..9fc776f9a 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -99,7 +99,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
return GetCrossingRailBits(t);
case MP_STATION:
- if (!IsRailwayStation(t) && !IsRailWaypoint(t)) return TRACK_BIT_NONE;
+ if (!HasStationRail(t)) return TRACK_BIT_NONE;
if (!HasCatenary(GetRailType(t))) return TRACK_BIT_NONE;
if (!IsStationTileElectrifiable(t)) return TRACK_BIT_NONE;
return TrackToTrackBits(GetRailStationTrack(t));
diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp
index acda32481..150402647 100644
--- a/src/newgrf_commons.cpp
+++ b/src/newgrf_commons.cpp
@@ -291,7 +291,7 @@ TileIndex GetNearbyTile(byte parameter, TileIndex tile)
if (y >= 8) y -= 16;
/* Swap width and height depending on axis for railway stations */
- if (IsRailwayStationTile(tile) && GetRailStationAxis(tile) == AXIS_Y) Swap(x, y);
+ if (HasStationTileRail(tile) && GetRailStationAxis(tile) == AXIS_Y) Swap(x, y);
/* Make sure we never roam outside of the map, better wrap in that case */
return TILE_MASK(tile + TileDiffXY(x, y));
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index 8b57b7c7b..950af1892 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -283,7 +283,7 @@ static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool ch
TileIndex new_tile = TILE_ADD(tile, delta);
if (!IsTileType(new_tile, MP_STATION) || GetStationIndex(new_tile) != sid) break;
- if (!IsRailwayStation(new_tile) && !IsRailWaypoint(new_tile)) break;
+ if (!HasStationRail(new_tile)) break;
if (check_type && GetCustomStationSpecIndex(new_tile) != orig_type) break;
if (check_axis && GetRailStationAxis(new_tile) != orig_axis) break;
@@ -479,7 +479,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
case 0x68: { // Station info of nearby tiles
TileIndex nearby_tile = GetNearbyTile(parameter, tile);
- if (!IsRailwayStationTile(nearby_tile)) return 0xFFFFFFFF;
+ if (!HasStationTileRail(nearby_tile)) return 0xFFFFFFFF;
uint32 grfid = st->speclist[GetCustomStationSpecIndex(tile)].grfid;
bool perpendicular = GetRailStationAxis(tile) != GetRailStationAxis(nearby_tile);
diff --git a/src/npf.cpp b/src/npf.cpp
index 34a2a9d55..dbdd93ec4 100644
--- a/src/npf.cpp
+++ b/src/npf.cpp
@@ -550,7 +550,7 @@ static void NPFSaveTargetData(AyStar *as, OpenListNode *current)
static bool CanEnterTileOwnerCheck(Owner owner, TileIndex tile, DiagDirection enterdir)
{
if (IsTileType(tile, MP_RAILWAY) || // Rail tile (also rail depot)
- IsRailwayStationTile(tile) || // Rail station tile
+ HasStationTileRail(tile) || // Rail station tile/waypoint
IsRoadDepotTile(tile) || // Road depot tile
IsStandardRoadStopTile(tile)) { // Road station tile (but not drive-through stops)
return IsTileOwner(tile, owner); // You need to own these tiles entirely to use them
diff --git a/src/pbs.cpp b/src/pbs.cpp
index 5045fc0f8..32440f914 100644
--- a/src/pbs.cpp
+++ b/src/pbs.cpp
@@ -26,7 +26,7 @@ TrackBits GetReservedTrackbits(TileIndex t)
break;
case MP_STATION:
- if (IsRailwayStation(t) || IsRailWaypoint(t)) return GetStationReservationTrackBits(t);
+ if (HasStationRail(t)) return GetStationReservationTrackBits(t);
break;
case MP_TUNNELBRIDGE:
@@ -99,7 +99,7 @@ bool TryReserveRailTrack(TileIndex tile, Track t)
break;
case MP_STATION:
- if ((IsRailwayStation(tile) || IsRailWaypoint(tile)) && !HasStationReservation(tile)) {
+ if (HasStationRail(tile) && !HasStationReservation(tile)) {
SetRailwayStationReservation(tile, true);
MarkTileDirtyByTile(tile); // some GRFs need redraw after reserving track
return true;
@@ -150,7 +150,7 @@ bool TryReserveRailTrack(TileIndex tile, Track t)
break;
case MP_STATION:
- if (IsRailwayStation(tile) || IsRailWaypoint(tile)) {
+ if (HasStationRail(tile)) {
SetRailwayStationReservation(tile, false);
MarkTileDirtyByTile(tile);
}
diff --git a/src/rail.cpp b/src/rail.cpp
index b5aa09fc8..6288e45ba 100644
--- a/src/rail.cpp
+++ b/src/rail.cpp
@@ -155,7 +155,7 @@ RailType GetTileRailType(TileIndex tile)
break;
case MP_STATION:
- if (IsRailwayStation(tile) || IsRailWaypoint(tile)) return GetRailType(tile);
+ if (HasStationRail(tile)) return GetRailType(tile);
break;
case MP_TUNNELBRIDGE:
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 881f09413..05497a898 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1280,7 +1280,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
case MP_RAILWAY:
break;
case MP_STATION:
- if (!IsRailwayStation(tile) && !IsRailWaypoint(tile)) continue;
+ if (!HasStationRail(tile)) continue;
break;
case MP_ROAD:
if (!IsLevelCrossing(tile)) continue;
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 25ba89f8b..f6c7d667a 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1858,7 +1858,7 @@ static void SetDefaultRailGui()
RailType count[RAILTYPE_END];
memset(count, 0, sizeof(count));
for (TileIndex t = 0; t < MapSize(); t++) {
- if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || IsRailwayStationTile(t) ||
+ if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || HasStationTileRail(t) ||
(IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)) {
count[GetRailType(t)]++;
}
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index d09af136b..3326bc53e 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -959,7 +959,7 @@ bool AfterLoadGame()
break;
case MP_STATION:
- if (IsRailwayStation(t)) {
+ if (HasStationRail(t)) {
SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
}
break;
diff --git a/src/signal.cpp b/src/signal.cpp
index 680036bc6..97404a2e3 100644
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -343,7 +343,7 @@ static SigFlags ExploreSegment(Owner owner)
}
case MP_STATION:
- if (!IsRailwayStation(tile) && !IsRailWaypoint(tile)) continue;
+ if (!HasStationRail(tile)) continue;
if (GetTileOwner(tile) != owner) continue;
if (DiagDirToAxis(enterdir) != GetRailStationAxis(tile)) continue; // different axis
if (IsStationTileBlocked(tile)) continue; // 'eye-candy' station tile
diff --git a/src/station_map.h b/src/station_map.h
index ef1a7a54f..b93154899 100644
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -109,6 +109,28 @@ static inline bool IsRailWaypointTile(TileIndex t)
return IsTileType(t, MP_STATION) && IsRailWaypoint(t);
}
+/**
+ * Has this station tile a rail? In other words, is this station
+ * tile a rail station or rail waypoint?
+ * @param t the tile to check
+ * @pre IsTileType(t, MP_STATION)
+ * @return true if and only if the tile has rail
+ */
+static inline bool HasStationRail(TileIndex t)
+{
+ return IsRailwayStation(t) || IsRailWaypoint(t);
+}
+
+/**
+ * Has this station tile a rail? In other words, is this station
+ * tile a rail station or rail waypoint?
+ * @param t the tile to check
+ * @return true if and only if the tile is a station tile and has rail
+ */
+static inline bool HasStationTileRail(TileIndex t)
+{
+ return IsTileType(t, MP_STATION) && HasStationRail(t);
+}
static inline bool IsAirport(TileIndex t)
{