src/aircraft_cmd.cpp
changeset 10126 bed2d9d38577
parent 10100 7125ef955902
child 10127 ab5e35f77e87
equal deleted inserted replaced
10125:64de1e83efa8 10126:bed2d9d38577
   544 	}
   544 	}
   545 
   545 
   546 	return CommandCost();
   546 	return CommandCost();
   547 }
   547 }
   548 
   548 
       
   549 bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse)
       
   550 {
       
   551 	const Station *st = GetStation(this->u.air.targetairport);
       
   552 	/* If the station is not a valid airport or if it has no hangars */
       
   553 	if (!st->IsValid() || st->airport_tile == 0 || st->Airport()->nof_depots == 0) {
       
   554 		/* the aircraft has to search for a hangar on its own */
       
   555 		StationID station = FindNearestHangar(this);
       
   556 
       
   557 		if (station == INVALID_STATION) return false;
       
   558 
       
   559 		st = GetStation(station);
       
   560 	}
       
   561 
       
   562 	if (location    != NULL) *location    = st->xy;
       
   563 	if (destination != NULL) *destination = st->index;
       
   564 
       
   565 	return true;
       
   566 }
       
   567 
   549 /** Send an aircraft to the hangar.
   568 /** Send an aircraft to the hangar.
   550  * @param tile unused
   569  * @param tile unused
   551  * @param flags for command type
   570  * @param flags for command type
   552  * @param p1 vehicle ID to send to the hangar
   571  * @param p1 vehicle ID to send to the hangar
   553  * @param p2 various bitmasked elements
   572  * @param p2 various bitmasked elements