aircraft.h

Go to the documentation of this file.
00001 /* $Id: aircraft.h 14343 2008-09-16 15:15:41Z smatz $ */
00002 
00005 #ifndef AIRCRAFT_H
00006 #define AIRCRAFT_H
00007 
00008 #include "station_map.h"
00009 #include "station_base.h"
00010 #include "vehicle_base.h"
00011 #include "engine_func.h"
00012 #include "engine_base.h"
00013 
00015 enum AircraftSubType {
00016   AIR_HELICOPTER = 0, 
00017   AIR_AIRCRAFT   = 2, 
00018   AIR_SHADOW     = 4, 
00019   AIR_ROTOR      = 6  
00020 };
00021 
00022 
00028 static inline bool IsNormalAircraft(const Vehicle *v)
00029 {
00030   assert(v->type == VEH_AIRCRAFT);
00031   /* To be fully correct the commented out functionality is the proper one,
00032    * but since value can only be 0 or 2, it is sufficient to only check <= 2
00033    * return (v->subtype == AIR_HELICOPTER) || (v->subtype == AIR_AIRCRAFT); */
00034   return v->subtype <= AIR_AIRCRAFT;
00035 }
00036 
00042 static inline bool CanAircraftUseStation(EngineID engine, const Station *st)
00043 {
00044   const AirportFTAClass *apc = st->Airport();
00045   const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
00046 
00047   return (apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
00048 }
00049 
00055 static inline bool CanAircraftUseStation(EngineID engine, TileIndex tile)
00056 {
00057   return CanAircraftUseStation(engine, GetStationByTile(tile));
00058 }
00059 
00067 uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi);
00068 
00076 void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);
00077 
00081 void HandleAircraftEnterHangar(Vehicle *v);
00082 
00088 void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height);
00089 
00094 void UpdateAirplanesOnNewStation(const Station *st);
00095 
00100 void UpdateAircraftCache(Vehicle *v);
00101 
00110 struct Aircraft : public Vehicle {
00112   Aircraft() { this->type = VEH_AIRCRAFT; }
00113 
00115   virtual ~Aircraft() { this->PreDestructor(); }
00116 
00117   const char *GetTypeString() const { return "aircraft"; }
00118   void MarkDirty();
00119   void UpdateDeltaXY(Direction direction);
00120   ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
00121   bool IsPrimaryVehicle() const { return IsNormalAircraft(this); }
00122   SpriteID GetImage(Direction direction) const;
00123   int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; }
00124   int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 16; }
00125   Money GetRunningCost() const { return AircraftVehInfo(this->engine_type)->running_cost * _price.aircraft_running; }
00126   bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
00127   void Tick();
00128   void OnNewDay();
00129   TileIndex GetOrderStationLocation(StationID station);
00130   bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
00131 };
00132 
00133 Station *GetTargetAirportIfValid(const Vehicle *v);
00134 
00135 #endif /* AIRCRAFT_H */

Generated on Fri Nov 21 19:01:31 2008 for openttd by  doxygen 1.5.6