tron@3963: /* $Id$ */ tron@3963: celestar@6447: /** @file aircraft.h */ belugas@6443: peter1138@3987: #ifndef AIRCRAFT_H peter1138@3987: #define AIRCRAFT_H peter1138@3987: tron@3963: #include "station_map.h" tron@3963: #include "vehicle.h" tron@3963: celestar@9908: /** An aircraft can be one ot those types */ celestar@9895: enum AircraftSubType { celestar@9908: AIR_HELICOPTER = 0, ///< an helicopter celestar@9908: AIR_AIRCRAFT = 2, ///< an airplane celestar@9908: AIR_SHADOW = 4, ///< shadow of the aircraft celestar@9908: AIR_ROTOR = 6 ///< rotor of an helicopter celestar@9895: }; Darkvater@6105: Darkvater@6105: Darkvater@6105: /** Check if the aircraft type is a normal flying device; eg Darkvater@6105: * not a rotor or a shadow Darkvater@6105: * @param v vehicle to check Darkvater@6105: * @return Returns true if the aircraft is a helicopter/airplane and Darkvater@6105: * false if it is a shadow or a rotor) */ Darkvater@6105: static inline bool IsNormalAircraft(const Vehicle *v) Darkvater@6105: { celestar@9895: assert(v->type == VEH_AIRCRAFT); Darkvater@6105: /* To be fully correct the commented out functionality is the proper one, Darkvater@6105: * but since value can only be 0 or 2, it is sufficient to only check <= 2 Darkvater@6105: * return (v->subtype == AIR_HELICOPTER) || (v->subtype == AIR_AIRCRAFT); */ Darkvater@6105: return v->subtype <= AIR_AIRCRAFT; Darkvater@6105: } Darkvater@6105: celestar@9908: /** Check if this aircraft is in a hangar celestar@9908: * @param v vehicle to check celestar@9908: * @return true if in hangar celestar@9908: */ tron@3963: static inline bool IsAircraftInHangar(const Vehicle* v) tron@3963: { celestar@9895: assert(v->type == VEH_AIRCRAFT); tron@3963: return v->vehstatus & VS_HIDDEN && IsHangarTile(v->tile); tron@3963: } tron@3963: celestar@9908: /** Check if this aircraft is in a hangar and stopped celestar@9908: * @param v vehicle to check celestar@9908: * @return true if in hangar and stopped celestar@9908: */ tron@3963: static inline bool IsAircraftInHangarStopped(const Vehicle* v) tron@3963: { tron@3963: return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED; tron@3963: } peter1138@3987: celestar@9895: /** Checks if an aircraft is buildable at the tile in question celestar@9895: * @param engine The engine to test celestar@9895: * @param tile The tile where the hangar is celestar@9895: * @return true if the aircraft can be build celestar@9895: */ celestar@9895: static inline bool IsAircraftBuildableAtStation(EngineID engine, TileIndex tile) celestar@9895: { celestar@9895: const Station *st = GetStationByTile(tile); celestar@9895: const AirportFTAClass *apc = st->Airport(); celestar@9895: const AircraftVehicleInfo *avi = AircraftVehInfo(engine); celestar@9895: celestar@9895: return (apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0; celestar@9895: } celestar@9895: celestar@9908: /** celestar@9908: * Calculates cargo capacity based on an aircraft's passenger celestar@9908: * and mail capacities. celestar@9908: * @param cid Which cargo type to calculate a capacity for. celestar@9908: * @param avi Which engine to find a cargo capacity for. celestar@9908: * @return New cargo capacity value. celestar@9908: */ celestar@9908: uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi); peter1138@3987: celestar@9908: /** celestar@9908: * This is the Callback method after the construction attempt of an aircraft celestar@9908: * @param success indicates completion (or not) of the operation celestar@9908: * @param tile of depot where aircraft is built celestar@9908: * @param p1 unused celestar@9908: * @param p2 unused celestar@9908: */ bjarni@6031: void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2); celestar@9908: celestar@9908: /** celestar@9908: * This is the Callback method after the cloning attempt of an aircraft celestar@9908: * @param success indicates completion (or not) of the operation celestar@9908: * @param tile unused celestar@9908: * @param p1 unused celestar@9908: * @param p2 unused celestar@9908: */ bjarni@4653: void CcCloneAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2); celestar@9908: celestar@9908: /** Handle Aircraft specific tasks when a an Aircraft enters a hangar celestar@9908: * @param *v Vehicle that enters the hangar celestar@9908: */ belugas@4732: void HandleAircraftEnterHangar(Vehicle *v); celestar@9908: celestar@9908: /** Get the size of the sprite of an aircraft sprite heading west (used for lists) celestar@9908: * @param engine The engine to get the sprite from celestar@9908: * @param width The width of the sprite celestar@9908: * @param height The height of the sprite celestar@9908: */ bjarni@6223: void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height); bjarni@4653: celestar@9908: /** celestar@9908: * Updates the status of the Aircraft heading or in the station celestar@9908: * @param st Station been updated celestar@9908: */ tron@6413: void UpdateAirplanesOnNewStation(const Station *st); tron@6413: peter1138@3987: #endif /* AIRCRAFT_H */