summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-04-17 00:44:20 +0000
committersmatz <smatz@openttd.org>2008-04-17 00:44:20 +0000
commit966e476df839bf259a7673a8c87f7bdf456dabce (patch)
tree5f5827bd541cf5d637cd23faa64aea957404ca89 /src
parent61074c4bf86990b0d6e6188a66d15243a534eeaa (diff)
downloadopenttd-966e476df839bf259a7673a8c87f7bdf456dabce.tar.xz
(svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
Diffstat (limited to 'src')
-rw-r--r--src/ai/default/default.cpp6
-rw-r--r--src/ai/trolly/pathfinder.cpp2
-rw-r--r--src/ai/trolly/trolly.cpp2
-rw-r--r--src/depot.h21
-rw-r--r--src/npf.cpp16
-rw-r--r--src/openttd.cpp2
-rw-r--r--src/order_cmd.cpp6
-rw-r--r--src/order_gui.cpp2
-rw-r--r--src/pathfind.cpp4
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/rail_map.h22
-rw-r--r--src/roadveh_cmd.cpp4
-rw-r--r--src/ship_cmd.cpp4
-rw-r--r--src/smallmap_gui.cpp1
-rw-r--r--src/train_cmd.cpp16
-rw-r--r--src/vehicle.cpp2
-rw-r--r--src/water_map.h5
-rw-r--r--src/yapf/follow_track.hpp8
-rw-r--r--src/yapf/yapf_destrail.hpp2
-rw-r--r--src/yapf/yapf_road.cpp8
20 files changed, 70 insertions, 65 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index 9a563e96a..430f487c9 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -330,7 +330,7 @@ static void AiHandleReplaceTrain(Player *p)
EngineID veh;
// wait until the vehicle reaches the depot.
- if (!IsTileDepotType(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) {
+ if (!IsDepotTypeTile(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) {
AiHandleGotoDepot(p, CMD_SEND_TRAIN_TO_DEPOT);
return;
}
@@ -2886,7 +2886,7 @@ static bool AiCheckRoadFinished(Player *p)
are.dest = _players_ai[p->index].cur_tile_b;
tile = TILE_MASK(_players_ai[p->index].cur_tile_a + TileOffsByDiagDir(dir));
- if (IsRoadStopTile(tile) || IsTileDepotType(tile, TRANSPORT_ROAD)) return false;
+ if (IsRoadStopTile(tile) || IsDepotTypeTile(tile, TRANSPORT_ROAD)) return false;
TrackdirBits bits = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ROADTYPES_ROAD)) & DiagdirReachesTrackdirs(dir);
if (bits == TRACKDIR_BIT_NONE) return false;
@@ -3606,7 +3606,7 @@ static void AiStateSellVeh(Player *p)
if (v->owner == _current_player) {
if (v->type == VEH_TRAIN) {
- if (!IsTileDepotType(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) {
+ if (!IsDepotTypeTile(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(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;
diff --git a/src/ai/trolly/pathfinder.cpp b/src/ai/trolly/pathfinder.cpp
index b2e44fd00..36bbb748a 100644
--- a/src/ai/trolly/pathfinder.cpp
+++ b/src/ai/trolly/pathfinder.cpp
@@ -45,7 +45,7 @@ static bool IsRoad(TileIndex tile)
{
return
// MP_ROAD, but not a road depot?
- (IsTileType(tile, MP_ROAD) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
+ (IsTileType(tile, MP_ROAD) && !IsDepotTypeTile(tile, TRANSPORT_ROAD)) ||
(IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD);
}
diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp
index e047a5a29..8a419ca09 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -1254,7 +1254,7 @@ static void AiNew_CheckVehicle(Player *p, Vehicle *v)
// We are already sending him back
if (AiNew_GetSpecialVehicleFlag(p, v) & AI_VEHICLEFLAG_SELL) {
- if (v->type == VEH_ROAD && IsTileDepotType(v->tile, TRANSPORT_ROAD) &&
+ if (v->type == VEH_ROAD && IsDepotTypeTile(v->tile, TRANSPORT_ROAD) &&
(v->vehstatus&VS_STOPPED)) {
// We are at the depot, sell the vehicle
AI_DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
diff --git a/src/depot.h b/src/depot.h
index 42bd84b54..28c5275c9 100644
--- a/src/depot.h
+++ b/src/depot.h
@@ -36,23 +36,20 @@ void ShowDepotWindow(TileIndex tile, VehicleType type);
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
/**
- * Check if a tile is a depot of the given type.
+ * Check if a tile is a depot and it is a depot of the given type.
*/
-static inline bool IsTileDepotType(TileIndex tile, TransportType type)
+static inline bool IsDepotTypeTile(TileIndex tile, TransportType type)
{
switch (type) {
+ default: NOT_REACHED();
case TRANSPORT_RAIL:
- return IsTileType(tile, MP_RAILWAY) && GetRailTileType(tile) == RAIL_TILE_DEPOT;
+ return IsRailDepotTile(tile);
case TRANSPORT_ROAD:
return IsRoadDepotTile(tile);
case TRANSPORT_WATER:
- return IsTileType(tile, MP_WATER) && GetWaterTileType(tile) == WATER_TILE_DEPOT;
-
- default:
- NOT_REACHED();
- return false;
+ return IsShipDepotTile(tile);
}
}
@@ -63,13 +60,7 @@ static inline bool IsTileDepotType(TileIndex tile, TransportType type)
*/
static inline bool IsDepotTile(TileIndex tile)
{
- switch (GetTileType(tile)) {
- case MP_ROAD: return IsRoadDepot(tile);
- case MP_WATER: return GetWaterTileType(tile) == WATER_TILE_DEPOT;
- case MP_RAILWAY: return GetRailTileType(tile) == RAIL_TILE_DEPOT;
- case MP_STATION: return IsHangar(tile);
- default: return false;
- }
+ return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
}
/**
diff --git a/src/npf.cpp b/src/npf.cpp
index 2b5050307..01c5c00c3 100644
--- a/src/npf.cpp
+++ b/src/npf.cpp
@@ -231,14 +231,14 @@ static void NPFMarkTile(TileIndex tile)
switch (GetTileType(tile)) {
case MP_RAILWAY:
/* DEBUG: mark visited tiles by mowing the grass under them ;-) */
- if (!IsTileDepotType(tile, TRANSPORT_RAIL)) {
+ if (!IsDepotTypeTile(tile, TRANSPORT_RAIL)) {
SetRailGroundType(tile, RAIL_GROUND_BARREN);
MarkTileDirtyByTile(tile);
}
break;
case MP_ROAD:
- if (!IsTileDepotType(tile, TRANSPORT_ROAD)) {
+ if (!IsDepotTypeTile(tile, TRANSPORT_ROAD)) {
SetRoadside(tile, ROADSIDE_BARREN);
MarkTileDirtyByTile(tile);
}
@@ -397,7 +397,7 @@ static int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare
* curves should be taken into account, as this affects the speed limit. */
/* Check for reverse in depot */
- if (IsTileDepotType(tile, TRANSPORT_RAIL) && as->EndNodeCheck(as, &new_node) != AYSTAR_FOUND_END_NODE) {
+ if (IsDepotTypeTile(tile, TRANSPORT_RAIL) && 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) */
@@ -417,7 +417,7 @@ static int32 NPFFindDepot(AyStar* as, OpenListNode *current)
{
/* It's not worth caching the result with NPF_FLAG_IS_TARGET here as below,
* since checking the cache not that much faster than the actual check */
- return IsTileDepotType(current->path.node.tile, (TransportType)as->user_data[NPF_TYPE]) ?
+ return IsDepotTypeTile(current->path.node.tile, (TransportType)as->user_data[NPF_TYPE]) ?
AYSTAR_FOUND_END_NODE : AYSTAR_DONE;
}
@@ -466,7 +466,7 @@ static bool CanEnterTileOwnerCheck(Owner owner, TileIndex tile, DiagDirection en
{
if (IsTileType(tile, MP_RAILWAY) || /* Rail tile (also rail depot) */
IsRailwayStationTile(tile) || /* Rail station tile */
- IsTileDepotType(tile, TRANSPORT_ROAD) || /* Road depot tile */
+ IsDepotTypeTile(tile, TRANSPORT_ROAD) || /* 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 */
}
@@ -499,7 +499,7 @@ static bool CanEnterTileOwnerCheck(Owner owner, TileIndex tile, DiagDirection en
*/
static DiagDirection GetDepotDirection(TileIndex tile, TransportType type)
{
- assert(IsTileDepotType(tile, type));
+ assert(IsDepotTypeTile(tile, type));
switch (type) {
case TRANSPORT_RAIL: return GetRailDepotDirection(tile);
@@ -537,7 +537,7 @@ static DiagDirection GetSingleTramBit(TileIndex tile)
*/
static DiagDirection GetTileSingleEntry(TileIndex tile, TransportType type, uint subtype)
{
- if (type != TRANSPORT_WATER && IsTileDepotType(tile, type)) return GetDepotDirection(tile, type);
+ if (type != TRANSPORT_WATER && IsDepotTypeTile(tile, type)) return GetDepotDirection(tile, type);
if (type == TRANSPORT_ROAD) {
if (IsStandardRoadStopTile(tile)) return GetRoadStopDir(tile);
@@ -879,7 +879,7 @@ NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir,
FOR_ALL_DEPOTS(depot) {
/* Check if this is really a valid depot, it is of the needed type and
* owner */
- if (IsTileDepotType(depot->xy, type) && IsTileOwner(depot->xy, owner))
+ if (IsDepotTypeTile(depot->xy, type) && IsTileOwner(depot->xy, owner))
/* If so, let's add it to the queue, sorted by distance */
depots.push(&depots, depot, DistanceManhattan(tile, depot->xy));
}
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 3d138d7f7..3bcbfb9da 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1874,7 +1874,7 @@ bool AfterLoadGame()
}
/* Clear PBS reservation on track */
- if (!IsTileDepotType(t, TRANSPORT_RAIL)) {
+ if (!IsDepotTypeTile(t, TRANSPORT_RAIL)) {
SB(_m[t].m4, 4, 4, 0);
} else {
ClrBit(_m[t].m3, 6);
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index b6e483d4c..e2caa7196 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -392,15 +392,15 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
switch (v->type) {
case VEH_TRAIN:
- if (!IsTileDepotType(dp->xy, TRANSPORT_RAIL)) return CMD_ERROR;
+ if (!IsDepotTypeTile(dp->xy, TRANSPORT_RAIL)) return CMD_ERROR;
break;
case VEH_ROAD:
- if (!IsTileDepotType(dp->xy, TRANSPORT_ROAD)) return CMD_ERROR;
+ if (!IsDepotTypeTile(dp->xy, TRANSPORT_ROAD)) return CMD_ERROR;
break;
case VEH_SHIP:
- if (!IsTileDepotType(dp->xy, TRANSPORT_WATER)) return CMD_ERROR;
+ if (!IsDepotTypeTile(dp->xy, TRANSPORT_WATER)) return CMD_ERROR;
break;
default: return CMD_ERROR;
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 782de13ba..f5c2611f9 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -462,7 +462,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
case MP_WATER:
if (v->type != VEH_SHIP) break;
- if (IsTileDepotType(tile, TRANSPORT_WATER) &&
+ if (IsDepotTypeTile(tile, TRANSPORT_WATER) &&
IsTileOwner(tile, _local_player)) {
TileIndex tile2 = GetOtherShipDepotTile(tile);
diff --git a/src/pathfind.cpp b/src/pathfind.cpp
index 89435aa39..24180db12 100644
--- a/src/pathfind.cpp
+++ b/src/pathfind.cpp
@@ -170,10 +170,10 @@ static inline bool CanAccessTileInDir(TileIndex tile, DiagDirection side, Transp
{
if (tracktype == TRANSPORT_RAIL) {
/* depot from wrong side */
- if (IsTileDepotType(tile, TRANSPORT_RAIL) && GetRailDepotDirection(tile) != side) return false;
+ if (IsDepotTypeTile(tile, TRANSPORT_RAIL) && GetRailDepotDirection(tile) != side) return false;
} else if (tracktype == TRANSPORT_ROAD) {
/* depot from wrong side */
- if (IsTileDepotType(tile, TRANSPORT_ROAD) && GetRoadDepotDirection(tile) != side) return false;
+ if (IsDepotTypeTile(tile, TRANSPORT_ROAD) && GetRoadDepotDirection(tile) != side) return false;
/* non-driverthrough road station from wrong side */
if (IsStandardRoadStopTile(tile) && GetRoadStopDir(tile) != side) return false;
}
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 673ad404f..4d4a596ee 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2268,7 +2268,7 @@ static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *v, TileIndex tile, int
int length;
/* this routine applies only to trains in depot tiles */
- if (v->type != VEH_TRAIN || !IsTileDepotType(tile, TRANSPORT_RAIL)) return VETSB_CONTINUE;
+ if (v->type != VEH_TRAIN || !IsDepotTypeTile(tile, TRANSPORT_RAIL)) return VETSB_CONTINUE;
/* depot direction */
dir = GetRailDepotDirection(tile);
diff --git a/src/rail_map.h b/src/rail_map.h
index 008fb39ef..2789b419a 100644
--- a/src/rail_map.h
+++ b/src/rail_map.h
@@ -72,7 +72,18 @@ static inline void SetHasSignals(TileIndex tile, bool signals)
}
/**
- * Is this tile a rail depot?
+ * Is this rail tile a rail waypoint?
+ * @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 waypoint
+ */
+static inline bool IsRailWaypoint(TileIndex t)
+{
+ return GetRailTileType(t) == RAIL_TILE_WAYPOINT;
+}
+
+/**
+ * Is this rail tile 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
@@ -83,17 +94,16 @@ static inline bool IsRailDepot(TileIndex t)
}
/**
- * Is this tile a rail waypoint?
+ * 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 waypoint
+ * @return true if and only if the tile is a rail depot
*/
-static inline bool IsRailWaypoint(TileIndex t)
+static inline bool IsRailDepotTile(TileIndex t)
{
- return GetRailTileType(t) == RAIL_TILE_WAYPOINT;
+ return IsTileType(t, MP_RAILWAY) && IsRailDepot(t);
}
-
/**
* Gets the rail type of the given tile
* @param t the tile to get the rail type from
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 2144c49a4..f146b3ada 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -178,7 +178,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* The ai_new queries the vehicle cost before building the route,
* so we must check against cheaters no sooner than now. --pasky */
- if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return CMD_ERROR;
+ if (!IsDepotTypeTile(tile, TRANSPORT_ROAD)) 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 @@ static bool CheckRoadVehInDepotStopped(const Vehicle *v)
{
TileIndex tile = v->tile;
- if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return false;
+ if (!IsDepotTypeTile(tile, TRANSPORT_ROAD)) return false;
if (IsRoadVehFront(v) && !(v->vehstatus & VS_STOPPED)) return false;
for (; v != NULL; v = v->Next()) {
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index e111cf77b..7f66ea806 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -130,7 +130,7 @@ static const Depot* FindClosestShipDepot(const Vehicle* v)
FOR_ALL_DEPOTS(depot) {
TileIndex tile = depot->xy;
- if (IsTileDepotType(tile, TRANSPORT_WATER) && IsTileOwner(tile, v->owner)) {
+ if (IsDepotTypeTile(tile, TRANSPORT_WATER) && IsTileOwner(tile, v->owner)) {
uint dist = DistanceManhattan(tile, v->tile);
if (dist < best_dist) {
best_dist = dist;
@@ -762,7 +762,7 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* The ai_new queries the vehicle cost before building the route,
* so we must check against cheaters no sooner than now. --pasky */
- if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR;
+ if (!IsDepotTypeTile(tile, TRANSPORT_WATER)) return CMD_ERROR;
if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP);
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 07baf6b2f..e4caa9837 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -1,4 +1,3 @@
-
/* $Id$ */
/** @file smallmap_gui.cpp */
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index b77a349d0..9f05d9af3 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -678,7 +678,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
/* 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 (!IsTileDepotType(tile, TRANSPORT_RAIL)) return CMD_ERROR;
+ if (!IsDepotTypeTile(tile, TRANSPORT_RAIL)) return CMD_ERROR;
if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
}
@@ -806,7 +806,7 @@ int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped)
TileIndex tile = v->tile;
/* check if stopped in a depot */
- if (!IsTileDepotType(tile, TRANSPORT_RAIL) || v->cur_speed != 0) return -1;
+ if (!IsDepotTypeTile(tile, TRANSPORT_RAIL) || v->cur_speed != 0) return -1;
int count = 0;
for (; v != NULL; v = v->Next()) {
@@ -1787,7 +1787,7 @@ static void AdvanceWagonsAfterSwap(Vehicle *v)
static void ReverseTrainDirection(Vehicle *v)
{
- if (IsTileDepotType(v->tile, TRANSPORT_RAIL)) {
+ if (IsDepotTypeTile(v->tile, TRANSPORT_RAIL)) {
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
}
@@ -1807,7 +1807,7 @@ static void ReverseTrainDirection(Vehicle *v)
AdvanceWagonsAfterSwap(v);
- if (IsTileDepotType(v->tile, TRANSPORT_RAIL)) {
+ if (IsDepotTypeTile(v->tile, TRANSPORT_RAIL)) {
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
}
@@ -2035,7 +2035,7 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance)
tfdd.reverse = false;
TileIndex tile = v->tile;
- if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
+ if (IsDepotTypeTile(tile, TRANSPORT_RAIL)) {
tfdd.tile = tile;
tfdd.best_length = 0;
return tfdd;
@@ -2154,7 +2154,7 @@ static void HandleLocomotiveSmokeCloud(const Vehicle *v)
}
/* No smoke in depots or tunnels */
- if (IsTileDepotType(v->tile, TRANSPORT_RAIL) || IsTunnelTile(v->tile)) continue;
+ if (IsDepotTypeTile(v->tile, TRANSPORT_RAIL) || 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 @@ static void DeleteLastWagon(Vehicle *v)
if (IsLevelCrossingTile(tile)) UpdateLevelCrossing(tile);
/* Update signals */
- if (IsTileType(tile, MP_TUNNELBRIDGE) || IsTileDepotType(tile, TRANSPORT_RAIL)) {
+ if (IsTileType(tile, MP_TUNNELBRIDGE) || IsDepotTypeTile(tile, TRANSPORT_RAIL)) {
UpdateSignalsOnSegment(tile, INVALID_DIAGDIR, owner);
} else {
SetSignalsOnBothDir(tile, (Track)(FIND_FIRST_BIT(track)), owner);
@@ -3311,7 +3311,7 @@ static bool TrainCanLeaveTile(const Vehicle *v)
}
/* entering a depot? */
- if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
+ if (IsDepotTypeTile(tile, TRANSPORT_RAIL)) {
DiagDirection dir = ReverseDiagDir(GetRailDepotDirection(tile));
if (DiagDirToDir(dir) == v->direction) return false;
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 54cb8e288..432774210 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -3217,7 +3217,7 @@ CommandCost Vehicle::SendToDepot(uint32 flags, DepotCommand command)
/* 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 && IsTileDepotType(this->tile, TRANSPORT_RAIL) && this->cur_speed == 0) return CMD_ERROR;
+ if (this->type == VEH_TRAIN && IsDepotTypeTile(this->tile, TRANSPORT_RAIL) && this->cur_speed == 0) return CMD_ERROR;
TileIndex location;
DestinationID destination;
diff --git a/src/water_map.h b/src/water_map.h
index ca3ba061a..b8c0de046 100644
--- a/src/water_map.h
+++ b/src/water_map.h
@@ -96,6 +96,11 @@ static inline TileIndex IsShipDepot(TileIndex t)
return IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END);
}
+static inline TileIndex IsShipDepotTile(TileIndex t)
+{
+ return IsTileType(t, MP_WATER) && IsShipDepot(t);
+}
+
static inline Axis GetShipDepotAxis(TileIndex t)
{
return (Axis)GB(_m[t].m5, 1, 1);
diff --git a/src/yapf/follow_track.hpp b/src/yapf/follow_track.hpp
index afde47dd7..0b5608fb4 100644
--- a/src/yapf/follow_track.hpp
+++ b/src/yapf/follow_track.hpp
@@ -196,7 +196,7 @@ protected:
}
// road depots can be also left in one direction only
- if (IsRoadTT() && IsTileDepotType(m_old_tile, TT())) {
+ if (IsRoadTT() && IsDepotTypeTile(m_old_tile, TT())) {
DiagDirection exitdir = GetRoadDepotDirection(m_old_tile);
if (exitdir != m_exitdir) {
m_err = EC_NO_WAY;
@@ -226,7 +226,7 @@ protected:
}
// road and rail depots can also be entered from one direction only
- if (IsRoadTT() && IsTileDepotType(m_new_tile, TT())) {
+ if (IsRoadTT() && IsDepotTypeTile(m_new_tile, TT())) {
DiagDirection exitdir = GetRoadDepotDirection(m_new_tile);
if (ReverseDiagDir(exitdir) != m_exitdir) {
m_err = EC_NO_WAY;
@@ -238,7 +238,7 @@ protected:
return false;
}
}
- if (IsRailTT() && IsTileDepotType(m_new_tile, TT())) {
+ if (IsRailTT() && IsDepotTypeTile(m_new_tile, TT())) {
DiagDirection exitdir = GetRailDepotDirection(m_new_tile);
if (ReverseDiagDir(exitdir) != m_exitdir) {
m_err = EC_NO_WAY;
@@ -305,7 +305,7 @@ protected:
FORCEINLINE bool ForcedReverse()
{
// rail and road depots cause reversing
- if (!IsWaterTT() && IsTileDepotType(m_old_tile, TT())) {
+ if (!IsWaterTT() && IsDepotTypeTile(m_old_tile, TT())) {
DiagDirection exitdir = IsRailTT() ? GetRailDepotDirection(m_old_tile) : GetRoadDepotDirection(m_old_tile);
if (exitdir != m_exitdir) {
// reverse
diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp
index 1de192334..b666999c3 100644
--- a/src/yapf/yapf_destrail.hpp
+++ b/src/yapf/yapf_destrail.hpp
@@ -43,7 +43,7 @@ public:
/// Called by YAPF to detect if node ends in the desired destination
FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
{
- bool bDest = IsTileDepotType(tile, TRANSPORT_RAIL);
+ bool bDest = IsDepotTypeTile(tile, TRANSPORT_RAIL);
return bDest;
}
diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp
index efa6bb70d..81a6eeb73 100644
--- a/src/yapf/yapf_road.cpp
+++ b/src/yapf/yapf_road.cpp
@@ -87,7 +87,7 @@ public:
if (v->current_order.IsType(OT_GOTO_STATION) && tile == v->dest_tile) break;
// stop if we have just entered the depot
- if (IsTileDepotType(tile, TRANSPORT_ROAD) && trackdir == DiagdirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) {
+ if (IsDepotTypeTile(tile, TRANSPORT_ROAD) && trackdir == DiagdirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) {
// next time we will reverse and leave the depot
break;
}
@@ -148,7 +148,7 @@ public:
/// Called by YAPF to detect if node ends in the desired destination
FORCEINLINE bool PfDetectDestination(Node& n)
{
- bool bDest = IsTileDepotType(n.m_segment_last_tile, TRANSPORT_ROAD);
+ bool bDest = IsDepotTypeTile(n.m_segment_last_tile, TRANSPORT_ROAD);
return bDest;
}
@@ -370,7 +370,7 @@ public:
// get found depot tile
Node *n = Yapf().GetBestNode();
TileIndex depot_tile = n->m_segment_last_tile;
- assert(IsTileDepotType(depot_tile, TRANSPORT_ROAD));
+ assert(IsDepotTypeTile(depot_tile, TRANSPORT_ROAD));
Depot* ret = GetDepotByTile(depot_tile);
return ret;
}
@@ -439,7 +439,7 @@ Depot* YapfFindNearestRoadDepot(const Vehicle *v)
return NULL;
// handle the case when our vehicle is already in the depot tile
- if (IsTileType(tile, MP_ROAD) && IsTileDepotType(tile, TRANSPORT_ROAD)) {
+ if (IsTileType(tile, MP_ROAD) && IsDepotTypeTile(tile, TRANSPORT_ROAD)) {
// only what we need to return is the Depot*
return GetDepotByTile(tile);
}