aircraft_cmd.c
changeset 1135 b939a3c018eb
parent 1128 d3ffc98b92ad
child 1139 c63f257aa7fb
--- a/aircraft_cmd.c	Mon Jan 24 08:49:14 2005 +0000
+++ b/aircraft_cmd.c	Mon Jan 24 10:50:57 2005 +0000
@@ -355,6 +355,7 @@
 }
 
 // p1 = vehicle
+// p2 = if set, the aircraft will try to goto a depot, but not stop
 int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 {
 	Vehicle *v;
@@ -365,7 +366,7 @@
 	if (!CheckOwnership(v->owner))
 		return CMD_ERROR;
 
-	if (v->current_order.type == OT_GOTO_DEPOT) {
+	if (v->current_order.type == OT_GOTO_DEPOT && p2 != 0) {
 		if (flags & DC_EXEC) {
 			if (v->current_order.flags & OF_UNLOAD) v->cur_order_index++;
 			v->current_order.type = OT_DUMMY;
@@ -381,7 +382,7 @@
 
 		if (flags & DC_EXEC) {
 			v->current_order.type = OT_GOTO_DEPOT;
-			v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
+			v->current_order.flags = p2 == 0 ? OF_NON_STOP | OF_FULL_LOAD : 0;
 			v->current_order.station = v->u.air.targetairport;
 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 		}
@@ -1431,6 +1432,14 @@
 	v->u.air.state = FLYING;
 	// get the next position to go to, differs per airport
 	AircraftNextAirportPos_and_Order(v);
+
+	// check if the aircraft needs to be replaced or renewed and send it to a hangar if needed
+	if ((v->owner == _local_player && _autoreplace_array[v->engine_type] != v->engine_type) ||
+		(v->owner == _local_player && _patches.autorenew && v->age - v->max_age > (_patches.autorenew_months * 30))) {
+		_current_player = _local_player;
+		DoCommandP(v->tile, v->index, 1, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR);
+		_current_player = OWNER_NONE;
+	}
 }
 
 static void AircraftEventHandler_Flying(Vehicle *v, const AirportFTAClass *Airport)