aircraft.h
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
00028
00032 void HandleAircraftEnterHangar(Aircraft *v);
00033
00039 void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height);
00040
00045 void UpdateAirplanesOnNewStation(const Station *st);
00046
00051 void UpdateAircraftCache(Aircraft *v);
00052
00053 void AircraftLeaveHangar(Aircraft *v);
00054 void AircraftNextAirportPos_and_Order(Aircraft *v);
00055 void SetAircraftPosition(Aircraft *v, int x, int y, int z);
00056 byte GetAircraftFlyingAltitude(const Aircraft *v);
00057
00059 struct AircraftCache {
00060 uint16 cached_max_speed;
00061 };
00062
00066 struct Aircraft : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
00067 AircraftCache acache;
00068
00069 uint16 crashed_counter;
00070 byte pos;
00071 byte previous_pos;
00072 StationID targetairport;
00073 byte state;
00074 DirectionByte last_direction;
00075 byte number_consecutive_turns;
00076
00078 byte turn_counter;
00079
00081 Aircraft() : SpecializedVehicle<Aircraft, VEH_AIRCRAFT>() {}
00083 virtual ~Aircraft() { this->PreDestructor(); }
00084
00085 const char *GetTypeString() const { return "aircraft"; }
00086 void MarkDirty();
00087 void UpdateDeltaXY(Direction direction);
00088 ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
00089 bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); }
00090 SpriteID GetImage(Direction direction) const;
00091 int GetDisplaySpeed() const { return this->cur_speed; }
00092 int GetDisplayMaxSpeed() const { return this->max_speed; }
00093 Money GetRunningCost() const;
00094 bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
00095 bool Tick();
00096 void OnNewDay();
00097 uint Crash(bool flooded = false);
00098 TileIndex GetOrderStationLocation(StationID station);
00099 bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
00100
00107 FORCEINLINE bool IsNormalAircraft() const
00108 {
00109
00110
00111
00112 return this->subtype <= AIR_AIRCRAFT;
00113 }
00114 };
00115
00116 #define FOR_ALL_AIRCRAFT(var) FOR_ALL_VEHICLES_OF_TYPE(Aircraft, var)
00117
00118 SpriteID GetRotorImage(const Aircraft *v);
00119
00120 Station *GetTargetAirportIfValid(const Aircraft *v);
00121
00122 #endif