summaryrefslogtreecommitdiff
path: root/aircraft_cmd.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-01-24 10:50:57 +0000
committerbjarni <bjarni@openttd.org>2005-01-24 10:50:57 +0000
commitdcacc38d817ae545b34aaa85cd94f51ed1f32faa (patch)
tree77159dfdc0fa6229488640bc1644f08200a516cc /aircraft_cmd.c
parentbce73fb080adeeff09b60e7293f8f21b32c83b2c (diff)
downloadopenttd-dcacc38d817ae545b34aaa85cd94f51ed1f32faa.tar.xz
(svn r1636) fix: helicopters now go to a hangar if they are set for replacement or needs to be renewed
Diffstat (limited to 'aircraft_cmd.c')
-rw-r--r--aircraft_cmd.c13
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)