1
0
Fork 0

(svn r16646) -Codechange: rename GetDepotByTile() to Depot::GetByTile()

release/1.0
smatz 2009-06-24 19:26:41 +00:00
parent fd4a9a9106
commit 05c695a647
13 changed files with 21 additions and 21 deletions

View File

@ -345,7 +345,7 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
order.MakeGoToDepot(::GetStationIndex(destination), odtf, onsf, odaf); order.MakeGoToDepot(::GetStationIndex(destination), odtf, onsf, odaf);
} else { } else {
if (::IsTileType(destination, MP_STATION)) return false; if (::IsTileType(destination, MP_STATION)) return false;
order.MakeGoToDepot(::GetDepotByTile(destination)->index, odtf, onsf, odaf); order.MakeGoToDepot(::Depot::GetByTile(destination)->index, odtf, onsf, odaf);
} }
break; break;
} }

View File

@ -17,10 +17,10 @@ INSTANTIATE_POOL_METHODS(Depot)
/** /**
* Gets a depot from a tile * Gets a depot from a tile
* * @param tile tile with depot
* @return Returns the depot if the tile had a depot, else it returns NULL * @return Returns the depot if the tile had a depot, else it returns NULL
*/ */
Depot *GetDepotByTile(TileIndex tile) /* static */ Depot *Depot::GetByTile(TileIndex tile)
{ {
/* A ship depot is multiple tiles. The north most tile is /* A ship depot is multiple tiles. The north most tile is
* always the ->xy tile, so make sure we always look for * always the ->xy tile, so make sure we always look for

View File

@ -19,9 +19,9 @@ struct Depot : DepotPool::PoolItem<&_depot_pool> {
Depot(TileIndex xy = INVALID_TILE) : xy(xy) {} Depot(TileIndex xy = INVALID_TILE) : xy(xy) {}
~Depot(); ~Depot();
};
Depot *GetDepotByTile(TileIndex tile); static Depot *GetByTile(TileIndex tile);
};
#define FOR_ALL_DEPOTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Depot, depot_index, var, start) #define FOR_ALL_DEPOTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Depot, depot_index, var, start)
#define FOR_ALL_DEPOTS(var) FOR_ALL_DEPOTS_FROM(var, 0) #define FOR_ALL_DEPOTS(var) FOR_ALL_DEPOTS_FROM(var, 0)

View File

@ -341,7 +341,7 @@ struct DepotWindow : Window {
if (this->type == VEH_AIRCRAFT) { if (this->type == VEH_AIRCRAFT) {
SetDParam(0, GetStationIndex(tile)); // Airport name SetDParam(0, GetStationIndex(tile)); // Airport name
} else { } else {
Depot *depot = GetDepotByTile(tile); Depot *depot = Depot::GetByTile(tile);
assert(depot != NULL); assert(depot != NULL);
SetDParam(0, depot->town_index); SetDParam(0, depot->town_index);
@ -815,7 +815,7 @@ struct DepotWindow : Window {
TileIndex tile = this->window_number; TileIndex tile = this->window_number;
byte vehtype = this->type; byte vehtype = this->type;
SetDParam(0, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotByTile(tile)->town_index); SetDParam(0, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : Depot::GetByTile(tile)->town_index);
ShowQuery( ShowQuery(
confirm_captions[vehtype], confirm_captions[vehtype],
STR_DEPOT_SELL_CONFIRMATION_TEXT, STR_DEPOT_SELL_CONFIRMATION_TEXT,

View File

@ -300,7 +300,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
case MP_RAILWAY: case MP_RAILWAY:
if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_company)) { if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_company)) {
if (IsRailDepot(tile)) { if (IsRailDepot(tile)) {
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS, order.MakeGoToDepot(Depot::GetByTile(tile)->index, ODTFB_PART_OF_ORDERS,
_settings_client.gui.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE); _settings_client.gui.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE)); if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
return order; return order;
@ -310,7 +310,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
case MP_ROAD: case MP_ROAD:
if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_company)) { if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_company)) {
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS, order.MakeGoToDepot(Depot::GetByTile(tile)->index, ODTFB_PART_OF_ORDERS,
_settings_client.gui.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE); _settings_client.gui.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE)); if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
return order; return order;
@ -331,7 +331,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
if (IsShipDepot(tile) && IsTileOwner(tile, _local_company)) { if (IsShipDepot(tile) && IsTileOwner(tile, _local_company)) {
TileIndex tile2 = GetOtherShipDepotTile(tile); TileIndex tile2 = GetOtherShipDepotTile(tile);
order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS, ONSF_STOP_EVERYWHERE); order.MakeGoToDepot(Depot::GetByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS, ONSF_STOP_EVERYWHERE);
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE)); if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
return order; return order;
} }

View File

@ -1441,7 +1441,7 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
} }
DoClearSquare(tile); DoClearSquare(tile);
delete GetDepotByTile(tile); delete Depot::GetByTile(tile);
AddSideToSignalBuffer(tile, dir, owner); AddSideToSignalBuffer(tile, dir, owner);
YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir)); YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir));
if (v != NULL) TryPathReserve(v, true); if (v != NULL) TryPathReserve(v, true);

View File

@ -882,7 +882,7 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
DoClearSquare(tile); DoClearSquare(tile);
delete GetDepotByTile(tile); delete Depot::GetByTile(tile);
} }
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road_depot); return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road_depot);

View File

@ -374,7 +374,7 @@ static const Depot *FindClosestRoadDepot(const RoadVehicle *v)
NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, false, v->tile, ReverseTrackdir(trackdir), false, TRANSPORT_ROAD, v->compatible_roadtypes, v->owner, INVALID_RAILTYPES, 0); NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, false, v->tile, ReverseTrackdir(trackdir), false, TRANSPORT_ROAD, v->compatible_roadtypes, v->owner, INVALID_RAILTYPES, 0);
if (ftd.best_bird_dist == 0) return GetDepotByTile(ftd.node.tile); // Target found if (ftd.best_bird_dist == 0) return Depot::GetByTile(ftd.node.tile); // Target found
} break; } break;
default: default:
@ -389,7 +389,7 @@ static const Depot *FindClosestRoadDepot(const RoadVehicle *v)
FollowTrack(v->tile, PATHFIND_FLAGS_NONE, TRANSPORT_ROAD, v->compatible_roadtypes, d, EnumRoadSignalFindDepot, NULL, &rfdd); FollowTrack(v->tile, PATHFIND_FLAGS_NONE, TRANSPORT_ROAD, v->compatible_roadtypes, d, EnumRoadSignalFindDepot, NULL, &rfdd);
} }
if (rfdd.best_length != UINT_MAX) return GetDepotByTile(rfdd.tile); if (rfdd.best_length != UINT_MAX) return Depot::GetByTile(rfdd.tile);
} break; } break;
} }

View File

@ -100,7 +100,7 @@ static const Depot *FindClosestShipDepot(const Vehicle *v)
Trackdir trackdir = v->GetVehicleTrackdir(); Trackdir trackdir = v->GetVehicleTrackdir();
NPFFoundTargetData ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES); NPFFoundTargetData ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
if (ftd.best_bird_dist == 0) return GetDepotByTile(ftd.node.tile); // Found target if (ftd.best_bird_dist == 0) return Depot::GetByTile(ftd.node.tile); // Found target
return NULL; // Did not find target return NULL; // Did not find target
} }

View File

@ -2231,7 +2231,7 @@ bool Train::FindClosestDepot(TileIndex *location, DestinationID *destination, bo
if (tfdd.best_length == UINT_MAX) return false; if (tfdd.best_length == UINT_MAX) return false;
if (location != NULL) *location = tfdd.tile; if (location != NULL) *location = tfdd.tile;
if (destination != NULL) *destination = GetDepotByTile(tfdd.tile)->index; if (destination != NULL) *destination = Depot::GetByTile(tfdd.tile)->index;
if (reverse != NULL) *reverse = tfdd.reverse; if (reverse != NULL) *reverse = tfdd.reverse;
return true; return true;
@ -4487,7 +4487,7 @@ static void CheckIfTrainNeedsService(Train *v)
return; return;
} }
const Depot *depot = GetDepotByTile(tfdd.tile); const Depot *depot = Depot::GetByTile(tfdd.tile);
if (v->current_order.IsType(OT_GOTO_DEPOT) && if (v->current_order.IsType(OT_GOTO_DEPOT) &&
v->current_order.GetDestination() != depot->index && v->current_order.GetDestination() != depot->index &&

View File

@ -1243,7 +1243,7 @@ void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileInde
if (vehicle_type == VEH_AIRCRAFT) { if (vehicle_type == VEH_AIRCRAFT) {
depot_airport_index = GetStationIndex(depot_tile); depot_airport_index = GetStationIndex(depot_tile);
} else { } else {
Depot *depot = GetDepotByTile(depot_tile); Depot *depot = Depot::GetByTile(depot_tile);
if (depot == NULL) return; // no depot to show if (depot == NULL) return; // no depot to show
depot_airport_index = depot->index; depot_airport_index = depot->index;
} }

View File

@ -177,7 +177,7 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
/* Kill the depot, which is registered at the northernmost tile. Use that one */ /* Kill the depot, which is registered at the northernmost tile. Use that one */
delete GetDepotByTile(tile2 < tile ? tile2 : tile); delete Depot::GetByTile(tile2 < tile ? tile2 : tile);
MakeWaterKeepingClass(tile, GetTileOwner(tile)); MakeWaterKeepingClass(tile, GetTileOwner(tile));
MakeWaterKeepingClass(tile2, GetTileOwner(tile2)); MakeWaterKeepingClass(tile2, GetTileOwner(tile2));

View File

@ -403,7 +403,7 @@ public:
Node *n = Yapf().GetBestNode(); Node *n = Yapf().GetBestNode();
TileIndex depot_tile = n->m_segment_last_tile; TileIndex depot_tile = n->m_segment_last_tile;
assert(IsRoadDepotTile(depot_tile)); assert(IsRoadDepotTile(depot_tile));
Depot *ret = GetDepotByTile(depot_tile); Depot *ret = Depot::GetByTile(depot_tile);
return ret; return ret;
} }
}; };
@ -478,7 +478,7 @@ Depot *YapfFindNearestRoadDepot(const Vehicle *v)
/* handle the case when our vehicle is already in the depot tile */ /* handle the case when our vehicle is already in the depot tile */
if (IsRoadDepotTile(tile)) { if (IsRoadDepotTile(tile)) {
/* only what we need to return is the Depot* */ /* only what we need to return is the Depot* */
return GetDepotByTile(tile); return Depot::GetByTile(tile);
} }
/* default is YAPF type 2 */ /* default is YAPF type 2 */