(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.

This commit is contained in:
rubidium
2008-04-05 12:01:34 +00:00
parent c830c4a369
commit ba0a9538cf
7 changed files with 75 additions and 88 deletions

View File

@@ -1277,6 +1277,22 @@ Date GetServiceIntervalClamped(uint index)
return (_patches.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
}
/**
*
* Check if a vehicle has any valid orders
*
* @return false if there are no valid orders
*
*/
static bool CheckForValidOrders(const Vehicle *v)
{
const Order *order;
FOR_VEHICLE_ORDERS(v, order) if (order->type != OT_DUMMY) return true;
return false;
}
/**
* Handle the orders of a vehicle and determine the next place
* to go to if needed.
@@ -1298,9 +1314,12 @@ bool ProcessOrders(Vehicle *v)
break;
case OT_LOADING:
case OT_LEAVESTATION:
return false;
case OT_LEAVESTATION:
if (v->type != VEH_AIRCRAFT) return false;
break;
default: break;
}
@@ -1334,7 +1353,14 @@ bool ProcessOrders(Vehicle *v)
const Order *order = GetVehicleOrder(v, v->cur_order_index);
/* If no order, do nothing. */
if (order == NULL) {
if (order == NULL || (v->type == VEH_AIRCRAFT && order->type == OT_DUMMY && !CheckForValidOrders(v))) {
if (v->type == VEH_AIRCRAFT) {
/* Aircraft do something vastly different here, so handle separately */
extern void HandleMissingAircraftOrders(Vehicle *v);
HandleMissingAircraftOrders(v);
return false;
}
v->current_order.Free();
v->dest_tile = 0;
if (v->type == VEH_ROAD) ClearSlot(v);
@@ -1361,6 +1387,7 @@ bool ProcessOrders(Vehicle *v)
case VEH_TRAIN:
break;
case VEH_AIRCRAFT:
case VEH_SHIP:
InvalidateWindowClasses(v->GetVehicleListWindowClass());
break;
@@ -1368,14 +1395,11 @@ bool ProcessOrders(Vehicle *v)
switch (order->type) {
case OT_GOTO_STATION:
if (order->dest == v->last_station_visited) {
v->last_station_visited = INVALID_STATION;
}
v->dest_tile = v->GetOrderStationLocation(order->dest);
break;
case OT_GOTO_DEPOT:
v->dest_tile = GetDepot(order->dest)->xy;
if (v->type != VEH_AIRCRAFT) v->dest_tile = GetDepot(order->dest)->xy;
break;
case OT_GOTO_WAYPOINT:
@@ -1390,22 +1414,6 @@ bool ProcessOrders(Vehicle *v)
return may_reverse;
}
/**
*
* Check if a vehicle has any valid orders
*
* @return false if there are no valid orders
*
*/
bool CheckForValidOrders(const Vehicle* v)
{
const Order *order;
FOR_VEHICLE_ORDERS(v, order) if (order->type != OT_DUMMY) return true;
return false;
}
void InitializeOrders()
{
_Order_pool.CleanPool();