diff options
-rw-r--r-- | aircraft_cmd.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c index e82eca179..713475de8 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -355,6 +355,7 @@ int32 CmdStartStopAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2) } // 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 @@ int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2) 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 @@ int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2) 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 @@ static void AircraftEventHandler_HeliTakeOff(Vehicle *v, const AirportFTAClass * 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) |