(svn r14309) -Fix [FS#2244]: aircraft frozen above oil rig when the next order is invalid.
authorrubidium
Sat, 13 Sep 2008 11:00:30 +0000
changeset 10125 8f12703df400
parent 10124 089100e22a6a
child 10126 48162ce1b642
(svn r14309) -Fix [FS#2244]: aircraft frozen above oil rig when the next order is invalid.
src/aircraft_cmd.cpp
--- a/src/aircraft_cmd.cpp	Sat Sep 13 10:41:00 2008 +0000
+++ b/src/aircraft_cmd.cpp	Sat Sep 13 11:00:30 2008 +0000
@@ -1578,17 +1578,12 @@
 	/* airport-road is free. We either have to go to another airport, or to the hangar
 	 * ---> start moving */
 
+	bool go_to_hangar = false;
 	switch (v->current_order.GetType()) {
 		case OT_GOTO_STATION: // ready to fly to another airport
-			/* airplane goto state takeoff, helicopter to helitakeoff */
-			v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF;
 			break;
 		case OT_GOTO_DEPOT:   // visit hangar for serivicing, sale, etc.
-			if (v->current_order.GetDestination() == v->u.air.targetairport) {
-				v->u.air.state = HANGAR;
-			} else {
-				v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF;
-			}
+			go_to_hangar = v->current_order.GetDestination() == v->u.air.targetairport;
 			break;
 		case OT_CONDITIONAL:
 			/* In case of a conditional order we just have to wait a tick
@@ -1597,7 +1592,14 @@
 			return;
 		default:  // orders have been deleted (no orders), goto depot and don't bother us
 			v->current_order.Free();
-			v->u.air.state = HANGAR;
+			go_to_hangar = GetStation(v->u.air.targetairport)->Airport()->nof_depots != 0;
+	}
+
+	if (go_to_hangar) {
+		v->u.air.state = HANGAR;
+	} else {
+		/* airplane goto state takeoff, helicopter to helitakeoff */
+		v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF;
 	}
 	AirportMove(v, apc);
 }