mirror of https://github.com/OpenTTD/OpenTTD
(svn r21807) -Codechange: split automatic order removal into a separate function (fonsinchen)
parent
53c9846f14
commit
bc9afec3b0
|
@ -1736,6 +1736,18 @@ uint GetVehicleCapacity(const Vehicle *v, uint16 *mail_capacity)
|
||||||
return capacity;
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all automatic orders which were not reached.
|
||||||
|
*/
|
||||||
|
void Vehicle::DeleteUnreachedAutoOrders()
|
||||||
|
{
|
||||||
|
const Order *order = this->GetOrder(this->cur_order_index);
|
||||||
|
while (order != NULL && order->IsType(OT_AUTOMATIC)) {
|
||||||
|
/* Delete order effectively deletes order, so get the next before deleting it. */
|
||||||
|
order = order->next;
|
||||||
|
DeleteOrder(this, this->cur_order_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Vehicle::BeginLoading()
|
void Vehicle::BeginLoading()
|
||||||
{
|
{
|
||||||
|
@ -1743,13 +1755,7 @@ void Vehicle::BeginLoading()
|
||||||
|
|
||||||
if (this->current_order.IsType(OT_GOTO_STATION) &&
|
if (this->current_order.IsType(OT_GOTO_STATION) &&
|
||||||
this->current_order.GetDestination() == this->last_station_visited) {
|
this->current_order.GetDestination() == this->last_station_visited) {
|
||||||
/* Delete all automatic orders which were not reached */
|
this->DeleteUnreachedAutoOrders();
|
||||||
const Order *order = this->GetOrder(this->cur_order_index);
|
|
||||||
while (order != NULL && order->IsType(OT_AUTOMATIC)) {
|
|
||||||
/* Delete order effectively deletes order, so get the next before deleting it. */
|
|
||||||
order = order->next;
|
|
||||||
DeleteOrder(this, this->cur_order_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now cur_order_index points to the destination station, and we can start loading */
|
/* Now cur_order_index points to the destination station, and we can start loading */
|
||||||
this->current_order.MakeLoading(true);
|
this->current_order.MakeLoading(true);
|
||||||
|
|
|
@ -243,6 +243,8 @@ public:
|
||||||
GroundVehicleCache *GetGroundVehicleCache();
|
GroundVehicleCache *GetGroundVehicleCache();
|
||||||
const GroundVehicleCache *GetGroundVehicleCache() const;
|
const GroundVehicleCache *GetGroundVehicleCache() const;
|
||||||
|
|
||||||
|
void DeleteUnreachedAutoOrders();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the loading of the vehicle; when not it skips through dummy
|
* Handle the loading of the vehicle; when not it skips through dummy
|
||||||
* orders and does nothing in all other cases.
|
* orders and does nothing in all other cases.
|
||||||
|
|
Loading…
Reference in New Issue