From 860a538adc56a678f640f606692ea7ca00c8d424 Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 10 Sep 2009 14:37:55 +0000 Subject: (svn r17495) -Codechange: replace 'Depot::Get(GetDepotIndex(tile))->index' with GetDepotIndex(tile) --- src/ai/api/ai_order.cpp | 2 +- src/ai/api/ai_vehiclelist.cpp | 6 +++--- src/order_gui.cpp | 8 +++----- src/road_cmd.cpp | 2 +- src/roadveh_cmd.cpp | 6 +++--- src/train_cmd.cpp | 8 ++++---- src/vehicle_gui.cpp | 4 +--- src/water_cmd.cpp | 2 +- 8 files changed, 17 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp index b45bab956..1e18333fa 100644 --- a/src/ai/api/ai_order.cpp +++ b/src/ai/api/ai_order.cpp @@ -349,7 +349,7 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or order.MakeGoToDepot(::GetStationIndex(destination), odtf, onsf, odaf); } else { if (::IsTileType(destination, MP_STATION)) return false; - order.MakeGoToDepot(::Depot::GetByTile(destination)->index, odtf, onsf, odaf); + order.MakeGoToDepot(::GetDepotIndex(destination), odtf, onsf, odaf); } break; } diff --git a/src/ai/api/ai_vehiclelist.cpp b/src/ai/api/ai_vehiclelist.cpp index 5e1fb6b07..61cbc9198 100644 --- a/src/ai/api/ai_vehiclelist.cpp +++ b/src/ai/api/ai_vehiclelist.cpp @@ -63,19 +63,19 @@ AIVehicleList_Depot::AIVehicleList_Depot(TileIndex tile) case MP_RAILWAY: if (!IsRailDepot(tile)) return; type = VEH_TRAIN; - dest = Depot::GetByTile(tile)->index; + dest = GetDepotIndex(tile); break; case MP_ROAD: if (!IsRoadDepot(tile)) return; type = VEH_ROAD; - dest = Depot::GetByTile(tile)->index; + dest = GetDepotIndex(tile); break; case MP_WATER: if (!IsShipDepot(tile)) return; type = VEH_SHIP; - dest = Depot::GetByTile(min(tile, GetOtherShipDepotTile(tile)))->index; + dest = GetDepotIndex(tile); break; default: // No depot diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 3604a69fa..288276ab8 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -303,7 +303,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) case MP_RAILWAY: if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_company)) { if (IsRailDepot(tile)) { - order.MakeGoToDepot(Depot::GetByTile(tile)->index, ODTFB_PART_OF_ORDERS, + order.MakeGoToDepot(GetDepotIndex(tile), ODTFB_PART_OF_ORDERS, _settings_client.gui.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE); if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE)); return order; @@ -313,7 +313,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) case MP_ROAD: if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_company)) { - order.MakeGoToDepot(Depot::GetByTile(tile)->index, ODTFB_PART_OF_ORDERS, + order.MakeGoToDepot(GetDepotIndex(tile), ODTFB_PART_OF_ORDERS, _settings_client.gui.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE); if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE)); return order; @@ -332,9 +332,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) case MP_WATER: if (v->type != VEH_SHIP) break; if (IsShipDepot(tile) && IsTileOwner(tile, _local_company)) { - TileIndex tile2 = GetOtherShipDepotTile(tile); - - order.MakeGoToDepot(Depot::GetByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS, ONSF_STOP_EVERYWHERE); + order.MakeGoToDepot(GetDepotIndex(tile), ODTFB_PART_OF_ORDERS, ONSF_STOP_EVERYWHERE); if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE)); return order; } diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 9f5787044..e94d9bb0e 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1266,7 +1266,7 @@ void UpdateNearestTownForRoadTiles(bool invalidate) assert(!invalidate || _generating_world); for (TileIndex t = 0; t < MapSize(); t++) { - if (IsTileType(t, MP_ROAD) && !HasTownOwnedRoad(t)) { + if (IsTileType(t, MP_ROAD) && !IsRoadDepot(t) && !HasTownOwnedRoad(t)) { TownID tid = (TownID)INVALID_TOWN; if (!invalidate) { const Town *town = CalcClosestTownFromTile(t); diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 11584d08e..8bafe33ce 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -436,7 +436,7 @@ bool RoadVehicle::FindClosestDepot(TileIndex *location, DestinationID *destinati if (rfdd.best_length == UINT_MAX) return false; if (location != NULL) *location = rfdd.tile; - if (destination != NULL) *destination = Depot::GetByTile(rfdd.tile)->index; + if (destination != NULL) *destination = GetDepotIndex(rfdd.tile); return true; } @@ -1850,7 +1850,7 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v) return; } - const Depot *depot = Depot::GetByTile(rfdd.tile); + DepotID depot = GetDepotIndex(rfdd.tile); if (v->current_order.IsType(OT_GOTO_DEPOT) && v->current_order.GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS && @@ -1861,7 +1861,7 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v) if (v->current_order.IsType(OT_LOADING)) v->LeaveStation(); ClearSlot(v); - v->current_order.MakeGoToDepot(depot->index, ODTFB_SERVICE); + v->current_order.MakeGoToDepot(depot, ODTFB_SERVICE); v->dest_tile = rfdd.tile; InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 80a88ef48..bdbe2d2e4 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2264,7 +2264,7 @@ bool Train::FindClosestDepot(TileIndex *location, DestinationID *destination, bo if (tfdd.best_length == UINT_MAX) return false; if (location != NULL) *location = tfdd.tile; - if (destination != NULL) *destination = Depot::GetByTile(tfdd.tile)->index; + if (destination != NULL) *destination = GetDepotIndex(tfdd.tile); if (reverse != NULL) *reverse = tfdd.reverse; return true; @@ -4526,15 +4526,15 @@ static void CheckIfTrainNeedsService(Train *v) return; } - const Depot *depot = Depot::GetByTile(tfdd.tile); + DepotID depot = GetDepotIndex(tfdd.tile); if (v->current_order.IsType(OT_GOTO_DEPOT) && - v->current_order.GetDestination() != depot->index && + v->current_order.GetDestination() != depot && !Chance16(3, 16)) { return; } - v->current_order.MakeGoToDepot(depot->index, ODTFB_SERVICE); + v->current_order.MakeGoToDepot(depot, ODTFB_SERVICE); v->dest_tile = tfdd.tile; InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 0719bbfe2..efb13681d 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1177,9 +1177,7 @@ void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileInde if (vehicle_type == VEH_AIRCRAFT) { depot_airport_index = GetStationIndex(depot_tile); } else { - Depot *depot = Depot::GetByTile(depot_tile); - if (depot == NULL) return; // no depot to show - depot_airport_index = depot->index; + depot_airport_index = GetDepotIndex(depot_tile); } ShowVehicleListWindowLocal(company, VLW_DEPOT_LIST, vehicle_type, depot_airport_index); } diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index a756024f2..2f27bc704 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -184,7 +184,7 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags) if (flags & DC_EXEC) { /* Kill the depot, which is registered at the northernmost tile. Use that one */ - delete Depot::GetByTile(tile2 < tile ? tile2 : tile); + delete Depot::GetByTile(tile); MakeWaterKeepingClass(tile, GetTileOwner(tile)); MakeWaterKeepingClass(tile2, GetTileOwner(tile2)); -- cgit v1.2.3-70-g09d2