Codechange: Use anonymous union for vehicle orders/old orders list
This commit is contained in:
@@ -332,9 +332,9 @@ public:
|
||||
Order current_order; ///< The current order (+ status, like: loading)
|
||||
|
||||
union {
|
||||
OrderList *list; ///< Pointer to the order list for this vehicle
|
||||
Order *old; ///< Only used during conversion of old save games
|
||||
} orders; ///< The orders currently assigned to the vehicle.
|
||||
OrderList *orders; ///< Pointer to the order list for this vehicle
|
||||
Order *old_orders; ///< Only used during conversion of old save games
|
||||
};
|
||||
|
||||
uint16 load_unload_ticks; ///< Ticks to wait before starting next cycle.
|
||||
GroupID group_id; ///< Index of group Pool array
|
||||
@@ -669,7 +669,7 @@ public:
|
||||
* Get the first order of the vehicles order list.
|
||||
* @return first order of order list.
|
||||
*/
|
||||
inline Order *GetFirstOrder() const { return (this->orders.list == nullptr) ? nullptr : this->orders.list->GetFirstOrder(); }
|
||||
inline Order *GetFirstOrder() const { return (this->orders == nullptr) ? nullptr : this->orders->GetFirstOrder(); }
|
||||
|
||||
void AddToShared(Vehicle *shared_chain);
|
||||
void RemoveFromShared();
|
||||
@@ -690,25 +690,25 @@ public:
|
||||
* Get the first vehicle of this vehicle chain.
|
||||
* @return the first vehicle of the chain.
|
||||
*/
|
||||
inline Vehicle *FirstShared() const { return (this->orders.list == nullptr) ? this->First() : this->orders.list->GetFirstSharedVehicle(); }
|
||||
inline Vehicle *FirstShared() const { return (this->orders == nullptr) ? this->First() : this->orders->GetFirstSharedVehicle(); }
|
||||
|
||||
/**
|
||||
* Check if we share our orders with another vehicle.
|
||||
* @return true if there are other vehicles sharing the same order
|
||||
*/
|
||||
inline bool IsOrderListShared() const { return this->orders.list != nullptr && this->orders.list->IsShared(); }
|
||||
inline bool IsOrderListShared() const { return this->orders != nullptr && this->orders->IsShared(); }
|
||||
|
||||
/**
|
||||
* Get the number of orders this vehicle has.
|
||||
* @return the number of orders this vehicle has.
|
||||
*/
|
||||
inline VehicleOrderID GetNumOrders() const { return (this->orders.list == nullptr) ? 0 : this->orders.list->GetNumOrders(); }
|
||||
inline VehicleOrderID GetNumOrders() const { return (this->orders == nullptr) ? 0 : this->orders->GetNumOrders(); }
|
||||
|
||||
/**
|
||||
* Get the number of manually added orders this vehicle has.
|
||||
* @return the number of manually added orders this vehicle has.
|
||||
*/
|
||||
inline VehicleOrderID GetNumManualOrders() const { return (this->orders.list == nullptr) ? 0 : this->orders.list->GetNumManualOrders(); }
|
||||
inline VehicleOrderID GetNumManualOrders() const { return (this->orders == nullptr) ? 0 : this->orders->GetNumManualOrders(); }
|
||||
|
||||
/**
|
||||
* Get the next station the vehicle will stop at.
|
||||
@@ -716,7 +716,7 @@ public:
|
||||
*/
|
||||
inline StationIDStack GetNextStoppingStation() const
|
||||
{
|
||||
return (this->orders.list == nullptr) ? INVALID_STATION : this->orders.list->GetNextStoppingStation(this);
|
||||
return (this->orders == nullptr) ? INVALID_STATION : this->orders->GetNextStoppingStation(this);
|
||||
}
|
||||
|
||||
void ResetRefitCaps();
|
||||
@@ -878,7 +878,7 @@ public:
|
||||
*/
|
||||
inline Order *GetOrder(int index) const
|
||||
{
|
||||
return (this->orders.list == nullptr) ? nullptr : this->orders.list->GetOrderAt(index);
|
||||
return (this->orders == nullptr) ? nullptr : this->orders->GetOrderAt(index);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -887,7 +887,7 @@ public:
|
||||
*/
|
||||
inline Order *GetLastOrder() const
|
||||
{
|
||||
return (this->orders.list == nullptr) ? nullptr : this->orders.list->GetLastOrder();
|
||||
return (this->orders == nullptr) ? nullptr : this->orders->GetLastOrder();
|
||||
}
|
||||
|
||||
bool IsEngineCountable() const;
|
||||
@@ -1038,7 +1038,7 @@ public:
|
||||
* Returns an iterable ensemble of orders of a vehicle
|
||||
* @return an iterable ensemble of orders of a vehicle
|
||||
*/
|
||||
IterateWrapper Orders() const { return IterateWrapper(this->orders.list); }
|
||||
IterateWrapper Orders() const { return IterateWrapper(this->orders); }
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user