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
00024 enum AircraftFlyingAltitude {
00025 AIRCRAFT_MIN_FLYING_ALTITUDE = 120,
00026 AIRCRAFT_MAX_FLYING_ALTITUDE = 360,
00027 PLANE_HOLD_MAX_FLYING_ALTITUDE = 150,
00028 HELICOPTER_HOLD_MAX_FLYING_ALTITUDE = 184
00029 };
00030
00031 struct Aircraft;
00032
00034 enum AircraftSubType {
00035 AIR_HELICOPTER = 0,
00036 AIR_AIRCRAFT = 2,
00037 AIR_SHADOW = 4,
00038 AIR_ROTOR = 6
00039 };
00040
00041 void HandleAircraftEnterHangar(Aircraft *v);
00042 void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height);
00043 void UpdateAirplanesOnNewStation(const Station *st);
00044 void UpdateAircraftCache(Aircraft *v);
00045
00046 void AircraftLeaveHangar(Aircraft *v);
00047 void AircraftNextAirportPos_and_Order(Aircraft *v);
00048 uint GetAircraftMinAltitude(int x_pos, int y_pos, int offset);
00049 uint GetAircraftMaxAltitude(int x_pos, int y_pos, int offset);
00050 uint GetAircraftHoldMaxAltitude(const Aircraft *v);
00051 void SetAircraftPosition(Aircraft *v, int x, int y, int z);
00052 void FindBreakdownDestination(Aircraft *v);
00053
00057 struct Aircraft : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
00058 uint16 crashed_counter;
00059 uint16 cached_max_speed;
00060 byte pos;
00061 byte previous_pos;
00062 StationID targetairport;
00063 byte state;
00064 DirectionByte last_direction;
00065 byte number_consecutive_turns;
00066 byte turn_counter;
00067
00074 bool in_max_height_correction;
00075
00082 bool in_min_height_correction;
00083
00085 Aircraft() : SpecializedVehicleBase() {}
00087 virtual ~Aircraft() { this->PreDestructor(); }
00088
00089 void MarkDirty();
00090 void UpdateDeltaXY(Direction direction);
00091 ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
00092 bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); }
00093 SpriteID GetImage(Direction direction) const;
00094 int GetDisplaySpeed() const { return this->cur_speed; }
00095 int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
00096 int GetSpeedOldUnits() const { return this->vcache.cached_max_speed * 10 / 128; }
00097 Money GetRunningCost() const;
00098 bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
00099 bool Tick();
00100 void OnNewDay();
00101 uint Crash(bool flooded = false);
00102 TileIndex GetOrderStationLocation(StationID station);
00103 bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
00104
00111 FORCEINLINE bool IsNormalAircraft() const
00112 {
00113
00114
00115
00116 return this->subtype <= AIR_AIRCRAFT;
00117 }
00118 };
00119
00123 #define FOR_ALL_AIRCRAFT(var) FOR_ALL_VEHICLES_OF_TYPE(Aircraft, var)
00124
00125 SpriteID GetRotorImage(const Aircraft *v);
00126
00127 Station *GetTargetAirportIfValid(const Aircraft *v);
00128
00129 #endif