mirror of https://github.com/OpenTTD/OpenTTD
Codechange: change DestinationID into class with conversion helpers
A DestinationID is either a DepotID or StationID, where the aircraft hangar being conceptually a depot is actually a StationID. When making those types stronger, a lot of casts would need to be added, but this shows the intent much better.pull/13482/head
parent
8ca03a3766
commit
e937c4dcfd
|
@ -136,7 +136,7 @@ static StationID FindNearestHangar(const Aircraft *v)
|
||||||
if (v->current_order.IsType(OT_GOTO_STATION) ||
|
if (v->current_order.IsType(OT_GOTO_STATION) ||
|
||||||
(v->current_order.IsType(OT_GOTO_DEPOT) && (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) == 0)) {
|
(v->current_order.IsType(OT_GOTO_DEPOT) && (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) == 0)) {
|
||||||
last_dest = Station::GetIfValid(v->last_station_visited);
|
last_dest = Station::GetIfValid(v->last_station_visited);
|
||||||
next_dest = Station::GetIfValid(v->current_order.GetDestination());
|
next_dest = Station::GetIfValid(v->current_order.GetDestination().ToStationID());
|
||||||
} else {
|
} else {
|
||||||
last_dest = GetTargetAirportIfValid(v);
|
last_dest = GetTargetAirportIfValid(v);
|
||||||
next_dest = Station::GetIfValid(v->GetNextStoppingStation().value);
|
next_dest = Station::GetIfValid(v->GetNextStoppingStation().value);
|
||||||
|
@ -424,7 +424,7 @@ static void CheckIfAircraftNeedsService(Aircraft *v)
|
||||||
* we don't want to consider going to a depot too. */
|
* we don't want to consider going to a depot too. */
|
||||||
if (!v->current_order.IsType(OT_GOTO_DEPOT) && !v->current_order.IsType(OT_GOTO_STATION)) return;
|
if (!v->current_order.IsType(OT_GOTO_DEPOT) && !v->current_order.IsType(OT_GOTO_STATION)) return;
|
||||||
|
|
||||||
const Station *st = Station::Get(v->current_order.GetDestination());
|
const Station *st = Station::Get(v->current_order.GetDestination().ToStationID());
|
||||||
|
|
||||||
assert(st != nullptr);
|
assert(st != nullptr);
|
||||||
|
|
||||||
|
@ -1447,7 +1447,7 @@ static void AircraftLandAirplane(Aircraft *v)
|
||||||
void AircraftNextAirportPos_and_Order(Aircraft *v)
|
void AircraftNextAirportPos_and_Order(Aircraft *v)
|
||||||
{
|
{
|
||||||
if (v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_GOTO_DEPOT)) {
|
if (v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_GOTO_DEPOT)) {
|
||||||
v->targetairport = v->current_order.GetDestination();
|
v->targetairport = v->current_order.GetDestination().ToStationID();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Station *st = GetTargetAirportIfValid(v);
|
const Station *st = GetTargetAirportIfValid(v);
|
||||||
|
@ -2101,7 +2101,7 @@ static bool AircraftEventHandler(Aircraft *v, int loop)
|
||||||
/* Check the distance to the next destination. This code works because the target
|
/* Check the distance to the next destination. This code works because the target
|
||||||
* airport is only updated after take off and not on the ground. */
|
* airport is only updated after take off and not on the ground. */
|
||||||
Station *cur_st = Station::GetIfValid(v->targetairport);
|
Station *cur_st = Station::GetIfValid(v->targetairport);
|
||||||
Station *next_st = v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_GOTO_DEPOT) ? Station::GetIfValid(v->current_order.GetDestination()) : nullptr;
|
Station *next_st = v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_GOTO_DEPOT) ? Station::GetIfValid(v->current_order.GetDestination().ToStationID()) : nullptr;
|
||||||
|
|
||||||
if (cur_st != nullptr && cur_st->airport.tile != INVALID_TILE && next_st != nullptr && next_st->airport.tile != INVALID_TILE) {
|
if (cur_st != nullptr && cur_st->airport.tile != INVALID_TILE && next_st != nullptr && next_st->airport.tile != INVALID_TILE) {
|
||||||
uint dist = DistanceSquare(cur_st->airport.tile, next_st->airport.tile);
|
uint dist = DistanceSquare(cur_st->airport.tile, next_st->airport.tile);
|
||||||
|
|
|
@ -2741,7 +2741,7 @@ int WhoCanServiceIndustry(Industry *ind)
|
||||||
for (const Order *o : v->Orders()) {
|
for (const Order *o : v->Orders()) {
|
||||||
if (o->IsType(OT_GOTO_STATION) && !(o->GetUnloadType() & OUFB_TRANSFER)) {
|
if (o->IsType(OT_GOTO_STATION) && !(o->GetUnloadType() & OUFB_TRANSFER)) {
|
||||||
/* Vehicle visits a station to load or unload */
|
/* Vehicle visits a station to load or unload */
|
||||||
Station *st = Station::Get(o->GetDestination());
|
Station *st = Station::Get(o->GetDestination().ToStationID());
|
||||||
assert(st != nullptr);
|
assert(st != nullptr);
|
||||||
|
|
||||||
/* Same cargo produced by industry is dropped here => not serviced by vehicle v */
|
/* Same cargo produced by industry is dropped here => not serviced by vehicle v */
|
||||||
|
|
|
@ -198,8 +198,8 @@ const Order *LinkRefresher::PredictNextOrder(const Order *cur, const Order *next
|
||||||
*/
|
*/
|
||||||
void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
|
void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
|
||||||
{
|
{
|
||||||
StationID next_station = next->GetDestination();
|
StationID next_station = next->GetDestination().ToStationID();
|
||||||
Station *st = Station::GetIfValid(cur->GetDestination());
|
Station *st = Station::GetIfValid(cur->GetDestination().ToStationID());
|
||||||
if (st != nullptr && next_station != INVALID_STATION && next_station != st->index) {
|
if (st != nullptr && next_station != INVALID_STATION && next_station != st->index) {
|
||||||
Station *st_to = Station::Get(next_station);
|
Station *st_to = Station::Get(next_station);
|
||||||
for (CargoType c = 0; c < NUM_CARGO; c++) {
|
for (CargoType c = 0; c < NUM_CARGO; c++) {
|
||||||
|
|
|
@ -734,7 +734,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
|
||||||
case 0x08: break; // not implemented
|
case 0x08: break; // not implemented
|
||||||
case 0x09: break; // not implemented
|
case 0x09: break; // not implemented
|
||||||
case 0x0A: return v->current_order.MapOldOrder();
|
case 0x0A: return v->current_order.MapOldOrder();
|
||||||
case 0x0B: return v->current_order.GetDestination();
|
case 0x0B: return v->current_order.GetDestination().value;
|
||||||
case 0x0C: return v->GetNumOrders();
|
case 0x0C: return v->GetNumOrders();
|
||||||
case 0x0D: return v->cur_real_order_index;
|
case 0x0D: return v->cur_real_order_index;
|
||||||
case 0x0E: break; // not implemented
|
case 0x0E: break; // not implemented
|
||||||
|
|
|
@ -47,7 +47,7 @@ private:
|
||||||
|
|
||||||
uint8_t type = 0; ///< The type of order + non-stop flags
|
uint8_t type = 0; ///< The type of order + non-stop flags
|
||||||
uint8_t flags = 0; ///< Load/unload types, depot order/action types.
|
uint8_t flags = 0; ///< Load/unload types, depot order/action types.
|
||||||
DestinationID dest = 0; ///< The destination of the order.
|
DestinationID dest{}; ///< The destination of the order.
|
||||||
|
|
||||||
CargoType refit_cargo = CARGO_NO_REFIT; ///< Refit CargoType
|
CargoType refit_cargo = CARGO_NO_REFIT; ///< Refit CargoType
|
||||||
|
|
||||||
|
@ -145,13 +145,13 @@ public:
|
||||||
/** What are we going to do when in the depot. */
|
/** What are we going to do when in the depot. */
|
||||||
inline OrderDepotActionFlags GetDepotActionType() const { return (OrderDepotActionFlags)GB(this->flags, 3, 4); }
|
inline OrderDepotActionFlags GetDepotActionType() const { return (OrderDepotActionFlags)GB(this->flags, 3, 4); }
|
||||||
/** What variable do we have to compare? */
|
/** What variable do we have to compare? */
|
||||||
inline OrderConditionVariable GetConditionVariable() const { return (OrderConditionVariable)GB(this->dest, 11, 5); }
|
inline OrderConditionVariable GetConditionVariable() const { return static_cast<OrderConditionVariable>(GB(this->dest.value, 11, 5)); }
|
||||||
/** What is the comparator to use? */
|
/** What is the comparator to use? */
|
||||||
inline OrderConditionComparator GetConditionComparator() const { return (OrderConditionComparator)GB(this->type, 5, 3); }
|
inline OrderConditionComparator GetConditionComparator() const { return (OrderConditionComparator)GB(this->type, 5, 3); }
|
||||||
/** Get the order to skip to. */
|
/** Get the order to skip to. */
|
||||||
inline VehicleOrderID GetConditionSkipToOrder() const { return this->flags; }
|
inline VehicleOrderID GetConditionSkipToOrder() const { return this->flags; }
|
||||||
/** Get the value to base the skip on. */
|
/** Get the value to base the skip on. */
|
||||||
inline uint16_t GetConditionValue() const { return GB(this->dest, 0, 11); }
|
inline uint16_t GetConditionValue() const { return GB(this->dest.value, 0, 11); }
|
||||||
|
|
||||||
/** Set how the consist must be loaded. */
|
/** Set how the consist must be loaded. */
|
||||||
inline void SetLoadType(OrderLoadFlags load_type) { SB(this->flags, 4, 3, load_type); }
|
inline void SetLoadType(OrderLoadFlags load_type) { SB(this->flags, 4, 3, load_type); }
|
||||||
|
@ -166,13 +166,13 @@ public:
|
||||||
/** Set what we are going to do in the depot. */
|
/** Set what we are going to do in the depot. */
|
||||||
inline void SetDepotActionType(OrderDepotActionFlags depot_service_type) { SB(this->flags, 3, 4, depot_service_type); }
|
inline void SetDepotActionType(OrderDepotActionFlags depot_service_type) { SB(this->flags, 3, 4, depot_service_type); }
|
||||||
/** Set variable we have to compare. */
|
/** Set variable we have to compare. */
|
||||||
inline void SetConditionVariable(OrderConditionVariable condition_variable) { SB(this->dest, 11, 5, condition_variable); }
|
inline void SetConditionVariable(OrderConditionVariable condition_variable) { SB(this->dest.value, 11, 5, condition_variable); }
|
||||||
/** Set the comparator to use. */
|
/** Set the comparator to use. */
|
||||||
inline void SetConditionComparator(OrderConditionComparator condition_comparator) { SB(this->type, 5, 3, condition_comparator); }
|
inline void SetConditionComparator(OrderConditionComparator condition_comparator) { SB(this->type, 5, 3, condition_comparator); }
|
||||||
/** Get the order to skip to. */
|
/** Get the order to skip to. */
|
||||||
inline void SetConditionSkipToOrder(VehicleOrderID order_id) { this->flags = order_id; }
|
inline void SetConditionSkipToOrder(VehicleOrderID order_id) { this->flags = order_id; }
|
||||||
/** Set the value to base the skip on. */
|
/** Set the value to base the skip on. */
|
||||||
inline void SetConditionValue(uint16_t value) { SB(this->dest, 0, 11, value); }
|
inline void SetConditionValue(uint16_t value) { SB(this->dest.value, 0, 11, value); }
|
||||||
|
|
||||||
/* As conditional orders write their "skip to" order all over the flags, we cannot check the
|
/* As conditional orders write their "skip to" order all over the flags, we cannot check the
|
||||||
* flags to find out if timetabling is enabled. However, as conditional orders are never
|
* flags to find out if timetabling is enabled. However, as conditional orders are never
|
||||||
|
|
|
@ -51,7 +51,7 @@ Order::~Order()
|
||||||
/* We can visit oil rigs and buoys that are not our own. They will be shown in
|
/* We can visit oil rigs and buoys that are not our own. They will be shown in
|
||||||
* the list of stations. So, we need to invalidate that window if needed. */
|
* the list of stations. So, we need to invalidate that window if needed. */
|
||||||
if (this->IsType(OT_GOTO_STATION) || this->IsType(OT_GOTO_WAYPOINT)) {
|
if (this->IsType(OT_GOTO_STATION) || this->IsType(OT_GOTO_WAYPOINT)) {
|
||||||
BaseStation *bs = BaseStation::GetIfValid(this->GetDestination());
|
BaseStation *bs = BaseStation::GetIfValid(this->GetDestination().ToStationID());
|
||||||
if (bs != nullptr && bs->owner == OWNER_NONE) InvalidateWindowClassesData(WC_STATION_LIST, 0);
|
if (bs != nullptr && bs->owner == OWNER_NONE) InvalidateWindowClassesData(WC_STATION_LIST, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,12 +202,12 @@ uint16_t Order::MapOldOrder() const
|
||||||
if (this->GetUnloadType() & OUFB_UNLOAD) SetBit(order, 5);
|
if (this->GetUnloadType() & OUFB_UNLOAD) SetBit(order, 5);
|
||||||
if (this->GetLoadType() & OLFB_FULL_LOAD) SetBit(order, 6);
|
if (this->GetLoadType() & OLFB_FULL_LOAD) SetBit(order, 6);
|
||||||
if (this->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) SetBit(order, 7);
|
if (this->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) SetBit(order, 7);
|
||||||
order |= GB(this->GetDestination(), 0, 8) << 8;
|
order |= GB(this->GetDestination().value, 0, 8) << 8;
|
||||||
break;
|
break;
|
||||||
case OT_GOTO_DEPOT:
|
case OT_GOTO_DEPOT:
|
||||||
if (!(this->GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) SetBit(order, 6);
|
if (!(this->GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) SetBit(order, 6);
|
||||||
SetBit(order, 7);
|
SetBit(order, 7);
|
||||||
order |= GB(this->GetDestination(), 0, 8) << 8;
|
order |= GB(this->GetDestination().value, 0, 8) << 8;
|
||||||
break;
|
break;
|
||||||
case OT_LOADING:
|
case OT_LOADING:
|
||||||
if (this->GetLoadType() & OLFB_FULL_LOAD) SetBit(order, 6);
|
if (this->GetLoadType() & OLFB_FULL_LOAD) SetBit(order, 6);
|
||||||
|
@ -434,7 +434,7 @@ StationIDStack OrderList::GetNextStoppingStation(const Vehicle *v, const Order *
|
||||||
}
|
}
|
||||||
} while (next->IsType(OT_GOTO_DEPOT) || next->GetDestination() == v->last_station_visited);
|
} while (next->IsType(OT_GOTO_DEPOT) || next->GetDestination() == v->last_station_visited);
|
||||||
|
|
||||||
return next->GetDestination();
|
return next->GetDestination().ToStationID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -469,7 +469,7 @@ void OrderList::InsertOrderAt(Order *new_order, int index)
|
||||||
/* We can visit oil rigs and buoys that are not our own. They will be shown in
|
/* We can visit oil rigs and buoys that are not our own. They will be shown in
|
||||||
* the list of stations. So, we need to invalidate that window if needed. */
|
* the list of stations. So, we need to invalidate that window if needed. */
|
||||||
if (new_order->IsType(OT_GOTO_STATION) || new_order->IsType(OT_GOTO_WAYPOINT)) {
|
if (new_order->IsType(OT_GOTO_STATION) || new_order->IsType(OT_GOTO_WAYPOINT)) {
|
||||||
BaseStation *bs = BaseStation::Get(new_order->GetDestination());
|
BaseStation *bs = BaseStation::Get(new_order->GetDestination().ToStationID());
|
||||||
if (bs->owner == OWNER_NONE) InvalidateWindowClassesData(WC_STATION_LIST, 0);
|
if (bs->owner == OWNER_NONE) InvalidateWindowClassesData(WC_STATION_LIST, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,12 +630,12 @@ TileIndex Order::GetLocation(const Vehicle *v, bool airport) const
|
||||||
case OT_GOTO_WAYPOINT:
|
case OT_GOTO_WAYPOINT:
|
||||||
case OT_GOTO_STATION:
|
case OT_GOTO_STATION:
|
||||||
case OT_IMPLICIT:
|
case OT_IMPLICIT:
|
||||||
if (airport && v->type == VEH_AIRCRAFT) return Station::Get(this->GetDestination())->airport.tile;
|
if (airport && v->type == VEH_AIRCRAFT) return Station::Get(this->GetDestination().ToStationID())->airport.tile;
|
||||||
return BaseStation::Get(this->GetDestination())->xy;
|
return BaseStation::Get(this->GetDestination().ToStationID())->xy;
|
||||||
|
|
||||||
case OT_GOTO_DEPOT:
|
case OT_GOTO_DEPOT:
|
||||||
if (this->GetDestination() == INVALID_DEPOT) return INVALID_TILE;
|
if (this->GetDestination() == INVALID_DEPOT) return INVALID_TILE;
|
||||||
return (v->type == VEH_AIRCRAFT) ? Station::Get(this->GetDestination())->xy : Depot::Get(this->GetDestination())->xy;
|
return (v->type == VEH_AIRCRAFT) ? Station::Get(this->GetDestination().ToStationID())->xy : Depot::Get(this->GetDestination().ToDepotID())->xy;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return INVALID_TILE;
|
return INVALID_TILE;
|
||||||
|
@ -694,7 +694,7 @@ CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se
|
||||||
* and has the correct flags if any */
|
* and has the correct flags if any */
|
||||||
switch (new_order.GetType()) {
|
switch (new_order.GetType()) {
|
||||||
case OT_GOTO_STATION: {
|
case OT_GOTO_STATION: {
|
||||||
const Station *st = Station::GetIfValid(new_order.GetDestination());
|
const Station *st = Station::GetIfValid(new_order.GetDestination().ToStationID());
|
||||||
if (st == nullptr) return CMD_ERROR;
|
if (st == nullptr) return CMD_ERROR;
|
||||||
|
|
||||||
if (st->owner != OWNER_NONE) {
|
if (st->owner != OWNER_NONE) {
|
||||||
|
@ -749,7 +749,7 @@ CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se
|
||||||
case OT_GOTO_DEPOT: {
|
case OT_GOTO_DEPOT: {
|
||||||
if ((new_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) == 0) {
|
if ((new_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) == 0) {
|
||||||
if (v->type == VEH_AIRCRAFT) {
|
if (v->type == VEH_AIRCRAFT) {
|
||||||
const Station *st = Station::GetIfValid(new_order.GetDestination());
|
const Station *st = Station::GetIfValid(new_order.GetDestination().ToStationID());
|
||||||
|
|
||||||
if (st == nullptr) return CMD_ERROR;
|
if (st == nullptr) return CMD_ERROR;
|
||||||
|
|
||||||
|
@ -760,7 +760,7 @@ CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const Depot *dp = Depot::GetIfValid(new_order.GetDestination());
|
const Depot *dp = Depot::GetIfValid(new_order.GetDestination().ToDepotID());
|
||||||
|
|
||||||
if (dp == nullptr) return CMD_ERROR;
|
if (dp == nullptr) return CMD_ERROR;
|
||||||
|
|
||||||
|
@ -802,7 +802,7 @@ CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se
|
||||||
}
|
}
|
||||||
|
|
||||||
case OT_GOTO_WAYPOINT: {
|
case OT_GOTO_WAYPOINT: {
|
||||||
const Waypoint *wp = Waypoint::GetIfValid(new_order.GetDestination());
|
const Waypoint *wp = Waypoint::GetIfValid(new_order.GetDestination().ToStationID());
|
||||||
if (wp == nullptr) return CMD_ERROR;
|
if (wp == nullptr) return CMD_ERROR;
|
||||||
|
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
|
@ -1536,7 +1536,7 @@ CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID ve
|
||||||
/* Allow copying unreachable destinations if they were already unreachable for the source.
|
/* Allow copying unreachable destinations if they were already unreachable for the source.
|
||||||
* This is basically to allow cloning / autorenewing / autoreplacing vehicles, while the stations
|
* This is basically to allow cloning / autorenewing / autoreplacing vehicles, while the stations
|
||||||
* are temporarily invalid due to reconstruction. */
|
* are temporarily invalid due to reconstruction. */
|
||||||
const Station *st = Station::Get(order->GetDestination());
|
const Station *st = Station::Get(order->GetDestination().ToStationID());
|
||||||
if (CanVehicleUseStation(src, st) && !CanVehicleUseStation(dst, st)) {
|
if (CanVehicleUseStation(src, st) && !CanVehicleUseStation(dst, st)) {
|
||||||
return CommandCost(STR_ERROR_CAN_T_COPY_SHARE_ORDER, GetVehicleCannotUseStationReason(dst, st));
|
return CommandCost(STR_ERROR_CAN_T_COPY_SHARE_ORDER, GetVehicleCannotUseStationReason(dst, st));
|
||||||
}
|
}
|
||||||
|
@ -1583,7 +1583,7 @@ CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID ve
|
||||||
* and neither can helicopters and aircraft. */
|
* and neither can helicopters and aircraft. */
|
||||||
for (const Order *order : src->Orders()) {
|
for (const Order *order : src->Orders()) {
|
||||||
if (!OrderGoesToStation(dst, order)) continue;
|
if (!OrderGoesToStation(dst, order)) continue;
|
||||||
Station *st = Station::Get(order->GetDestination());
|
Station *st = Station::Get(order->GetDestination().ToStationID());
|
||||||
if (!CanVehicleUseStation(dst, st)) {
|
if (!CanVehicleUseStation(dst, st)) {
|
||||||
return CommandCost(STR_ERROR_CAN_T_COPY_SHARE_ORDER, GetVehicleCannotUseStationReason(dst, st));
|
return CommandCost(STR_ERROR_CAN_T_COPY_SHARE_ORDER, GetVehicleCannotUseStationReason(dst, st));
|
||||||
}
|
}
|
||||||
|
@ -1722,7 +1722,7 @@ void CheckOrders(const Vehicle *v)
|
||||||
}
|
}
|
||||||
/* Does station have a load-bay for this vehicle? */
|
/* Does station have a load-bay for this vehicle? */
|
||||||
if (order->IsType(OT_GOTO_STATION)) {
|
if (order->IsType(OT_GOTO_STATION)) {
|
||||||
const Station *st = Station::Get(order->GetDestination());
|
const Station *st = Station::Get(order->GetDestination().ToStationID());
|
||||||
|
|
||||||
n_st++;
|
n_st++;
|
||||||
if (!CanVehicleUseStation(v, st)) {
|
if (!CanVehicleUseStation(v, st)) {
|
||||||
|
@ -1989,7 +1989,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool
|
||||||
|
|
||||||
switch (order->GetType()) {
|
switch (order->GetType()) {
|
||||||
case OT_GOTO_STATION:
|
case OT_GOTO_STATION:
|
||||||
v->SetDestTile(v->GetOrderStationLocation(order->GetDestination()));
|
v->SetDestTile(v->GetOrderStationLocation(order->GetDestination().ToStationID()));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case OT_GOTO_DEPOT:
|
case OT_GOTO_DEPOT:
|
||||||
|
@ -2035,13 +2035,13 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool
|
||||||
v->IncrementRealOrderIndex();
|
v->IncrementRealOrderIndex();
|
||||||
} else {
|
} else {
|
||||||
if (v->type != VEH_AIRCRAFT) {
|
if (v->type != VEH_AIRCRAFT) {
|
||||||
v->SetDestTile(Depot::Get(order->GetDestination())->xy);
|
v->SetDestTile(Depot::Get(order->GetDestination().ToStationID())->xy);
|
||||||
} else {
|
} else {
|
||||||
Aircraft *a = Aircraft::From(v);
|
Aircraft *a = Aircraft::From(v);
|
||||||
DestinationID destination = a->current_order.GetDestination();
|
DestinationID destination = a->current_order.GetDestination();
|
||||||
if (a->targetairport != destination) {
|
if (a->targetairport != destination) {
|
||||||
/* The aircraft is now heading for a different hangar than the next in the orders */
|
/* The aircraft is now heading for a different hangar than the next in the orders */
|
||||||
a->SetDestTile(a->GetOrderStationLocation(destination));
|
a->SetDestTile(a->GetOrderStationLocation(destination.ToStationID()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -2049,7 +2049,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OT_GOTO_WAYPOINT:
|
case OT_GOTO_WAYPOINT:
|
||||||
v->SetDestTile(Waypoint::Get(order->GetDestination())->xy);
|
v->SetDestTile(Waypoint::Get(order->GetDestination().ToStationID())->xy);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case OT_CONDITIONAL: {
|
case OT_CONDITIONAL: {
|
||||||
|
@ -2144,7 +2144,7 @@ bool ProcessOrders(Vehicle *v)
|
||||||
* the train to stop at this 'via' station if the next order
|
* the train to stop at this 'via' station if the next order
|
||||||
* is a no-non-stop order; in that case not setting the last
|
* is a no-non-stop order; in that case not setting the last
|
||||||
* visited station will cause the vehicle to still stop. */
|
* visited station will cause the vehicle to still stop. */
|
||||||
v->last_station_visited = v->current_order.GetDestination();
|
v->last_station_visited = v->current_order.GetDestination().ToStationID();
|
||||||
UpdateVehicleTimetable(v, true);
|
UpdateVehicleTimetable(v, true);
|
||||||
v->IncrementImplicitOrderIndex();
|
v->IncrementImplicitOrderIndex();
|
||||||
}
|
}
|
||||||
|
@ -2174,7 +2174,7 @@ bool ProcessOrders(Vehicle *v)
|
||||||
|
|
||||||
/* If it is unchanged, keep it. */
|
/* If it is unchanged, keep it. */
|
||||||
if (order->Equals(v->current_order) && (v->type == VEH_AIRCRAFT || v->dest_tile != 0) &&
|
if (order->Equals(v->current_order) && (v->type == VEH_AIRCRAFT || v->dest_tile != 0) &&
|
||||||
(v->type != VEH_SHIP || !order->IsType(OT_GOTO_STATION) || Station::Get(order->GetDestination())->ship_station.tile != INVALID_TILE)) {
|
(v->type != VEH_SHIP || !order->IsType(OT_GOTO_STATION) || Station::Get(order->GetDestination().ToStationID())->ship_station.tile != INVALID_TILE)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,12 @@ DEF_CMD_TRAIT(CMD_CLEAR_ORDER_BACKUP, CmdClearOrderBackup, CMD_CLIENT_ID, CMDT_
|
||||||
template <typename Tcont, typename Titer>
|
template <typename Tcont, typename Titer>
|
||||||
inline EndianBufferWriter<Tcont, Titer> &operator <<(EndianBufferWriter<Tcont, Titer> &buffer, const Order &order)
|
inline EndianBufferWriter<Tcont, Titer> &operator <<(EndianBufferWriter<Tcont, Titer> &buffer, const Order &order)
|
||||||
{
|
{
|
||||||
return buffer << order.type << order.flags << order.dest << order.refit_cargo << order.wait_time << order.travel_time << order.max_speed;
|
return buffer << order.type << order.flags << order.dest.value << order.refit_cargo << order.wait_time << order.travel_time << order.max_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline EndianBufferReader &operator >>(EndianBufferReader &buffer, Order &order)
|
inline EndianBufferReader &operator >>(EndianBufferReader &buffer, Order &order)
|
||||||
{
|
{
|
||||||
return buffer >> order.type >> order.flags >> order.dest >> order.refit_cargo >> order.wait_time >> order.travel_time >> order.max_speed;
|
return buffer >> order.type >> order.flags >> order.dest.value >> order.refit_cargo >> order.wait_time >> order.travel_time >> order.max_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* ORDER_CMD_H */
|
#endif /* ORDER_CMD_H */
|
||||||
|
|
|
@ -262,7 +262,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||||
case OT_GOTO_STATION: {
|
case OT_GOTO_STATION: {
|
||||||
OrderLoadFlags load = order->GetLoadType();
|
OrderLoadFlags load = order->GetLoadType();
|
||||||
OrderUnloadFlags unload = order->GetUnloadType();
|
OrderUnloadFlags unload = order->GetUnloadType();
|
||||||
bool valid_station = CanVehicleUseStation(v, Station::Get(order->GetDestination()));
|
bool valid_station = CanVehicleUseStation(v, Station::Get(order->GetDestination().ToStationID()));
|
||||||
|
|
||||||
SetDParam(0, valid_station ? STR_ORDER_GO_TO_STATION : STR_ORDER_GO_TO_STATION_CAN_T_USE_STATION);
|
SetDParam(0, valid_station ? STR_ORDER_GO_TO_STATION : STR_ORDER_GO_TO_STATION_CAN_T_USE_STATION);
|
||||||
SetDParam(1, STR_ORDER_GO_TO + (v->IsGroundVehicle() ? order->GetNonStopType() : 0));
|
SetDParam(1, STR_ORDER_GO_TO + (v->IsGroundVehicle() ? order->GetNonStopType() : 0));
|
||||||
|
|
|
@ -11,11 +11,32 @@
|
||||||
#define ORDER_TYPE_H
|
#define ORDER_TYPE_H
|
||||||
|
|
||||||
#include "core/enum_type.hpp"
|
#include "core/enum_type.hpp"
|
||||||
|
#include "depot_type.h"
|
||||||
|
#include "station_type.h"
|
||||||
|
|
||||||
typedef uint8_t VehicleOrderID; ///< The index of an order within its current vehicle (not pool related)
|
typedef uint8_t VehicleOrderID; ///< The index of an order within its current vehicle (not pool related)
|
||||||
typedef uint32_t OrderID;
|
typedef uint32_t OrderID;
|
||||||
typedef uint16_t OrderListID;
|
typedef uint16_t OrderListID;
|
||||||
typedef uint16_t DestinationID;
|
|
||||||
|
struct DestinationID {
|
||||||
|
using BaseType = uint16_t;
|
||||||
|
BaseType value = 0;
|
||||||
|
|
||||||
|
explicit DestinationID() = default;
|
||||||
|
constexpr DestinationID(size_t index) : value(static_cast<BaseType>(index)) {}
|
||||||
|
|
||||||
|
constexpr DepotID ToDepotID() const noexcept { return static_cast<DepotID>(this->value); }
|
||||||
|
constexpr StationID ToStationID() const noexcept { return static_cast<StationID>(this->value); }
|
||||||
|
constexpr BaseType base() const noexcept { return this->value; }
|
||||||
|
|
||||||
|
constexpr bool operator ==(const DestinationID &destination) const { return this->value == destination.value; }
|
||||||
|
constexpr bool operator !=(const DestinationID &destination) const { return this->value != destination.value; }
|
||||||
|
constexpr bool operator ==(const StationID &station) const { return this->value == station; }
|
||||||
|
constexpr bool operator !=(const StationID &station) const { return this->value != station; }
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr bool operator ==(const StationID &station, const DestinationID &destination) { return destination == station; }
|
||||||
|
constexpr bool operator !=(const StationID &station, const DestinationID &destination) { return destination != station; }
|
||||||
|
|
||||||
/** Invalid vehicle order index (sentinel) */
|
/** Invalid vehicle order index (sentinel) */
|
||||||
static const VehicleOrderID INVALID_VEH_ORDER_ID = 0xFF;
|
static const VehicleOrderID INVALID_VEH_ORDER_ID = 0xFF;
|
||||||
|
|
|
@ -404,7 +404,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
|
||||||
} else if (cur.tile_type == MP_STATION && IsRailWaypoint(cur.tile)) {
|
} else if (cur.tile_type == MP_STATION && IsRailWaypoint(cur.tile)) {
|
||||||
if (v->current_order.IsType(OT_GOTO_WAYPOINT) &&
|
if (v->current_order.IsType(OT_GOTO_WAYPOINT) &&
|
||||||
GetStationIndex(cur.tile) == v->current_order.GetDestination() &&
|
GetStationIndex(cur.tile) == v->current_order.GetDestination() &&
|
||||||
!Waypoint::Get(v->current_order.GetDestination())->IsSingleTile()) {
|
!Waypoint::Get(v->current_order.GetDestination().ToStationID())->IsSingleTile()) {
|
||||||
/* This waypoint is our destination; maybe this isn't an unreserved
|
/* This waypoint is our destination; maybe this isn't an unreserved
|
||||||
* one, so check that and if so see that as the last signal being
|
* one, so check that and if so see that as the last signal being
|
||||||
* red. This way waypoints near stations should work better. */
|
* red. This way waypoints near stations should work better. */
|
||||||
|
|
|
@ -135,7 +135,7 @@ public:
|
||||||
this->any_depot = false;
|
this->any_depot = false;
|
||||||
switch (v->current_order.GetType()) {
|
switch (v->current_order.GetType()) {
|
||||||
case OT_GOTO_WAYPOINT:
|
case OT_GOTO_WAYPOINT:
|
||||||
if (!Waypoint::Get(v->current_order.GetDestination())->IsSingleTile()) {
|
if (!Waypoint::Get(v->current_order.GetDestination().ToStationID())->IsSingleTile()) {
|
||||||
/* In case of 'complex' waypoints we need to do a look
|
/* In case of 'complex' waypoints we need to do a look
|
||||||
* ahead. This look ahead messes a bit about, which
|
* ahead. This look ahead messes a bit about, which
|
||||||
* means that it 'corrupts' the cache. To prevent this
|
* means that it 'corrupts' the cache. To prevent this
|
||||||
|
@ -146,8 +146,8 @@ public:
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
|
|
||||||
case OT_GOTO_STATION:
|
case OT_GOTO_STATION:
|
||||||
this->dest_tile = CalcClosestStationTile(v->current_order.GetDestination(), v->tile, v->current_order.IsType(OT_GOTO_STATION) ? StationType::Rail : StationType::RailWaypoint);
|
this->dest_tile = CalcClosestStationTile(v->current_order.GetDestination().ToStationID(), v->tile, v->current_order.IsType(OT_GOTO_STATION) ? StationType::Rail : StationType::RailWaypoint);
|
||||||
this->dest_station_id = v->current_order.GetDestination();
|
this->dest_station_id = v->current_order.GetDestination().ToStationID();
|
||||||
this->dest_trackdirs = INVALID_TRACKDIR_BIT;
|
this->dest_trackdirs = INVALID_TRACKDIR_BIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -241,13 +241,13 @@ public:
|
||||||
void SetDestination(const RoadVehicle *v)
|
void SetDestination(const RoadVehicle *v)
|
||||||
{
|
{
|
||||||
if (v->current_order.IsType(OT_GOTO_STATION)) {
|
if (v->current_order.IsType(OT_GOTO_STATION)) {
|
||||||
this->dest_station = v->current_order.GetDestination();
|
this->dest_station = v->current_order.GetDestination().ToStationID();
|
||||||
this->station_type = v->IsBus() ? StationType::Bus : StationType::Truck;
|
this->station_type = v->IsBus() ? StationType::Bus : StationType::Truck;
|
||||||
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, this->station_type);
|
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, this->station_type);
|
||||||
this->non_artic = !v->HasArticulatedPart();
|
this->non_artic = !v->HasArticulatedPart();
|
||||||
this->dest_trackdirs = INVALID_TRACKDIR_BIT;
|
this->dest_trackdirs = INVALID_TRACKDIR_BIT;
|
||||||
} else if (v->current_order.IsType(OT_GOTO_WAYPOINT)) {
|
} else if (v->current_order.IsType(OT_GOTO_WAYPOINT)) {
|
||||||
this->dest_station = v->current_order.GetDestination();
|
this->dest_station = v->current_order.GetDestination().ToStationID();
|
||||||
this->station_type = StationType::RoadWaypoint;
|
this->station_type = StationType::RoadWaypoint;
|
||||||
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, this->station_type);
|
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, this->station_type);
|
||||||
this->non_artic = !v->HasArticulatedPart();
|
this->non_artic = !v->HasArticulatedPart();
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
void SetDestination(const Ship *v)
|
void SetDestination(const Ship *v)
|
||||||
{
|
{
|
||||||
if (v->current_order.IsType(OT_GOTO_STATION)) {
|
if (v->current_order.IsType(OT_GOTO_STATION)) {
|
||||||
this->dest_station = v->current_order.GetDestination();
|
this->dest_station = v->current_order.GetDestination().ToStationID();
|
||||||
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, StationType::Dock);
|
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, StationType::Dock);
|
||||||
this->dest_trackdirs = INVALID_TRACKDIR_BIT;
|
this->dest_trackdirs = INVALID_TRACKDIR_BIT;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -185,7 +185,7 @@ public:
|
||||||
pf.SetDestination(start_water_region_patch);
|
pf.SetDestination(start_water_region_patch);
|
||||||
|
|
||||||
if (v->current_order.IsType(OT_GOTO_STATION)) {
|
if (v->current_order.IsType(OT_GOTO_STATION)) {
|
||||||
DestinationID station_id = v->current_order.GetDestination();
|
StationID station_id = v->current_order.GetDestination().ToStationID();
|
||||||
const BaseStation *station = BaseStation::Get(station_id);
|
const BaseStation *station = BaseStation::Get(station_id);
|
||||||
TileArea tile_area;
|
TileArea tile_area;
|
||||||
station->GetTileArea(&tile_area, StationType::Dock);
|
station->GetTileArea(&tile_area, StationType::Dock);
|
||||||
|
|
|
@ -1369,7 +1369,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
|
||||||
v->current_order.AssignOrder(UnpackOldOrder(_old_order));
|
v->current_order.AssignOrder(UnpackOldOrder(_old_order));
|
||||||
|
|
||||||
if (v->type == VEH_DISASTER) {
|
if (v->type == VEH_DISASTER) {
|
||||||
DisasterVehicle::From(v)->state = UnpackOldOrder(_old_order).GetDestination();
|
DisasterVehicle::From(v)->state = UnpackOldOrder(_old_order).GetDestination().value;
|
||||||
}
|
}
|
||||||
|
|
||||||
v->next = (Vehicle *)(size_t)_old_next_ptr;
|
v->next = (Vehicle *)(size_t)_old_next_ptr;
|
||||||
|
|
|
@ -32,10 +32,10 @@ static void UpdateWaypointOrder(Order *o)
|
||||||
{
|
{
|
||||||
if (!o->IsType(OT_GOTO_STATION)) return;
|
if (!o->IsType(OT_GOTO_STATION)) return;
|
||||||
|
|
||||||
const Station *st = Station::Get(o->GetDestination());
|
const Station *st = Station::Get(o->GetDestination().ToStationID());
|
||||||
if ((st->had_vehicle_of_type & HVOT_WAYPOINT) == 0) return;
|
if ((st->had_vehicle_of_type & HVOT_WAYPOINT) == 0) return;
|
||||||
|
|
||||||
o->MakeGoToWaypoint(o->GetDestination());
|
o->MakeGoToWaypoint(o->GetDestination().ToStationID());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -252,15 +252,15 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||||
/* We don't know where the nearest depot is... (yet) */
|
/* We don't know where the nearest depot is... (yet) */
|
||||||
if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) return INVALID_TILE;
|
if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) return INVALID_TILE;
|
||||||
|
|
||||||
if (v->type != VEH_AIRCRAFT) return ::Depot::Get(order->GetDestination())->xy;
|
if (v->type != VEH_AIRCRAFT) return ::Depot::Get(order->GetDestination().ToDepotID())->xy;
|
||||||
/* Aircraft's hangars are referenced by StationID, not DepotID */
|
/* Aircraft's hangars are referenced by StationID, not DepotID */
|
||||||
const Station *st = ::Station::Get(order->GetDestination());
|
const Station *st = ::Station::Get(order->GetDestination().ToStationID());
|
||||||
if (!st->airport.HasHangar()) return INVALID_TILE;
|
if (!st->airport.HasHangar()) return INVALID_TILE;
|
||||||
return st->airport.GetHangarTile(0);
|
return st->airport.GetHangarTile(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
case OT_GOTO_STATION: {
|
case OT_GOTO_STATION: {
|
||||||
const Station *st = ::Station::Get(order->GetDestination());
|
const Station *st = ::Station::Get(order->GetDestination().ToStationID());
|
||||||
if (st->train_station.tile != INVALID_TILE) {
|
if (st->train_station.tile != INVALID_TILE) {
|
||||||
for (TileIndex t : st->train_station) {
|
for (TileIndex t : st->train_station) {
|
||||||
if (st->TileBelongsToRailStation(t)) return t;
|
if (st->TileBelongsToRailStation(t)) return t;
|
||||||
|
@ -282,7 +282,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
|
||||||
}
|
}
|
||||||
|
|
||||||
case OT_GOTO_WAYPOINT: {
|
case OT_GOTO_WAYPOINT: {
|
||||||
const Waypoint *wp = ::Waypoint::Get(order->GetDestination());
|
const Waypoint *wp = ::Waypoint::Get(order->GetDestination().ToStationID());
|
||||||
if (wp->train_station.tile != INVALID_TILE) {
|
if (wp->train_station.tile != INVALID_TILE) {
|
||||||
for (TileIndex t : wp->train_station) {
|
for (TileIndex t : wp->train_station) {
|
||||||
if (wp->TileBelongsToRailStation(t)) return t;
|
if (wp->TileBelongsToRailStation(t)) return t;
|
||||||
|
|
|
@ -35,7 +35,7 @@ ScriptStationList_Vehicle::ScriptStationList_Vehicle(VehicleID vehicle_id)
|
||||||
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||||
|
|
||||||
for (Order *o = v->GetFirstOrder(); o != nullptr; o = o->next) {
|
for (Order *o = v->GetFirstOrder(); o != nullptr; o = o->next) {
|
||||||
if (o->IsType(OT_GOTO_STATION)) this->AddItem(o->GetDestination());
|
if (o->IsType(OT_GOTO_STATION)) this->AddItem(o->GetDestination().ToStationID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,6 @@ ScriptWaypointList_Vehicle::ScriptWaypointList_Vehicle(VehicleID vehicle_id)
|
||||||
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||||
|
|
||||||
for (const Order *o = v->GetFirstOrder(); o != nullptr; o = o->next) {
|
for (const Order *o = v->GetFirstOrder(); o != nullptr; o = o->next) {
|
||||||
if (o->IsType(OT_GOTO_WAYPOINT)) this->AddItem(o->GetDestination());
|
if (o->IsType(OT_GOTO_WAYPOINT)) this->AddItem(o->GetDestination().ToStationID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -773,7 +773,7 @@ static void ShipController(Ship *v)
|
||||||
}
|
}
|
||||||
} else if (v->current_order.IsType(OT_GOTO_STATION) && IsDockingTile(gp.new_tile)) {
|
} else if (v->current_order.IsType(OT_GOTO_STATION) && IsDockingTile(gp.new_tile)) {
|
||||||
/* Process station in the orderlist. */
|
/* Process station in the orderlist. */
|
||||||
Station *st = Station::Get(v->current_order.GetDestination());
|
Station *st = Station::Get(v->current_order.GetDestination().ToStationID());
|
||||||
if (st->docking_station.Contains(gp.new_tile) && IsShipDestinationTile(gp.new_tile, st->index)) {
|
if (st->docking_station.Contains(gp.new_tile) && IsShipDestinationTile(gp.new_tile, st->index)) {
|
||||||
v->last_station_visited = st->index;
|
v->last_station_visited = st->index;
|
||||||
if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations
|
if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations
|
||||||
|
|
|
@ -4194,7 +4194,7 @@ void Train::OnNewEconomyDay()
|
||||||
|
|
||||||
/* update destination */
|
/* update destination */
|
||||||
if (this->current_order.IsType(OT_GOTO_STATION)) {
|
if (this->current_order.IsType(OT_GOTO_STATION)) {
|
||||||
TileIndex tile = Station::Get(this->current_order.GetDestination())->train_station.tile;
|
TileIndex tile = Station::Get(this->current_order.GetDestination().ToStationID())->train_station.tile;
|
||||||
if (tile != INVALID_TILE) this->dest_tile = tile;
|
if (tile != INVALID_TILE) this->dest_tile = tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2635,7 +2635,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommandFlags command)
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SetDestTile(closestDepot.location);
|
this->SetDestTile(closestDepot.location);
|
||||||
this->current_order.MakeGoToDepot(closestDepot.destination, ODTF_MANUAL);
|
this->current_order.MakeGoToDepot(closestDepot.destination.ToDepotID(), ODTF_MANUAL);
|
||||||
if (!command.Test(DepotCommandFlag::Service)) this->current_order.SetDepotActionType(ODATFB_HALT);
|
if (!command.Test(DepotCommandFlag::Service)) this->current_order.SetDepotActionType(ODATFB_HALT);
|
||||||
SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
|
SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
|
||||||
|
|
||||||
|
|
|
@ -228,13 +228,12 @@ struct RefitDesc {
|
||||||
* and whether it could be found.
|
* and whether it could be found.
|
||||||
*/
|
*/
|
||||||
struct ClosestDepot {
|
struct ClosestDepot {
|
||||||
TileIndex location;
|
TileIndex location = INVALID_TILE;
|
||||||
DestinationID destination; ///< The DestinationID as used for orders.
|
DestinationID destination{}; ///< The DestinationID as used for orders.
|
||||||
bool reverse;
|
bool reverse = false;
|
||||||
bool found;
|
bool found = false;
|
||||||
|
|
||||||
ClosestDepot() :
|
ClosestDepot() = default;
|
||||||
location(INVALID_TILE), destination(0), reverse(false), found(false) {}
|
|
||||||
|
|
||||||
ClosestDepot(TileIndex location, DestinationID destination, bool reverse = false) :
|
ClosestDepot(TileIndex location, DestinationID destination, bool reverse = false) :
|
||||||
location(location), destination(destination), reverse(reverse), found(true) {}
|
location(location), destination(destination), reverse(reverse), found(true) {}
|
||||||
|
|
Loading…
Reference in New Issue