@ -410,12 +410,8 @@ int32 CmdStartStopAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return 0 ;
return 0 ;
}
}
/* Send an aircraft to the hangar in the next station
// p1 = vehicle
p1 = index of the aircraft
// p2 = if set, the aircraft will try to goto a depot, but not stop
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 )
int32 CmdSendAircraftToHangar ( int x , int y , uint32 flags , uint32 p1 , uint32 p2 )
{
{
Vehicle * v ;
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 ) )
if ( v - > type ! = VEH_Aircraft | | ! CheckOwnership ( v - > owner ) )
return CMD_ERROR ;
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 ( v - > current_order . type = = OT_GOTO_DEPOT & & p2 = = 0 ) {
if ( flags & DC_EXEC ) {
if ( flags & DC_EXEC ) {
if ( v - > current_order . flags & OF_UNLOAD ) v - > cur_order_index + + ;
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 & &
if ( v - > current_order . type = = OT_GOTO_DEPOT & &
( v - > current_order . flags & ( OF_UNLOAD | OF_FULL_LOAD ) ) = = ( OF_UNLOAD | OF_FULL_LOAD ) & &
( v - > current_order . flags & ( OF_UNLOAD | OF_FULL_LOAD ) ) = = ( OF_UNLOAD | OF_FULL_LOAD ) & &
! VehicleNeedsService ( v ) & &
! VehicleNeedsService ( v ) ) {
v - > set_for_replacement = = false ) {
v - > cur_order_index + + ;
v - > cur_order_index + + ;
}
}
@ -1530,49 +1518,11 @@ static void AircraftEventHandler_HeliTakeOff(Vehicle *v, const AirportFTAClass *
AircraftNextAirportPos_and_Order ( v ) ;
AircraftNextAirportPos_and_Order ( v ) ;
// check if the aircraft needs to be replaced or renewed and send it to a hangar if needed
// 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 ) {
if ( ( v - > owner = = _local_player & & _autoreplace_array [ v - > engine_type ] ! = v - > engine_type ) | |
// only the vehicle owner needs to calculate the rest (locally)
( v - > owner = = _local_player & & _patches . autorenew & & v - > age - v - > max_age > ( _patches . autorenew_months * 30 ) ) ) {
if ( ( _autoreplace_array [ v - > engine_type ] ! = v - > engine_type ) | |
_current_player = _local_player ;
( _patches . autorenew & & v - > age - v - > max_age > ( _patches . autorenew_months * 30 ) ) ) {
DoCommandP ( v - > tile , v - > index , 1 , NULL , CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR ) ;
_current_player = OWNER_NONE ;
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 ;
}
}
}
}
}
}
@ -1636,13 +1586,6 @@ static void AircraftEventHandler_Landing(Vehicle *v, const AirportFTAClass *Airp
_current_player = _local_player ;
_current_player = _local_player ;
DoCommandP ( v - > tile , v - > index , 1 < < 16 , NULL , CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR ) ;
DoCommandP ( v - > tile , v - > index , 1 < < 16 , NULL , CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR ) ;
_current_player = OWNER_NONE ;
_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 ;
}
}
}
}
}
}
}