src/aircraft.h
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6447 3b71e57fd22b
child 9908 0fa543611bbe
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
     6 #define AIRCRAFT_H
     6 #define AIRCRAFT_H
     7 
     7 
     8 #include "station_map.h"
     8 #include "station_map.h"
     9 #include "vehicle.h"
     9 #include "vehicle.h"
    10 
    10 
    11 typedef enum AircraftSubTypes {
    11 enum AircraftSubType {
    12 	AIR_HELICOPTER = 0,
    12 	AIR_HELICOPTER = 0,
    13 	AIR_AIRCRAFT   = 2,
    13 	AIR_AIRCRAFT   = 2,
    14 	AIR_SHADOW     = 4,
    14 	AIR_SHADOW     = 4,
    15 	AIR_ROTOR      = 6
    15 	AIR_ROTOR      = 6
    16 } AircraftSubType;
    16 };
    17 
    17 
    18 
    18 
    19 /** Check if the aircraft type is a normal flying device; eg
    19 /** Check if the aircraft type is a normal flying device; eg
    20  * not a rotor or a shadow
    20  * not a rotor or a shadow
    21  * @param v vehicle to check
    21  * @param v vehicle to check
    22  * @return Returns true if the aircraft is a helicopter/airplane and
    22  * @return Returns true if the aircraft is a helicopter/airplane and
    23  * false if it is a shadow or a rotor) */
    23  * false if it is a shadow or a rotor) */
    24 static inline bool IsNormalAircraft(const Vehicle *v)
    24 static inline bool IsNormalAircraft(const Vehicle *v)
    25 {
    25 {
    26 	assert(v->type == VEH_Aircraft);
    26 	assert(v->type == VEH_AIRCRAFT);
    27 	/* To be fully correct the commented out functionality is the proper one,
    27 	/* To be fully correct the commented out functionality is the proper one,
    28 	 * but since value can only be 0 or 2, it is sufficient to only check <= 2
    28 	 * but since value can only be 0 or 2, it is sufficient to only check <= 2
    29 	 * return (v->subtype == AIR_HELICOPTER) || (v->subtype == AIR_AIRCRAFT); */
    29 	 * return (v->subtype == AIR_HELICOPTER) || (v->subtype == AIR_AIRCRAFT); */
    30 	return v->subtype <= AIR_AIRCRAFT;
    30 	return v->subtype <= AIR_AIRCRAFT;
    31 }
    31 }
    32 
    32 
    33 
    33 
    34 static inline bool IsAircraftInHangar(const Vehicle* v)
    34 static inline bool IsAircraftInHangar(const Vehicle* v)
    35 {
    35 {
    36 	assert(v->type == VEH_Aircraft);
    36 	assert(v->type == VEH_AIRCRAFT);
    37 	return v->vehstatus & VS_HIDDEN && IsHangarTile(v->tile);
    37 	return v->vehstatus & VS_HIDDEN && IsHangarTile(v->tile);
    38 }
    38 }
    39 
    39 
    40 static inline bool IsAircraftInHangarStopped(const Vehicle* v)
    40 static inline bool IsAircraftInHangarStopped(const Vehicle* v)
    41 {
    41 {
    42 	return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED;
    42 	return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED;
       
    43 }
       
    44 
       
    45 /** Checks if an aircraft is buildable at the tile in question
       
    46  * @param engine The engine to test
       
    47  * @param tile The tile where the hangar is
       
    48  * @return true if the aircraft can be build
       
    49  */
       
    50 static inline bool IsAircraftBuildableAtStation(EngineID engine, TileIndex tile)
       
    51 {
       
    52 	const Station *st = GetStationByTile(tile);
       
    53 	const AirportFTAClass *apc = st->Airport();
       
    54 	const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
       
    55 
       
    56 	return (apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
    43 }
    57 }
    44 
    58 
    45 uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo*);
    59 uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo*);
    46 
    60 
    47 void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);
    61 void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);