Mercurial > hg > openttd
changeset 3005:b548505d4678 draft
(svn r3585) Similar changes to the order handlers of the other vehicle types like r3584
author | tron <tron@openttd.org> |
---|---|
date | Fri, 10 Feb 2006 06:33:56 +0000 |
parents | 7a4daa3e1cd9 |
children | 10f0441416e3 |
files | aircraft_cmd.c ship_cmd.c train_cmd.c |
diffstat | 3 files changed, 34 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -1043,20 +1043,18 @@ { 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; + + case OT_LOADING: return; } - 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++; - } - if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0; order = GetVehicleOrder(v, v->cur_order_index); @@ -1067,8 +1065,7 @@ 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 &&
--- a/ship_cmd.c +++ b/ship_cmd.c @@ -203,22 +203,21 @@ { 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)) + 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; + + case OT_LOADING: + case OT_LEAVESTATION: return; } - 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++; - } - - - 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);
--- a/train_cmd.c +++ b/train_cmd.c @@ -2274,21 +2274,20 @@ 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)) + 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; + + case OT_LOADING: + case OT_LEAVESTATION: return false; } - 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++; - } - // check if we've reached the waypoint? if (v->current_order.type == OT_GOTO_WAYPOINT && v->tile == v->dest_tile) { v->cur_order_index++;