mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-06-21 12:39:47 +01:00
(svn r1636) fix: helicopters now go to a hangar if they are set for replacement or needs to be renewed
This commit is contained in:
parent
b4c4daf775
commit
6dc99f7738
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user