UFO: Alien Invasion
|
Most of the aircraft related stuff. More...
#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"
Go to the source code of this file.
Functions | |
aircraft_t * | AIR_GetFirstFromBase (const base_t *b) |
Iterates through the aircraft of a base. More... | |
bool | AIR_BaseHasAircraft (const base_t *base) |
Checks whether there is any aircraft assigned to the given base. More... | |
int | AIR_BaseCountAircraft (const base_t *base) |
Returns the number of aircraft on the given base. More... | |
static void | AII_CollectAmmo (void *data, const Item *magazine) |
Count and collect ammo from gun magazine. More... | |
void | AII_CollectItem (aircraft_t *aircraft, const objDef_t *item, int amount) |
Add an item to aircraft inventory. More... | |
static void | AII_CollectItem_ (void *data, const objDef_t *item, int amount) |
static void | AII_CarriedItems (const Inventory *soldierInventory) |
Process items carried by soldiers. More... | |
void | AII_CollectingItems (aircraft_t *aircraft, int won) |
Collect items from the battlefield. More... | |
const char * | AIR_AircraftStatusToName (const aircraft_t *aircraft) |
Translates the aircraft status id to a translatable string. More... | |
bool | AIR_IsAircraftInBase (const aircraft_t *aircraft) |
Checks whether given aircraft is in its homebase. More... | |
bool | AIR_IsAircraftOnGeoscape (const aircraft_t *aircraft) |
Checks whether given aircraft is on geoscape. More... | |
int | AIR_CountInBaseByTemplate (const base_t *base, const aircraft_t *aircraftTemplate) |
Calculates the amount of aircraft (of the given type) in the selected base. More... | |
int | AIR_AircraftMenuStatsValues (const int value, const int stat) |
Some of the aircraft values needs special calculations when they are shown in the menus. More... | |
int | AIR_GetOperationRange (const aircraft_t *aircraft) |
Calculates the range an aircraft can fly on the geoscape. More... | |
int | AIR_GetRemainingRange (const aircraft_t *aircraft) |
Calculates the remaining range the aircraft can fly. More... | |
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 More... | |
bool | AIR_AircraftHasEnoughFuelOneWay (const aircraft_t *aircraft, const vec2_t destination) |
check if aircraft has enough fuel to go to destination More... | |
void | AIR_AircraftReturnToBase (aircraft_t *aircraft) |
Calculates the way back to homebase for given aircraft and returns it. More... | |
aircraft_t * | AIR_GetAircraftFromBaseByIDXSafe (const base_t *base, int index) |
const aircraft_t * | AIR_GetAircraftSilent (const char *name) |
Searches the global array of aircraft types for a given aircraft. More... | |
const aircraft_t * | AIR_GetAircraft (const char *name) |
Searches the global array of aircraft types for a given aircraft. More... | |
static void | AII_SetAircraftInSlots (aircraft_t *aircraft) |
Initialise aircraft pointer in each slot of an aircraft. More... | |
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. More... | |
bool | AIR_Delete (base_t *base, aircraft_t *aircraft) |
Will remove the given aircraft from the base. More... | |
aircraft_t * | AIR_NewAircraft (base_t *base, const aircraft_t *aircraftTemplate) |
Places a new aircraft in the given base. More... | |
baseCapacities_t | AIR_GetHangarCapacityType (const aircraft_t *aircraft) |
Returns capacity type needed for an aircraft. More... | |
static int | AIR_GetStorageRoom (const aircraft_t *aircraft) |
Calculate used storage room corresponding to items in an aircraft. More... | |
const char * | AIR_CheckMoveIntoNewHomebase (const aircraft_t *aircraft, const base_t *base) |
Checks if destination base can store an aircraft and its team. More... | |
static void | AIR_TransferItemsCarriedByCharacterToBase (character_t *chr, base_t *sourceBase, base_t *destBase) |
Transfer items carried by a soldier from one base to another. More... | |
void | AIR_MoveAircraftIntoNewHomebase (aircraft_t *aircraft, base_t *base) |
Moves a given aircraft to a new base (also the employees and inventory) More... | |
void | AIR_DeleteAircraft (aircraft_t *aircraft) |
Removes an aircraft from its base and the game. More... | |
void | AIR_DestroyAircraft (aircraft_t *aircraft, bool killPilot) |
Removes an aircraft from its base and the game. More... | |
bool | AIR_AircraftMakeMove (int dt, aircraft_t *aircraft) |
Moves given aircraft. More... | |
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. More... | |
aircraft_t * | AIR_AircraftGetFromIDX (int aircraftIdx) |
Returns aircraft for a given global index. More... | |
bool | AIR_SendAircraftToMission (aircraft_t *aircraft, mission_t *mission) |
Sends the specified aircraft to specified mission. More... | |
static void | AII_InitialiseAircraftSlots (aircraft_t *aircraftTemplate) |
Initialise all values of an aircraft slot. More... | |
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. More... | |
void | AIR_AircraftsNotifyMissionRemoved (const mission_t *const mission) |
Notify aircraft that a mission has been removed. More... | |
void | AIR_AircraftsNotifyUFORemoved (const aircraft_t *const ufo, bool destroyed) |
Notify that a UFO has been removed. More... | |
void | AIR_AircraftsUFODisappear (const aircraft_t *const ufo) |
Notify that a UFO disappear from radars. More... | |
static float | AIR_GetDestinationFunction (const float c, const float B, const float speedRatio, float a) |
funtion we need to find roots. More... | |
static float | AIR_GetDestinationDerivativeFunction (const float c, const float B, const float speedRatio, float a) |
derivative of the funtion we need to find roots. More... | |
static float | AIR_GetDestinationFindRoot (const float c, const float B, const float speedRatio, float start) |
Find the roots of a function. More... | |
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. More... | |
bool | AIR_SendAircraftPursuingUFO (aircraft_t *aircraft, aircraft_t *ufo) |
Make the specified aircraft purchasing a UFO. More... | |
void | AIR_ResetAircraftTeam (aircraft_t *aircraft) |
Resets team in given aircraft. More... | |
bool | AIR_AddToAircraftTeam (aircraft_t *aircraft, Employee *employee) |
Adds given employee to given aircraft. More... | |
bool | AIR_IsInAircraftTeam (const aircraft_t *aircraft, const Employee *employee) |
Checks whether given employee is in given aircraft. More... | |
int | AIR_GetTeamSize (const aircraft_t *aircraft) |
Counts the number of soldiers in given aircraft. More... | |
bool | AIR_SetPilot (aircraft_t *aircraft, Employee *pilot) |
Assign a pilot to an aircraft. More... | |
Employee * | AIR_GetPilot (const aircraft_t *aircraft) |
Get pilot of an aircraft. More... | |
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) More... | |
void | AIR_AutoAddPilotToAircraft (const base_t *base, Employee *pilot) |
Adds the pilot to the first available aircraft at the specified base. More... | |
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. More... | |
int | AIR_GetAircraftWeaponRanges (const aircraftSlot_t *slot, int maxSlot, float *weaponRanges) |
Get the all the unique weapon ranges of this aircraft. More... | |
static void | AIR_SaveRouteXML (xmlNode_t *node, const mapline_t *route) |
Saves an route plan of an aircraft. More... | |
static void | AIR_SaveAircraftSlotsXML (const aircraftSlot_t *slot, const int num, xmlNode_t *p, bool weapon) |
Saves an item slot. More... | |
static bool | AIR_SaveAircraftXML (xmlNode_t *p, const aircraft_t *const aircraft, bool const isUfo) |
Saves an aircraft. More... | |
bool | AIR_SaveXML (xmlNode_t *parent) |
Save callback for savegames in xml format. More... | |
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. More... | |
static bool | AIR_LoadRouteXML (xmlNode_t *p, mapline_t *route) |
Loads the route of an aircraft. More... | |
static bool | AIR_LoadAircraftXML (xmlNode_t *p, aircraft_t *craft) |
Loads an Aircraft from the savegame. More... | |
static void | AIR_CorrectAircraftSlotPointers (aircraft_t *aircraft) |
resets aircraftSlots' backreference pointers for aircraft More... | |
bool | AIR_LoadXML (xmlNode_t *parent) |
static bool | AIR_PostLoadInitMissions (void) |
Set the mission pointers for all the aircraft after loading a savegame. More... | |
bool | AIR_PostLoadInit (void) |
Actions needs to be done after loading the savegame. More... | |
bool | AIR_AircraftAllowed (const base_t *base) |
Returns true if the current base is able to handle aircraft. More... | |
bool | AIR_CanIntercept (const aircraft_t *aircraft) |
bool | AIR_ScriptSanityCheck (void) |
Checks the parsed aircraft for errors. More... | |
bool | AIR_RemoveEmployee (Employee *employee, aircraft_t *aircraft) |
Removes a soldier from an aircraft. More... | |
const aircraft_t * | AIR_IsEmployeeInAircraft (const Employee *employee, const aircraft_t *aircraft) |
Tells you if an employee is assigned to an aircraft. More... | |
void | AIR_RemoveEmployees (aircraft_t &aircraft) |
Removes all soldiers from an aircraft. More... | |
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. More... | |
bool | AIR_AddEmployee (Employee *employee, aircraft_t *aircraft) |
Assigns a soldier to an aircraft. More... | |
void | AIR_AssignInitial (aircraft_t *aircraft) |
Assigns initial team of soldiers to aircraft. More... | |
void | AIR_InitStartup (void) |
Init actions for aircraft-subsystem. More... | |
void | AIR_Shutdown (void) |
Closing actions for aircraft-subsystem. More... | |
Variables | |
static char const *const | air_position_strings [] |
List of valid strings for itemPos_t. More... | |
static const value_t | aircraft_param_vals [] |
Valid aircraft parameter definitions from script files. More... | |
static const value_t | aircraft_vals [] |
Valid aircraft definition values from script files. More... | |
static const value_t | aircraft_radar_vals [] |
Valid radar definition values for an aircraft from script files. More... | |
const char *const | air_slot_type_strings [] = AIR_SLOT_TYPE_STRINGS |
static const cmdList_t | aircraftDebugCmds [] |
Most of the aircraft related stuff.
Definition in file cp_aircraft.cpp.
Process items carried by soldiers.
[in] | soldierInventory | Pointer to inventory from a soldier of our team. |
Definition at line 255 of file cp_aircraft.cpp.
References Container::_invList, equipDef_s::addClip(), ccs, Item::def(), ccs_s::eMission, Item::getAmmoLeft(), Item::getNext(), Inventory::getNextCont(), objDef_s::idx, objDef_s::isReloadable(), objDef_s::isVirtual, equipDef_s::numItems, RS_GetTechForItem(), and RS_MarkCollected().
Referenced by AII_CollectingItems().
Count and collect ammo from gun magazine.
[in] | data | Pointer to aircraft used in this mission. |
[in] | magazine | Pointer to Item being magazine. |
Definition at line 218 of file cp_aircraft.cpp.
References ItemCargo::add(), Item::ammoDef(), Item::getAmmoLeft(), and aircraft_s::itemCargo.
Referenced by AII_CollectingItems().
void AII_CollectingItems | ( | aircraft_t * | aircraft, |
int | won | ||
) |
Collect items from the battlefield.
Definition at line 293 of file cp_aircraft.cpp.
References ItemCargo::add(), AII_CarriedItems(), AII_CollectAmmo(), AII_CollectItem_(), cgi, DEBUG_CLIENT, ItemCargo::empty(), missionResults_s::itemAmount, aircraft_s::itemCargo, missionResults_s::itemTypes, ItemCargo::list(), LIST_Foreach, aircraft_s::mission, and mission_s::missionResults.
Referenced by GAME_CP_Results().
void AII_CollectItem | ( | aircraft_t * | aircraft, |
const objDef_t * | item, | ||
int | amount | ||
) |
Add an item to aircraft inventory.
[in,out] | aircraft | Aircraft to load to |
[in] | item | Item to add |
amount | Number of items to add |
Definition at line 236 of file cp_aircraft.cpp.
References ItemCargo::add(), and aircraft_s::itemCargo.
Referenced by AII_CollectItem_(), and AM_MoveCharacterInventoryIntoItemCargo().
Definition at line 245 of file cp_aircraft.cpp.
References AII_CollectItem().
Referenced by AII_CollectingItems().
|
static |
Initialise all values of an aircraft slot.
[in] | aircraftTemplate | Pointer to the aircraft which needs initalisation of its slots. |
Definition at line 1195 of file cp_aircraft.cpp.
References AC_ITEM_ELECTRONICS, AC_ITEM_SHIELD, AC_ITEM_WEAPON, AII_InitialiseSlot(), aircraft_s::electronics, i, MAX_AIRCRAFTSLOT, aircraft_s::shield, and aircraft_s::weapons.
Referenced by AIR_ParseAircraft().
|
static |
Initialise aircraft pointer in each slot of an aircraft.
[in] | aircraft | Pointer to the aircraft where slots are. |
Definition at line 586 of file cp_aircraft.cpp.
References aircraftSlot_s::aircraft, aircraft_s::electronics, i, MAX_AIRCRAFTSLOT, aircraft_s::shield, and aircraft_s::weapons.
Referenced by AIR_NewAircraft().
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.
[out] | base | The base to add the aircraft to |
[in] | aircraftTemplate | The template to create the new aircraft from |
Definition at line 604 of file cp_aircraft.cpp.
References AIR_CRASHED, AIR_GetHangarCapacityType(), ccs_s::aircraft, CAP_AddCurrent(), ccs, aircraft_s::homebase, LIST_Add(), MAX_CAP, and aircraft_s::status.
Referenced by AIR_LoadXML(), and AIR_NewAircraft().
bool AIR_AddEmployee | ( | Employee * | employee, |
aircraft_t * | aircraft | ||
) |
Assigns a soldier to an aircraft.
[in] | employee | The employee to be assigned to the aircraft. |
[in] | aircraft | What aircraft to assign employee to. |
Definition at line 2849 of file cp_aircraft.cpp.
References AIR_AddToAircraftTeam(), AIR_GetTeamSize(), AIR_IsEmployeeInAircraft(), and aircraft_s::maxTeamSize.
Referenced by AIR_AssignInitial().
bool AIR_AddToAircraftTeam | ( | aircraft_t * | aircraft, |
Employee * | employee | ||
) |
Adds given employee to given aircraft.
[in] | aircraft | Pointer to an aircraft, to which we will add employee. |
[in] | employee | The employee to add to the aircraft. |
Definition at line 1944 of file cp_aircraft.cpp.
References aircraft_s::acTeam, AIR_GetTeamSize(), cgi, and aircraft_s::maxTeamSize.
Referenced by AIR_AddEmployee(), and CP_TEAM_AssignSoldierByUCN_f().
bool AIR_AircraftAllowed | ( | const base_t * | base | ) |
Returns true if the current base is able to handle aircraft.
Definition at line 2637 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().
aircraft_t* AIR_AircraftGetFromIDX | ( | int | aircraftIdx | ) |
Returns aircraft for a given global index.
[in] | aircraftIdx | Global aircraft index. |
Definition at line 1131 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().
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
[in] | aircraft | Pointer to the aircraft |
[in] | destination | Pointer to the position the aircraft should go to |
Definition at line 471 of file cp_aircraft.cpp.
References AIR_GetRemainingRange(), GetDistanceOnGlobe(), aircraft_s::homebase, base_s::pos, aircraft_s::pos, and SECONDS_PER_HOUR.
Referenced by AIR_CampaignRun(), AIR_GeoSelectAircraft_f(), AIR_SendAircraftPursuingUFO(), AIR_SendAircraftToMission(), CL_DisplayPopupInterceptUFO(), and GEO_Click().
bool AIR_AircraftHasEnoughFuelOneWay | ( | const aircraft_t * | aircraft, |
const vec2_t | destination | ||
) |
check if aircraft has enough fuel to go to destination
[in] | aircraft | Pointer to the aircraft |
[in] | destination | Pointer to the position the aircraft should go to |
Definition at line 497 of file cp_aircraft.cpp.
References AIR_GetRemainingRange(), GetDistanceOnGlobe(), aircraft_s::pos, and SECONDS_PER_HOUR.
Referenced by AIR_CheckMoveIntoNewHomebase().
bool AIR_AircraftMakeMove | ( | int | dt, |
aircraft_t * | aircraft | ||
) |
Moves given aircraft.
[in] | dt | time delta |
[in] | aircraft | Pointer to aircraft on its way. |
Definition at line 925 of file cp_aircraft.cpp.
References AIR_STATS_SPEED, mapline_s::distance, aircraft_s::fuel, GEO_CheckPositionBoundaries(), int(), mapline_s::numPoints, mapline_s::point, aircraft_s::point, aircraft_s::pos, aircraft_s::projectedPos, aircraft_s::route, SECONDS_PER_HOUR, aircraft_s::stats, aircraft_s::time, and VectorSet.
Referenced by AIR_Move(), and UFO_CampaignRunUFOs().
Some of the aircraft values needs special calculations when they are shown in the menus.
Definition at line 428 of file cp_aircraft.cpp.
References AIR_STATS_FUELSIZE, AIR_STATS_MAXSPEED, AIR_STATS_SPEED, f, and int().
Referenced by AIR_AircraftSelect(), GEO_GetAircraftText(), GEO_GetUFOText(), UP_AircraftDescription(), and UP_AircraftItemDescription().
void AIR_AircraftReturnToBase | ( | aircraft_t * | aircraft | ) |
Calculates the way back to homebase for given aircraft and returns it.
[in] | aircraft | Pointer to aircraft, which should return to base. |
Definition at line 515 of file cp_aircraft.cpp.
References AIR_IsAircraftOnGeoscape(), AIR_RETURNING, aircraft_s::aircraftTarget, GEO_CalcLine(), aircraft_s::homebase, aircraft_s::mission, aircraft_s::point, base_s::pos, aircraft_s::pos, aircraft_s::route, aircraft_s::status, and aircraft_s::time.
Referenced by AIM_AircraftReturnToBase_f(), AIR_AircraftsNotifyMissionRemoved(), AIR_AircraftsNotifyUFORemoved(), AIR_AircraftsUFODisappear(), AIR_CampaignRun(), AIR_MoveAircraftIntoNewHomebase(), AIR_PostLoadInitMissions(), AIR_SendAircraftPursuingUFO(), AIRFIGHT_ExecuteActions(), AIRFIGHT_RemoveProjectileAimingAircraft(), and CP_MissionEndActions().
Notify aircraft that a mission has been removed.
[in] | mission | Pointer to the mission that has been removed. |
Definition at line 1595 of file cp_aircraft.cpp.
References AIR_AircraftReturnToBase(), and AIR_Foreach.
Referenced by CP_MissionRemoveFromGeoscape().
void AIR_AircraftsNotifyUFORemoved | ( | const aircraft_t *const | ufo, |
bool | destroyed | ||
) |
Notify that a UFO has been removed.
[in] | ufo | Pointer to UFO that has been removed. |
[in] | destroyed | True if the UFO has been destroyed, false if it only landed. |
Definition at line 1608 of file cp_aircraft.cpp.
References AIR_AircraftReturnToBase(), AIR_Foreach, aircraft_s::aircraftTarget, B_GetNext(), base_s::batteries, i, base_s::lasers, base_s::numBatteries, base_s::numLasers, and baseWeapon_s::target.
Referenced by CP_UFORemoveFromGeoscape().
const char* AIR_AircraftStatusToName | ( | const aircraft_t * | aircraft | ) |
Translates the aircraft status id to a translatable string.
[in] | aircraft | Aircraft to translate the status of |
Definition at line 327 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_s::homebase, base_s::name, aircraft_s::status, and va().
Referenced by AIR_AircraftFillList_f(), AIR_ShowAircraft_f(), CL_DisplayPopupInterceptMission(), CL_DisplayPopupInterceptUFO(), and GEO_GetAircraftText().
void AIR_AircraftsUFODisappear | ( | const aircraft_t *const | ufo | ) |
Notify that a UFO disappear from radars.
[in] | ufo | Pointer to a UFO that has disappeared. |
Definition at line 1650 of file cp_aircraft.cpp.
References AIR_AircraftReturnToBase(), AIR_Foreach, AIR_UFO, and aircraft_s::aircraftTarget.
Referenced by UFO_CampaignCheckEvents().
void AIR_AssignInitial | ( | aircraft_t * | aircraft | ) |
Assigns initial team of soldiers to aircraft.
[in,out] | aircraft | soldiers to add to |
Definition at line 2869 of file cp_aircraft.cpp.
References AIR_AddEmployee(), cgi, count, E_Foreach, EMPL_SOLDIER, aircraft_s::homebase, and aircraft_s::maxTeamSize.
Referenced by B_SetUpFirstBase().
Adds the pilot to the first available aircraft at the specified base.
[in] | base | Which base has aircraft to add the pilot to. |
[in] | pilot | Which pilot to add. |
Definition at line 2053 of file cp_aircraft.cpp.
References AIR_ForeachFromBase, and AIR_SetPilot().
Referenced by E_HireEmployee(), and TR_EmptyTransferCargo().
Returns the number of aircraft on the given base.
[in] | base | The base to check |
Definition at line 74 of file cp_aircraft.cpp.
References AIR_ForeachFromBase, and count.
Referenced by TEST_F().
bool AIR_BaseHasAircraft | ( | const base_t * | base | ) |
Checks whether there is any aircraft assigned to the given base.
[in] | base | The base to check |
true
if there is at least one aircraft, false
otherwise (or when the base
pointer is nullptr
) Definition at line 65 of file cp_aircraft.cpp.
References AIR_GetFirstFromBase().
Referenced by AIR_AircraftSelect(), AIR_DeleteAircraft(), B_BaseInit_f(), and B_BuildingOpenAfterClick_f().
void AIR_CampaignRun | ( | const campaign_t * | campaign, |
int | dt, | ||
bool | updateRadarOverlay | ||
) |
Handles aircraft movement and actions in geoscape mode.
[in] | campaign | The campaign data structure |
[in] | dt | time delta (may be 0 if radar overlay should be updated but no aircraft moves) |
[in] | updateRadarOverlay | True if radar overlay should be updated (not needed if geoscape isn't updated) |
Definition at line 1071 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_s::ammoLeft, aircraftSlot_s::delayNextShot, GEO_IsRadarOverlayActivated(), MS_AddNewMessage(), RADAR_UpdateWholeRadarOverlay(), and va().
Referenced by CP_CampaignFunctionPeriodicCall().
bool AIR_CanIntercept | ( | const aircraft_t * | aircraft | ) |
aircraft | The aircraft to check |
true
if the given aircraft can go on interceptions Definition at line 2646 of file cp_aircraft.cpp.
References AIR_CRASHED, AIR_GetPilot(), AIR_NONE, B_GetBuildingStatus(), B_GetBuildingTemplateSilent(), aircraft_s::building, building_s::buildingType, aircraft_s::homebase, and aircraft_s::status.
Referenced by CL_DisplayPopupInterceptMission(), and CL_DisplayPopupInterceptUFO().
const char* AIR_CheckMoveIntoNewHomebase | ( | const aircraft_t * | aircraft, |
const base_t * | base | ||
) |
Checks if destination base can store an aircraft and its team.
[in] | aircraft | Pointer to the aircraft to check |
[in] | base | Pointer to the base to store aircraft |
Definition at line 731 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_s::maxTeamSize, and base_s::pos.
Referenced by B_MoveAircraftOnGeoscapeToOtherBases(), CL_DisplayHomebasePopup(), and CL_PopupChangeHomebase_f().
|
static |
resets aircraftSlots' backreference pointers for aircraft
[in] | aircraft | Pointer to the aircraft |
Definition at line 2503 of file cp_aircraft.cpp.
References aircraftSlot_s::aircraft, aircraftSlot_s::base, aircraft_s::electronics, i, aircraftSlot_s::installation, aircraft_s::maxElectronics, aircraft_s::maxWeapons, aircraft_s::shield, and aircraft_s::weapons.
Referenced by AIR_LoadXML().
int AIR_CountInBaseByTemplate | ( | const base_t * | base, |
const aircraft_t * | aircraftTemplate | ||
) |
Calculates the amount of aircraft (of the given type) in the selected base.
[in] | base | The base to count the aircraft in |
[in] | aircraftTemplate | The type of the aircraft you want |
Definition at line 412 of file cp_aircraft.cpp.
References AIR_ForeachFromBase, and count.
Referenced by PR_UpdateProductionList().
bool AIR_Delete | ( | base_t * | base, |
aircraft_t * | aircraft | ||
) |
Will remove the given aircraft from the base.
[out] | base | The base to remove the aircraft from |
aircraft | The aircraft to remove |
true
if the aircraft was removed, false
otherwise Definition at line 621 of file cp_aircraft.cpp.
References AIR_CRASHED, AIR_GetHangarCapacityType(), ccs_s::aircraft, aircraft_s::alienCargo, CAP_AddCurrent(), ccs, cgi, MAX_CAP, and aircraft_s::status.
Referenced by AIR_DeleteAircraft(), and CP_ResetCampaignData().
void AIR_DeleteAircraft | ( | aircraft_t * | aircraft | ) |
Removes an aircraft from its base and the game.
[in] | aircraft | Pointer to aircraft that should be removed. |
Definition at line 836 of file cp_aircraft.cpp.
References AII_RemoveItemFromSlot(), AIR_BaseHasAircraft(), AIR_Delete(), AIR_GetFirstFromBase(), AIR_IsAircraftOnGeoscape(), AIR_RemoveEmployees(), base_s::aircraftCurrent, cgi, cgame_import_s::Cvar_Set(), aircraft_s::electronics, GEO_NotifyAircraftRemoved(), aircraft_s::homebase, i, base_s::idx, MAX_AIRCRAFTSLOT, RADAR_UpdateWholeRadarOverlay(), aircraft_s::shield, TR_NotifyAircraftRemoved(), and aircraft_s::weapons.
Referenced by AIR_DestroyAircraft(), B_Destroy(), BS_SellAircraft(), TEST_F(), and TR_EmptyTransferCargo().
void AIR_DestroyAircraft | ( | aircraft_t * | aircraft, |
bool | killPilot | ||
) |
Removes an aircraft from its base and the game.
[in] | aircraft | Pointer to aircraft that should be removed. |
[in] | killPilot | Should pilot be removed from game or not? |
Definition at line 888 of file cp_aircraft.cpp.
References aircraft_s::acTeam, AIR_CRASHED, AIR_DeleteAircraft(), AIR_GetPilot(), AIR_SetPilot(), cgi, Employee::chr, E_DeleteEmployee(), E_RemoveInventoryFromStorage(), ERR_DROP, aircraft_s::id, LIST_Foreach, character_s::name, aircraft_s::status, and character_s::ucn.
Referenced by AIRFIGHT_ActionsAfterAirfight(), B_MoveAircraftOnGeoscapeToOtherBases(), CP_EndRescueMission(), and CP_SpawnRescueMission().
const aircraft_t* AIR_GetAircraft | ( | const char * | name | ) |
Searches the global array of aircraft types for a given aircraft.
[in] | name | Aircraft id. |
Definition at line 571 of file cp_aircraft.cpp.
References AIR_GetAircraftSilent(), cgi, ERR_DROP, and Q_strnull().
Referenced by AIR_LoadAircraftXML(), B_SetUpFirstBase(), BS_InitMarket(), CP_CampaignRunMarket(), PR_LoadXML(), RS_AssignTechLinks(), TEST_F(), UP_AircraftDescription(), UR_DialogInitSell_f(), and US_LoadXML().
aircraft_t* AIR_GetAircraftFromBaseByIDXSafe | ( | const base_t * | base, |
int | index | ||
) |
base | The base to get the aircraft from |
index | The index of the aircraft in the given base |
nullptr
if there is no such aircraft in the given base, or the aircraft pointer that belongs to the given index. Definition at line 534 of file cp_aircraft.cpp.
References AIR_ForeachFromBase, and i.
Referenced by AIM_SelectAircraft_f().
const aircraft_t* AIR_GetAircraftSilent | ( | const char * | name | ) |
Searches the global array of aircraft types for a given aircraft.
[in] | name | Aircraft id. |
Definition at line 554 of file cp_aircraft.cpp.
References ccs_s::aircraftTemplates, ccs, i, aircraft_s::id, ccs_s::numAircraftTemplates, 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().
int AIR_GetAircraftWeaponRanges | ( | const aircraftSlot_t * | slot, |
int | maxSlot, | ||
float * | weaponRanges | ||
) |
Get the all the unique weapon ranges of this aircraft.
[in] | slot | Pointer to the aircrafts weapon slot list. |
[in] | maxSlot | maximum number of weapon slots in aircraft. |
[out] | weaponRanges | An array containing a unique list of weapons ranges. |
Definition at line 2084 of file cp_aircraft.cpp.
References AIR_STATS_WRANGE, aircraftSlot_s::ammo, objDef_s::craftitem, MAX_AIRCRAFTSLOT, Q_FloatSort(), and craftitem_s::stats.
|
inlinestatic |
derivative of the funtion we need to find roots.
[in] | c | angle SOT |
[in] | B | angle STI |
[in] | speedRatio | ratio of speed of shooter divided by speed of target. |
[in] | a | angle TOI |
Definition at line 1684 of file cp_aircraft.cpp.
Referenced by AIR_GetDestinationFindRoot().
|
static |
Find the roots of a function.
[in] | c | angle SOT |
[in] | B | angle STI |
[in] | speedRatio | ratio of speed of shooter divided by speed of target. |
[in] | start | minimum value of the root to find |
< 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 1700 of file cp_aircraft.cpp.
References AIR_GetDestinationDerivativeFunction(), AIR_GetDestinationFunction(), cgi, DEBUG_CLIENT, ERR_DROP, and M_PI.
Referenced by AIR_GetDestinationWhilePursuing().
|
inlinestatic |
funtion we need to find roots.
[in] | c | angle SOT |
[in] | B | angle STI |
[in] | speedRatio | ratio of speed of shooter divided by speed of target. |
[in] | a | angle TOI |
Definition at line 1668 of file cp_aircraft.cpp.
References f.
Referenced by AIR_GetDestinationFindRoot().
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.
[in] | shooter | Pointer to shooting aircraft. |
[in] | target | Pointer to target aircraft. |
[out] | dest | Destination that shooting aircraft should aim to intercept target aircraft. |
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.)
Definition at line 1805 of file cp_aircraft.cpp.
References AIR_GetDestinationFindRoot(), AIR_STATS_SPEED, cgi, CrossProduct(), DEBUG_CLIENT, DotProduct, f, GetDistanceOnGlobe(), mapline_s::numPoints, mapline_s::point, PolarToVec(), aircraft_s::pos, RotatePointAroundVector(), aircraft_s::route, aircraft_s::stats, todeg, torad, VecToPolar(), Vector2Copy, and VectorNormalize().
Referenced by AIR_SendAircraftPursuingUFO(), UFO_SearchAircraftTarget(), and UFO_SendPursuingAircraft().
aircraft_t* AIR_GetFirstFromBase | ( | const base_t * | b | ) |
Iterates through the aircraft of a base.
[in] | b | The base to get the craft from |
Definition at line 50 of file cp_aircraft.cpp.
References AIR_ForeachFromBase.
Referenced by AIR_BaseHasAircraft(), AIR_DeleteAircraft(), AIR_MoveAircraftIntoNewHomebase(), B_SetCurrentSelectedBase(), CP_BaseAttackMissionIsFailure(), CP_SpawnRescueMission(), TEST_F(), and TR_TransferStart().
baseCapacities_t AIR_GetHangarCapacityType | ( | const aircraft_t * | aircraft | ) |
Returns capacity type needed for an aircraft.
[in] | aircraft | Aircraft to check |
Definition at line 688 of file cp_aircraft.cpp.
References B_GetBuildingTemplateSilent(), B_GetCapacityFromBuildingType(), aircraft_s::building, building_s::buildingType, and MAX_CAP.
Referenced by AIR_Add(), AIR_CheckMoveIntoNewHomebase(), AIR_Delete(), AIR_MoveAircraftIntoNewHomebase(), B_SetUpFirstBase(), BS_Buy_f(), CP_SpawnRescueMission(), PR_ProductionIncrease_f(), TR_CountAircraftInList(), TR_TransferStart(), and UP_AircraftDescription().
int AIR_GetOperationRange | ( | const aircraft_t * | aircraft | ) |
Calculates the range an aircraft can fly on the geoscape.
aircraft | The aircraft to calculate the range for |
Definition at line 447 of file cp_aircraft.cpp.
References AIR_STATS_FUELSIZE, AIR_STATS_SPEED, f, int(), KILOMETER_PER_DEGREE, SECONDS_PER_HOUR, and aircraft_s::stats.
Referenced by AIR_AircraftSelect(), and UP_AircraftDescription().
Employee* AIR_GetPilot | ( | const aircraft_t * | aircraft | ) |
Get pilot of an aircraft.
[in] | aircraft | Pointer to the aircraft |
nullptr
if there is no pilot assigned to this craft, the employee pointer otherwise Definition at line 2007 of file cp_aircraft.cpp.
References Employee::chr, E_GetEmployeeByTypeFromChrUCN(), Employee::getType(), aircraft_s::pilot, and character_s::ucn.
Referenced by AIM_AircraftStart_f(), AIM_PilotAssignedAircraft(), AIR_CanIntercept(), AIR_CheckMoveIntoNewHomebase(), AIR_DestroyAircraft(), AIR_IsEmployeeInAircraft(), AIR_MoveAircraftIntoNewHomebase(), AIR_RemoveEmployee(), AIR_RemovePilotFromAssignedAircraft(), AIR_SaveAircraftXML(), CP_SpawnRescueMission(), CP_TEAM_FillEmployeeList_f(), and CP_UpdateActorAircraftVar().
int AIR_GetRemainingRange | ( | const aircraft_t * | aircraft | ) |
Calculates the remaining range the aircraft can fly.
aircraft | The aircraft to calculate the remaining range for |
Definition at line 459 of file cp_aircraft.cpp.
References AIR_STATS_SPEED, aircraft_s::fuel, and aircraft_s::stats.
Referenced by AIR_AircraftHasEnoughFuel(), and AIR_AircraftHasEnoughFuelOneWay().
|
static |
Calculate used storage room corresponding to items in an aircraft.
[in] | aircraft | Pointer to the aircraft. |
Definition at line 704 of file cp_aircraft.cpp.
References aircraft_s::acTeam, Item::ammoDef(), Item::def(), Container::getNextItem(), LIST_Foreach, and objDef_s::size.
Referenced by AIR_CheckMoveIntoNewHomebase().
int AIR_GetTeamSize | ( | const aircraft_t * | aircraft | ) |
Counts the number of soldiers in given aircraft.
[in] | aircraft | Pointer to the aircraft, for which we return the amount of soldiers. |
Definition at line 1978 of file cp_aircraft.cpp.
References aircraft_s::acTeam, and cgi.
Referenced by AIR_AddEmployee(), AIR_AddToAircraftTeam(), AIR_AircraftFillList_f(), AIR_CheckMoveIntoNewHomebase(), AIR_GeoSelectAircraft_f(), AIR_LoadAircraftXML(), AIR_MoveEmployeeInventoryIntoStorage(), AIR_RemoveEmployees(), AIR_SendAircraftToMission(), BS_SellAircraft(), CL_DisplayPopupInterceptMission(), CL_DisplayPopupInterceptUFO(), CP_StartSelectedMission(), CP_TEAM_AssignSoldierByUCN_f(), CP_TEAM_FillBDEFEmployeeList_f(), CP_TEAM_FillEmployeeList_f(), CP_UpdateActorAircraftVar(), GEO_GetAircraftText(), and TEST_F().
Init actions for aircraft-subsystem.
Definition at line 2905 of file cp_aircraft.cpp.
References AIR_InitCallbacks(), and cgi.
Referenced by CP_InitStartup().
bool AIR_IsAircraftInBase | ( | const aircraft_t * | aircraft | ) |
Checks whether given aircraft is in its homebase.
[in] | aircraft | Pointer to an aircraft. |
Definition at line 371 of file cp_aircraft.cpp.
References AIR_HOME, AIR_REFUEL, and aircraft_s::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().
bool AIR_IsAircraftOnGeoscape | ( | const aircraft_t * | aircraft | ) |
Checks whether given aircraft is on geoscape.
[in] | aircraft | Pointer to an aircraft. |
false
if given aircraft is not on geoscape, true
if given aircraft is on geoscape. Definition at line 385 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_s::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().
const aircraft_t* AIR_IsEmployeeInAircraft | ( | const Employee * | employee, |
const aircraft_t * | aircraft | ||
) |
Tells you if an employee is assigned to an aircraft.
[in] | employee | The employee to search for. |
[in] | aircraft | The aircraft to search the employee in. Use nullptr to check if the soldier is in any aircraft. |
Definition at line 2759 of file cp_aircraft.cpp.
References AIR_Foreach, AIR_GetPilot(), AIR_IsInAircraftTeam(), Employee::isPilot(), and Employee::transfer.
Referenced by AIR_AddEmployee(), 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().
bool AIR_IsInAircraftTeam | ( | const aircraft_t * | aircraft, |
const Employee * | employee | ||
) |
Checks whether given employee is in given aircraft.
[in] | aircraft | The aircraft to check |
[in] | employee | Employee to check. |
true
if the given employee is assigned to the given aircraft. Definition at line 1966 of file cp_aircraft.cpp.
References aircraft_s::acTeam, cgi, and cgame_import_s::LIST_GetPointer().
Referenced by AIR_IsEmployeeInAircraft().
|
static |
Loads the weapon slots of an aircraft.
[in] | aircraft | Pointer to the aircraft. |
[out] | slot | Pointer to the slot where item should be added. |
[in] | p | XML Node structure, where we get the information from |
[in] | weapon | True if the slot is a weapon slot. |
[in] | max | Maximum number of slots for this aircraft that should be loaded. |
Definition at line 2309 of file cp_aircraft.cpp.
References AII_LoadOneSlotXML(), aircraftSlot_s::aircraft, cgi, i, SAVE_AIRCRAFT_SLOT, cgame_import_s::XML_GetNextNode(), cgame_import_s::XML_GetNode(), and xmlNode_t.
Referenced by AIR_LoadAircraftXML().
|
static |
Loads an Aircraft from the savegame.
[in] | p | XML Node structure, where we get the information from |
[out] | craft | Pointer to the aircraft |
Definition at line 2354 of file cp_aircraft.cpp.
References _, aircraft_s::acTeam, AIR_AircraftGetFromIDX(), AIR_GetAircraft(), AIR_GetTeamSize(), AIR_LoadAircraftSlotsXML(), AIR_LoadRouteXML(), AIR_SetPilot(), AIR_STATS_DAMAGE, aircraft_s::aircraftTarget, aircraft_s::alienCargo, B_GetBaseByIDX(), ccs, cgi, cp_campaignPool, aircraft_s::damage, date_s::day, aircraft_s::defaultName, aircraft_s::detected, aircraft_s::detectionIdx, aircraft_s::direction, E_GetEmployeeFromChrUCN(), aircraft_s::electronics, ERR_DROP, aircraft_s::fuel, aircraft_s::homebase, aircraft_s::id, aircraft_s::idx, aircraft_s::itemCargo, aircraft_s::landed, aircraft_s::lastSpotted, AlienCargo::load(), ItemCargo::load(), MAX_BASES, aircraft_s::maxElectronics, aircraft_s::maxTeamSize, aircraft_s::maxWeapons, aircraft_s::missionID, aircraft_s::name, aircraft_s::point, cgame_import_s::PoolStrDup(), aircraft_s::pos, Q_strncpyz(), aircraft_s::radar, RADAR_Initialise(), RADAR_InitialiseUFOs(), radar_s::range, aircraft_s::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, date_s::sec, aircraft_s::shield, aircraft_s::stats, aircraft_s::status, aircraft_s::time, radar_s::trackingRange, radar_s::ufoDetectionProbability, ccs_s::ufos, aircraft_s::weapons, cgame_import_s::XML_GetDate(), cgame_import_s::XML_GetNextNode(), cgame_import_s::XML_GetNode(), cgame_import_s::XML_GetPos3(), cgame_import_s::XML_GetString(), and xmlNode_t.
Referenced by AIR_LoadXML().
Loads the route of an aircraft.
[in] | p | XML Node structure, where we get the information from |
[out] | route | Route points of the aircraft |
Definition at line 2327 of file cp_aircraft.cpp.
References cgi, count, mapline_s::distance, LINE_MAXPTS, mapline_s::numPoints, mapline_s::point, SAVE_AIRCRAFT_ROUTE, SAVE_AIRCRAFT_ROUTE_DISTANCE, SAVE_AIRCRAFT_ROUTE_POINT, cgame_import_s::XML_GetNextPos2(), cgame_import_s::XML_GetNode(), cgame_import_s::XML_GetPos2(), and xmlNode_t.
Referenced by AIR_LoadAircraftXML().
bool AIR_LoadXML | ( | xmlNode_t * | parent | ) |
Definition at line 2524 of file cp_aircraft.cpp.
References AIR_Add(), AIR_CorrectAircraftSlotPointers(), AIR_LoadAircraftXML(), AIR_STATS_SPEED, AIRFIGHT_LoadXML(), ccs, cgi, aircraft_s::homebase, i, MAX_UFOONGEOSCAPE, ccs_s::numUFOs, SAVE_AIRCRAFT_AIRCRAFT, SAVE_AIRCRAFT_PHALANX, SAVE_AIRCRAFT_PROJECTILES, SAVE_AIRCRAFT_UFOS, aircraft_s::stats, aircraft_s::time, UFO_GetByIDX(), UFO_RemoveFromGeoscape(), cgame_import_s::XML_GetNextNode(), cgame_import_s::XML_GetNode(), and xmlNode_t.
Referenced by SAV_Init().
|
static |
Definition at line 970 of file cp_aircraft.cpp.
References _, mission_s::active, AIR_AircraftMakeMove(), AIR_DROP, AIR_IDLE, AIR_MISSION, AIR_REFUEL, AIR_RETURNING, AIR_TRANSFER, AIR_UFO, B_AircraftReturnedToHomeBase(), cgi, Com_sprintf(), CP_GameTimeStop(), cp_messageBuffer, GEO_CheckPositionBoundaries(), GEO_SelectMission(), GEO_SetInterceptorAircraft, GEO_SetMissionAircraft, aircraft_s::homebase, lengthof, MIS_GetName(), aircraft_s::mission, MSO_CheckAddNewMessage(), base_s::name, aircraft_s::name, NT_AIRCRAFT_ARRIVEDHOME, mapline_s::numPoints, mapline_s::point, aircraft_s::pos, aircraft_s::route, aircraft_s::status, and Vector2Copy.
Referenced by AIR_CampaignRun().
void AIR_MoveAircraftIntoNewHomebase | ( | aircraft_t * | aircraft, |
base_t * | base | ||
) |
Moves a given aircraft to a new base (also the employees and inventory)
[in] | aircraft | The aircraft to move into a new base |
[in] | base | The base to move the aircraft into |
Definition at line 785 of file cp_aircraft.cpp.
References aircraft_s::acTeam, AIR_AircraftReturnToBase(), AIR_GetFirstFromBase(), AIR_GetHangarCapacityType(), AIR_GetPilot(), AIR_RETURNING, AIR_TransferItemsCarriedByCharacterToBase(), base_s::aircraftCurrent, CAP_AddCurrent(), cgi, DEBUG_CLIENT, E_MoveIntoNewBase(), GEO_SelectAircraft(), aircraft_s::homebase, aircraft_s::id, LIST_Foreach, base_s::name, and aircraft_s::status.
Referenced by B_MoveAircraftOnGeoscapeToOtherBases(), and CL_PopupChangeHomebase_f().
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.
[in] | aircraft | The craft with the team (and thus equipment) onboard. |
[out] | ed | The equipment definition which will receive all the stuff from the aircraft-team. |
Definition at line 2813 of file cp_aircraft.cpp.
References aircraft_s::acTeam, equipDef_s::addClip(), AIR_GetTeamSize(), Item::ammoDef(), cgi, DEBUG_CLIENT, Item::def(), Item::getAmmoLeft(), Item::getNext(), Container::getNextItem(), objDef_s::idx, objDef_s::isReloadable(), LIST_Foreach, equipDef_s::numItems, and type.
Referenced by B_InitialEquipment().
aircraft_t* AIR_NewAircraft | ( | base_t * | base, |
const aircraft_t * | aircraftTemplate | ||
) |
Places a new aircraft in the given base.
[in] | base | Pointer to base where aircraft should be added. |
[in] | aircraftTemplate | The aircraft template to create the new aircraft from. |
< set a unique index to this aircraft.
Definition at line 645 of file cp_aircraft.cpp.
References _, AII_SetAircraftInSlots(), AII_UpdateAircraftStats(), AIR_Add(), AIR_ResetAircraftTeam(), AIR_STATS_DAMAGE, base_s::aircraftCurrent, stats_s::aircraftHad, aircraft_s::building, ccs_s::campaignStats, ccs, cgi, Com_sprintf(), cp_messageBuffer, aircraft_s::damage, DEBUG_CLIENT, aircraft_s::defaultName, aircraft_s::direction, aircraft_s::homebase, aircraft_s::id, base_s::idx, aircraft_s::idx, lengthof, MS_AddNewMessage(), base_s::name, aircraft_s::name, base_s::pos, aircraft_s::pos, Q_strncpyz(), aircraft_s::radar, RADAR_Initialise(), radar_s::range, aircraft_s::stats, aircraft_s::tpl, radar_s::trackingRange, radar_s::ufoDetectionProbability, Vector2Copy, and VectorSet.
Referenced by B_SetUpFirstBase(), BS_BuyAircraft(), PR_FinishProduction(), and TEST_F().
void AIR_ParseAircraft | ( | const char * | name, |
const char ** | text, | ||
bool | assignAircraftItems | ||
) |
Parses all aircraft that are defined in our UFO-scripts.
Definition at line 1275 of file cp_aircraft.cpp.
References AC_ITEM_ELECTRONICS, AC_ITEM_WEAPON, AII_InitialiseAircraftSlots(), AIR_GetAircraftSilent(), AIR_HOME, AIR_POSITIONS_MAX, AIR_STATS_FUELSIZE, AIR_STATS_SPEED, ccs_s::aircraftTemplates, aircraftSlot_s::ammo, aircraft_s::building, ccs, cgi, cgame_import_s::Com_EParse(), Com_Parse(), Com_SkipBlock(), cp_campaignPool, DEBUG_CLIENT, aircraft_s::electronics, ERR_DROP, f, i, aircraft_s::id, int(), INVSH_GetItemByID(), aircraftSlot_s::item, ITEM_HEAVY, ITEM_LIGHT, ITEM_MEDIUM, MAX_ACITEMS, MAX_AIRCRAFT, aircraft_s::maxElectronics, aircraft_s::maxWeapons, MEMBER_SIZEOF, aircraft_s::name, ccs_s::numAircraftTemplates, OBJZERO, cgame_import_s::PoolStrDup(), aircraftSlot_s::pos, aircraft_s::price, aircraft_s::productionCost, technology_s::provides, Q_streq, Q_strncpyz(), aircraft_s::radar, RADAR_InitialiseUFOs(), RS_GetTechByID(), SECONDS_PER_HOUR, aircraft_s::setUfoType(), aircraft_s::shield, aircraftSlot_s::size, aircraft_s::stats, aircraft_s::status, Sys_Error(), aircraft_s::tpl, UFO_NONE, radar_s::ufoDetectionProbability, V_INT, and aircraft_s::weapons.
Referenced by CP_ParseScriptFirst(), and CP_ParseScriptSecond().
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)
[in] | aircraft | Pointer to crashed aircraft |
Definition at line 2022 of file cp_aircraft.cpp.
References cgi, Employee::chr, crand(), cgame_import_s::csi, f, GEO_GetColor(), TerrainDefs::getSurvivalChance(), MAPTYPE_TERRAIN, aircraft_s::pilot, aircraft_s::pos, character_s::score, SKILL_PILOTING, chrScoreGlobal_s::skills, and csi_s::terrainDefs.
Referenced by AIRFIGHT_ActionsAfterAirfight(), and CP_SpawnRescueMission().
bool AIR_PostLoadInit | ( | void | ) |
Actions needs to be done after loading the savegame.
Definition at line 2627 of file cp_aircraft.cpp.
References AIR_PostLoadInitMissions().
Referenced by SAV_GameActionsAfterLoad().
|
static |
Set the mission pointers for all the aircraft after loading a savegame.
Definition at line 2572 of file cp_aircraft.cpp.
References AIR_AircraftReturnToBase(), AIR_DROP, AIR_Foreach, AIR_IDLE, AIR_MISSION, cgi, CP_GetMissionByID(), aircraft_s::idx, aircraft_s::mission, aircraft_s::missionID, aircraft_s::name, Q_strnull(), mission_s::ufo, UFO_GetNext(), and UFO_RemoveFromGeoscape().
Referenced by AIR_PostLoadInit().
|
static |
Definition at line 1013 of file cp_aircraft.cpp.
References _, AIR_CANNOT_REFUEL, AIR_HOME, AIR_STATS_ANTIMATTER, AIR_STATS_FUELSIZE, AIRCRAFT_REFUEL_FACTOR, ANTIMATTER_ITEM_ID, B_AddAntimatter(), B_ItemInBase(), Com_sprintf(), cp_messageBuffer, aircraft_s::fuel, aircraft_s::homebase, INVSH_GetItemByID(), lengthof, MSO_CheckAddNewMessage(), base_s::name, aircraft_s::name, aircraft_s::notifySent, NT_AIRCRAFT_CANNOTREFUEL, NT_AIRCRAFT_REFUELED, aircraft_s::stats, and aircraft_s::status.
Referenced by AIR_CampaignRun().
bool AIR_RemoveEmployee | ( | Employee * | employee, |
aircraft_t * | aircraft | ||
) |
Removes a soldier from an aircraft.
[in,out] | employee | The soldier to be removed from the aircraft. |
[in,out] | aircraft | The aircraft to remove the soldier from. Use nullptr to remove the soldier from any aircraft. |
Definition at line 2720 of file cp_aircraft.cpp.
References aircraft_s::acTeam, AIR_Foreach, AIR_GetPilot(), AIR_IsEmployeeInAircraft(), AIR_SetPilot(), cgi, Employee::chr, DEBUG_CLIENT, EMPL_PILOT, Employee::getType(), aircraft_s::homebase, base_s::idx, aircraft_s::idx, and character_s::ucn.
Referenced by AIR_RemoveEmployees(), CP_EndRescueMission(), CP_TEAM_AssignSoldierByUCN_f(), TR_TransferStart(), and Employee::unassign().
void AIR_RemoveEmployees | ( | aircraft_t & | aircraft | ) |
Removes all soldiers from an aircraft.
[in,out] | aircraft | The aircraft to remove the soldiers from. |
Definition at line 2793 of file cp_aircraft.cpp.
References aircraft_s::acTeam, AIR_GetTeamSize(), AIR_RemoveEmployee(), AIR_SetPilot(), cgi, ERR_DROP, and LIST_Foreach.
Referenced by AIR_DeleteAircraft(), and BS_Buy_f().
Checks to see if the pilot is in any aircraft at this base. If he is then he is removed from that aircraft.
[in] | base | Which base has the aircraft to search for the employee in. |
[in] | pilot | Which pilot to search for. |
Definition at line 2067 of file cp_aircraft.cpp.
References AIR_ForeachFromBase, AIR_GetPilot(), and AIR_SetPilot().
Referenced by Employee::unassign().
void AIR_ResetAircraftTeam | ( | aircraft_t * | aircraft | ) |
Resets team in given aircraft.
[in] | aircraft | Pointer to an aircraft, where the team will be reset. |
Definition at line 1933 of file cp_aircraft.cpp.
References aircraft_s::acTeam, and cgi.
Referenced by AIR_NewAircraft(), and AIR_Shutdown().
|
static |
Saves an item slot.
[in] | slot | Pointer to the slot where item is. |
[in] | num | Number of slots for this aircraft. |
[out] | p | XML Node structure, where we write the information to |
[in] | p | pointer where information are written. |
[in] | weapon | True if the slot is a weapon slot. |
Definition at line 2145 of file cp_aircraft.cpp.
References AII_SaveOneSlotXML(), cgi, SAVE_AIRCRAFT_SLOT, cgame_import_s::XML_AddNode(), and xmlNode_t.
Referenced by AIR_SaveAircraftXML().
|
static |
Saves an aircraft.
[out] | p | XML Node structure, where we write the information to |
[in] | aircraft | Aircraft we save |
[in] | isUfo | If this aircraft is a UFO |
detection id and time
Definition at line 2159 of file cp_aircraft.cpp.
References aircraft_s::acTeam, AIR_DROP, AIR_GetPilot(), AIR_MISSION, AIR_SaveAircraftSlotsXML(), AIR_SaveRouteXML(), AIR_STATS_DAMAGE, AIR_STATS_MAX, aircraft_s::aircraftTarget, aircraft_s::alienCargo, cgi, Employee::chr, cgame_import_s::Com_GetConstVariable(), aircraft_s::damage, date_s::day, aircraft_s::detected, aircraft_s::detectionIdx, aircraft_s::direction, aircraft_s::electronics, aircraft_s::fuel, aircraft_s::homebase, mission_s::id, aircraft_s::id, base_s::idx, aircraft_s::idx, aircraft_s::itemCargo, aircraft_s::landed, aircraft_s::lastSpotted, LIST_Foreach, aircraft_s::maxElectronics, aircraft_s::maxWeapons, aircraft_s::mission, aircraft_s::name, aircraft_s::point, aircraft_s::pos, aircraft_s::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, date_s::sec, aircraft_s::shield, aircraft_s::stats, aircraft_s::status, aircraft_s::time, character_s::ucn, UFO_GetGeoscapeIDX, aircraft_s::weapons, cgame_import_s::XML_AddNode(), and xmlNode_t.
Referenced by AIR_SaveXML().
Saves an route plan of an aircraft.
[out] | node | XML Node structure, where we write the information to |
[in] | route | Aircraft route plan |
Definition at line 2126 of file cp_aircraft.cpp.
References cgi, mapline_s::distance, mapline_s::numPoints, mapline_s::point, SAVE_AIRCRAFT_ROUTE, SAVE_AIRCRAFT_ROUTE_DISTANCE, SAVE_AIRCRAFT_ROUTE_POINT, cgame_import_s::XML_AddNode(), and xmlNode_t.
Referenced by AIR_SaveAircraftXML().
bool AIR_SaveXML | ( | xmlNode_t * | parent | ) |
Save callback for savegames in xml format.
Definition at line 2274 of file cp_aircraft.cpp.
References AIR_Foreach, AIR_SaveAircraftXML(), AIRFIGHT_SaveXML(), cgi, aircraft_s::id, MAX_UFOONGEOSCAPE, SAVE_AIRCRAFT_PHALANX, SAVE_AIRCRAFT_PROJECTILES, SAVE_AIRCRAFT_UFOS, UFO_GetByIDX(), cgame_import_s::XML_AddNode(), and xmlNode_t.
Referenced by SAV_Init().
bool AIR_ScriptSanityCheck | ( | void | ) |
Checks the parsed aircraft for errors.
Definition at line 2667 of file cp_aircraft.cpp.
References AII_GetItemWeightBySize(), AIR_IsUFO, ccs_s::aircraftTemplates, ccs, cgi, aircraft_s::defaultName, aircraft_s::electronics, i, aircraft_s::id, objDef_s::id, aircraftSlot_s::item, aircraft_s::maxElectronics, aircraft_s::maxWeapons, aircraft_s::name, ccs_s::numAircraftTemplates, aircraftSlot_s::pos, aircraftSlot_s::size, and aircraft_s::weapons.
bool AIR_SendAircraftPursuingUFO | ( | aircraft_t * | aircraft, |
aircraft_t * | ufo | ||
) |
Make the specified aircraft purchasing a UFO.
[in] | aircraft | Pointer to an aircraft which will hunt for a UFO. |
[in] | ufo | Pointer to a UFO. |
Definition at line 1890 of file cp_aircraft.cpp.
References _, AII_ReloadAircraftWeapons(), AIR_AircraftHasEnoughFuel(), AIR_AircraftReturnToBase(), AIR_GetDestinationWhilePursuing(), AIR_IsAircraftInBase(), AIR_UFO, aircraft_s::aircraftTarget, cgi, DEBUG_CLIENT, dest, GEO_CalcLine(), aircraft_s::homebase, MS_AddNewMessage(), base_s::name, aircraft_s::name, aircraft_s::point, aircraft_s::pos, aircraft_s::route, aircraft_s::status, aircraft_s::time, va(), and Vector2Copy.
Referenced by AIRFIGHT_ExecuteActions(), and CL_PopupInterceptClick_f().
bool AIR_SendAircraftToMission | ( | aircraft_t * | aircraft, |
mission_t * | mission | ||
) |
Sends the specified aircraft to specified mission.
[in] | aircraft | Pointer to aircraft to send to mission. |
[in] | mission | Pointer to given mission. |
Definition at line 1149 of file cp_aircraft.cpp.
References _, mission_s::active, AII_ReloadAircraftWeapons(), AIR_AircraftHasEnoughFuel(), AIR_GetTeamSize(), AIR_IsAircraftInBase(), AIR_MISSION, B_IsUnderAttack, cgi, CP_Popup(), GEO_CalcLine(), GEO_SetInterceptorAircraft, aircraft_s::homebase, aircraft_s::mission, MS_AddNewMessage(), aircraft_s::point, mission_s::pos, aircraft_s::pos, aircraft_s::route, aircraft_s::status, and aircraft_s::time.
Referenced by AIR_SendAircraftToMission_f(), and CL_PopupInterceptClick_f().
bool AIR_SetPilot | ( | aircraft_t * | aircraft, |
Employee * | pilot | ||
) |
Assign a pilot to an aircraft.
[out] | aircraft | Pointer to the aircraft to add pilot to |
[in] | pilot | Pointer to the pilot to add |
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 1992 of file cp_aircraft.cpp.
References aircraft_s::pilot.
Referenced by AIR_AutoAddPilotToAircraft(), AIR_DestroyAircraft(), AIR_LoadAircraftXML(), AIR_RemoveEmployee(), AIR_RemoveEmployees(), AIR_RemovePilotFromAssignedAircraft(), and CP_TEAM_AssignSoldierByUCN_f().
Closing actions for aircraft-subsystem.
Definition at line 2914 of file cp_aircraft.cpp.
References AIR_Foreach, AIR_ResetAircraftTeam(), AIR_ShutdownCallbacks(), ccs_s::aircraft, ccs, and cgi.
Referenced by CP_Shutdown().
|
static |
Transfer items carried by a soldier from one base to another.
[in] | chr | Pointer to the character. |
[in] | sourceBase | Base where employee comes from. |
[in] | destBase | Base where employee is going. |
Definition at line 761 of file cp_aircraft.cpp.
References Item::ammoDef(), B_AddToStorage(), Item::def(), Inventory::getNextCont(), Container::getNextItem(), and character_s::inv.
Referenced by AIR_MoveAircraftIntoNewHomebase().
CASSERT | ( | lengthof(air_slot_type_strings) | = =MAX_ACITEMS | ) |
|
static |
List of valid strings for itemPos_t.
itemPos_t
Definition at line 1209 of file cp_aircraft.cpp.
const char* const air_slot_type_strings[] = AIR_SLOT_TYPE_STRINGS |
Definition at line 1266 of file cp_aircraft.cpp.
|
static |
Valid aircraft parameter definitions from script files.
Definition at line 1223 of file cp_aircraft.cpp.
|
static |
Valid radar definition values for an aircraft from script files.
Definition at line 1258 of file cp_aircraft.cpp.
|
static |
Valid aircraft definition values from script files.
Definition at line 1236 of file cp_aircraft.cpp.
|
static |
Definition at line 2893 of file cp_aircraft.cpp.