summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_cmd.c25
-rw-r--r--ship_cmd.c25
-rw-r--r--train_cmd.c23
3 files changed, 34 insertions, 39 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index d1cc12a46..75aacb6a9 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -1043,19 +1043,17 @@ static void ProcessAircraftOrder(Vehicle *v)
{
const Order *order;
- // OT_GOTO_DEPOT, OT_LOADING
- if (v->current_order.type == OT_GOTO_DEPOT ||
- v->current_order.type == OT_LOADING) {
- if (v->current_order.type != OT_GOTO_DEPOT ||
- !(v->current_order.flags & OF_UNLOAD))
- return;
- }
+ switch (v->current_order.type) {
+ case OT_GOTO_DEPOT:
+ if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return;
+ if (v->current_order.flags & OF_SERVICE_IF_NEEDED &&
+ !VehicleNeedsService(v)) {
+ v->cur_order_index++;
+ }
+ break;
- if (v->current_order.type == OT_GOTO_DEPOT &&
- (v->current_order.flags & (OF_PART_OF_ORDERS | OF_SERVICE_IF_NEEDED)) == (OF_PART_OF_ORDERS | OF_SERVICE_IF_NEEDED) &&
- !VehicleNeedsService(v)) {
- v->cur_order_index++;
- }
+ case OT_LOADING: return;
+ }
if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0;
@@ -1067,8 +1065,7 @@ static void ProcessAircraftOrder(Vehicle *v)
return;
}
- if (order->type == OT_DUMMY && !CheckForValidOrders(v))
- CrashAirplane(v);
+ if (order->type == OT_DUMMY && !CheckForValidOrders(v)) CrashAirplane(v);
if (order->type == v->current_order.type &&
order->flags == v->current_order.flags &&
diff --git a/ship_cmd.c b/ship_cmd.c
index 3a80aca09..651239286 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -203,22 +203,21 @@ static void ProcessShipOrder(Vehicle *v)
{
const Order *order;
- if (v->current_order.type >= OT_GOTO_DEPOT &&
- v->current_order.type <= OT_LEAVESTATION) {
- if (v->current_order.type != OT_GOTO_DEPOT ||
- !(v->current_order.flags & OF_UNLOAD))
- return;
- }
+ switch (v->current_order.type) {
+ case OT_GOTO_DEPOT:
+ if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return;
+ if (v->current_order.flags & OF_SERVICE_IF_NEEDED &&
+ !VehicleNeedsService(v)) {
+ v->cur_order_index++;
+ }
+ break;
- if (v->current_order.type == OT_GOTO_DEPOT &&
- (v->current_order.flags & (OF_PART_OF_ORDERS | OF_SERVICE_IF_NEEDED)) == (OF_PART_OF_ORDERS | OF_SERVICE_IF_NEEDED) &&
- !VehicleNeedsService(v)) {
- v->cur_order_index++;
+ case OT_LOADING:
+ case OT_LEAVESTATION:
+ return;
}
-
- if (v->cur_order_index >= v->num_orders)
- v->cur_order_index = 0;
+ if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0;
order = GetVehicleOrder(v, v->cur_order_index);
diff --git a/train_cmd.c b/train_cmd.c
index 21839c44b..403093b06 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -2274,19 +2274,18 @@ static bool ProcessTrainOrder(Vehicle *v)
const Order *order;
bool result;
- // These are un-interruptible
- if (v->current_order.type >= OT_GOTO_DEPOT &&
- v->current_order.type <= OT_LEAVESTATION) {
- // Let a depot order in the orderlist interrupt.
- if (v->current_order.type != OT_GOTO_DEPOT ||
- !(v->current_order.flags & OF_UNLOAD))
- return false;
- }
+ switch (v->current_order.type) {
+ case OT_GOTO_DEPOT:
+ if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return false;
+ if ((v->current_order.flags & OF_SERVICE_IF_NEEDED) &&
+ !VehicleNeedsService(v)) {
+ v->cur_order_index++;
+ }
+ break;
- if (v->current_order.type == OT_GOTO_DEPOT &&
- (v->current_order.flags & (OF_PART_OF_ORDERS | OF_SERVICE_IF_NEEDED)) == (OF_PART_OF_ORDERS | OF_SERVICE_IF_NEEDED) &&
- !VehicleNeedsService(v)) {
- v->cur_order_index++;
+ case OT_LOADING:
+ case OT_LEAVESTATION:
+ return false;
}
// check if we've reached the waypoint?