summaryrefslogtreecommitdiff
path: root/aircraft_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'aircraft_cmd.c')
-rw-r--r--aircraft_cmd.c73
1 files changed, 8 insertions, 65 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 526acc6c5..827614963 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -410,12 +410,8 @@ int32 CmdStartStopAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return 0;
}
-/* 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 */
+// 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;
@@ -429,13 +425,6 @@ int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (v->type != VEH_Aircraft || !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++;
@@ -1125,8 +1114,7 @@ static void ProcessAircraftOrder(Vehicle *v)
if (v->current_order.type == OT_GOTO_DEPOT &&
(v->current_order.flags & (OF_UNLOAD | OF_FULL_LOAD)) == (OF_UNLOAD | OF_FULL_LOAD) &&
- !VehicleNeedsService(v) &&
- v->set_for_replacement == false) {
+ !VehicleNeedsService(v)) {
v->cur_order_index++;
}
@@ -1530,49 +1518,11 @@ static void AircraftEventHandler_HeliTakeOff(Vehicle *v, const AirportFTAClass *
AircraftNextAirportPos_and_Order(v);
// check if the aircraft needs to be replaced or renewed and send it to a hangar if needed
- if (v->current_order.type != OT_GOTO_DEPOT && v->owner == _local_player) {
- // only the vehicle owner needs to calculate the rest (locally)
- if ((_autoreplace_array[v->engine_type] != v->engine_type) ||
- (_patches.autorenew && v->age - v->max_age > (_patches.autorenew_months * 30))) {
-
- if (v->set_for_replacement) {
- Station *st = GetStation(v->u.air.targetairport);
- // If an airport doesn't have terminals (so no landing space for airports),
- // it surely doesn't have any hangars
- if (st->xy == 0 || st->airport_tile == 0 || GetAirport(st->airport_type)->terminals == NULL)
- return;
- /* this is not the airport, where the helicopter will be replaced
- No need to make everybody check this, since it would be a waste of bandwidth */
- }
-
- {
- bool has_hangar = HaveHangarInOrderList(v); // this info is needed twice, but we only want to loop the orders once ;)
- uint32 next_airport = 0;
-
- if (!has_hangar) {
- // the helicopter needs help to find a hangar since there are none in the schedule
- SETBIT(next_airport, 17);
- next_airport |= FindNearestHangar(v);
- if (HASBIT(next_airport, 16)) {
- /* when shared airports are allowed, a check for a rentable hangar should be added here */
- /* TODO: tell the player that he needs a hangar */
- v->set_for_replacement = false; //needed so it will check again later when the player might have build a hangar
- return; // player do not own any hangars
- }
- }
- SETBIT(next_airport, 16);
- _current_player = _local_player;
- 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;
- }
- }
+ 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;
}
}
@@ -1636,13 +1586,6 @@ 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;
- }
}
}
}