summaryrefslogtreecommitdiff
path: root/aircraft_cmd.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-01-29 01:02:47 +0000
committerbjarni <bjarni@openttd.org>2005-01-29 01:02:47 +0000
commitdb4721a31d05a259b8c3f6fa2118f81799e1dfa6 (patch)
tree0d0ec4513dede4a34d5a0b379893ef26e1520b53 /aircraft_cmd.c
parent27cd24c3169eb5bc254e32ee294dd560b3b9079a (diff)
downloadopenttd-db4721a31d05a259b8c3f6fa2118f81799e1dfa6.tar.xz
(svn r1710) - Fix: [autoreplace] vehicles do no longer go to a depot all the time if the owner clicked 'stop replacing' ( ship+aircraft+road vehicles )
Diffstat (limited to 'aircraft_cmd.c')
-rw-r--r--aircraft_cmd.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index ac6ed9126..59f2fe1a6 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -399,8 +399,12 @@ int32 CmdStartStopAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return 0;
}
-// p1 = vehicle
-// p2 = if set, the aircraft will try to goto a depot, but not stop
+/* Send an aircraft to the hangar in the next station
+ p1 = index of the aircraft
+ p2 = bit 0..15 = index of station with hangar to use (only used if bit 17 is set)
+ bit 16 = set v->set_for_replacement & do not stop in hangar
+ bit 17 = goto the hangar in airport given in bit 0..15 instead of next stop
+ bit 18 = clear v->set_for_replacement */
int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -409,11 +413,16 @@ int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v = GetVehicle(p1);
- if (HASBIT(p2, 16)) v->set_for_replacement = true; //now all clients knows that the vehicle wants to be replaced
-
if (!CheckOwnership(v->owner))
return CMD_ERROR;
+ if (HASBIT(p2, 16)) v->set_for_replacement = true; //now all clients knows that the vehicle wants to be replaced
+
+ if (HASBIT(p2, 18)) {
+ v->set_for_replacement = false;
+ return CMD_ERROR; // no need to send aircraft to a depot. We just told that it don't have to anymore
+ }
+
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++;
@@ -1525,6 +1534,13 @@ static void AircraftEventHandler_HeliTakeOff(Vehicle *v, const AirportFTAClass *
DoCommandP(v->tile, v->index, next_airport, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR);
_current_player = OWNER_NONE;
}
+ } else { // no need to go to a depot
+ if (v->set_for_replacement) {
+ // it seems that the user clicked "Stop replacing"
+ _current_player = _local_player;
+ DoCommandP(v->tile, v->index, (1 | (1 << 2)) << 16, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR);
+ _current_player = OWNER_NONE;
+ }
}
}
}
@@ -1589,6 +1605,13 @@ static void AircraftEventHandler_Landing(Vehicle *v, const AirportFTAClass *Airp
_current_player = _local_player;
DoCommandP(v->tile, v->index, 1 << 16, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR);
_current_player = OWNER_NONE;
+ } else { // no need to go to a depot
+ if (v->set_for_replacement) {
+ // it seems that the user clicked "Stop replacing"
+ _current_player = _local_player;
+ DoCommandP(v->tile, v->index, (1 | (1 << 2)) << 16, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR);
+ _current_player = OWNER_NONE;
+ }
}
}
}