(svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
authorsmatz
Tue, 09 Sep 2008 12:26:25 +0000
changeset 10099 a42cafcba550
parent 10098 de9c1bd521c8
child 10100 115b73724f1a
(svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
src/newgrf_station.cpp
src/openttd.cpp
src/order_gui.cpp
src/rail_map.h
src/waypoint.cpp
src/waypoint.h
--- a/src/newgrf_station.cpp	Tue Sep 09 11:26:17 2008 +0000
+++ b/src/newgrf_station.cpp	Tue Sep 09 12:26:25 2008 +0000
@@ -244,8 +244,7 @@
 		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 @@
 		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
--- a/src/openttd.cpp	Tue Sep 09 11:26:17 2008 +0000
+++ b/src/openttd.cpp	Tue Sep 09 12:26:25 2008 +0000
@@ -2539,9 +2539,8 @@
 		/* 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;
 		}
 	}
--- a/src/order_gui.cpp	Tue Sep 09 11:26:17 2008 +0000
+++ b/src/order_gui.cpp	Tue Sep 09 12:26:25 2008 +0000
@@ -318,10 +318,9 @@
 	}
 
 	/* 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;
--- a/src/rail_map.h	Tue Sep 09 11:26:17 2008 +0000
+++ b/src/rail_map.h	Tue Sep 09 12:26:25 2008 +0000
@@ -83,6 +83,16 @@
 }
 
 /**
+ * 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 @@
 /**
  * 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)
--- a/src/waypoint.cpp	Tue Sep 09 11:26:17 2008 +0000
+++ b/src/waypoint.cpp	Tue Sep 09 12:26:25 2008 +0000
@@ -309,8 +309,7 @@
 	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;
--- a/src/waypoint.h	Tue Sep 09 11:26:17 2008 +0000
+++ b/src/waypoint.h	Tue Sep 09 12:26:25 2008 +0000
@@ -55,7 +55,7 @@
  */
 static inline Waypoint *GetWaypointByTile(TileIndex tile)
 {
-	assert(IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile));
+	assert(IsRailWaypointTile(tile));
 	return GetWaypoint(GetWaypointIndex(tile));
 }