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: belugas@6911: /** An aircraft can be one ot those types */ rubidium@6574: enum AircraftSubType { belugas@6905: AIR_HELICOPTER = 0, ///< an helicopter rubidium@6906: AIR_AIRCRAFT = 2, ///< an airplane belugas@6905: AIR_SHADOW = 4, ///< shadow of the aircraft belugas@6905: AIR_ROTOR = 6 ///< rotor of an helicopter rubidium@6574: }; 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: { rubidium@6585: 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: belugas@6905: /** Check if this aircraft is in a hangar belugas@6905: * @param v vehicle to check belugas@6905: * @return true if in hangar belugas@6905: */ tron@3963: static inline bool IsAircraftInHangar(const Vehicle* v) tron@3963: { rubidium@6585: assert(v->type == VEH_AIRCRAFT); tron@3963: return v->vehstatus & VS_HIDDEN && IsHangarTile(v->tile); tron@3963: } tron@3963: belugas@6905: /** Check if this aircraft is in a hangar and stopped belugas@6905: * @param v vehicle to check belugas@6905: * @return true if in hangar and stopped belugas@6905: */ tron@3963: static inline bool IsAircraftInHangarStopped(const Vehicle* v) tron@3963: { tron@3963: return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED; tron@3963: } peter1138@3987: bjarni@6563: /** Checks if an aircraft is buildable at the tile in question bjarni@6563: * @param engine The engine to test bjarni@6563: * @param tile The tile where the hangar is bjarni@6563: * @return true if the aircraft can be build bjarni@6563: */ bjarni@6563: static inline bool IsAircraftBuildableAtStation(EngineID engine, TileIndex tile) bjarni@6563: { bjarni@6563: const Station *st = GetStationByTile(tile); bjarni@6563: const AirportFTAClass *apc = st->Airport(); bjarni@6563: const AircraftVehicleInfo *avi = AircraftVehInfo(engine); bjarni@6563: glx@6571: return (apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0; bjarni@6563: } bjarni@6563: belugas@6905: /** belugas@6905: * Calculates cargo capacity based on an aircraft's passenger belugas@6905: * and mail capacities. belugas@6905: * @param cid Which cargo type to calculate a capacity for. belugas@6905: * @param avi Which engine to find a cargo capacity for. belugas@6905: * @return New cargo capacity value. belugas@6905: */ rubidium@6906: uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi); peter1138@3987: belugas@6911: /** belugas@6911: * This is the Callback method after the construction attempt of an aircraft belugas@6911: * @param success indicates completion (or not) of the operation belugas@6911: * @param tile of depot where aircraft is built belugas@6911: * @param p1 unused belugas@6911: * @param p2 unused belugas@6911: */ bjarni@6031: void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2); belugas@6911: belugas@6911: /** belugas@6911: * This is the Callback method after the cloning attempt of an aircraft belugas@6911: * @param success indicates completion (or not) of the operation belugas@6911: * @param tile unused belugas@6911: * @param p1 unused belugas@6911: * @param p2 unused belugas@6911: */ bjarni@4653: void CcCloneAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2); belugas@6905: belugas@6905: /** Handle Aircraft specific tasks when a an Aircraft enters a hangar belugas@6905: * @param *v Vehicle that enters the hangar belugas@6905: */ belugas@4732: void HandleAircraftEnterHangar(Vehicle *v); belugas@6905: belugas@6905: /** Get the size of the sprite of an aircraft sprite heading west (used for lists) belugas@6905: * @param engine The engine to get the sprite from belugas@6905: * @param width The width of the sprite belugas@6905: * @param height The height of the sprite belugas@6905: */ bjarni@6223: void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height); bjarni@4653: belugas@6911: /** belugas@6911: * Updates the status of the Aircraft heading or in the station belugas@6911: * @param st Station been updated belugas@6911: */ tron@6413: void UpdateAirplanesOnNewStation(const Station *st); tron@6413: peter1138@6986: /** Update cached values of an aircraft. peter1138@6986: * Currently caches callback 36 max speed. peter1138@6986: * @param v Vehicle peter1138@6986: */ peter1138@6986: void UpdateAircraftCache(Vehicle *v); peter1138@6986: rubidium@7048: /** rubidium@7048: * This class 'wraps' Vehicle; you do not actually instantiate this class. rubidium@7048: * You create a Vehicle using AllocateVehicle, so it is added to the pool rubidium@7048: * and you reinitialize that to a Train using: rubidium@7048: * v = new (v) Aircraft(); rubidium@7048: * rubidium@7048: * As side-effect the vehicle type is set correctly. rubidium@7048: */ rubidium@7048: struct Aircraft : public Vehicle { rubidium@7048: /** Initializes the Vehicle to an aircraft */ rubidium@7048: Aircraft() { this->type = VEH_AIRCRAFT; } rubidium@7048: rubidium@7048: /** We want to 'destruct' the right class. */ rubidium@7048: virtual ~Aircraft() {} rubidium@7048: rubidium@7059: const char *GetTypeString() const { return "aircraft"; } rubidium@7049: void MarkDirty(); rubidium@7054: void UpdateDeltaXY(Direction direction); rubidium@7059: ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; } rubidium@7059: WindowClass GetVehicleListWindowClass() const { return WC_AIRCRAFT_LIST; } rubidium@7048: }; rubidium@7048: peter1138@3987: #endif /* AIRCRAFT_H */