mirror of https://github.com/OpenTTD/OpenTTD
Codechange: add and use GetDepotDestinationIndex map accessor
parent
dccc6185b9
commit
ce07ea00b8
|
@ -299,7 +299,7 @@ struct DepotWindow : Window {
|
|||
void Close([[maybe_unused]] int data = 0) override
|
||||
{
|
||||
CloseWindowById(WC_BUILD_VEHICLE, this->window_number);
|
||||
CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDepotIndex()).ToWindowNumber(), false);
|
||||
CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDestinationIndex().base()).ToWindowNumber(), false);
|
||||
OrderBackup::Reset(TileIndex(this->window_number));
|
||||
this->Window::Close();
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ struct DepotWindow : Window {
|
|||
if (widget != WID_D_CAPTION) return;
|
||||
|
||||
SetDParam(0, this->type);
|
||||
SetDParam(1, this->GetDepotIndex());
|
||||
SetDParam(1, this->GetDestinationIndex());
|
||||
}
|
||||
|
||||
struct GetDepotVehiclePtData {
|
||||
|
@ -823,7 +823,7 @@ struct DepotWindow : Window {
|
|||
/* Only open the confirmation window if there are anything to sell */
|
||||
if (!this->vehicle_list.empty() || !this->wagon_list.empty()) {
|
||||
SetDParam(0, this->type);
|
||||
SetDParam(1, this->GetDepotIndex());
|
||||
SetDParam(1, this->GetDestinationIndex());
|
||||
ShowQuery(
|
||||
STR_DEPOT_CAPTION,
|
||||
STR_DEPOT_SELL_CONFIRMATION_TEXT,
|
||||
|
@ -849,7 +849,7 @@ struct DepotWindow : Window {
|
|||
if (!str.has_value()) return;
|
||||
|
||||
/* Do depot renaming */
|
||||
Command<CMD_RENAME_DEPOT>::Post(STR_ERROR_CAN_T_RENAME_DEPOT, this->GetDepotIndex(), *str);
|
||||
Command<CMD_RENAME_DEPOT>::Post(STR_ERROR_CAN_T_RENAME_DEPOT, this->GetDestinationIndex().ToDepotID(), *str);
|
||||
}
|
||||
|
||||
bool OnRightClick([[maybe_unused]] Point pt, WidgetID widget) override
|
||||
|
@ -1139,9 +1139,9 @@ struct DepotWindow : Window {
|
|||
* In the case of airports, this is the station ID.
|
||||
* @return Depot or station ID of this window.
|
||||
*/
|
||||
inline uint16_t GetDepotIndex() const
|
||||
inline DestinationID GetDestinationIndex() const
|
||||
{
|
||||
return (this->type == VEH_AIRCRAFT) ? ::GetStationIndex(this->window_number) : ::GetDepotIndex(this->window_number);
|
||||
return GetDepotDestinationIndex(this->window_number);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#ifndef DEPOT_MAP_H
|
||||
#define DEPOT_MAP_H
|
||||
|
||||
#include "order_type.h"
|
||||
#include "station_map.h"
|
||||
|
||||
/**
|
||||
|
@ -56,6 +57,18 @@ inline DepotID GetDepotIndex(Tile t)
|
|||
return t.m2();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the destination index of a 'depot'. For hangars that's the station index, for the rest a depot index.
|
||||
* @param t the tile
|
||||
* @pre IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t) || IsHangarTile(t)
|
||||
* @return DepotID
|
||||
*/
|
||||
inline DestinationID GetDepotDestinationIndex(Tile t)
|
||||
{
|
||||
if (IsHangarTile(t)) return GetStationIndex(t);
|
||||
return GetDepotIndex(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of vehicles that can use a depot
|
||||
* @param t The tile
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
void Free();
|
||||
|
||||
void MakeGoToStation(StationID destination);
|
||||
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type = ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action = ODATF_SERVICE_ONLY, CargoType cargo = CARGO_NO_REFIT);
|
||||
void MakeGoToDepot(DestinationID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type = ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action = ODATF_SERVICE_ONLY, CargoType cargo = CARGO_NO_REFIT);
|
||||
void MakeGoToWaypoint(StationID destination);
|
||||
void MakeLoading(bool ordered);
|
||||
void MakeLeaveStation();
|
||||
|
|
|
@ -87,7 +87,7 @@ void Order::MakeGoToStation(StationID destination)
|
|||
* @param action what to do in the depot?
|
||||
* @param cargo the cargo type to change to.
|
||||
*/
|
||||
void Order::MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type, OrderDepotActionFlags action, CargoType cargo)
|
||||
void Order::MakeGoToDepot(DestinationID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type, OrderDepotActionFlags action, CargoType cargo)
|
||||
{
|
||||
this->type = OT_GOTO_DEPOT;
|
||||
this->SetDepotOrderType(order);
|
||||
|
|
|
@ -384,7 +384,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
|||
|
||||
/* check depot first */
|
||||
if (IsDepotTypeTile(tile, (TransportType)(uint)v->type) && IsTileOwner(tile, _local_company)) {
|
||||
order.MakeGoToDepot(v->type == VEH_AIRCRAFT ? GetStationIndex(tile) : GetDepotIndex(tile),
|
||||
order.MakeGoToDepot(GetDepotDestinationIndex(tile),
|
||||
ODTFB_PART_OF_ORDERS,
|
||||
(_settings_client.gui.new_nonstop && v->IsGroundVehicle()) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
|
||||
|
||||
|
|
|
@ -2347,14 +2347,7 @@ void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationI
|
|||
|
||||
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile)
|
||||
{
|
||||
uint16_t depot_airport_index;
|
||||
|
||||
if (vehicle_type == VEH_AIRCRAFT) {
|
||||
depot_airport_index = GetStationIndex(depot_tile);
|
||||
} else {
|
||||
depot_airport_index = GetDepotIndex(depot_tile);
|
||||
}
|
||||
ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, depot_airport_index);
|
||||
ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, GetDepotDestinationIndex(depot_tile).base());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue