aircraft.h

Go to the documentation of this file.
00001 /* $Id: aircraft.h 18402 2009-12-04 20:29:46Z rubidium $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #ifndef AIRCRAFT_H
00013 #define AIRCRAFT_H
00014 
00015 #include "station_map.h"
00016 #include "vehicle_base.h"
00017 #include "engine_func.h"
00018 #include "engine_base.h"
00019 
00020 struct Aircraft;
00021 
00023 enum AircraftSubType {
00024   AIR_HELICOPTER = 0, 
00025   AIR_AIRCRAFT   = 2, 
00026   AIR_SHADOW     = 4, 
00027   AIR_ROTOR      = 6  
00028 };
00029 
00030 
00038 void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);
00039 
00043 void HandleAircraftEnterHangar(Aircraft *v);
00044 
00050 void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height);
00051 
00056 void UpdateAirplanesOnNewStation(const Station *st);
00057 
00062 void UpdateAircraftCache(Aircraft *v);
00063 
00064 void AircraftLeaveHangar(Aircraft *v);
00065 void AircraftNextAirportPos_and_Order(Aircraft *v);
00066 void SetAircraftPosition(Aircraft *v, int x, int y, int z);
00067 byte GetAircraftFlyingAltitude(const Aircraft *v);
00068 
00070 struct AircraftCache {
00071   uint16 cached_max_speed; 
00072 };
00073 
00077 struct Aircraft : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
00078   AircraftCache acache; 
00079 
00080   uint16 crashed_counter;
00081   byte pos;
00082   byte previous_pos;
00083   StationID targetairport;
00084   byte state;
00085   DirectionByte last_direction;
00086   byte number_consecutive_turns;
00087 
00089   Aircraft() : SpecializedVehicle<Aircraft, VEH_AIRCRAFT>() {}
00091   virtual ~Aircraft() { this->PreDestructor(); }
00092 
00093   const char *GetTypeString() const { return "aircraft"; }
00094   void MarkDirty();
00095   void UpdateDeltaXY(Direction direction);
00096   ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
00097   bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); }
00098   SpriteID GetImage(Direction direction) const;
00099   int GetDisplaySpeed() const { return this->cur_speed; }
00100   int GetDisplayMaxSpeed() const { return this->max_speed; }
00101   Money GetRunningCost() const;
00102   bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
00103   bool Tick();
00104   void OnNewDay();
00105   uint Crash(bool flooded = false);
00106   TileIndex GetOrderStationLocation(StationID station);
00107   bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
00108 
00115   FORCEINLINE bool IsNormalAircraft() const
00116   {
00117     /* To be fully correct the commented out functionality is the proper one,
00118      * but since value can only be 0 or 2, it is sufficient to only check <= 2
00119      * return (this->subtype == AIR_HELICOPTER) || (this->subtype == AIR_AIRCRAFT); */
00120     return this->subtype <= AIR_AIRCRAFT;
00121   }
00122 };
00123 
00124 #define FOR_ALL_AIRCRAFT(var) FOR_ALL_VEHICLES_OF_TYPE(Aircraft, var)
00125 
00126 SpriteID GetRotorImage(const Aircraft *v);
00127 
00128 Station *GetTargetAirportIfValid(const Aircraft *v);
00129 
00130 #endif /* AIRCRAFT_H */

Generated on Tue Jan 5 21:02:52 2010 for OpenTTD by  doxygen 1.5.6