aircraft.h

Go to the documentation of this file.
00001 /* $Id: aircraft.h 21097 2010-11-06 12:53:31Z terkhen $ */
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 
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 
00033 void HandleAircraftEnterHangar(Aircraft *v);
00034 
00041 void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height);
00042 
00047 void UpdateAirplanesOnNewStation(const Station *st);
00048 
00054 void UpdateAircraftCache(Aircraft *v);
00055 
00056 void AircraftLeaveHangar(Aircraft *v);
00057 void AircraftNextAirportPos_and_Order(Aircraft *v);
00058 void SetAircraftPosition(Aircraft *v, int x, int y, int z);
00059 byte GetAircraftFlyingAltitude(const Aircraft *v);
00060 
00064 struct Aircraft : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
00065   uint16 crashed_counter;        
00066   byte pos;                      
00067   byte previous_pos;             
00068   StationID targetairport;       
00069   byte state;                    
00070   DirectionByte last_direction;
00071   byte number_consecutive_turns; 
00072   byte turn_counter;             
00073 
00075   Aircraft() : SpecializedVehicle<Aircraft, VEH_AIRCRAFT>() {}
00077   virtual ~Aircraft() { this->PreDestructor(); }
00078 
00079   const char *GetTypeString() const { return "aircraft"; }
00080   void MarkDirty();
00081   void UpdateDeltaXY(Direction direction);
00082   ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
00083   bool IsPrimaryVehicle() const                  { return this->IsNormalAircraft(); }
00084   SpriteID GetImage(Direction direction) const;
00085   int GetDisplaySpeed() const    { return this->cur_speed; }
00086   int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
00087   int GetSpeedOldUnits() const   { return this->vcache.cached_max_speed * 10 / 128; }
00088   Money GetRunningCost() const;
00089   bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
00090   bool Tick();
00091   void OnNewDay();
00092   uint Crash(bool flooded = false);
00093   TileIndex GetOrderStationLocation(StationID station);
00094   bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
00095 
00102   FORCEINLINE bool IsNormalAircraft() const
00103   {
00104     /* To be fully correct the commented out functionality is the proper one,
00105      * but since value can only be 0 or 2, it is sufficient to only check <= 2
00106      * return (this->subtype == AIR_HELICOPTER) || (this->subtype == AIR_AIRCRAFT); */
00107     return this->subtype <= AIR_AIRCRAFT;
00108   }
00109 };
00110 
00114 #define FOR_ALL_AIRCRAFT(var) FOR_ALL_VEHICLES_OF_TYPE(Aircraft, var)
00115 
00116 SpriteID GetRotorImage(const Aircraft *v);
00117 
00118 Station *GetTargetAirportIfValid(const Aircraft *v);
00119 
00120 #endif /* AIRCRAFT_H */

Generated on Sun Jan 9 16:01:51 2011 for OpenTTD by  doxygen 1.6.1