changeset 8961:b33bcd7fa037 draft

(svn r12753) -Codechange: do not use IsDepotTypeTile() where simpler function can be used
author smatz <smatz@openttd.org>
date Thu, 17 Apr 2008 18:24:45 +0000
parents 4bfe53511dc9
children 322e2779f67a
files src/ai/default/default.cpp src/ai/trolly/pathfinder.cpp src/ai/trolly/trolly.cpp src/npf.cpp src/openttd.cpp src/order_cmd.cpp src/order_gui.cpp src/pathfind.cpp src/rail_cmd.cpp src/roadveh_cmd.cpp src/ship_cmd.cpp src/train_cmd.cpp src/vehicle.cpp src/yapf/yapf_destrail.hpp src/yapf/yapf_road.cpp
diffstat 15 files changed, 38 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -330,7 +330,7 @@
 	EngineID veh;
 
 	// wait until the vehicle reaches the depot.
-	if (!IsDepotTypeTile(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) {
+	if (!IsRailDepotTile(v->tile) || v->u.rail.track != TRACK_BIT_DEPOT || !(v->vehstatus & VS_STOPPED)) {
 		AiHandleGotoDepot(p, CMD_SEND_TRAIN_TO_DEPOT);
 		return;
 	}
@@ -2886,7 +2886,7 @@
 	are.dest = _players_ai[p->index].cur_tile_b;
 	tile = TILE_MASK(_players_ai[p->index].cur_tile_a + TileOffsByDiagDir(dir));
 
-	if (IsRoadStopTile(tile) || IsDepotTypeTile(tile, TRANSPORT_ROAD)) return false;
+	if (IsRoadStopTile(tile) || IsRoadDepotTile(tile)) return false;
 	TrackdirBits bits = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ROADTYPES_ROAD)) & DiagdirReachesTrackdirs(dir);
 	if (bits == TRACKDIR_BIT_NONE) return false;
 
@@ -3606,7 +3606,7 @@
 	if (v->owner == _current_player) {
 		if (v->type == VEH_TRAIN) {
 
-			if (!IsDepotTypeTile(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) {
+			if (!IsRailDepotTile(v->tile) || v->u.rail.track != TRACK_BIT_DEPOT || !(v->vehstatus & VS_STOPPED)) {
 				if (!v->current_order.IsType(OT_GOTO_DEPOT))
 					DoCommand(0, v->index, 0, DC_EXEC, CMD_SEND_TRAIN_TO_DEPOT);
 				goto going_to_depot;
--- a/src/ai/trolly/pathfinder.cpp
+++ b/src/ai/trolly/pathfinder.cpp
@@ -45,7 +45,7 @@
 {
 	return
 		// MP_ROAD, but not a road depot?
-		(IsTileType(tile, MP_ROAD) && !IsDepotTypeTile(tile, TRANSPORT_ROAD)) ||
+		(IsTileType(tile, MP_ROAD) && !IsRoadDepot(tile)) ||
 		(IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD);
 }
 
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -1254,8 +1254,8 @@
 
 			// We are already sending him back
 			if (AiNew_GetSpecialVehicleFlag(p, v) & AI_VEHICLEFLAG_SELL) {
-				if (v->type == VEH_ROAD && IsDepotTypeTile(v->tile, TRANSPORT_ROAD) &&
-						(v->vehstatus&VS_STOPPED)) {
+				if (v->type == VEH_ROAD && IsRoadDepotTile(v->tile) &&
+						(v->vehstatus & VS_STOPPED)) {
 					// We are at the depot, sell the vehicle
 					AI_DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
 				}
--- a/src/npf.cpp
+++ b/src/npf.cpp
@@ -231,14 +231,14 @@
 	switch (GetTileType(tile)) {
 		case MP_RAILWAY:
 			/* DEBUG: mark visited tiles by mowing the grass under them ;-) */
-			if (!IsDepotTypeTile(tile, TRANSPORT_RAIL)) {
+			if (!IsRailDepot(tile)) {
 				SetRailGroundType(tile, RAIL_GROUND_BARREN);
 				MarkTileDirtyByTile(tile);
 			}
 			break;
 
 		case MP_ROAD:
-			if (!IsDepotTypeTile(tile, TRANSPORT_ROAD)) {
+			if (!IsRoadDepot(tile)) {
 				SetRoadside(tile, ROADSIDE_BARREN);
 				MarkTileDirtyByTile(tile);
 			}
@@ -397,7 +397,7 @@
 	 *      curves should be taken into account, as this affects the speed limit. */
 
 	/* Check for reverse in depot */
-	if (IsDepotTypeTile(tile, TRANSPORT_RAIL) && as->EndNodeCheck(as, &new_node) != AYSTAR_FOUND_END_NODE) {
+	if (IsRailDepotTile(tile) && as->EndNodeCheck(as, &new_node) != AYSTAR_FOUND_END_NODE) {
 		/* Penalise any depot tile that is not the last tile in the path. This
 		 * _should_ penalise every occurence of reversing in a depot (and only
 		 * that) */
@@ -464,9 +464,9 @@
  */
 static bool CanEnterTileOwnerCheck(Owner owner, TileIndex tile, DiagDirection enterdir)
 {
-	if (IsTileType(tile, MP_RAILWAY) ||           /* Rail tile (also rail depot) */
-			IsRailwayStationTile(tile) ||               /* Rail station tile */
-			IsDepotTypeTile(tile, TRANSPORT_ROAD) ||  /* Road depot tile */
+	if (IsTileType(tile, MP_RAILWAY) ||             /* Rail tile (also rail depot) */
+			IsRailwayStationTile(tile) ||   /* Rail station tile */
+			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 */
 	}
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1874,7 +1874,7 @@
 					}
 
 					/* Clear PBS reservation on track */
-					if (!IsDepotTypeTile(t, TRANSPORT_RAIL)) {
+					if (!IsRailDepotTile(t)) {
 						SB(_m[t].m4, 4, 4, 0);
 					} else {
 						ClrBit(_m[t].m3, 6);
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -392,15 +392,15 @@
 
 					switch (v->type) {
 						case VEH_TRAIN:
-							if (!IsDepotTypeTile(dp->xy, TRANSPORT_RAIL)) return CMD_ERROR;
+							if (!IsRailDepotTile(dp->xy)) return CMD_ERROR;
 							break;
 
 						case VEH_ROAD:
-							if (!IsDepotTypeTile(dp->xy, TRANSPORT_ROAD)) return CMD_ERROR;
+							if (!IsRoadDepotTile(dp->xy)) return CMD_ERROR;
 							break;
 
 						case VEH_SHIP:
-							if (!IsDepotTypeTile(dp->xy, TRANSPORT_WATER)) return CMD_ERROR;
+							if (!IsShipDepotTile(dp->xy)) return CMD_ERROR;
 							break;
 
 						default: return CMD_ERROR;
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -462,8 +462,7 @@
 
 			case MP_WATER:
 				if (v->type != VEH_SHIP) break;
-				if (IsDepotTypeTile(tile, TRANSPORT_WATER) &&
-						IsTileOwner(tile, _local_player)) {
+				if (IsShipDepot(tile) && IsTileOwner(tile, _local_player)) {
 					TileIndex tile2 = GetOtherShipDepotTile(tile);
 
 					order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS);
--- a/src/pathfind.cpp
+++ b/src/pathfind.cpp
@@ -170,10 +170,10 @@
 {
 	if (tracktype == TRANSPORT_RAIL) {
 		/* depot from wrong side */
-		if (IsDepotTypeTile(tile, TRANSPORT_RAIL) && GetRailDepotDirection(tile) != side) return false;
+		if (IsRailDepotTile(tile) && GetRailDepotDirection(tile) != side) return false;
 	} else if (tracktype == TRANSPORT_ROAD) {
 		/* depot from wrong side */
-		if (IsDepotTypeTile(tile, TRANSPORT_ROAD) && GetRoadDepotDirection(tile) != side) return false;
+		if (IsRoadDepotTile(tile) && GetRoadDepotDirection(tile) != side) return false;
 		/* non-driverthrough road station from wrong side */
 		if (IsStandardRoadStopTile(tile) && GetRoadStopDir(tile) != side) return false;
 	}
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2268,7 +2268,7 @@
 	int length;
 
 	/* this routine applies only to trains in depot tiles */
-	if (v->type != VEH_TRAIN || !IsDepotTypeTile(tile, TRANSPORT_RAIL)) return VETSB_CONTINUE;
+	if (v->type != VEH_TRAIN || !IsRailDepotTile(tile)) return VETSB_CONTINUE;
 
 	/* depot direction */
 	dir = GetRailDepotDirection(tile);
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -178,7 +178,7 @@
 
 	/* The ai_new queries the vehicle cost before building the route,
 	 * so we must check against cheaters no sooner than now. --pasky */
-	if (!IsDepotTypeTile(tile, TRANSPORT_ROAD)) return CMD_ERROR;
+	if (!IsRoadDepotTile(tile)) return CMD_ERROR;
 	if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
 
 	if (HasTileRoadType(tile, ROADTYPE_TRAM) != HasBit(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE);
@@ -340,7 +340,7 @@
 {
 	TileIndex tile = v->tile;
 
-	if (!IsDepotTypeTile(tile, TRANSPORT_ROAD)) return false;
+	if (!IsRoadDepotTile(tile)) return false;
 	if (IsRoadVehFront(v) && !(v->vehstatus & VS_STOPPED)) return false;
 
 	for (; v != NULL; v = v->Next()) {
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -130,7 +130,7 @@
 
 	FOR_ALL_DEPOTS(depot) {
 		TileIndex tile = depot->xy;
-		if (IsDepotTypeTile(tile, TRANSPORT_WATER) && IsTileOwner(tile, v->owner)) {
+		if (IsShipDepotTile(tile) && IsTileOwner(tile, v->owner)) {
 			uint dist = DistanceManhattan(tile, v->tile);
 			if (dist < best_dist) {
 				best_dist = dist;
@@ -762,7 +762,7 @@
 
 	/* The ai_new queries the vehicle cost before building the route,
 	 * so we must check against cheaters no sooner than now. --pasky */
-	if (!IsDepotTypeTile(tile, TRANSPORT_WATER)) return CMD_ERROR;
+	if (!IsShipDepotTile(tile)) return CMD_ERROR;
 	if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
 
 	unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP);
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -678,7 +678,7 @@
 	/* Check if the train is actually being built in a depot belonging
 	 * to the player. Doesn't matter if only the cost is queried */
 	if (!(flags & DC_QUERY_COST)) {
-		if (!IsDepotTypeTile(tile, TRANSPORT_RAIL)) return CMD_ERROR;
+		if (!IsRailDepotTile(tile)) return CMD_ERROR;
 		if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
 	}
 
@@ -806,7 +806,7 @@
 	TileIndex tile = v->tile;
 
 	/* check if stopped in a depot */
-	if (!IsDepotTypeTile(tile, TRANSPORT_RAIL) || v->cur_speed != 0) return -1;
+	if (!IsRailDepotTile(tile) || v->cur_speed != 0) return -1;
 
 	int count = 0;
 	for (; v != NULL; v = v->Next()) {
@@ -1787,7 +1787,7 @@
 
 static void ReverseTrainDirection(Vehicle *v)
 {
-	if (IsDepotTypeTile(v->tile, TRANSPORT_RAIL)) {
+	if (IsRailDepotTile(v->tile)) {
 		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 	}
 
@@ -1807,7 +1807,7 @@
 
 	AdvanceWagonsAfterSwap(v);
 
-	if (IsDepotTypeTile(v->tile, TRANSPORT_RAIL)) {
+	if (IsRailDepotTile(v->tile)) {
 		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 	}
 
@@ -2035,7 +2035,7 @@
 	tfdd.reverse = false;
 
 	TileIndex tile = v->tile;
-	if (IsDepotTypeTile(tile, TRANSPORT_RAIL)) {
+	if (IsRailDepotTile(tile)) {
 		tfdd.tile = tile;
 		tfdd.best_length = 0;
 		return tfdd;
@@ -2154,7 +2154,7 @@
 		}
 
 		/* No smoke in depots or tunnels */
-		if (IsDepotTypeTile(v->tile, TRANSPORT_RAIL) || IsTunnelTile(v->tile)) continue;
+		if (IsRailDepotTile(v->tile) || IsTunnelTile(v->tile)) continue;
 
 		/* No sparks for electric vehicles on nonelectrified tracks */
 		if (!HasPowerOnRail(v->u.rail.railtype, GetTileRailType(v->tile))) continue;
@@ -3149,7 +3149,7 @@
 	if (IsLevelCrossingTile(tile)) UpdateLevelCrossing(tile);
 
 	/* Update signals */
-	if (IsTileType(tile, MP_TUNNELBRIDGE) || IsDepotTypeTile(tile, TRANSPORT_RAIL)) {
+	if (IsTileType(tile, MP_TUNNELBRIDGE) || IsRailDepotTile(tile)) {
 		UpdateSignalsOnSegment(tile, INVALID_DIAGDIR, owner);
 	} else {
 		SetSignalsOnBothDir(tile, (Track)(FIND_FIRST_BIT(track)), owner);
@@ -3311,7 +3311,7 @@
 	}
 
 	/* entering a depot? */
-	if (IsDepotTypeTile(tile, TRANSPORT_RAIL)) {
+	if (IsRailDepotTile(tile)) {
 		DiagDirection dir = ReverseDiagDir(GetRailDepotDirection(tile));
 		if (DiagDirToDir(dir) == v->direction) return false;
 	}
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -3217,7 +3217,7 @@
 
 	/* check if at a standstill (not stopped only) in a depot
 	 * the check is down here to make it possible to alter stop/service for trains entering the depot */
-	if (this->type == VEH_TRAIN && IsDepotTypeTile(this->tile, TRANSPORT_RAIL) && this->cur_speed == 0) return CMD_ERROR;
+	if (this->type == VEH_TRAIN && IsRailDepotTile(this->tile) && this->cur_speed == 0) return CMD_ERROR;
 
 	TileIndex location;
 	DestinationID destination;
--- a/src/yapf/yapf_destrail.hpp
+++ b/src/yapf/yapf_destrail.hpp
@@ -43,7 +43,7 @@
 	/// Called by YAPF to detect if node ends in the desired destination
 	FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
 	{
-		bool bDest = IsDepotTypeTile(tile, TRANSPORT_RAIL);
+		bool bDest = IsRailDepotTile(tile);
 		return bDest;
 	}
 
--- a/src/yapf/yapf_road.cpp
+++ b/src/yapf/yapf_road.cpp
@@ -87,7 +87,7 @@
 			if (v->current_order.IsType(OT_GOTO_STATION) && tile == v->dest_tile) break;
 
 			// stop if we have just entered the depot
-			if (IsDepotTypeTile(tile, TRANSPORT_ROAD) && trackdir == DiagdirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) {
+			if (IsRoadDepotTile(tile) && trackdir == DiagdirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) {
 				// next time we will reverse and leave the depot
 				break;
 			}
@@ -148,7 +148,7 @@
 	/// Called by YAPF to detect if node ends in the desired destination
 	FORCEINLINE bool PfDetectDestination(Node& n)
 	{
-		bool bDest = IsDepotTypeTile(n.m_segment_last_tile, TRANSPORT_ROAD);
+		bool bDest = IsRoadDepotTile(n.m_segment_last_tile);
 		return bDest;
 	}
 
@@ -370,7 +370,7 @@
 		// get found depot tile
 		Node *n = Yapf().GetBestNode();
 		TileIndex depot_tile = n->m_segment_last_tile;
-		assert(IsDepotTypeTile(depot_tile, TRANSPORT_ROAD));
+		assert(IsRoadDepotTile(depot_tile));
 		Depot* ret = GetDepotByTile(depot_tile);
 		return ret;
 	}
@@ -439,7 +439,7 @@
 		return NULL;
 
 	// handle the case when our vehicle is already in the depot tile
-	if (IsTileType(tile, MP_ROAD) && IsDepotTypeTile(tile, TRANSPORT_ROAD)) {
+	if (IsRoadDepotTile(tile)) {
 		// only what we need to return is the Depot*
 		return GetDepotByTile(tile);
 	}