Aircraft Struct Reference

Aircraft, helicopters, rotors and their shadows belong to this class. More...

#include <aircraft.h>

Inheritance diagram for Aircraft:
SpecializedVehicle< Aircraft, VEH_AIRCRAFT > Vehicle Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool > BaseVehicle

Public Member Functions

 Aircraft ()
 We don't want GCC to zero our struct! It already is zeroed and has an index!
virtual ~Aircraft ()
 We want to 'destruct' the right class.
void MarkDirty ()
 Marks the vehicles to be redrawn and updates cached variables.
void UpdateDeltaXY (Direction direction)
 Updates the x and y offsets and the size of the sprite used for this vehicle.
ExpensesType GetExpenseType (bool income) const
 Sets the expense type associated to this vehicle type.
bool IsPrimaryVehicle () const
 Whether this is the primary vehicle in the chain.
SpriteID GetImage (Direction direction) const
 Gets the sprite to show for the given direction.
int GetDisplaySpeed () const
 Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
int GetDisplayMaxSpeed () const
 Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
int GetSpeedOldUnits () const
Money GetRunningCost () const
 Gets the running cost of a vehicle.
bool IsInDepot () const
 Check whether the vehicle is in the depot.
bool Tick ()
 Calls the tick handler of the vehicle.
void OnNewDay ()
 Calls the new day handler of the vehicle.
uint Crash (bool flooded=false)
 Crash the (whole) vehicle chain.
TileIndex GetOrderStationLocation (StationID station)
 Determine the location for the station where the vehicle goes to next.
bool FindClosestDepot (TileIndex *location, DestinationID *destination, bool *reverse)
 Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should reverse.
FORCEINLINE bool IsNormalAircraft () const
 Check if the aircraft type is a normal flying device; eg not a rotor or a shadow.

Data Fields

uint16 crashed_counter
 Timer for handling crash animations.
byte pos
 Next desired position of the aircraft.
byte previous_pos
 Previous desired position of the aircraft.
StationID targetairport
 Airport to go to next.
byte state
 State of the airport.
DirectionByte last_direction
byte number_consecutive_turns
 Protection to prevent the aircraft of making a lot of turns in order to reach a specific point.
byte turn_counter
 Ticks between each turn to prevent > 45 degree turns.

Detailed Description

Aircraft, helicopters, rotors and their shadows belong to this class.

Definition at line 42 of file aircraft.h.


Constructor & Destructor Documentation

virtual Aircraft::~Aircraft (  )  [inline, virtual]

We want to 'destruct' the right class.

Definition at line 55 of file aircraft.h.

References Vehicle::PreDestructor().


Member Function Documentation

uint Aircraft::Crash ( bool  flooded = false  )  [virtual]

Crash the (whole) vehicle chain.

Parameters:
flooded whether the cause of the crash is flooding or not.
Returns:
the number of lost souls.

Reimplemented from Vehicle.

Definition at line 1126 of file aircraft_cmd.cpp.

References crashed_counter.

Referenced by CrashAirplane().

bool Aircraft::FindClosestDepot ( TileIndex location,
DestinationID *  destination,
bool *  reverse 
) [virtual]

Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should reverse.

Parameters:
location where do we go to?
destination what hangar do we go to?
reverse should the vehicle be reversed?
Returns:
true if a depot could be found.

Reimplemented from Vehicle.

Definition at line 346 of file aircraft_cmd.cpp.

References Station::airport, FindNearestHangar(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::Get(), GetTargetAirportIfValid(), Airport::HasHangar(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, and BaseStation::xy.

int Aircraft::GetDisplayMaxSpeed (  )  const [inline, virtual]

Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.

Returns:
the vehicle's maximum speed

Reimplemented from Vehicle.

Definition at line 63 of file aircraft.h.

References VehicleCache::cached_max_speed, and Vehicle::vcache.

int Aircraft::GetDisplaySpeed (  )  const [inline, virtual]

Gets the speed in km-ish/h that can be sent into SetDParam for string processing.

Returns:
the vehicle's speed

Reimplemented from Vehicle.

Definition at line 62 of file aircraft.h.

References Vehicle::cur_speed.

ExpensesType Aircraft::GetExpenseType ( bool  income  )  const [inline, virtual]

Sets the expense type associated to this vehicle type.

Parameters:
income whether this is income or (running) expenses of the vehicle

Reimplemented from Vehicle.

Definition at line 59 of file aircraft.h.

References EXPENSES_AIRCRAFT_INC, and EXPENSES_AIRCRAFT_RUN.

SpriteID Aircraft::GetImage ( Direction  direction  )  const [virtual]

Gets the sprite to show for the given direction.

Parameters:
direction the direction the vehicle is facing
Returns:
the sprite for the given vehicle in the given direction

Reimplemented from Vehicle.

Definition at line 147 of file aircraft_cmd.cpp.

References Vehicle::engine_type, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::Get(), and Vehicle::spritenum.

TileIndex Aircraft::GetOrderStationLocation ( StationID  station  )  [virtual]

Determine the location for the station where the vehicle goes to next.

Things done for example are allocating slots in a road stop or exact location of the platform is determined for ships.

Parameters:
station the station to make the next location of the vehicle.
Returns:
the location (tile) to aim for.

Reimplemented from Vehicle.

Definition at line 1108 of file aircraft_cmd.cpp.

References AircraftNextAirportPos_and_Order(), FLYING, and state.

Money Aircraft::GetRunningCost (  )  const [virtual]

Gets the running cost of a vehicle.

Returns:
the vehicle's running cost

Reimplemented from Vehicle.

Definition at line 391 of file aircraft_cmd.cpp.

References Vehicle::engine_type, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::Get(), GetPrice(), Engine::grf_prop, GRFFilePropsBase< Tcnt >::grffile, and PROP_AIRCRAFT_RUNNING_COST_FACTOR.

Referenced by OnNewDay().

bool Aircraft::IsInDepot (  )  const [inline, virtual]

Check whether the vehicle is in the depot.

Returns:
true if and only if the vehicle is in the depot.

Reimplemented from Vehicle.

Definition at line 66 of file aircraft.h.

References IsHangarTile(), Vehicle::tile, Vehicle::vehstatus, and VS_HIDDEN.

FORCEINLINE bool Aircraft::IsNormalAircraft (  )  const [inline]

Check if the aircraft type is a normal flying device; eg not a rotor or a shadow.

Returns:
Returns true if the aircraft is a helicopter/airplane and false if it is a shadow or a rotor

Definition at line 79 of file aircraft.h.

References AIR_AIRCRAFT, and Vehicle::subtype.

Referenced by AfterLoadGame(), CalculateCompanyValue(), Vehicle::IsEngineCountable(), IsPrimaryVehicle(), LoadUnloadVehicle(), NewVehicleAvailable(), OnNewDay(), RemoveAirport(), Tick(), UpdateAirplanesOnNewStation(), UpdateOldAircraft(), and Station::~Station().

void Aircraft::MarkDirty (  )  [virtual]

Marks the vehicles to be redrawn and updates cached variables.

This method marks the area of the vehicle on the screen as dirty. It can be use to repaint the vehicle.

Reimplemented from Vehicle.

Definition at line 1119 of file aircraft_cmd.cpp.

References AIR_HELICOPTER, Vehicle::cur_image, SpecializedVehicle< T, Type >::Next(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::Next(), Vehicle::subtype, and SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::UpdateViewport().

bool Aircraft::Tick (  )  [virtual]

Calls the tick handler of the vehicle.

Returns:
is this vehicle still valid?

Reimplemented from Vehicle.

Definition at line 1854 of file aircraft_cmd.cpp.

References AIR_HELICOPTER, Vehicle::current_order_time, IsNormalAircraft(), Vehicle::running_ticks, Vehicle::subtype, Vehicle::vehstatus, and VS_STOPPED.

void Aircraft::UpdateDeltaXY ( Direction  direction  )  [virtual]

Updates the x and y offsets and the size of the sprite used for this vehicle.

Parameters:
direction the direction the vehicle is facing

Reimplemented from Vehicle.

Definition at line 48 of file aircraft_cmd.cpp.

References AIR_AIRCRAFT, AIR_HELICOPTER, AIR_ROTOR, AIR_SHADOW, ENDTAKEOFF, FLYING, HELILANDING, LANDING, state, Vehicle::subtype, Vehicle::x_extent, Vehicle::x_offs, Vehicle::y_extent, Vehicle::y_offs, and Vehicle::z_extent.

Referenced by AircraftLandAirplane(), and CmdBuildAircraft().


Field Documentation


The documentation for this struct was generated from the following files:

Generated on Sun May 8 07:30:53 2011 for OpenTTD by  doxygen 1.6.1