(svn r12753) -Codechange: do not use IsDepotTypeTile() where simpler function can be used

This commit is contained in:
smatz 2008-04-17 18:24:45 +00:00
parent e098b50379
commit 059e94e355
15 changed files with 38 additions and 39 deletions

View File

@ -330,7 +330,7 @@ static void AiHandleReplaceTrain(Player *p)
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 @@ 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) || 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 @@ static void AiStateSellVeh(Player *p)
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;

View File

@ -45,7 +45,7 @@ static bool IsRoad(TileIndex tile)
{
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);
}

View File

@ -1254,8 +1254,8 @@ 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 && 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);
}

View File

@ -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 (!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 @@ 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 (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 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 */
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 */
}

View File

@ -1874,7 +1874,7 @@ bool AfterLoadGame()
}
/* 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);

View File

@ -392,15 +392,15 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
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;

View File

@ -462,8 +462,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
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);

View File

@ -170,10 +170,10 @@ static inline bool CanAccessTileInDir(TileIndex tile, DiagDirection side, Transp
{
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;
}

View File

@ -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 || !IsDepotTypeTile(tile, TRANSPORT_RAIL)) return VETSB_CONTINUE;
if (v->type != VEH_TRAIN || !IsRailDepotTile(tile)) return VETSB_CONTINUE;
/* depot direction */
dir = GetRailDepotDirection(tile);

View File

@ -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 (!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 @@ static bool CheckRoadVehInDepotStopped(const Vehicle *v)
{
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()) {

View File

@ -130,7 +130,7 @@ static const Depot* FindClosestShipDepot(const Vehicle* v)
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 @@ 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 (!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);

View File

@ -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 (!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 @@ int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped)
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 AdvanceWagonsAfterSwap(Vehicle *v)
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 @@ static void ReverseTrainDirection(Vehicle *v)
AdvanceWagonsAfterSwap(v);
if (IsDepotTypeTile(v->tile, TRANSPORT_RAIL)) {
if (IsRailDepotTile(v->tile)) {
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 (IsDepotTypeTile(tile, TRANSPORT_RAIL)) {
if (IsRailDepotTile(tile)) {
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 (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 @@ static void DeleteLastWagon(Vehicle *v)
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 @@ static bool TrainCanLeaveTile(const Vehicle *v)
}
/* entering a depot? */
if (IsDepotTypeTile(tile, TRANSPORT_RAIL)) {
if (IsRailDepotTile(tile)) {
DiagDirection dir = ReverseDiagDir(GetRailDepotDirection(tile));
if (DiagDirToDir(dir) == v->direction) return false;
}

View File

@ -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 && 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;

View File

@ -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 = IsDepotTypeTile(tile, TRANSPORT_RAIL);
bool bDest = IsRailDepotTile(tile);
return bDest;
}

View File

@ -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 (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 @@ public:
/// 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 @@ public:
// 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 @@ Depot* YapfFindNearestRoadDepot(const Vehicle *v)
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);
}