UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_aircraft.cpp File Reference

Most of the aircraft related stuff. More...

#include "../../DateTime.h"
#include "../../cl_shared.h"
#include "../../ui/ui_dataids.h"
#include "../../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_mapfightequip.h"
#include "cp_geoscape.h"
#include "cp_ufo.h"
#include "cp_alienbase.h"
#include "cp_time.h"
#include "cp_missions.h"
#include "cp_aircraft_callbacks.h"
#include "save/save_aircraft.h"
#include "cp_popup.h"
#include "aliencargo.h"
#include "itemcargo.h"
#include "cp_building.h"
Include dependency graph for cp_aircraft.cpp:

Go to the source code of this file.

Functions

aircraft_tAIR_GetFirstFromBase (const base_t *b)
 Iterates through the aircraft of a base.
bool AIR_BaseHasAircraft (const base_t *base)
 Checks whether there is any aircraft assigned to the given base.
int AIR_BaseCountAircraft (const base_t *base)
 Returns the number of aircraft on the given base.
static void AII_CollectAmmo (void *data, const Item *magazine)
 Count and collect ammo from gun magazine.
void AII_CollectItem (aircraft_t *aircraft, const objDef_t *item, int amount)
 Add an item to aircraft inventory.
static void AII_CollectItem_ (void *data, const objDef_t *item, int amount)
static void AII_CarriedItems (const Inventory *soldierInventory)
 Process items carried by soldiers.
void AII_CollectingItems (aircraft_t *aircraft, int won)
 Collect items from the battlefield.
const char * AIR_AircraftStatusToName (const aircraft_t *aircraft)
 Translates the aircraft status id to a translatable string.
bool AIR_IsAircraftInBase (const aircraft_t *aircraft)
 Checks whether given aircraft is in its homebase.
bool AIR_IsAircraftOnGeoscape (const aircraft_t *aircraft)
 Checks whether given aircraft is on geoscape.
int AIR_CountInBaseByTemplate (const base_t *base, const aircraft_t *aircraftTemplate)
 Calculates the amount of aircraft (of the given type) in the selected base.
int AIR_AircraftMenuStatsValues (const int value, const int stat)
 Some of the aircraft values needs special calculations when they are shown in the menus.
int AIR_GetOperationRange (const aircraft_t *aircraft)
 Calculates the range an aircraft can fly on the geoscape.
int AIR_GetRemainingRange (const aircraft_t *aircraft)
 Calculates the remaining range the aircraft can fly.
bool AIR_AircraftHasEnoughFuel (const aircraft_t *aircraft, const vec2_t destination)
 check if aircraft has enough fuel to go to destination, and then come back home
bool AIR_AircraftHasEnoughFuelOneWay (const aircraft_t *aircraft, const vec2_t destination)
 check if aircraft has enough fuel to go to destination
void AIR_AircraftReturnToBase (aircraft_t *aircraft)
 Calculates the way back to homebase for given aircraft and returns it.
aircraft_tAIR_GetAircraftFromBaseByIDXSafe (const base_t *base, int index)
const aircraft_tAIR_GetAircraftSilent (const char *name)
 Searches the global array of aircraft types for a given aircraft.
const aircraft_tAIR_GetAircraft (const char *name)
 Searches the global array of aircraft types for a given aircraft.
static void AII_SetAircraftInSlots (aircraft_t *aircraft)
 Initialise aircraft pointer in each slot of an aircraft.
aircraft_tAIR_Add (base_t *base, const aircraft_t *aircraftTemplate)
 Adds a new aircraft from a given aircraft template to the base and sets the homebase for the new aircraft to the given base.
bool AIR_Delete (base_t *base, aircraft_t *aircraft)
 Will remove the given aircraft from the base.
aircraft_tAIR_NewAircraft (base_t *base, const aircraft_t *aircraftTemplate)
 Places a new aircraft in the given base.
baseCapacities_t AIR_GetHangarCapacityType (const aircraft_t *aircraft)
 Returns capacity type needed for an aircraft.
static int AIR_GetStorageRoom (const aircraft_t *aircraft)
 Calculate used storage room corresponding to items in an aircraft.
const char * AIR_CheckMoveIntoNewHomebase (const aircraft_t *aircraft, const base_t *base)
 Checks if destination base can store an aircraft and its team.
static void AIR_TransferItemsCarriedByCharacterToBase (character_t *chr, base_t *sourceBase, base_t *destBase)
 Transfer items carried by a soldier from one base to another.
void AIR_MoveAircraftIntoNewHomebase (aircraft_t *aircraft, base_t *base)
 Moves a given aircraft to a new base (also the employees and inventory).
void AIR_DeleteAircraft (aircraft_t *aircraft)
 Removes an aircraft from its base and the game.
void AIR_DestroyAircraft (aircraft_t *aircraft, bool killPilot)
 Removes an aircraft from its base and the game.
bool AIR_AircraftMakeMove (int dt, aircraft_t *aircraft)
 Moves given aircraft.
static void AIR_Move (aircraft_t *aircraft, int deltaTime)
static void AIR_Refuel (aircraft_t *aircraft, int deltaTime)
void AIR_CampaignRun (const campaign_t *campaign, int dt, bool updateRadarOverlay)
 Handles aircraft movement and actions in geoscape mode.
aircraft_tAIR_AircraftGetFromIDX (int aircraftIdx)
 Returns aircraft for a given global index.
bool AIR_SendAircraftToMission (aircraft_t *aircraft, mission_t *mission)
 Sends the specified aircraft to specified mission.
static void AII_InitialiseAircraftSlots (aircraft_t *aircraftTemplate)
 Initialise all values of an aircraft slot.
 CASSERT (lengthof(air_slot_type_strings)==MAX_ACITEMS)
void AIR_ParseAircraft (const char *name, const char **text, bool assignAircraftItems)
 Parses all aircraft that are defined in our UFO-scripts.
void AIR_AircraftsNotifyMissionRemoved (const mission_t *const mission)
 Notify aircraft that a mission has been removed.
void AIR_AircraftsNotifyUFORemoved (const aircraft_t *const ufo, bool destroyed)
 Notify that a UFO has been removed.
void AIR_AircraftsUFODisappear (const aircraft_t *const ufo)
 Notify that a UFO disappear from radars.
static float AIR_GetDestinationFunction (const float c, const float B, const float speedRatio, float a)
 funtion we need to find roots.
static float AIR_GetDestinationDerivativeFunction (const float c, const float B, const float speedRatio, float a)
 derivative of the funtion we need to find roots.
static float AIR_GetDestinationFindRoot (const float c, const float B, const float speedRatio, float start)
 Find the roots of a function.
void AIR_GetDestinationWhilePursuing (const aircraft_t *shooter, const aircraft_t *target, vec2_t dest)
 Calculates the point where aircraft should go to intecept a moving target.
bool AIR_SendAircraftPursuingUFO (aircraft_t *aircraft, aircraft_t *ufo)
 Make the specified aircraft purchasing a UFO.
void AIR_ResetAircraftTeam (aircraft_t *aircraft)
 Resets team in given aircraft.
bool AIR_AddToAircraftTeam (aircraft_t *aircraft, Employee *employee)
 Adds given employee to given aircraft.
bool AIR_IsInAircraftTeam (const aircraft_t *aircraft, const Employee *employee)
 Checks whether given employee is in given aircraft.
int AIR_GetTeamSize (const aircraft_t *aircraft)
 Counts the number of soldiers in given aircraft.
bool AIR_SetPilot (aircraft_t *aircraft, Employee *pilot)
 Assign a pilot to an aircraft.
EmployeeAIR_GetPilot (const aircraft_t *aircraft)
 Get pilot of an aircraft.
bool AIR_PilotSurvivedCrash (const aircraft_t *aircraft)
 Determine if an aircraft's pilot survived a crash, based on his piloting skill (and a bit of randomness).
void AIR_AutoAddPilotToAircraft (const base_t *base, Employee *pilot)
 Adds the pilot to the first available aircraft at the specified base.
void AIR_RemovePilotFromAssignedAircraft (const base_t *base, const Employee *pilot)
 Checks to see if the pilot is in any aircraft at this base. If he is then he is removed from that aircraft.
int AIR_GetAircraftWeaponRanges (const aircraftSlot_t *slot, int maxSlot, float *weaponRanges)
 Get the all the unique weapon ranges of this aircraft.
static void AIR_SaveRouteXML (xmlNode_t *node, const mapline_t *route)
 Saves an route plan of an aircraft.
static void AIR_SaveAircraftSlotsXML (const aircraftSlot_t *slot, const int num, xmlNode_t *p, bool weapon)
 Saves an item slot.
static bool AIR_SaveAircraftXML (xmlNode_t *p, const aircraft_t *const aircraft, bool const isUfo)
 Saves an aircraft.
bool AIR_SaveXML (xmlNode_t *parent)
 Save callback for savegames in xml format.
static void AIR_LoadAircraftSlotsXML (aircraft_t *aircraft, aircraftSlot_t *slot, xmlNode_t *p, bool weapon, const int max)
 Loads the weapon slots of an aircraft.
static bool AIR_LoadRouteXML (xmlNode_t *p, mapline_t *route)
 Loads the route of an aircraft.
static bool AIR_LoadAircraftXML (xmlNode_t *p, aircraft_t *craft)
 Loads an Aircraft from the savegame.
static void AIR_CorrectAircraftSlotPointers (aircraft_t *aircraft)
 resets aircraftSlots' backreference pointers for aircraft
bool AIR_LoadXML (xmlNode_t *parent)
static bool AIR_PostLoadInitMissions (void)
 Set the mission pointers for all the aircraft after loading a savegame.
bool AIR_PostLoadInit (void)
 Actions needs to be done after loading the savegame.
bool AIR_AircraftAllowed (const base_t *base)
 Returns true if the current base is able to handle aircraft.
bool AIR_CanIntercept (const aircraft_t *aircraft)
bool AIR_ScriptSanityCheck (void)
 Checks the parsed aircraft for errors.
bool AIR_RemoveEmployee (Employee *employee, aircraft_t *aircraft)
 Removes a soldier from an aircraft.
const aircraft_tAIR_IsEmployeeInAircraft (const Employee *employee, const aircraft_t *aircraft)
 Tells you if an employee is assigned to an aircraft.
void AIR_RemoveEmployees (aircraft_t &aircraft)
 Removes all soldiers from an aircraft.
void AIR_MoveEmployeeInventoryIntoStorage (const aircraft_t &aircraft, equipDef_t &ed)
 Move all the equipment carried by the team on the aircraft into the given equipment.
bool AIR_AddEmployee (Employee *employee, aircraft_t *aircraft)
 Assigns a soldier to an aircraft.
void AIR_AssignInitial (aircraft_t *aircraft)
 Assigns initial team of soldiers to aircraft.
void AIR_InitStartup (void)
 Init actions for aircraft-subsystem.
void AIR_Shutdown (void)
 Closing actions for aircraft-subsystem.

Variables

static char const *const air_position_strings []
 List of valid strings for itemPos_t.
static const value_t aircraft_param_vals []
 Valid aircraft parameter definitions from script files.
static const value_t aircraft_vals []
 Valid aircraft definition values from script files.
static const value_t aircraft_radar_vals []
 Valid radar definition values for an aircraft from script files.
const char *const air_slot_type_strings [] = AIR_SLOT_TYPE_STRINGS
static const cmdList_t aircraftDebugCmds []

Detailed Description

Most of the aircraft related stuff.

See also
cl_airfight.c
Note
Aircraft management functions prefix: AIR_
Aircraft menu(s) functions prefix: AIM_
Aircraft equipment handling functions prefix: AII_

Definition in file cp_aircraft.cpp.

Function Documentation

◆ AII_CarriedItems()

void AII_CarriedItems ( const Inventory * soldierInventory)
static

Process items carried by soldiers.

Parameters
[in]soldierInventoryPointer to inventory from a soldier of our team.
See also
AII_CollectingItems

Definition at line 256 of file cp_aircraft.cpp.

References Container::_invList, equipDef_t::addClip(), ccs, Item::def(), Item::getAmmoLeft(), Item::getNext(), Inventory::getNextCont(), objDef_t::idx, objDef_t::isReloadable(), objDef_t::isVirtual, equipDef_t::numItems, RS_GetTechForItem(), and RS_MarkCollected().

Referenced by AII_CollectingItems().

◆ AII_CollectAmmo()

void AII_CollectAmmo ( void * data,
const Item * magazine )
static

Count and collect ammo from gun magazine.

Parameters
[in]dataPointer to aircraft used in this mission.
[in]magazinePointer to Item being magazine.

Definition at line 219 of file cp_aircraft.cpp.

References ItemCargo::add(), Item::ammoDef(), data, Item::getAmmoLeft(), and aircraft_t::itemCargo.

Referenced by AII_CollectingItems().

◆ AII_CollectingItems()

void AII_CollectingItems ( aircraft_t * aircraft,
int won )

Collect items from the battlefield.

Note
The way we are collecting items:
1. Grab everything from the floor and add it to the aircraft cargo here.
2. When collecting gun, collect it's remaining ammo as well
3. Sell everything or add to base storage when dropship lands in base.
4. Items carried by soldiers are processed nothing is being sold.
See also
CL_ParseResults
AII_CollectingAmmo
AII_CarriedItems
Todo
Simplify this logic

Definition at line 294 of file cp_aircraft.cpp.

References ItemCargo::add(), AII_CarriedItems(), AII_CollectAmmo(), AII_CollectItem_(), cgi, DEBUG_CLIENT, ItemCargo::empty(), aircraft_t::itemCargo, ItemCargo::list(), LIST_Foreach, and aircraft_t::mission.

Referenced by GAME_CP_Results().

◆ AII_CollectItem()

void AII_CollectItem ( aircraft_t * aircraft,
const objDef_t * item,
int amount )

Add an item to aircraft inventory.

Parameters
[in,out]aircraftAircraft to load to
[in]itemItem to add
amountNumber of items to add
See also
AL_AddAliens
AII_CollectingItems

Definition at line 237 of file cp_aircraft.cpp.

References ItemCargo::add(), and aircraft_t::itemCargo.

Referenced by AII_CollectItem_(), and AM_MoveCharacterInventoryIntoItemCargo().

◆ AII_CollectItem_()

void AII_CollectItem_ ( void * data,
const objDef_t * item,
int amount )
inlinestatic

Definition at line 246 of file cp_aircraft.cpp.

References AII_CollectItem(), and data.

Referenced by AII_CollectingItems().

◆ AII_InitialiseAircraftSlots()

void AII_InitialiseAircraftSlots ( aircraft_t * aircraftTemplate)
static

Initialise all values of an aircraft slot.

Parameters
[in]aircraftTemplatePointer to the aircraft which needs initalisation of its slots.

Definition at line 1196 of file cp_aircraft.cpp.

References AC_ITEM_ELECTRONICS, AC_ITEM_SHIELD, AC_ITEM_WEAPON, AII_InitialiseSlot(), aircraft_t::electronics, i, MAX_AIRCRAFTSLOT, aircraft_t::shield, and aircraft_t::weapons.

Referenced by AIR_ParseAircraft().

◆ AII_SetAircraftInSlots()

void AII_SetAircraftInSlots ( aircraft_t * aircraft)
static

Initialise aircraft pointer in each slot of an aircraft.

Parameters
[in]aircraftPointer to the aircraft where slots are.

Definition at line 587 of file cp_aircraft.cpp.

References aircraftSlot_t::aircraft, aircraft_t::electronics, i, MAX_AIRCRAFTSLOT, aircraft_t::shield, and aircraft_t::weapons.

Referenced by AIR_NewAircraft().

◆ AIR_Add()

aircraft_t * AIR_Add ( base_t * base,
const aircraft_t * aircraftTemplate )

Adds a new aircraft from a given aircraft template to the base and sets the homebase for the new aircraft to the given base.

Parameters
[out]baseThe base to add the aircraft to
[in]aircraftTemplateThe template to create the new aircraft from
Returns
the newly added aircraft
See also
AIR_Delete

Definition at line 605 of file cp_aircraft.cpp.

References AIR_CRASHED, AIR_GetHangarCapacityType(), CAP_AddCurrent(), ccs, aircraft_t::homebase, LIST_Add(), MAX_CAP, and aircraft_t::status.

Referenced by AIR_LoadXML(), and AIR_NewAircraft().

◆ AIR_AddEmployee()

bool AIR_AddEmployee ( Employee * employee,
aircraft_t * aircraft )

Assigns a soldier to an aircraft.

Parameters
[in]employeeThe employee to be assigned to the aircraft.
[in]aircraftWhat aircraft to assign employee to.
Returns
returns true if a soldier could be assigned to the aircraft.
See also
AIR_RemoveEmployee
AIR_AddToAircraftTeam

Definition at line 2853 of file cp_aircraft.cpp.

References AIR_AddToAircraftTeam(), AIR_GetTeamSize(), AIR_IsEmployeeInAircraft(), and aircraft_t::maxTeamSize.

Referenced by AIR_AssignInitial().

◆ AIR_AddToAircraftTeam()

bool AIR_AddToAircraftTeam ( aircraft_t * aircraft,
Employee * employee )

Adds given employee to given aircraft.

Parameters
[in]aircraftPointer to an aircraft, to which we will add employee.
[in]employeeThe employee to add to the aircraft.
Note
this is responsible for adding soldiers to a team in dropship

Definition at line 1945 of file cp_aircraft.cpp.

References aircraft_t::acTeam, AIR_GetTeamSize(), cgi, and aircraft_t::maxTeamSize.

Referenced by AIR_AddEmployee(), and CP_TEAM_AssignSoldierByUCN_f().

◆ AIR_AircraftAllowed()

bool AIR_AircraftAllowed ( const base_t * base)

Returns true if the current base is able to handle aircraft.

See also
B_BaseInit_f
Note
Hangar must be accessible during base attack to make aircraft lift off and to equip soldiers.

Definition at line 2641 of file cp_aircraft.cpp.

References B_GetBuildingStatus(), B_HANGAR, and B_SMALL_HANGAR.

Referenced by AIR_ShowAircraft_f(), B_BaseInit_f(), B_BuildingOpenAfterClick_f(), and BS_Buy_f().

◆ AIR_AircraftGetFromIDX()

aircraft_t * AIR_AircraftGetFromIDX ( int aircraftIdx)

Returns aircraft for a given global index.

Parameters
[in]aircraftIdxGlobal aircraft index.
Returns
An aircraft pointer (to a struct in a base) that has the given index or nullptr if no aircraft found.

Definition at line 1132 of file cp_aircraft.cpp.

References AIR_Foreach, cgi, and DEBUG_CLIENT.

Referenced by AIM_AircraftReturnToBase_f(), AIR_GeoSelectAircraft_f(), AIR_LoadAircraftXML(), AIR_SendAircraftToMission_f(), AIR_ShowChangeHomebaseAircraft_f(), AIR_StopAircraft_f(), AIRFIGHT_LoadXML(), BS_Buy_f(), BS_ShowInfo_f(), CP_TEAM_FillEmployeeList_f(), CP_TEAM_FillEquipSoldierList_f(), MIS_LoadXML(), TR_Add_f(), TR_LoadXML(), and TR_TransferStart().

◆ AIR_AircraftHasEnoughFuel()

bool AIR_AircraftHasEnoughFuel ( const aircraft_t * aircraft,
const vec2_t destination )

check if aircraft has enough fuel to go to destination, and then come back home

Parameters
[in]aircraftPointer to the aircraft
[in]destinationPointer to the position the aircraft should go to
See also
GEO_CalcLine
Returns
true if the aircraft can go to the position, false else

Definition at line 472 of file cp_aircraft.cpp.

References AIR_GetRemainingRange(), GetDistanceOnGlobe(), aircraft_t::homebase, aircraft_t::pos, base_t::pos, and DateTime::SECONDS_PER_HOUR.

Referenced by AIR_CampaignRun(), AIR_GeoSelectAircraft_f(), AIR_SendAircraftPursuingUFO(), AIR_SendAircraftToMission(), CL_DisplayPopupInterceptUFO(), and GEO_Click().

◆ AIR_AircraftHasEnoughFuelOneWay()

bool AIR_AircraftHasEnoughFuelOneWay ( const aircraft_t * aircraft,
const vec2_t destination )

check if aircraft has enough fuel to go to destination

Parameters
[in]aircraftPointer to the aircraft
[in]destinationPointer to the position the aircraft should go to
See also
GEO_CalcLine
Returns
true if the aircraft can go to the position, false else

Definition at line 498 of file cp_aircraft.cpp.

References AIR_GetRemainingRange(), GetDistanceOnGlobe(), aircraft_t::pos, and DateTime::SECONDS_PER_HOUR.

Referenced by AIR_CheckMoveIntoNewHomebase().

◆ AIR_AircraftMakeMove()

bool AIR_AircraftMakeMove ( int dt,
aircraft_t * aircraft )

Moves given aircraft.

Parameters
[in]dttime delta
[in]aircraftPointer to aircraft on its way.
Returns
true if the aircraft reached its destination.

Definition at line 926 of file cp_aircraft.cpp.

References AIR_STATS_SPEED, mapline_t::distance, aircraft_t::fuel, GEO_CheckPositionBoundaries(), int(), mapline_t::numPoints, aircraft_t::point, mapline_t::point, aircraft_t::pos, aircraft_t::projectedPos, aircraft_t::route, DateTime::SECONDS_PER_HOUR, aircraft_t::stats, aircraft_t::time, and VectorSet.

Referenced by AIR_Move(), and UFO_CampaignRunUFOs().

◆ AIR_AircraftMenuStatsValues()

int AIR_AircraftMenuStatsValues ( const int value,
const int stat )

Some of the aircraft values needs special calculations when they are shown in the menus.

See also
UP_AircraftStatToName

Definition at line 429 of file cp_aircraft.cpp.

References AIR_STATS_FUELSIZE, AIR_STATS_MAXSPEED, AIR_STATS_SPEED, and int().

Referenced by AIR_AircraftSelect(), GEO_GetAircraftText(), GEO_GetUFOText(), UP_AircraftDescription(), and UP_AircraftItemDescription().

◆ AIR_AircraftReturnToBase()

◆ AIR_AircraftsNotifyMissionRemoved()

void AIR_AircraftsNotifyMissionRemoved ( const mission_t *const mission)

Notify aircraft that a mission has been removed.

Parameters
[in]missionPointer to the mission that has been removed.
Note
Aircraft currently moving to the mission will be redirect to base

Definition at line 1596 of file cp_aircraft.cpp.

References AIR_AircraftReturnToBase(), and AIR_Foreach.

Referenced by CP_MissionRemoveFromGeoscape().

◆ AIR_AircraftsNotifyUFORemoved()

void AIR_AircraftsNotifyUFORemoved ( const aircraft_t *const ufo,
bool destroyed )

Notify that a UFO has been removed.

Parameters
[in]ufoPointer to UFO that has been removed.
[in]destroyedTrue if the UFO has been destroyed, false if it only landed.
Todo
this should be in a BDEF_NotifyUFORemoved callback

Definition at line 1609 of file cp_aircraft.cpp.

References AIR_AircraftReturnToBase(), AIR_Foreach, aircraft_t::aircraftTarget, B_GetNext(), base_t::batteries, i, base_t::lasers, base_t::numBatteries, base_t::numLasers, and baseWeapon_t::target.

Referenced by CP_UFORemoveFromGeoscape().

◆ AIR_AircraftStatusToName()

const char * AIR_AircraftStatusToName ( const aircraft_t * aircraft)

Translates the aircraft status id to a translatable string.

Parameters
[in]aircraftAircraft to translate the status of
Returns
Translation string of given status.

Definition at line 328 of file cp_aircraft.cpp.

References _, AIR_CRASHED, AIR_DROP, AIR_HOME, AIR_IDLE, AIR_INTERCEPT, AIR_IsAircraftInBase(), AIR_MISSION, AIR_NONE, AIR_REFUEL, AIR_RETURNING, AIR_TRANSFER, AIR_TRANSIT, AIR_UFO, B_IsUnderAttack, cgi, ERR_DROP, aircraft_t::homebase, aircraft_t::status, and va().

Referenced by AIR_AircraftFillList_f(), AIR_ShowAircraft_f(), CL_DisplayPopupInterceptMission(), CL_DisplayPopupInterceptUFO(), and GEO_GetAircraftText().

◆ AIR_AircraftsUFODisappear()

void AIR_AircraftsUFODisappear ( const aircraft_t *const ufo)

Notify that a UFO disappear from radars.

Parameters
[in]ufoPointer to a UFO that has disappeared.
Note
Aircraft currently pursuing the specified UFO will be redirected to base

Definition at line 1651 of file cp_aircraft.cpp.

References AIR_AircraftReturnToBase(), AIR_Foreach, AIR_UFO, and aircraft_t::aircraftTarget.

Referenced by UFO_CampaignCheckEvents().

◆ AIR_AssignInitial()

void AIR_AssignInitial ( aircraft_t * aircraft)

Assigns initial team of soldiers to aircraft.

Parameters
[in,out]aircraftsoldiers to add to

Definition at line 2873 of file cp_aircraft.cpp.

References AIR_AddEmployee(), cgi, count, E_Foreach, EMPL_SOLDIER, aircraft_t::homebase, and aircraft_t::maxTeamSize.

Referenced by B_SetUpFirstBase().

◆ AIR_AutoAddPilotToAircraft()

void AIR_AutoAddPilotToAircraft ( const base_t * base,
Employee * pilot )

Adds the pilot to the first available aircraft at the specified base.

Parameters
[in]baseWhich base has aircraft to add the pilot to.
[in]pilotWhich pilot to add.

Definition at line 2054 of file cp_aircraft.cpp.

References AIR_ForeachFromBase, and AIR_SetPilot().

Referenced by E_HireEmployee(), and TR_EmptyTransferCargo().

◆ AIR_BaseCountAircraft()

int AIR_BaseCountAircraft ( const base_t * base)

Returns the number of aircraft on the given base.

Parameters
[in]baseThe base to check

Definition at line 75 of file cp_aircraft.cpp.

References AIR_ForeachFromBase, and count.

Referenced by TEST_F(), and TEST_F().

◆ AIR_BaseHasAircraft()

bool AIR_BaseHasAircraft ( const base_t * base)

Checks whether there is any aircraft assigned to the given base.

Parameters
[in]baseThe base to check
Returns
true if there is at least one aircraft, false otherwise (or when the base pointer is nullptr)

Definition at line 66 of file cp_aircraft.cpp.

References AIR_GetFirstFromBase().

Referenced by AIR_AircraftSelect(), AIR_DeleteAircraft(), B_BaseInit_f(), and B_BuildingOpenAfterClick_f().

◆ AIR_CampaignRun()

void AIR_CampaignRun ( const campaign_t * campaign,
int dt,
bool updateRadarOverlay )

Handles aircraft movement and actions in geoscape mode.

See also
CP_CampaignRun
Parameters
[in]campaignThe campaign data structure
[in]dttime delta (may be 0 if radar overlay should be updated but no aircraft moves)
[in]updateRadarOverlayTrue if radar overlay should be updated (not needed if geoscape isn't updated)
Todo
check if aircraft can go to a closer base with free space

Definition at line 1072 of file cp_aircraft.cpp.

References _, AII_ReloadWeapon(), AIR_AircraftHasEnoughFuel(), AIR_AircraftReturnToBase(), AIR_CRASHED, AIR_Foreach, AIR_IDLE, AIR_IsAircraftOnGeoscape(), AIR_Move(), AIR_REFUEL, AIR_Refuel(), AIR_RETURNING, AIR_UFO, AIRFIGHT_ExecuteActions(), aircraftSlot_t::ammoLeft, aircraftSlot_t::delayNextShot, GEO_IsRadarOverlayActivated(), MS_AddNewMessage(), RADAR_UpdateWholeRadarOverlay(), and va().

Referenced by CP_CampaignFunctionPeriodicCall().

◆ AIR_CanIntercept()

bool AIR_CanIntercept ( const aircraft_t * aircraft)
Parameters
aircraftThe aircraft to check
Returns
true if the given aircraft can go on interceptions

Definition at line 2650 of file cp_aircraft.cpp.

References AIR_CRASHED, AIR_GetPilot(), AIR_NONE, B_GetBuildingStatus(), B_GetBuildingTemplateSilent(), aircraft_t::building, building_t::buildingType, aircraft_t::homebase, and aircraft_t::status.

Referenced by CL_DisplayPopupInterceptMission(), and CL_DisplayPopupInterceptUFO().

◆ AIR_CheckMoveIntoNewHomebase()

const char * AIR_CheckMoveIntoNewHomebase ( const aircraft_t * aircraft,
const base_t * base )

Checks if destination base can store an aircraft and its team.

Parameters
[in]aircraftPointer to the aircraft to check
[in]basePointer to the base to store aircraft

Definition at line 732 of file cp_aircraft.cpp.

References _, AIR_AircraftHasEnoughFuelOneWay(), AIR_GetHangarCapacityType(), AIR_GetPilot(), AIR_GetStorageRoom(), AIR_GetTeamSize(), B_GetBuildingStatus(), B_GetBuildingTypeByCapacity(), CAP_EMPLOYEES, CAP_GetFreeCapacity(), CAP_ITEMS, aircraft_t::maxTeamSize, and base_t::pos.

Referenced by B_MoveAircraftOnGeoscapeToOtherBases(), CL_DisplayHomebasePopup(), and CL_PopupChangeHomebase_f().

◆ AIR_CorrectAircraftSlotPointers()

void AIR_CorrectAircraftSlotPointers ( aircraft_t * aircraft)
static

resets aircraftSlots' backreference pointers for aircraft

Parameters
[in]aircraftPointer to the aircraft

Definition at line 2507 of file cp_aircraft.cpp.

References aircraftSlot_t::aircraft, aircraftSlot_t::base, aircraft_t::electronics, i, aircraftSlot_t::installation, aircraft_t::maxElectronics, aircraft_t::maxWeapons, aircraft_t::shield, and aircraft_t::weapons.

Referenced by AIR_LoadXML().

◆ AIR_CountInBaseByTemplate()

int AIR_CountInBaseByTemplate ( const base_t * base,
const aircraft_t * aircraftTemplate )

Calculates the amount of aircraft (of the given type) in the selected base.

Parameters
[in]baseThe base to count the aircraft in
[in]aircraftTemplateThe type of the aircraft you want

Definition at line 413 of file cp_aircraft.cpp.

References AIR_ForeachFromBase, and count.

Referenced by PR_UpdateProductionList().

◆ AIR_Delete()

bool AIR_Delete ( base_t * base,
aircraft_t * aircraft )

Will remove the given aircraft from the base.

Parameters
[out]baseThe base to remove the aircraft from
aircraftThe aircraft to remove
Returns
true if the aircraft was removed, false otherwise
See also
AIR_Add

Definition at line 622 of file cp_aircraft.cpp.

References AIR_CRASHED, AIR_GetHangarCapacityType(), aircraft_t::alienCargo, CAP_AddCurrent(), ccs, cgi, MAX_CAP, and aircraft_t::status.

Referenced by AIR_DeleteAircraft(), and CP_ResetCampaignData().

◆ AIR_DeleteAircraft()

void AIR_DeleteAircraft ( aircraft_t * aircraft)

Removes an aircraft from its base and the game.

Parameters
[in]aircraftPointer to aircraft that should be removed.
Note
The assigned soldiers (if any) are unassinged from the aircraft - not fired.
See also
AIR_DestroyAircraft
Note
If you want to do something different (kill, fire, etc...) do it before calling this function.
Todo
Return status of deletion for better error handling.

Definition at line 837 of file cp_aircraft.cpp.

References AII_RemoveItemFromSlot(), AIR_BaseHasAircraft(), AIR_Delete(), AIR_GetFirstFromBase(), AIR_IsAircraftOnGeoscape(), AIR_RemoveEmployees(), base_t::aircraftCurrent, cgi, aircraft_t::electronics, GEO_NotifyAircraftRemoved(), aircraft_t::homebase, i, base_t::idx, MAX_AIRCRAFTSLOT, RADAR_UpdateWholeRadarOverlay(), aircraft_t::shield, TR_NotifyAircraftRemoved(), and aircraft_t::weapons.

Referenced by AIR_DestroyAircraft(), B_Destroy(), BS_SellAircraft(), TEST_F(), and TR_EmptyTransferCargo().

◆ AIR_DestroyAircraft()

void AIR_DestroyAircraft ( aircraft_t * aircraft,
bool killPilot )

Removes an aircraft from its base and the game.

Parameters
[in]aircraftPointer to aircraft that should be removed.
[in]killPilotShould pilot be removed from game or not?
Note
aircraft and assigned soldiers (if any) are removed from game.
Todo
Return status of deletion for better error handling.

Definition at line 889 of file cp_aircraft.cpp.

References aircraft_t::acTeam, AIR_CRASHED, AIR_DeleteAircraft(), AIR_GetPilot(), AIR_SetPilot(), cgi, Employee::chr, E_DeleteEmployee(), E_RemoveInventoryFromStorage(), ERR_DROP, aircraft_t::id, LIST_Foreach, character_t::name, aircraft_t::status, and character_t::ucn.

Referenced by AIRFIGHT_ActionsAfterAirfight(), B_MoveAircraftOnGeoscapeToOtherBases(), CP_EndRescueMission(), and CP_SpawnRescueMission().

◆ AIR_GetAircraft()

const aircraft_t * AIR_GetAircraft ( const char * name)

Searches the global array of aircraft types for a given aircraft.

Parameters
[in]nameAircraft id.
Returns
aircraft_t pointer or errors out (ERR_DROP)

Definition at line 572 of file cp_aircraft.cpp.

References AIR_GetAircraftSilent(), cgi, ERR_DROP, name, and Q_strnull().

Referenced by AIR_LoadAircraftXML(), B_SetUpFirstBase(), BS_InitMarket(), CP_CampaignRunMarket(), PR_LoadXML(), RS_AssignTechLinks(), TEST_F(), TEST_F(), TEST_F(), UP_AircraftDescription(), UR_DialogInitSell_f(), and US_LoadXML().

◆ AIR_GetAircraftFromBaseByIDXSafe()

aircraft_t * AIR_GetAircraftFromBaseByIDXSafe ( const base_t * base,
int index )
Parameters
baseThe base to get the aircraft from
indexThe index of the aircraft in the given base
Returns
nullptr if there is no such aircraft in the given base, or the aircraft pointer that belongs to the given index.
Todo
Remove this! Aircraft no longer have local index per base

Definition at line 535 of file cp_aircraft.cpp.

References AIR_ForeachFromBase, i, and index.

Referenced by AIM_SelectAircraft_f().

◆ AIR_GetAircraftSilent()

const aircraft_t * AIR_GetAircraftSilent ( const char * name)

Searches the global array of aircraft types for a given aircraft.

Parameters
[in]nameAircraft id.
Returns
aircraft_t pointer or nullptr if not found.
Note
This function gives no warning on null name or if no aircraft found

Definition at line 555 of file cp_aircraft.cpp.

References ccs, i, aircraft_t::id, name, and Q_streq.

Referenced by AIR_GetAircraft(), AIR_ParseAircraft(), BS_Buy_f(), BS_SetAutosell_f(), BS_ShowInfo_f(), GAME_CP_GetItemModel(), and UR_DialogStartStore_f().

◆ AIR_GetAircraftWeaponRanges()

int AIR_GetAircraftWeaponRanges ( const aircraftSlot_t * slot,
int maxSlot,
float * weaponRanges )

Get the all the unique weapon ranges of this aircraft.

Parameters
[in]slotPointer to the aircrafts weapon slot list.
[in]maxSlotmaximum number of weapon slots in aircraft.
[out]weaponRangesAn array containing a unique list of weapons ranges.
Returns
Number of unique weapons ranges.

Definition at line 2085 of file cp_aircraft.cpp.

References AIR_STATS_WRANGE, aircraftSlot_t::ammo, objDef_t::craftitem, MAX_AIRCRAFTSLOT, Q_FloatSort(), and craftItem::stats.

◆ AIR_GetDestinationDerivativeFunction()

float AIR_GetDestinationDerivativeFunction ( const float c,
const float B,
const float speedRatio,
float a )
inlinestatic

derivative of the funtion we need to find roots.

Parameters
[in]cangle SOT
[in]Bangle STI
[in]speedRatioratio of speed of shooter divided by speed of target.
[in]aangle TOI
Note
S is the position of the shooter, T the position of the target, D the destination of the target and I the interception point where shooter should reach target.
Returns
value of the derivative function.

Definition at line 1685 of file cp_aircraft.cpp.

Referenced by AIR_GetDestinationFindRoot().

◆ AIR_GetDestinationFindRoot()

float AIR_GetDestinationFindRoot ( const float c,
const float B,
const float speedRatio,
float start )
static

Find the roots of a function.

Parameters
[in]cangle SOT
[in]Bangle STI
[in]speedRatioratio of speed of shooter divided by speed of target.
[in]startminimum value of the root to find
Note
S is the position of the shooter, T the position of the target, D the destination of the target and I the interception point where shooter should reach target.
Returns
root of the function.

< step for rough calculation. this value must be short enough so that we're sure there's only 1 root in this range.

< precision of the calculation

< maximum value of the root to search

< precision of current point

< abscissa of the point

< ordinate of the point

< derivative of the point

Definition at line 1701 of file cp_aircraft.cpp.

References AIR_GetDestinationDerivativeFunction(), AIR_GetDestinationFindRoot(), AIR_GetDestinationFunction(), cgi, DEBUG_CLIENT, ERR_DROP, and M_PI.

Referenced by AIR_GetDestinationFindRoot(), and AIR_GetDestinationWhilePursuing().

◆ AIR_GetDestinationFunction()

float AIR_GetDestinationFunction ( const float c,
const float B,
const float speedRatio,
float a )
inlinestatic

funtion we need to find roots.

Parameters
[in]cangle SOT
[in]Bangle STI
[in]speedRatioratio of speed of shooter divided by speed of target.
[in]aangle TOI
Note
S is the position of the shooter, T the position of the target, D the destination of the target and I the interception point where shooter should reach target.
Returns
value of the function.

Definition at line 1669 of file cp_aircraft.cpp.

Referenced by AIR_GetDestinationFindRoot().

◆ AIR_GetDestinationWhilePursuing()

void AIR_GetDestinationWhilePursuing ( const aircraft_t * shooter,
const aircraft_t * target,
vec2_t dest )

Calculates the point where aircraft should go to intecept a moving target.

Parameters
[in]shooterPointer to shooting aircraft.
[in]targetPointer to target aircraft.
[out]destDestination that shooting aircraft should aim to intercept target aircraft.
Todo
only compute this calculation every time target changes destination, or one of the aircraft speed changes.
See also
AIR_SendAircraftPursuingUFO
UFO_SendPursuingAircraft

In the following, we note S the position of the shooter, T the position of the target, D the destination of the target and I the interception point where shooter should reach target O is the center of earth. A, B and C are the angles TSI, STI and SIT a, b, and c are the angles TOI, SOI and SOT

According to geometry on a sphere, the values defined above must be solutions of both equations: sin(A) / sin(a) = sin(B) / sin(b) cos(a) = cos(b) * cos(c) + sin(b) * sin(c) * cos(A) And we have another equation, given by the fact that shooter and target must reach I at the same time: shooterSpeed * a = targetSpeed * b We the want to find and equation linking a, c and B (we know the last 2 values). We therefore eliminate b, then A, to get the equation we need to solve: pow(cos(a) - cos(speedRatio * a) * cos(c), 2.)

  • sin(c) * sin(c) * (sin(speedRatio * a) * sin(speedRatio * a) - sin(a) * sin(a) * sin(B) * sin(B)) = 0
Todo
add EQUAL_EPSILON here?

Definition at line 1806 of file cp_aircraft.cpp.

References AIR_GetDestinationFindRoot(), AIR_STATS_SPEED, cgi, CrossProduct(), DEBUG_CLIENT, dest, DotProduct, GetDistanceOnGlobe(), mapline_t::numPoints, mapline_t::point, PolarToVec(), aircraft_t::pos, RotatePointAroundVector(), aircraft_t::route, aircraft_t::stats, todeg, torad, VecToPolar(), Vector2Copy, and VectorNormalize().

Referenced by AIR_SendAircraftPursuingUFO(), UFO_SearchAircraftTarget(), and UFO_SendPursuingAircraft().

◆ AIR_GetFirstFromBase()

aircraft_t * AIR_GetFirstFromBase ( const base_t * b)

Iterates through the aircraft of a base.

Parameters
[in]bThe base to get the craft from

Definition at line 51 of file cp_aircraft.cpp.

References AIR_ForeachFromBase.

Referenced by AIR_BaseHasAircraft(), AIR_DeleteAircraft(), AIR_MoveAircraftIntoNewHomebase(), B_SetCurrentSelectedBase(), CP_BaseAttackMissionIsFailure(), CP_SpawnRescueMission(), TEST_F(), TEST_F(), and TR_TransferStart().

◆ AIR_GetHangarCapacityType()

◆ AIR_GetOperationRange()

int AIR_GetOperationRange ( const aircraft_t * aircraft)

Calculates the range an aircraft can fly on the geoscape.

Parameters
aircraftThe aircraft to calculate the range for
Returns
The range

Definition at line 448 of file cp_aircraft.cpp.

References AIR_STATS_FUELSIZE, AIR_STATS_SPEED, int(), KILOMETER_PER_DEGREE, DateTime::SECONDS_PER_HOUR, and aircraft_t::stats.

Referenced by AIR_AircraftSelect(), and UP_AircraftDescription().

◆ AIR_GetPilot()

◆ AIR_GetRemainingRange()

int AIR_GetRemainingRange ( const aircraft_t * aircraft)

Calculates the remaining range the aircraft can fly.

Parameters
aircraftThe aircraft to calculate the remaining range for
Returns
The remaining range

Definition at line 460 of file cp_aircraft.cpp.

References AIR_STATS_SPEED, aircraft_t::fuel, and aircraft_t::stats.

Referenced by AIR_AircraftHasEnoughFuel(), and AIR_AircraftHasEnoughFuelOneWay().

◆ AIR_GetStorageRoom()

int AIR_GetStorageRoom ( const aircraft_t * aircraft)
static

Calculate used storage room corresponding to items in an aircraft.

Parameters
[in]aircraftPointer to the aircraft.

Definition at line 705 of file cp_aircraft.cpp.

References aircraft_t::acTeam, Item::ammoDef(), Item::def(), Container::getNextItem(), LIST_Foreach, and objDef_t::size.

Referenced by AIR_CheckMoveIntoNewHomebase().

◆ AIR_GetTeamSize()

◆ AIR_InitStartup()

void AIR_InitStartup ( void )

Init actions for aircraft-subsystem.

Definition at line 2909 of file cp_aircraft.cpp.

References AIR_InitCallbacks(), aircraftDebugCmds, and cgi.

Referenced by CP_InitStartup().

◆ AIR_IsAircraftInBase()

bool AIR_IsAircraftInBase ( const aircraft_t * aircraft)

Checks whether given aircraft is in its homebase.

Parameters
[in]aircraftPointer to an aircraft.
Returns
true if given aircraft is in its homebase.
false if given aircraft is not in its homebase.

Definition at line 372 of file cp_aircraft.cpp.

References AIR_HOME, AIR_REFUEL, and aircraft_t::status.

Referenced by AII_AutoAddAmmo(), AII_ReloadWeapon(), AII_RepairAircraft(), AII_UpdateInstallationDelay(), AIM_AircraftStart_f(), AIR_AircraftFillList_f(), AIR_AircraftSelect(), AIR_AircraftStatusToName(), AIR_SendAircraftPursuingUFO(), AIR_SendAircraftToMission(), AIR_ShowAircraft_f(), AIRFIGHT_ProjectileHits(), BS_FillMarket_f(), BS_SellAircraft(), GEO_Draw(), Employee::isAwayFromBase(), TR_AircraftListSelect(), and TR_FillAircraft().

◆ AIR_IsAircraftOnGeoscape()

bool AIR_IsAircraftOnGeoscape ( const aircraft_t * aircraft)

Checks whether given aircraft is on geoscape.

Parameters
[in]aircraftPointer to an aircraft.
Note
aircraft may be neither on geoscape, nor in base (like when it's transferred)
Returns
false if given aircraft is not on geoscape, true if given aircraft is on geoscape.
See also
UFO_IsUFOSeenOnGeoscape

Definition at line 386 of file cp_aircraft.cpp.

References AIR_CRASHED, AIR_DROP, AIR_HOME, AIR_IDLE, AIR_INTERCEPT, AIR_MISSION, AIR_NONE, AIR_REFUEL, AIR_RETURNING, AIR_TRANSFER, AIR_TRANSIT, AIR_UFO, cgi, ERR_FATAL, and aircraft_t::status.

Referenced by AB_UpdateStealthForAllBase(), AIR_AircraftReturnToBase(), AIR_CampaignRun(), AIR_DeleteAircraft(), B_MoveAircraftOnGeoscapeToOtherBases(), GEO_Click(), GEO_DrawMarkers(), GEO_GetGeoscapeAngle(), RADAR_AddDetectedUFOToEveryRadar(), RADAR_UpdateWholeRadarOverlay(), TEST_F(), UFO_CampaignCheckEvents(), UFO_CheckShootBack(), and UFO_SearchAircraftTarget().

◆ AIR_IsEmployeeInAircraft()

const aircraft_t * AIR_IsEmployeeInAircraft ( const Employee * employee,
const aircraft_t * aircraft )

Tells you if an employee is assigned to an aircraft.

Parameters
[in]employeeThe employee to search for.
[in]aircraftThe aircraft to search the employee in. Use nullptr to check if the soldier is in any aircraft.
Returns
true if the soldier was found in the aircraft otherwise false.

Definition at line 2763 of file cp_aircraft.cpp.

References AIR_Foreach, AIR_GetPilot(), AIR_IsEmployeeInAircraft(), AIR_IsInAircraftTeam(), Employee::isPilot(), and Employee::transfer.

Referenced by AIR_AddEmployee(), AIR_IsEmployeeInAircraft(), AIR_RemoveEmployee(), CHAR_UpdateStats(), CP_MissionEnd(), CP_TEAM_AssignSoldierByUCN_f(), CP_TEAM_FillBDEFEmployeeList_f(), CP_TEAM_FillEmployeeList_f(), CP_TEAM_FillEquipSoldierList_f(), E_EmployeeList_f(), HOS_Entry(), Employee::isAwayFromBase(), TR_TransferStart(), and Employee::unassign().

◆ AIR_IsInAircraftTeam()

bool AIR_IsInAircraftTeam ( const aircraft_t * aircraft,
const Employee * employee )

Checks whether given employee is in given aircraft.

Parameters
[in]aircraftThe aircraft to check
[in]employeeEmployee to check.
Returns
true if the given employee is assigned to the given aircraft.

Definition at line 1967 of file cp_aircraft.cpp.

References aircraft_t::acTeam, and cgi.

Referenced by AIR_IsEmployeeInAircraft().

◆ AIR_LoadAircraftSlotsXML()

void AIR_LoadAircraftSlotsXML ( aircraft_t * aircraft,
aircraftSlot_t * slot,
xmlNode_t * p,
bool weapon,
const int max )
static

Loads the weapon slots of an aircraft.

Parameters
[in]aircraftPointer to the aircraft.
[out]slotPointer to the slot where item should be added.
[in]pXML Node structure, where we get the information from
[in]weaponTrue if the slot is a weapon slot.
[in]maxMaximum number of slots for this aircraft that should be loaded.
See also
B_Load
B_SaveAircraftSlots

Definition at line 2310 of file cp_aircraft.cpp.

References AII_LoadOneSlotXML(), aircraftSlot_t::aircraft, cgi, i, SAVE_AIRCRAFT_SLOT, XML_GetNextNode(), and xmlNode_t.

Referenced by AIR_LoadAircraftXML().

◆ AIR_LoadAircraftXML()

bool AIR_LoadAircraftXML ( xmlNode_t * p,
aircraft_t * craft )
static

Loads an Aircraft from the savegame.

Parameters
[in]pXML Node structure, where we get the information from
[out]craftPointer to the aircraft

Definition at line 2355 of file cp_aircraft.cpp.

References _, aircraft_t::acTeam, AIR_AircraftGetFromIDX(), AIR_GetAircraft(), AIR_GetTeamSize(), AIR_LoadAircraftSlotsXML(), AIR_LoadRouteXML(), AIR_SetPilot(), AIR_STATS_DAMAGE, aircraft_t::aircraftTarget, aircraft_t::alienCargo, B_GetBaseByIDX(), ccs, cgi, cp_campaignPool, aircraft_t::damage, aircraft_t::defaultName, aircraft_t::detected, aircraft_t::detectionIdx, aircraft_t::direction, E_GetEmployeeFromChrUCN(), aircraft_t::electronics, ERR_DROP, aircraft_t::fuel, aircraft_t::homebase, aircraft_t::id, aircraft_t::idx, aircraft_t::itemCargo, aircraft_t::landed, aircraft_t::lastSpotted, AlienCargo::load(), ItemCargo::load(), MAX_BASES, aircraft_t::maxElectronics, aircraft_t::maxTeamSize, aircraft_t::maxWeapons, aircraft_t::missionID, aircraft_t::name, aircraft_t::point, aircraft_t::pos, Q_strncpyz(), aircraft_t::radar, RADAR_Initialise(), RADAR_InitialiseUFOs(), aircraft_t::route, SAVE_AIRCRAFT_AIRCRAFTTARGET, SAVE_AIRCRAFT_AIRCRAFTTEAM, SAVE_AIRCRAFT_AIRSTAT, SAVE_AIRCRAFT_AIRSTATID, SAVE_AIRCRAFT_AIRSTATS, SAVE_AIRCRAFT_ALIENCARGO, SAVE_AIRCRAFT_CARGO, SAVE_AIRCRAFT_DAMAGE, SAVE_AIRCRAFT_DETECTED, SAVE_AIRCRAFT_DETECTIONIDX, SAVE_AIRCRAFT_DIRECTION, SAVE_AIRCRAFT_ELECTRONICS, SAVE_AIRCRAFT_FUEL, SAVE_AIRCRAFT_HOMEBASE, SAVE_AIRCRAFT_ID, SAVE_AIRCRAFT_IDX, SAVE_AIRCRAFT_LANDED, SAVE_AIRCRAFT_LASTSPOTTED_DATE, SAVE_AIRCRAFT_MEMBER, SAVE_AIRCRAFT_MISSIONID, SAVE_AIRCRAFT_NAME, SAVE_AIRCRAFT_PILOTUCN, SAVE_AIRCRAFT_POINT, SAVE_AIRCRAFT_POS, SAVE_AIRCRAFT_SHIELDS, SAVE_AIRCRAFT_STATUS, SAVE_AIRCRAFT_TEAM_UCN, SAVE_AIRCRAFT_TIME, SAVE_AIRCRAFT_VAL, SAVE_AIRCRAFT_WEAPONS, SAVE_AIRCRAFTSTAT_NAMESPACE, SAVE_AIRCRAFTSTATUS_NAMESPACE, saveAircraftConstants, aircraft_t::shield, aircraft_t::stats, aircraft_t::status, aircraft_t::time, aircraft_t::weapons, and xmlNode_t.

Referenced by AIR_LoadXML().

◆ AIR_LoadRouteXML()

bool AIR_LoadRouteXML ( xmlNode_t * p,
mapline_t * route )
static

Loads the route of an aircraft.

Parameters
[in]pXML Node structure, where we get the information from
[out]routeRoute points of the aircraft

Definition at line 2328 of file cp_aircraft.cpp.

References cgi, count, mapline_t::distance, LINE_MAXPTS, mapline_t::numPoints, mapline_t::point, SAVE_AIRCRAFT_ROUTE, SAVE_AIRCRAFT_ROUTE_DISTANCE, SAVE_AIRCRAFT_ROUTE_POINT, and xmlNode_t.

Referenced by AIR_LoadAircraftXML().

◆ AIR_LoadXML()

◆ AIR_Move()

◆ AIR_MoveAircraftIntoNewHomebase()

void AIR_MoveAircraftIntoNewHomebase ( aircraft_t * aircraft,
base_t * base )

Moves a given aircraft to a new base (also the employees and inventory).

Parameters
[in]aircraftThe aircraft to move into a new base
[in]baseThe base to move the aircraft into

Definition at line 786 of file cp_aircraft.cpp.

References aircraft_t::acTeam, AIR_AircraftReturnToBase(), AIR_GetFirstFromBase(), AIR_GetHangarCapacityType(), AIR_GetPilot(), AIR_RETURNING, AIR_TransferItemsCarriedByCharacterToBase(), base_t::aircraftCurrent, CAP_AddCurrent(), cgi, DEBUG_CLIENT, E_MoveIntoNewBase(), GEO_SelectAircraft(), aircraft_t::homebase, aircraft_t::id, LIST_Foreach, base_t::name, and aircraft_t::status.

Referenced by B_MoveAircraftOnGeoscapeToOtherBases(), and CL_PopupChangeHomebase_f().

◆ AIR_MoveEmployeeInventoryIntoStorage()

void AIR_MoveEmployeeInventoryIntoStorage ( const aircraft_t & aircraft,
equipDef_t & ed )

Move all the equipment carried by the team on the aircraft into the given equipment.

Parameters
[in]aircraftThe craft with the team (and thus equipment) onboard.
[out]edThe equipment definition which will receive all the stuff from the aircraft-team.

Definition at line 2817 of file cp_aircraft.cpp.

References aircraft_t::acTeam, equipDef_t::addClip(), AIR_GetTeamSize(), Item::ammoDef(), cgi, DEBUG_CLIENT, Item::def(), Item::getAmmoLeft(), Item::getNext(), Container::getNextItem(), LIST_Foreach, equipDef_t::numItems, and type.

Referenced by B_InitialEquipment().

◆ AIR_NewAircraft()

aircraft_t * AIR_NewAircraft ( base_t * base,
const aircraft_t * aircraftTemplate )

◆ AIR_ParseAircraft()

◆ AIR_PilotSurvivedCrash()

bool AIR_PilotSurvivedCrash ( const aircraft_t * aircraft)

Determine if an aircraft's pilot survived a crash, based on his piloting skill (and a bit of randomness).

Parameters
[in]aircraftPointer to crashed aircraft
Returns
true if survived, false if not

Definition at line 2023 of file cp_aircraft.cpp.

References cgi, Employee::chr, crand(), GEO_GetColor(), MAPTYPE_TERRAIN, aircraft_t::pilot, aircraft_t::pos, character_t::score, SKILL_PILOTING, and chrScoreGlobal_t::skills.

Referenced by AIRFIGHT_ActionsAfterAirfight(), and CP_SpawnRescueMission().

◆ AIR_PostLoadInit()

bool AIR_PostLoadInit ( void )

Actions needs to be done after loading the savegame.

See also
SAV_GameActionsAfterLoad

Definition at line 2631 of file cp_aircraft.cpp.

References AIR_PostLoadInitMissions().

Referenced by SAV_GameActionsAfterLoad().

◆ AIR_PostLoadInitMissions()

bool AIR_PostLoadInitMissions ( void )
static

Set the mission pointers for all the aircraft after loading a savegame.

Todo
UFO_RemoveFromGeoscape call doesn't notify other systems (aircraft, base defences, sam sites, radar) about the removal of the UFO. Destroying UFOs should get a dedicated function with all necessary notify-callbacks called

Definition at line 2576 of file cp_aircraft.cpp.

References AIR_AircraftReturnToBase(), AIR_DROP, AIR_Foreach, AIR_IDLE, AIR_MISSION, cgi, CP_GetMissionByID(), aircraft_t::idx, aircraft_t::mission, aircraft_t::missionID, aircraft_t::name, Q_strnull(), UFO_GetNext(), and UFO_RemoveFromGeoscape().

Referenced by AIR_PostLoadInit().

◆ AIR_Refuel()

◆ AIR_RemoveEmployee()

bool AIR_RemoveEmployee ( Employee * employee,
aircraft_t * aircraft )

Removes a soldier from an aircraft.

Parameters
[in,out]employeeThe soldier to be removed from the aircraft.
[in,out]aircraftThe aircraft to remove the soldier from. Use nullptr to remove the soldier from any aircraft.
See also
AIR_AddEmployee

Definition at line 2724 of file cp_aircraft.cpp.

References aircraft_t::acTeam, AIR_Foreach, AIR_GetPilot(), AIR_IsEmployeeInAircraft(), AIR_SetPilot(), cgi, Employee::chr, DEBUG_CLIENT, EMPL_PILOT, Employee::getType(), aircraft_t::homebase, aircraft_t::idx, and character_t::ucn.

Referenced by AIR_RemoveEmployees(), CP_EndRescueMission(), CP_TEAM_AssignSoldierByUCN_f(), TR_TransferStart(), and Employee::unassign().

◆ AIR_RemoveEmployees()

void AIR_RemoveEmployees ( aircraft_t & aircraft)

Removes all soldiers from an aircraft.

Parameters
[in,out]aircraftThe aircraft to remove the soldiers from.
See also
AIR_RemoveEmployee

Definition at line 2797 of file cp_aircraft.cpp.

References aircraft_t::acTeam, AIR_GetTeamSize(), AIR_RemoveEmployee(), AIR_SetPilot(), cgi, ERR_DROP, and LIST_Foreach.

Referenced by AIR_DeleteAircraft(), and BS_Buy_f().

◆ AIR_RemovePilotFromAssignedAircraft()

void AIR_RemovePilotFromAssignedAircraft ( const base_t * base,
const Employee * pilot )

Checks to see if the pilot is in any aircraft at this base. If he is then he is removed from that aircraft.

Parameters
[in]baseWhich base has the aircraft to search for the employee in.
[in]pilotWhich pilot to search for.

Definition at line 2068 of file cp_aircraft.cpp.

References AIR_ForeachFromBase, AIR_GetPilot(), and AIR_SetPilot().

Referenced by Employee::unassign().

◆ AIR_ResetAircraftTeam()

void AIR_ResetAircraftTeam ( aircraft_t * aircraft)

Resets team in given aircraft.

Parameters
[in]aircraftPointer to an aircraft, where the team will be reset.

Definition at line 1934 of file cp_aircraft.cpp.

References aircraft_t::acTeam, and cgi.

Referenced by AIR_NewAircraft(), and AIR_Shutdown().

◆ AIR_SaveAircraftSlotsXML()

void AIR_SaveAircraftSlotsXML ( const aircraftSlot_t * slot,
const int num,
xmlNode_t * p,
bool weapon )
static

Saves an item slot.

Parameters
[in]slotPointer to the slot where item is.
[in]numNumber of slots for this aircraft.
[out]pXML Node structure, where we write the information to
[in]ppointer where information are written.
[in]weaponTrue if the slot is a weapon slot.
See also
B_Save
AII_InitialiseSlot

Definition at line 2146 of file cp_aircraft.cpp.

References AII_SaveOneSlotXML(), cgi, i, SAVE_AIRCRAFT_SLOT, and xmlNode_t.

Referenced by AIR_SaveAircraftXML().

◆ AIR_SaveAircraftXML()

bool AIR_SaveAircraftXML ( xmlNode_t * p,
const aircraft_t *const aircraft,
bool const isUfo )
static

Saves an aircraft.

Parameters
[out]pXML Node structure, where we write the information to
[in]aircraftAircraft we save
[in]isUfoIf this aircraft is a UFO

detection id and time

Definition at line 2160 of file cp_aircraft.cpp.

References aircraft_t::acTeam, AIR_DROP, AIR_GetPilot(), AIR_MISSION, AIR_SaveAircraftSlotsXML(), AIR_SaveRouteXML(), AIR_STATS_DAMAGE, AIR_STATS_MAX, aircraft_t::aircraftTarget, aircraft_t::alienCargo, cgi, Employee::chr, aircraft_t::damage, aircraft_t::detected, aircraft_t::detectionIdx, aircraft_t::direction, aircraft_t::electronics, aircraft_t::fuel, DateTime::getDateAsDays(), DateTime::getTimeAsSeconds(), aircraft_t::homebase, i, aircraft_t::id, aircraft_t::idx, aircraft_t::itemCargo, aircraft_t::landed, aircraft_t::lastSpotted, LIST_Foreach, aircraft_t::maxElectronics, aircraft_t::maxWeapons, aircraft_t::mission, aircraft_t::name, aircraft_t::point, aircraft_t::pos, aircraft_t::route, AlienCargo::save(), ItemCargo::save(), SAVE_AIRCRAFT_AIRCRAFT, SAVE_AIRCRAFT_AIRCRAFTTARGET, SAVE_AIRCRAFT_AIRCRAFTTEAM, SAVE_AIRCRAFT_AIRSTAT, SAVE_AIRCRAFT_AIRSTATID, SAVE_AIRCRAFT_AIRSTATS, SAVE_AIRCRAFT_ALIENCARGO, SAVE_AIRCRAFT_CARGO, SAVE_AIRCRAFT_DAMAGE, SAVE_AIRCRAFT_DETECTED, SAVE_AIRCRAFT_DETECTIONIDX, SAVE_AIRCRAFT_DIRECTION, SAVE_AIRCRAFT_ELECTRONICS, SAVE_AIRCRAFT_FUEL, SAVE_AIRCRAFT_HOMEBASE, SAVE_AIRCRAFT_ID, SAVE_AIRCRAFT_IDX, SAVE_AIRCRAFT_LANDED, SAVE_AIRCRAFT_LASTSPOTTED_DATE, SAVE_AIRCRAFT_MEMBER, SAVE_AIRCRAFT_MISSIONID, SAVE_AIRCRAFT_NAME, SAVE_AIRCRAFT_PILOTUCN, SAVE_AIRCRAFT_POINT, SAVE_AIRCRAFT_POS, SAVE_AIRCRAFT_SHIELDS, SAVE_AIRCRAFT_STATUS, SAVE_AIRCRAFT_TEAM_UCN, SAVE_AIRCRAFT_TIME, SAVE_AIRCRAFT_VAL, SAVE_AIRCRAFT_WEAPONS, SAVE_AIRCRAFTSTAT_NAMESPACE, SAVE_AIRCRAFTSTATUS_NAMESPACE, saveAircraftConstants, aircraft_t::shield, aircraft_t::stats, aircraft_t::status, aircraft_t::time, character_t::ucn, UFO_GetGeoscapeIDX, aircraft_t::weapons, and xmlNode_t.

Referenced by AIR_SaveXML().

◆ AIR_SaveRouteXML()

void AIR_SaveRouteXML ( xmlNode_t * node,
const mapline_t * route )
static

Saves an route plan of an aircraft.

Parameters
[out]nodeXML Node structure, where we write the information to
[in]routeAircraft route plan

Definition at line 2127 of file cp_aircraft.cpp.

References cgi, mapline_t::distance, mapline_t::numPoints, mapline_t::point, SAVE_AIRCRAFT_ROUTE, SAVE_AIRCRAFT_ROUTE_DISTANCE, SAVE_AIRCRAFT_ROUTE_POINT, and xmlNode_t.

Referenced by AIR_SaveAircraftXML().

◆ AIR_SaveXML()

bool AIR_SaveXML ( xmlNode_t * parent)

Save callback for savegames in xml format.

See also
AIR_LoadXML
B_SaveXML
SAV_GameSaveXML

Definition at line 2275 of file cp_aircraft.cpp.

References AIR_Foreach, AIR_SaveAircraftXML(), AIRFIGHT_SaveXML(), cgi, i, aircraft_t::id, MAX_UFOONGEOSCAPE, SAVE_AIRCRAFT_PHALANX, SAVE_AIRCRAFT_PROJECTILES, SAVE_AIRCRAFT_UFOS, UFO_GetByIDX(), and xmlNode_t.

Referenced by SAV_Init().

◆ AIR_ScriptSanityCheck()

bool AIR_ScriptSanityCheck ( void )

◆ AIR_SendAircraftPursuingUFO()

bool AIR_SendAircraftPursuingUFO ( aircraft_t * aircraft,
aircraft_t * ufo )

◆ AIR_SendAircraftToMission()

bool AIR_SendAircraftToMission ( aircraft_t * aircraft,
mission_t * mission )

Sends the specified aircraft to specified mission.

Parameters
[in]aircraftPointer to aircraft to send to mission.
[in]missionPointer to given mission.
Returns
true if sending an aircraft to specified mission is possible.

Definition at line 1150 of file cp_aircraft.cpp.

References _, mission_t::active, AII_ReloadAircraftWeapons(), AIR_AircraftHasEnoughFuel(), AIR_GetTeamSize(), AIR_IsAircraftInBase(), AIR_MISSION, B_IsUnderAttack, cgi, CP_Popup(), GEO_CalcLine(), GEO_SetInterceptorAircraft, aircraft_t::homebase, aircraft_t::mission, MS_AddNewMessage(), aircraft_t::point, aircraft_t::pos, mission_t::pos, aircraft_t::route, aircraft_t::status, and aircraft_t::time.

Referenced by AIR_SendAircraftToMission_f(), and CL_PopupInterceptClick_f().

◆ AIR_SetPilot()

bool AIR_SetPilot ( aircraft_t * aircraft,
Employee * pilot )

Assign a pilot to an aircraft.

Parameters
[out]aircraftPointer to the aircraft to add pilot to
[in]pilotPointer to the pilot to add
Returns
true if the assignment was successful (there wasn't a pilot assigned), false if there was already a pilot assigned and we tried to assign a new one (pilot isn't nullptr).

Definition at line 1993 of file cp_aircraft.cpp.

References aircraft_t::pilot.

Referenced by AIR_AutoAddPilotToAircraft(), AIR_DestroyAircraft(), AIR_LoadAircraftXML(), AIR_RemoveEmployee(), AIR_RemoveEmployees(), AIR_RemovePilotFromAssignedAircraft(), and CP_TEAM_AssignSoldierByUCN_f().

◆ AIR_Shutdown()

void AIR_Shutdown ( void )

Closing actions for aircraft-subsystem.

Definition at line 2918 of file cp_aircraft.cpp.

References AIR_Foreach, AIR_ResetAircraftTeam(), AIR_ShutdownCallbacks(), aircraftDebugCmds, ccs, and cgi.

Referenced by CP_Shutdown().

◆ AIR_TransferItemsCarriedByCharacterToBase()

void AIR_TransferItemsCarriedByCharacterToBase ( character_t * chr,
base_t * sourceBase,
base_t * destBase )
static

Transfer items carried by a soldier from one base to another.

Parameters
[in]chrPointer to the character.
[in]sourceBaseBase where employee comes from.
[in]destBaseBase where employee is going.

Definition at line 762 of file cp_aircraft.cpp.

References Item::ammoDef(), B_AddToStorage(), Item::def(), Inventory::getNextCont(), Container::getNextItem(), and character_t::inv.

Referenced by AIR_MoveAircraftIntoNewHomebase().

◆ CASSERT()

Variable Documentation

◆ air_position_strings

char const* const air_position_strings[]
static
Initial value:
= {
"nose_left",
"nose_center",
"nose_right",
"wing_left",
"wing_right",
"rear_left",
"rear_center",
"rear_right"
}

List of valid strings for itemPos_t.

Note
must be in the same order than itemPos_t

Definition at line 1210 of file cp_aircraft.cpp.

Referenced by AIR_ParseAircraft().

◆ air_slot_type_strings

const char* const air_slot_type_strings[] = AIR_SLOT_TYPE_STRINGS

Definition at line 1267 of file cp_aircraft.cpp.

Referenced by AIR_ParseAircraft(), CASSERT(), and Com_ParseItem().

◆ aircraft_param_vals

const value_t aircraft_param_vals[]
static
Initial value:
= {
{"speed", V_INT, offsetof(aircraft_t, stats[AIR_STATS_SPEED]), MEMBER_SIZEOF(aircraft_t, stats[0])},
{"maxspeed", V_INT, offsetof(aircraft_t, stats[AIR_STATS_MAXSPEED]), MEMBER_SIZEOF(aircraft_t, stats[0])},
{"shield", V_INT, offsetof(aircraft_t, stats[AIR_STATS_SHIELD]), MEMBER_SIZEOF(aircraft_t, stats[0])},
{"ecm", V_INT, offsetof(aircraft_t, stats[AIR_STATS_ECM]), MEMBER_SIZEOF(aircraft_t, stats[0])},
{"damage", V_INT, offsetof(aircraft_t, stats[AIR_STATS_DAMAGE]), MEMBER_SIZEOF(aircraft_t, stats[0])},
{"accuracy", V_INT, offsetof(aircraft_t, stats[AIR_STATS_ACCURACY]), MEMBER_SIZEOF(aircraft_t, stats[0])},
{"antimatter", V_INT, offsetof(aircraft_t, stats[AIR_STATS_ANTIMATTER]), MEMBER_SIZEOF(aircraft_t, stats[0])},
{nullptr, V_NULL, 0, 0}
}
@ AIR_STATS_ECM
Definition inv_shared.h:229
@ AIR_STATS_ANTIMATTER
Definition inv_shared.h:235
@ AIR_STATS_ACCURACY
Definition inv_shared.h:231
@ AIR_STATS_SPEED
Definition inv_shared.h:226
@ AIR_STATS_DAMAGE
Definition inv_shared.h:230
@ AIR_STATS_SHIELD
Definition inv_shared.h:228
@ AIR_STATS_MAXSPEED
Definition inv_shared.h:227
@ V_NULL
Definition scripts.h:49
@ V_INT
Definition scripts.h:52
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition scripts.h:34
An aircraft with all it's data.

Valid aircraft parameter definitions from script files.

Note
wrange can't be parsed in aircraft definition: this is a property of weapon

Definition at line 1224 of file cp_aircraft.cpp.

Referenced by AIR_ParseAircraft().

◆ aircraft_radar_vals

const value_t aircraft_radar_vals[]
static
Initial value:
= {
{"range", V_INT, offsetof(aircraft_t, radar.range), MEMBER_SIZEOF(aircraft_t, radar.range)},
{"trackingrange", V_INT, offsetof(aircraft_t, radar.trackingRange), MEMBER_SIZEOF(aircraft_t, radar.trackingRange)},
{"detectionprobability", V_FLOAT, offsetof(aircraft_t, radar.ufoDetectionProbability), MEMBER_SIZEOF(aircraft_t, radar.ufoDetectionProbability)},
{nullptr, V_NULL, 0, 0}
}
@ V_FLOAT
Definition scripts.h:54
static hudRadar_t radar

Valid radar definition values for an aircraft from script files.

Definition at line 1259 of file cp_aircraft.cpp.

Referenced by AIR_ParseAircraft().

◆ aircraft_vals

const value_t aircraft_vals[]
static
Initial value:
= {
{"name", V_STRING, offsetof(aircraft_t, name), 0},
{"defaultname", V_TRANSLATION_STRING, offsetof(aircraft_t, defaultName), 0},
{"numteam", V_INT, offsetof(aircraft_t, maxTeamSize), MEMBER_SIZEOF(aircraft_t, maxTeamSize)},
{"nogeoscape", V_BOOL, offsetof(aircraft_t, notOnGeoscape), MEMBER_SIZEOF(aircraft_t, notOnGeoscape)},
{"interestlevel", V_INT, offsetof(aircraft_t, ufoInterestOnGeoscape), MEMBER_SIZEOF(aircraft_t, ufoInterestOnGeoscape)},
{"leader", V_BOOL, offsetof(aircraft_t, leader), MEMBER_SIZEOF(aircraft_t, leader)},
{"image", V_HUNK_STRING, offsetof(aircraft_t, image), 0},
{"model", V_HUNK_STRING, offsetof(aircraft_t, model), 0},
{"price", V_INT, offsetof(aircraft_t, price), MEMBER_SIZEOF(aircraft_t, price)},
{"productioncost", V_INT, offsetof(aircraft_t, productionCost), MEMBER_SIZEOF(aircraft_t, productionCost)},
{"building", V_HUNK_STRING, offsetof(aircraft_t, building), 0},
{"missiontypes", V_LIST, offsetof(aircraft_t, missionTypes), 0},
{nullptr, V_NULL, 0, 0}
}
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
@ V_BOOL
Definition scripts.h:50
@ V_TRANSLATION_STRING
Definition scripts.h:59
@ V_HUNK_STRING
Definition scripts.h:69
@ V_LIST
Definition scripts.h:78
@ V_STRING
Definition scripts.h:58

Valid aircraft definition values from script files.

Definition at line 1237 of file cp_aircraft.cpp.

Referenced by AIR_ParseAircraft().

◆ aircraftDebugCmds

const cmdList_t aircraftDebugCmds[]
static
Initial value:
= {
{nullptr, nullptr, nullptr}
}

Definition at line 2897 of file cp_aircraft.cpp.

Referenced by AIR_InitStartup(), and AIR_Shutdown().