This file deals with aircraft and airport movements functionalities. More...
#include "stdafx.h"
#include "aircraft.h"
#include "landscape.h"
#include "news_func.h"
#include "tile_map.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "newgrf_sound.h"
#include "spritecache.h"
#include "strings_func.h"
#include "command_func.h"
#include "window_func.h"
#include "date_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
#include "cheat_type.h"
#include "company_base.h"
#include "ai/ai.hpp"
#include "company_func.h"
#include "effectvehicle_func.h"
#include "station_base.h"
#include "engine_base.h"
#include "core/random_func.hpp"
#include "core/backup_type.hpp"
#include "infrastructure_func.h"
#include "table/strings.h"
Go to the source code of this file.
Data Structures | |
struct | MovementTerminalMapping |
Combination of aircraft state for going to a certain terminal and the airport flag for that terminal block. More... | |
Typedefs | |
typedef void | AircraftStateHandler (Aircraft *v, const AirportFTAClass *apc) |
Signature of the aircraft handler function. | |
Enumerations | |
enum | HelicopterRotorStates { HRS_ROTOR_STOPPED, HRS_ROTOR_MOVING_1, HRS_ROTOR_MOVING_2, HRS_ROTOR_MOVING_3 } |
Helicopter rotor animation states. | |
enum | AircraftSpeedLimits { SPEED_LIMIT_TAXI = 50, SPEED_LIMIT_APPROACH = 230, SPEED_LIMIT_BROKEN = 320, SPEED_LIMIT_HOLD = 425, SPEED_LIMIT_NONE = 0xFFFF } |
Special velocities for aircraft. More... | |
Functions | |
static bool | AirportMove (Aircraft *v, const AirportFTAClass *apc) |
static bool | AirportSetBlocks (Aircraft *v, const AirportFTA *current_pos, const AirportFTAClass *apc) |
"reserve" a block for the plane | |
static bool | AirportHasBlock (Aircraft *v, const AirportFTA *current_pos, const AirportFTAClass *apc) |
returns true if the road ahead is busy, eg. | |
static bool | AirportFindFreeTerminal (Aircraft *v, const AirportFTAClass *apc) |
Find a free terminal, and assign it if available. | |
static bool | AirportFindFreeHelipad (Aircraft *v, const AirportFTAClass *apc) |
Find a free helipad, and assign it if available. | |
static void | CrashAirplane (Aircraft *v) |
Bring the aircraft in a crashed state, create the explosion animation, and create a news item about the crash. | |
static StationID | FindNearestHangar (const Aircraft *v) |
Find the nearest hangar to v INVALID_STATION is returned, if the company does not have any suitable airports (like helipads only). | |
SpriteID | GetRotorImage (const Aircraft *v) |
static SpriteID | GetAircraftIcon (EngineID engine) |
void | DrawAircraftEngine (int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal) |
void | GetAircraftSpriteSize (EngineID engine, uint &width, uint &height) |
Get the size of the sprite of an aircraft sprite heading west (used for lists). | |
CommandCost | CmdBuildAircraft (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **ret) |
Build an aircraft. | |
static void | CheckIfAircraftNeedsService (Aircraft *v) |
static void | HelicopterTickHandler (Aircraft *v) |
void | SetAircraftPosition (Aircraft *v, int x, int y, int z) |
Set aircraft position. | |
void | HandleAircraftEnterHangar (Aircraft *v) |
Handle Aircraft specific tasks when an Aircraft enters a hangar. | |
static void | PlayAircraftSound (const Vehicle *v) |
void | UpdateAircraftCache (Aircraft *v) |
Update cached values of an aircraft. | |
static int | UpdateAircraftSpeed (Aircraft *v, uint speed_limit=SPEED_LIMIT_NONE, bool hard_limit=true) |
Sets the new speed for an aircraft. | |
uint | GetAircraftFlyingAltitudeOffset (const Aircraft *v) |
Get the offset in pixels to be added to the AIRCRAFT_MIN_FLYING_ALTITUDE, AIRCRAFT_MAX_FLYING_ALTITUDE constants, in order to make collisions less probable. | |
uint | GetTileHeightBelowAircraft (int x_pos, int y_pos) |
Get the tile height below the aircraft. | |
uint | GetAircraftMinAltitude (int x_pos, int y_pos, int offset) |
Get the height in pixels, from level 0, dependant on terrain below, at wich an aircraft should start increasing it's altitude, to prevent aircraft crashing in higher terrain ahead. | |
uint | GetAircraftMaxAltitude (int x_pos, int y_pos, int offset) |
Get the height in pixels, from level 0, dependant on terrain below, at wich an aircraft should start decreasing it's altitude, to prevent aircraft taking off to space. | |
uint | GetAircraftHoldMaxAltitude (const Aircraft *v) |
Checks the flightpath height of the aircraft, in pixels, from level 0, dependant on terrain below, after adjusting height. | |
static byte | AircraftGetEntryPoint (const Aircraft *v, const AirportFTAClass *apc, Direction rotation) |
Find the entry point to an airport depending on direction which the airport is being approached from. | |
static void | MaybeCrashAirplane (Aircraft *v) |
Decide whether aircraft v should crash. | |
static bool | AircraftController (Aircraft *v) |
Controls the movement of an aircraft. | |
void | FindBreakdownDestination (Aircraft *v) |
Send a broken plane that needs to visit a depot to the correct location. | |
static bool | HandleCrashedAircraft (Aircraft *v) |
Handle crashed aircraft v. | |
static void | HandleAircraftSmoke (Aircraft *v) |
void | HandleMissingAircraftOrders (Aircraft *v) |
static void | AircraftEntersTerminal (Aircraft *v) |
Aircraft arrives at a terminal. | |
static void | AircraftLandAirplane (Aircraft *v) |
Aircraft touched down at the landing strip. | |
void | AircraftNextAirportPos_and_Order (Aircraft *v) |
set the right pos when heading to other airports after takeoff | |
void | AircraftLeaveHangar (Aircraft *v) |
static void | AircraftEventHandler_EnterTerminal (Aircraft *v, const AirportFTAClass *apc) |
static void | AircraftEventHandler_EnterHangar (Aircraft *v, const AirportFTAClass *apc) |
Aircraft arrived in an airport hangar. | |
static void | AircraftEventHandler_InHangar (Aircraft *v, const AirportFTAClass *apc) |
Handle aircraft movement/decision making in an airport hangar. | |
static void | AircraftEventHandler_AtTerminal (Aircraft *v, const AirportFTAClass *apc) |
At one of the Airport's Terminals. | |
static void | AircraftEventHandler_General (Aircraft *v, const AirportFTAClass *apc) |
static void | AircraftEventHandler_TakeOff (Aircraft *v, const AirportFTAClass *apc) |
static void | AircraftEventHandler_StartTakeOff (Aircraft *v, const AirportFTAClass *apc) |
static void | AircraftEventHandler_EndTakeOff (Aircraft *v, const AirportFTAClass *apc) |
static void | AircraftEventHandler_HeliTakeOff (Aircraft *v, const AirportFTAClass *apc) |
static void | AircraftEventHandler_Flying (Aircraft *v, const AirportFTAClass *apc) |
static void | AircraftEventHandler_Landing (Aircraft *v, const AirportFTAClass *apc) |
static void | AircraftEventHandler_HeliLanding (Aircraft *v, const AirportFTAClass *apc) |
static void | AircraftEventHandler_EndLanding (Aircraft *v, const AirportFTAClass *apc) |
static void | AircraftEventHandler_HeliEndLanding (Aircraft *v, const AirportFTAClass *apc) |
static void | AirportClearBlock (const Aircraft *v, const AirportFTAClass *apc) |
static void | AirportGoToNextPosition (Aircraft *v) |
static bool | FreeTerminal (Aircraft *v, byte i, byte last_terminal) |
Find a free terminal or helipad, and if available, assign it. | |
static uint | GetNumTerminals (const AirportFTAClass *apc) |
Get the number of terminals at the airport. | |
static bool | AircraftEventHandler (Aircraft *v, int loop) |
Station * | GetTargetAirportIfValid (const Aircraft *v) |
Returns aircraft's target station if v->target_airport is a valid station with airport. | |
void | UpdateAirplanesOnNewStation (const Station *st) |
Updates the status of the Aircraft heading or in the station. | |
Variables | |
static const uint | ROTOR_Z_OFFSET = 5 |
Z Offset between helicopter- and rotorsprite. | |
static const SpriteID | _aircraft_sprite [] |
static AircraftStateHandler *const | _aircraft_state_handlers [] |
Array of handler functions for each target of the aircraft. | |
static const MovementTerminalMapping | _airport_terminal_mapping [] |
A list of all valid terminals and their associated blocks. |
This file deals with aircraft and airport movements functionalities.
Definition in file aircraft_cmd.cpp.
typedef void AircraftStateHandler(Aircraft *v, const AirportFTAClass *apc) |
Signature of the aircraft handler function.
Definition at line 1749 of file aircraft_cmd.cpp.
enum AircraftSpeedLimits |
Special velocities for aircraft.
Definition at line 595 of file aircraft_cmd.cpp.
static bool AircraftController | ( | Aircraft * | v | ) | [static] |
Controls the movement of an aircraft.
This function actually moves the vehicle on the map and takes care of minor things like sound playback.
v | The vehicle that is moved. Must be the first vehicle of the chain |
Definition at line 830 of file aircraft_cmd.cpp.
References _settings_game, abs(), AIR_AIRCRAFT, AircraftGetEntryPoint(), AircraftNextAirportPos_and_Order(), Station::airport, AMED_BRAKE, AMED_EXACTPOS, AMED_HELI_LOWER, AMED_HELI_RAISE, AMED_HOLD, AMED_LAND, AMED_NOSPDCLAMP, AMED_SLOWTURN, AMED_TAKEOFF, AT_DUMMY, CeilDiv(), ChangeDir(), Vehicle::cur_speed, Vehicle::current_order, DEBUG, AirportFTAClass::delta_z, DIR_N, DIRDIFF_45LEFT, DIRDIFF_45RIGHT, DIRDIFF_REVERSE, DIRDIFF_SAME, DirDifference(), Vehicle::direction, AirportMovingData::direction, AirportMovingData::flag, GetAircraftFlyingAltitudeOffset(), GetAircraftHoldMaxAltitude(), GetAircraftMaxAltitude(), GetAircraftMinAltitude(), GetAirport(), Order::GetDestination(), Airport::GetFTA(), SpecializedStation< Station, false >::GetIfValid(), GetNewVehiclePos(), TileArea::h, Aircraft::in_max_height_correction, Aircraft::in_min_height_correction, INVALID_TILE, max(), MaybeCrashAirplane(), min(), AirportFTAClass::MovingData(), GetNewVehiclePosResult::new_tile, SpecializedVehicle< T, Type >::Next(), AirportFTAClass::nofelements, Aircraft::number_consecutive_turns, GetNewVehiclePosResult::old_tile, VehicleSettings::plane_speed, Aircraft::pos, Aircraft::previous_pos, RotateAirportMovingData(), Airport::rotation, SetAircraftPosition(), SPEED_LIMIT_TAXI, Aircraft::state, Vehicle::subtype, Aircraft::targetairport, Vehicle::tile, TileArea::tile, TILE_SIZE, TileVirtXY(), TileX(), TileY(), Aircraft::turn_counter, Airport::type, UpdateAircraftCache(), UpdateAircraftSpeed(), GameSettings::vehicle, Vehicle::vehstatus, VS_CRASHED, VSE_START, TileArea::w, AirportMovingData::x, Vehicle::x_pos, BaseStation::xy, GetNewVehiclePosResult::y, AirportMovingData::y, Vehicle::y_pos, and Vehicle::z_pos.
static void AircraftEntersTerminal | ( | Aircraft * | v | ) | [static] |
Aircraft arrives at a terminal.
If it is the first aircraft, throw a party. Start loading cargo.
v | Aircraft that arrived. |
Definition at line 1415 of file aircraft_cmd.cpp.
References _local_company, AddVehicleNewsItem(), Vehicle::BeginLoading(), Vehicle::current_order, SpecializedStation< Station, false >::Get(), HVOT_AIRCRAFT, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Order::IsType(), Vehicle::last_station_visited, AI::NewEvent(), NS_ARRIVAL_COMPANY, NS_ARRIVAL_OTHER, Vehicle::owner, SetDParam(), and Aircraft::targetairport.
static void AircraftEventHandler_EnterHangar | ( | Aircraft * | v, | |
const AirportFTAClass * | apc | |||
) | [static] |
Aircraft arrived in an airport hangar.
Definition at line 1505 of file aircraft_cmd.cpp.
References AirportFTA::heading, AirportFTAClass::layout, Aircraft::pos, Aircraft::state, and VehicleEnterDepot().
Referenced by AircraftEventHandler_InHangar().
static void AircraftEventHandler_InHangar | ( | Aircraft * | v, | |
const AirportFTAClass * | apc | |||
) | [static] |
Handle aircraft movement/decision making in an airport hangar.
Definition at line 1516 of file aircraft_cmd.cpp.
References AIR_HELICOPTER, AircraftEventHandler_EnterHangar(), AirportFindFreeHelipad(), AirportFindFreeTerminal(), AirportHasBlock(), Vehicle::current_order, Order::Free(), Order::GetDestination(), HELITAKEOFF, Order::IsType(), AirportFTAClass::layout, Aircraft::pos, Aircraft::previous_pos, Aircraft::state, Vehicle::subtype, TAKEOFF, Aircraft::targetairport, VehicleEnterDepot(), and Vehicle::vehstatus.
static byte AircraftGetEntryPoint | ( | const Aircraft * | v, | |
const AirportFTAClass * | apc, | |||
Direction | rotation | |||
) | [static] |
Find the entry point to an airport depending on direction which the airport is being approached from.
Each airport can have up to four entry points for its approach system so that approaching aircraft do not fly through each other or are forced to do 180 degree turns during the approach. The arrivals are grouped into four sectors dependent on the DiagDirection from which the airport is approached.
v | The vehicle that is approaching the airport | |
apc | The Airport Class being approached. | |
rotation | The rotation of the airport. |
Definition at line 789 of file aircraft_cmd.cpp.
References abs(), Station::airport, ChangeDiagDir(), DIAGDIR_NE, DIAGDIR_NW, DirToDiagDir(), AirportFTAClass::entry_points, SpecializedStation< Station, false >::GetIfValid(), INVALID_TILE, ReverseDiagDir(), Aircraft::targetairport, TileArea::tile, TILE_SIZE, TileX(), TileY(), Vehicle::x_pos, BaseStation::xy, and Vehicle::y_pos.
Referenced by AircraftController(), AircraftNextAirportPos_and_Order(), and UpdateAirplanesOnNewStation().
static void AircraftLandAirplane | ( | Aircraft * | v | ) | [static] |
Aircraft touched down at the landing strip.
v | Aircraft that landed. |
Definition at line 1443 of file aircraft_cmd.cpp.
References INVALID_DIR, Aircraft::UpdateDeltaXY(), and VSE_TOUCHDOWN.
static bool AirportFindFreeHelipad | ( | Aircraft * | v, | |
const AirportFTAClass * | apc | |||
) | [static] |
Find a free helipad, and assign it if available.
Definition at line 2034 of file aircraft_cmd.cpp.
References AirportFindFreeTerminal(), FreeTerminal(), MAX_TERMINALS, and AirportFTAClass::num_helipads.
Referenced by AircraftEventHandler_InHangar().
static bool AirportFindFreeTerminal | ( | Aircraft * | v, | |
const AirportFTAClass * | apc | |||
) | [static] |
Find a free terminal, and assign it if available.
Definition at line 1981 of file aircraft_cmd.cpp.
References Station::airport, AirportFTA::block, Airport::flags, FreeTerminal(), SpecializedStation< Station, false >::Get(), GetNumTerminals(), AirportFTA::heading, AirportFTAClass::layout, AirportFTA::next, AirportFTA::next_position, Aircraft::pos, Aircraft::targetairport, and AirportFTAClass::terminals.
Referenced by AircraftEventHandler_InHangar(), and AirportFindFreeHelipad().
static bool AirportHasBlock | ( | Aircraft * | v, | |
const AirportFTA * | current_pos, | |||
const AirportFTAClass * | apc | |||
) | [static] |
returns true if the road ahead is busy, eg.
you must wait before proceeding.
Definition at line 1846 of file aircraft_cmd.cpp.
References Station::airport, AirportFTA::block, Vehicle::cur_speed, Airport::flags, SpecializedStation< Station, false >::Get(), AirportFTAClass::layout, AirportFTA::next_position, Aircraft::pos, AirportFTA::position, Vehicle::subspeed, and Aircraft::targetairport.
Referenced by AircraftEventHandler_AtTerminal(), and AircraftEventHandler_InHangar().
static bool AirportSetBlocks | ( | Aircraft * | v, | |
const AirportFTA * | current_pos, | |||
const AirportFTAClass * | apc | |||
) | [static] |
"reserve" a block for the plane
v | airplane that requires the operation | |
current_pos | of the vehicle in the list of blocks | |
apc | airport on which block is requsted to be set |
Definition at line 1877 of file aircraft_cmd.cpp.
References Station::airport, AirportFTA::block, Vehicle::cur_speed, Airport::flags, SpecializedStation< Station, false >::Get(), AirportFTA::heading, AirportFTAClass::layout, AirportFTA::next, AirportFTA::next_position, Aircraft::pos, AirportFTA::position, SETBITS, Vehicle::subspeed, and Aircraft::targetairport.
CommandCost CmdBuildAircraft | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
const Engine * | e, | |||
uint16 | data, | |||
Vehicle ** | ret | |||
) |
Build an aircraft.
tile | tile of the depot where aircraft is built. | |
flags | type of operation. | |
e | the engine to build. | |
data | unused. | |
ret[out] | the vehicle that has been built. |
Definition at line 250 of file aircraft_cmd.cpp.
References _cur_year, _current_company, _date, Vehicle::acceleration, AIR_AIRCRAFT, AIR_HELICOPTER, Station::airport, Vehicle::breakdown_chance, Vehicle::build_year, CanVehicleUseStation(), Vehicle::cargo_cap, Vehicle::cargo_type, Clamp(), CMD_ERROR, Vehicle::cur_image, Vehicle::date_of_last_service, DC_EXEC, DC_QUERY_COST, Vehicle::direction, ENGINE_EXCLUSIVE_PREVIEW, Vehicle::engine_type, Engine::flags, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), SpecializedStation< Station, false >::GetByTile(), Engine::GetDefaultCargoType(), Airport::GetHangarNum(), Airport::GetHangarTile(), Engine::GetLifeLengthInDays(), GetStationIndex(), GetTileOwner(), GetVehicleCapacity(), GetVehiclePosOnBuild(), Aircraft::in_max_height_correction, Aircraft::in_min_height_correction, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_DIR, Vehicle::InvalidateNewGRFCacheOfChain(), IsHangarTile(), IsInfraUsageAllowed(), Vehicle::last_loading_station, Vehicle::last_station_visited, AircraftVehicleInfo::mail_capacity, Vehicle::max_age, Vehicle::name, Vehicle::owner, AircraftVehicleInfo::passenger_capacity, Aircraft::pos, Aircraft::previous_pos, Vehicle::random_bits, Engine::reliability, Vehicle::reliability, Engine::reliability_spd_dec, Vehicle::reliability_spd_dec, ROTOR_Z_OFFSET, Vehicle::service_interval, SetBit(), Vehicle::SetNext(), Vehicle::spritenum, Aircraft::state, AircraftVehicleInfo::subtype, Vehicle::subtype, Aircraft::targetairport, Vehicle::tile, TILE_SIZE, TileX(), TileY(), UpdateAircraftCache(), Aircraft::UpdateDeltaXY(), VEH_AIRCRAFT, Vehicle::vehicle_flags, VehicleMove(), VehicleRandomBits(), Vehicle::vehstatus, VF_BUILT_AS_PROTOTYPE, VS_HIDDEN, VS_STOPPED, VS_UNCLICKABLE, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by CmdBuildVehicle().
static void CrashAirplane | ( | Aircraft * | v | ) | [static] |
Bring the aircraft in a crashed state, create the explosion animation, and create a news item about the crash.
v | Aircraft that crashed. |
Definition at line 1345 of file aircraft_cmd.cpp.
References AddVehicleNewsItem(), Vehicle::cargo, Aircraft::Crash(), AIEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT, AIEventVehicleCrashed::CRASH_PLANE_LANDING, CreateEffectVehicleRel(), EV_EXPLOSION_LARGE, GetTargetAirportIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, AI::NewEvent(), SpecializedVehicle< T, Type >::Next(), NS_ACCIDENT, Vehicle::owner, SetDParam(), Vehicle::tile, and CargoList< Tinst, Tcont >::Truncate().
Referenced by FindBreakdownDestination(), and MaybeCrashAirplane().
void FindBreakdownDestination | ( | Aircraft * | v | ) |
Send a broken plane that needs to visit a depot to the correct location.
v | Airplane in question. |
Definition at line 1164 of file aircraft_cmd.cpp.
References AircraftNextAirportPos_and_Order(), BREAKDOWN_AIRCRAFT_DEPOT, BREAKDOWN_AIRCRAFT_EM_LANDING, Vehicle::breakdown_ctr, Vehicle::breakdown_type, CrashAirplane(), Vehicle::current_order, Aircraft::FindClosestDepot(), FindNearestHangar(), Order::GetDestination(), Order::MakeGoToDepot(), ODTFB_BREAKDOWN, Aircraft::targetairport, and VEH_AIRCRAFT.
Referenced by Vehicle::HandleBreakdown().
Find the nearest hangar to v INVALID_STATION is returned, if the company does not have any suitable airports (like helipads only).
v | vehicle looking for a hangar |
Definition at line 114 of file aircraft_cmd.cpp.
References _cheats, AirportFTAClass::AIRPLANES, Station::airport, DistanceSquare(), Vehicle::engine_type, FACIL_AIRPORT, BaseStation::facilities, AirportFTAClass::flags, Airport::GetFTA(), Airport::HasHangar(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsInfraUsageAllowed(), Cheats::no_jetcrash, BaseStation::owner, Vehicle::owner, AircraftVehicleInfo::subtype, TileArea::tile, TileVirtXY(), Cheat::value, VEH_AIRCRAFT, Vehicle::x_pos, and Vehicle::y_pos.
Referenced by FindBreakdownDestination(), and Aircraft::FindClosestDepot().
static bool FreeTerminal | ( | Aircraft * | v, | |
byte | i, | |||
byte | last_terminal | |||
) | [static] |
Find a free terminal or helipad, and if available, assign it.
v | Aircraft looking for a free terminal or helipad. | |
i | First terminal to examine. | |
last_terminal | Terminal number to stop examining. |
Definition at line 1946 of file aircraft_cmd.cpp.
References Station::airport, MovementTerminalMapping::airport_flag, Airport::flags, SpecializedStation< Station, false >::Get(), lengthof, SETBITS, MovementTerminalMapping::state, Aircraft::state, and Aircraft::targetairport.
Referenced by AirportFindFreeHelipad(), and AirportFindFreeTerminal().
uint GetAircraftFlyingAltitudeOffset | ( | const Aircraft * | v | ) |
Get the offset in pixels to be added to the AIRCRAFT_MIN_FLYING_ALTITUDE, AIRCRAFT_MAX_FLYING_ALTITUDE constants, in order to make collisions less probable.
The offset is determined by the velocity of the vehicle and the direction it is moving.
v | The aircraft that needs an offset. |
Definition at line 668 of file aircraft_cmd.cpp.
References AIR_HELICOPTER, VehicleCache::cached_max_speed, DIR_E, DIR_N, DIR_NE, DIR_SE, Vehicle::direction, HELICOPTER_HOLD_MAX_FLYING_ALTITUDE, min(), Vehicle::subtype, and Vehicle::vcache.
Referenced by AircraftController().
uint GetAircraftHoldMaxAltitude | ( | const Aircraft * | v | ) |
Checks the flightpath height of the aircraft, in pixels, from level 0, dependant on terrain below, after adjusting height.
v | The aircraft that may or may not need to decrease its altitude. |
Definition at line 764 of file aircraft_cmd.cpp.
References AIR_HELICOPTER, GetTileHeightBelowAircraft(), Vehicle::subtype, Vehicle::x_pos, and Vehicle::y_pos.
Referenced by AircraftController().
uint GetAircraftMaxAltitude | ( | int | x_pos, | |
int | y_pos, | |||
int | offset | |||
) |
Get the height in pixels, from level 0, dependant on terrain below, at wich an aircraft should start decreasing it's altitude, to prevent aircraft taking off to space.
x_pos | x position of the aircraft's shadow on the map. | |
y_pos | y position of the aircraft's shadow on the map. | |
offset | offset to add to returned altitude. |
Definition at line 750 of file aircraft_cmd.cpp.
References AIRCRAFT_MAX_FLYING_ALTITUDE, and GetTileHeightBelowAircraft().
Referenced by AfterLoadGame(), AircraftController(), and UpdateOldAircraft().
uint GetAircraftMinAltitude | ( | int | x_pos, | |
int | y_pos, | |||
int | offset | |||
) |
Get the height in pixels, from level 0, dependant on terrain below, at wich an aircraft should start increasing it's altitude, to prevent aircraft crashing in higher terrain ahead.
x_pos | x position of the aircraft's shadow on the map. | |
y_pos | y position of the aircraft's shadow on the map. | |
offset | offset to add to returned altitude. |
Definition at line 733 of file aircraft_cmd.cpp.
References AIRCRAFT_MIN_FLYING_ALTITUDE, and GetTileHeightBelowAircraft().
Referenced by AircraftController(), Disaster_Helicopter_Init(), Disaster_Small_Ufo_Init(), and Disaster_Zeppeliner_Init().
void GetAircraftSpriteSize | ( | EngineID | engine, | |
uint & | width, | |||
uint & | height | |||
) |
Get the size of the sprite of an aircraft sprite heading west (used for lists).
engine | The engine to get the sprite from | |
width | The width of the sprite | |
height | The height of the sprite |
Definition at line 233 of file aircraft_cmd.cpp.
References Sprite::height, ST_NORMAL, and Sprite::width.
static uint GetNumTerminals | ( | const AirportFTAClass * | apc | ) | [static] |
Get the number of terminals at the airport.
afc | Airport description. |
Definition at line 1966 of file aircraft_cmd.cpp.
References AirportFTAClass::terminals.
Referenced by AirportFindFreeTerminal().
Returns aircraft's target station if v->target_airport is a valid station with airport.
v | vehicle to get target airport for |
Definition at line 2092 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(), Vehicle::HandleBreakdown(), HandleCrashedAircraft(), MapAircraftMovementState(), and Vehicle::PreDestructor().
uint GetTileHeightBelowAircraft | ( | int | x_pos, | |
int | y_pos | |||
) |
Get the tile height below the aircraft.
This function is needed because aircraft can leave the mapborders. The game would crash if an aircraft leaves the northeast or southeast border. Just for completeness we check all four map edges.
x_pos | x position of the aircraft's shadow on the map. | |
y_pos | y position of the aircraft's shadow on the map. |
Definition at line 707 of file aircraft_cmd.cpp.
References IsInsideMM(), MapSizeX(), MapSizeY(), TILE_HEIGHT, TILE_SIZE, TileHeight(), TileHeightOutsideMap(), and TileVirtXY().
Referenced by GetAircraftHoldMaxAltitude(), GetAircraftMaxAltitude(), and GetAircraftMinAltitude().
void HandleAircraftEnterHangar | ( | Aircraft * | v | ) |
Handle Aircraft specific tasks when an Aircraft enters a hangar.
*v | Vehicle that enters the hangar |
Definition at line 548 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().
static bool HandleCrashedAircraft | ( | Aircraft * | v | ) | [static] |
Handle crashed aircraft v.
v | Crashed aircraft. |
Definition at line 1197 of file aircraft_cmd.cpp.
References Station::airport, Chance16R(), ChangeDir(), CLRBITS, Aircraft::crashed_counter, CreateEffectVehicleRel(), DIRDIFF_45RIGHT, Vehicle::direction, EV_EXPLOSION_SMALL, Airport::flags, GB(), GetTargetAirportIfValid(), SetAircraftPosition(), Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
static void MaybeCrashAirplane | ( | Aircraft * | v | ) | [static] |
Decide whether aircraft v should crash.
v | Aircraft to test. |
Definition at line 1378 of file aircraft_cmd.cpp.
References _cheats, _settings_game, Station::airport, BREAKDOWN_AIRCRAFT_EM_LANDING, Vehicle::breakdown_ctr, Vehicle::breakdown_type, GoodsEntry::cargo, CrashAirplane(), GameSettings::difficulty, Vehicle::engine_type, AirportFTAClass::flags, GB(), SpecializedStation< Station, false >::Get(), Airport::GetFTA(), Station::goods, VehicleSettings::improved_breakdowns, Cheats::no_jetcrash, VehicleSettings::plane_crashes, GoodsEntry::rating, Aircraft::targetairport, CargoList< Tinst, Tcont >::Truncate(), Cheat::value, GameSettings::vehicle, and DifficultySettings::vehicle_breakdowns.
Referenced by AircraftController().
void SetAircraftPosition | ( | Aircraft * | v, | |
int | x, | |||
int | y, | |||
int | z | |||
) |
Set aircraft position.
v | Aircraft to position. | |
x | New X position. | |
y | New y position. | |
z | New z position. |
Definition at line 512 of file aircraft_cmd.cpp.
References AIR_HELICOPTER, Clamp(), Vehicle::cur_image, MapMaxX(), MapMaxY(), SpecializedVehicle< T, Type >::Next(), ROTOR_Z_OFFSET, Vehicle::subtype, TILE_SIZE, SpecializedVehicle< T, Type >::UpdateViewport(), VehicleMove(), Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
Referenced by AfterLoadGame(), AircraftController(), HandleAircraftEnterHangar(), HandleCrashedAircraft(), and UpdateOldAircraft().
void UpdateAircraftCache | ( | Aircraft * | v | ) |
Update cached values of an aircraft.
Currently caches callback 36 max speed.
v | Vehicle |
Definition at line 577 of file aircraft_cmd.cpp.
References VehicleCache::cached_max_speed, Vehicle::engine_type, PROP_AIRCRAFT_SPEED, and Vehicle::vcache.
Referenced by AfterLoadGame(), AfterLoadVehicles(), AircraftController(), CheckCaches(), CmdBuildAircraft(), UpdateAirplanesOnNewStation(), and UpdateOldAircraft().
static int UpdateAircraftSpeed | ( | Aircraft * | v, | |
uint | speed_limit = SPEED_LIMIT_NONE , |
|||
bool | hard_limit = true | |||
) | [static] |
Sets the new speed for an aircraft.
v | The vehicle for which the speed should be obtained | |
speed_limit | The maximum speed the vehicle may have. | |
hard_limit | If true, the limit is directly enforced, otherwise the plane is slowed down gradually |
Definition at line 610 of file aircraft_cmd.cpp.
References _settings_client, _settings_game, Vehicle::acceleration, BREAKDOWN_AIRCRAFT_SPEED, Vehicle::breakdown_ctr, Vehicle::breakdown_severity, Vehicle::breakdown_type, VehicleCache::cached_max_speed, Vehicle::cur_speed, Vehicle::GetOldAdvanceSpeed(), ClientSettings::gui, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, max(), min(), VehicleSettings::plane_speed, Vehicle::progress, SetWindowWidgetDirty(), Vehicle::subspeed, Vehicle::vcache, GameSettings::vehicle, and GUISettings::vehicle_speed.
Referenced by AircraftController().
void UpdateAirplanesOnNewStation | ( | const Station * | st | ) |
Updates the status of the Aircraft heading or in the station.
st | Station been updated |
Definition at line 2106 of file aircraft_cmd.cpp.
References AircraftGetEntryPoint(), Station::airport, DIR_N, FLYING, FOR_ALL_AIRCRAFT, Airport::GetFTA(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, Aircraft::IsNormalAircraft(), Aircraft::pos, Aircraft::previous_pos, Airport::rotation, Aircraft::state, Aircraft::targetairport, TileArea::tile, and UpdateAircraftCache().
Referenced by CmdBuildAirport().
const SpriteID _aircraft_sprite[] [static] |
{ 0x0EB5, 0x0EBD, 0x0EC5, 0x0ECD, 0x0ED5, 0x0EDD, 0x0E9D, 0x0EA5, 0x0EAD, 0x0EE5, 0x0F05, 0x0F0D, 0x0F15, 0x0F1D, 0x0F25, 0x0F2D, 0x0EED, 0x0EF5, 0x0EFD, 0x0F35, 0x0E9D, 0x0EA5, 0x0EAD, 0x0EB5, 0x0EBD, 0x0EC5 }
Definition at line 89 of file aircraft_cmd.cpp.
AircraftStateHandler* const _aircraft_state_handlers[] [static] |
{ AircraftEventHandler_General, AircraftEventHandler_InHangar, AircraftEventHandler_AtTerminal, AircraftEventHandler_AtTerminal, AircraftEventHandler_AtTerminal, AircraftEventHandler_AtTerminal, AircraftEventHandler_AtTerminal, AircraftEventHandler_AtTerminal, AircraftEventHandler_AtTerminal, AircraftEventHandler_AtTerminal, AircraftEventHandler_TakeOff, AircraftEventHandler_StartTakeOff, AircraftEventHandler_EndTakeOff, AircraftEventHandler_HeliTakeOff, AircraftEventHandler_Flying, AircraftEventHandler_Landing, AircraftEventHandler_EndLanding, AircraftEventHandler_HeliLanding, AircraftEventHandler_HeliEndLanding, AircraftEventHandler_AtTerminal, AircraftEventHandler_AtTerminal, AircraftEventHandler_AtTerminal, }
Array of handler functions for each target of the aircraft.
Definition at line 1751 of file aircraft_cmd.cpp.
const MovementTerminalMapping _airport_terminal_mapping[] [static] |
{ {TERM1, TERM1_block}, {TERM2, TERM2_block}, {TERM3, TERM3_block}, {TERM4, TERM4_block}, {TERM5, TERM5_block}, {TERM6, TERM6_block}, {TERM7, TERM7_block}, {TERM8, TERM8_block}, {HELIPAD1, HELIPAD1_block}, {HELIPAD2, HELIPAD2_block}, {HELIPAD3, HELIPAD3_block}, }
A list of all valid terminals and their associated blocks.
Definition at line 1925 of file aircraft_cmd.cpp.