Data Structures | Defines | Enumerations | Functions

aircraft.h File Reference

Base for aircraft. More...

#include "station_map.h"
#include "vehicle_base.h"

Go to the source code of this file.

Data Structures

struct  AircraftCache
 Variables that are cached to improve performance and such. More...
struct  Aircraft
 Aircraft, helicopters, rotors and their shadows belong to this class. More...

Defines

#define FOR_ALL_AIRCRAFT(var)   FOR_ALL_VEHICLES_OF_TYPE(Aircraft, var)
 Macro for iterating over all aircrafts.

Enumerations

enum  AircraftSubType { AIR_HELICOPTER = 0, AIR_AIRCRAFT = 2, AIR_SHADOW = 4, AIR_ROTOR = 6 }
 

An aircraft can be one of those types.

More...
enum  VehicleAirFlags { VAF_DEST_TOO_FAR = 0 }
 

Aircraft flags.

More...

Functions

void HandleAircraftEnterHangar (Aircraft *v)
 Handle Aircraft specific tasks when an Aircraft enters a hangar.
void GetAircraftSpriteSize (EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
 Get the size of the sprite of an aircraft sprite heading west (used for lists).
void UpdateAirplanesOnNewStation (const Station *st)
 Updates the status of the Aircraft heading or in the station.
void UpdateAircraftCache (Aircraft *v, bool update_range=false)
 Update cached values of an aircraft.
void AircraftLeaveHangar (Aircraft *v, Direction exit_dir)
 Aircraft is about to leave the hangar.
void AircraftNextAirportPos_and_Order (Aircraft *v)
 set the right pos when heading to other airports after takeoff
void SetAircraftPosition (Aircraft *v, int x, int y, int z)
 Set aircraft position.
int GetAircraftFlyingAltitude (const Aircraft *v)
 Gets the cruise altitude of an aircraft.
SpriteID GetRotorImage (const Aircraft *v, EngineImageType image_type)
StationGetTargetAirportIfValid (const Aircraft *v)
 Returns aircraft's target station if v->target_airport is a valid station with airport.

Detailed Description

Base for aircraft.

Definition in file aircraft.h.


Enumeration Type Documentation

An aircraft can be one of those types.

Enumerator:
AIR_HELICOPTER 

an helicopter

AIR_AIRCRAFT 

an airplane

AIR_SHADOW 

shadow of the aircraft

AIR_ROTOR 

rotor of an helicopter

Definition at line 21 of file aircraft.h.

Aircraft flags.

Enumerator:
VAF_DEST_TOO_FAR 

Next destination is too far away.

Definition at line 29 of file aircraft.h.


Function Documentation

void AircraftLeaveHangar ( Aircraft v,
Direction  exit_dir 
)

Aircraft is about to leave the hangar.

Parameters:
v Aircraft leaving.
exit_dir The direction the vehicle leaves the hangar.
Note:
This function is called in AfterLoadGame for old savegames, so don't rely on any data to be valid, especially don't rely on the fact that the vehicle is actually on the ground inside a depot.

Definition at line 1289 of file aircraft_cmd.cpp.

References Vehicle::cur_speed, Vehicle::direction, InvalidateWindowData(), Vehicle::Next(), SpecializedVehicle< T, Type >::Next(), Vehicle::progress, SetAircraftPosition(), SetWindowClassesDirty(), Vehicle::subspeed, Vehicle::tile, Vehicle::vehstatus, WC_AIRCRAFT_LIST, WC_VEHICLE_DEPOT, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.

Referenced by AircraftEventHandler_InHangar(), and UpdateOldAircraft().

int GetAircraftFlyingAltitude ( const Aircraft v  ) 

Gets the cruise altitude of an aircraft.

The cruise altitude is determined by the velocity of the vehicle and the direction it is moving

Parameters:
v The vehicle. Should be an aircraft
Returns:
Altitude in pixel units

Definition at line 664 of file aircraft_cmd.cpp.

References AIR_HELICOPTER, VehicleCache::cached_max_speed, DIR_E, DIR_N, DIR_NE, DIR_SE, Vehicle::direction, HELI_FLIGHT_ALTITUDE, min(), PLANE_HOLDING_ALTITUDE, Vehicle::subtype, and Vehicle::vcache.

Referenced by AfterLoadGame(), AircraftController(), and UpdateOldAircraft().

void GetAircraftSpriteSize ( EngineID  engine,
uint &  width,
uint &  height,
int &  xoffs,
int &  yoffs,
EngineImageType  image_type 
)

Get the size of the sprite of an aircraft sprite heading west (used for lists).

Parameters:
engine The engine to get the sprite from.
[out] width The width of the sprite.
[out] height The height of the sprite.
[out] xoffs Number of pixels to shift the sprite to the right.
[out] yoffs Number of pixels to shift the sprite downwards.
image_type Context the sprite is used in.

Definition at line 218 of file aircraft_cmd.cpp.

References Sprite::height, ST_NORMAL, UnScaleByZoom(), Sprite::width, Sprite::x_offs, Sprite::y_offs, and ZOOM_LVL_GUI.

Station* GetTargetAirportIfValid ( const Aircraft v  ) 

Returns aircraft's target station if v->target_airport is a valid station with airport.

Parameters:
v vehicle to get target airport for
Returns:
pointer to target station, NULL if invalid

Definition at line 1960 of file aircraft_cmd.cpp.

References Station::airport, SpecializedStation< Station, false >::GetIfValid(), INVALID_TILE, Aircraft::targetairport, TileArea::tile, and VEH_AIRCRAFT.

Referenced by AfterLoadGame(), AircraftNextAirportPos_and_Order(), CrashAirplane(), Aircraft::FindClosestDepot(), FindNearestHangar(), HandleCrashedAircraft(), MapAircraftMovementState(), and Vehicle::PreDestructor().

void HandleAircraftEnterHangar ( Aircraft v  ) 

Handle Aircraft specific tasks when an Aircraft enters a hangar.

Parameters:
*v Vehicle that enters the hangar

Definition at line 527 of file aircraft_cmd.cpp.

References Vehicle::cur_speed, SpecializedVehicle< T, Type >::Next(), Vehicle::progress, SetAircraftPosition(), Vehicle::subspeed, Vehicle::vehstatus, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.

Referenced by VehicleEnterDepot().

void SetAircraftPosition ( Aircraft v,
int  x,
int  y,
int  z 
)
void UpdateAircraftCache ( Aircraft v,
bool  update_range 
)
void UpdateAirplanesOnNewStation ( const Station st  )