Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef AIRCRAFT_H
00013 #define AIRCRAFT_H
00014
00015 #include "station_map.h"
00016 #include "vehicle_base.h"
00017
00018 struct Aircraft;
00019
00021 enum AircraftSubType {
00022 AIR_HELICOPTER = 0,
00023 AIR_AIRCRAFT = 2,
00024 AIR_SHADOW = 4,
00025 AIR_ROTOR = 6,
00026 };
00027
00029 enum VehicleAirFlags {
00030 VAF_DEST_TOO_FAR = 0,
00031 };
00032
00033
00034 void HandleAircraftEnterHangar(Aircraft *v);
00035 void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, EngineImageType image_type);
00036 void UpdateAirplanesOnNewStation(const Station *st);
00037 void UpdateAircraftCache(Aircraft *v, bool update_range = false);
00038
00039 void AircraftLeaveHangar(Aircraft *v, Direction exit_dir);
00040 void AircraftNextAirportPos_and_Order(Aircraft *v);
00041 void SetAircraftPosition(Aircraft *v, int x, int y, int z);
00042 int GetAircraftFlyingAltitude(const Aircraft *v);
00043
00045 struct AircraftCache {
00046 uint32 cached_max_range_sqr;
00047 uint16 cached_max_range;
00048 };
00049
00053 struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
00054 uint16 crashed_counter;
00055 byte pos;
00056 byte previous_pos;
00057 StationID targetairport;
00058 byte state;
00059 DirectionByte last_direction;
00060 byte number_consecutive_turns;
00061 byte turn_counter;
00062 byte flags;
00063
00064 AircraftCache acache;
00065
00067 Aircraft() : SpecializedVehicleBase() {}
00069 virtual ~Aircraft() { this->PreDestructor(); }
00070
00071 void MarkDirty();
00072 void UpdateDeltaXY(Direction direction);
00073 ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
00074 bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); }
00075 SpriteID GetImage(Direction direction, EngineImageType image_type) const;
00076 int GetDisplaySpeed() const { return this->cur_speed; }
00077 int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
00078 int GetSpeedOldUnits() const { return this->vcache.cached_max_speed * 10 / 128; }
00079 int GetCurrentMaxSpeed() const { return this->GetSpeedOldUnits(); }
00080 Money GetRunningCost() const;
00081
00082 bool IsInDepot() const
00083 {
00084 assert(this->IsPrimaryVehicle());
00085 return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile);
00086 }
00087
00088 bool Tick();
00089 void OnNewDay();
00090 uint Crash(bool flooded = false);
00091 TileIndex GetOrderStationLocation(StationID station);
00092 bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
00093
00100 inline bool IsNormalAircraft() const
00101 {
00102
00103
00104
00105 return this->subtype <= AIR_AIRCRAFT;
00106 }
00107
00112 uint16 GetRange() const
00113 {
00114 return this->acache.cached_max_range;
00115 }
00116 };
00117
00121 #define FOR_ALL_AIRCRAFT(var) FOR_ALL_VEHICLES_OF_TYPE(Aircraft, var)
00122
00123 SpriteID GetRotorImage(const Aircraft *v, EngineImageType image_type);
00124
00125 Station *GetTargetAirportIfValid(const Aircraft *v);
00126
00127 #endif