cp_aircraft.h File Reference

Header file for aircraft stuff. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mapline_s
 A path on the map described by 2D points. More...
struct  aliensTmp_s
struct  aircraftSlot_s
 slot of aircraft More...
struct  itemsTmp_s
 A cargo of items collected after mission. More...
struct  aircraft_s
 An aircraft with all it's data. More...

Defines

#define MAX_CARGO   32
#define MAX_AIRCRAFT   64
#define LINE_MAXSEG   64
#define LINE_MAXPTS   (LINE_MAXSEG + 2)
#define LINE_DPHI   (M_PI / LINE_MAXSEG)
#define AIRCRAFT_INVALID   -1
#define AIRCRAFT_INBASE_INVALID   -1
#define AIRCRAFT_REFUEL_FACTOR   16
#define AIR_IsUFO(aircraft)   ((aircraft)->ufotype != UFO_MAX)
#define MAX_HUMAN_AIRCRAFT_TYPE   AIRCRAFT_INTERCEPTOR
#define MAX_AIRCRAFTITEMS   64
#define MAX_AIRCRAFTSLOT   4

Typedefs

typedef struct mapline_s mapline_t
 A path on the map described by 2D points.
typedef struct aliensTmp_s aliensTmp_t
typedef struct aircraftSlot_s aircraftSlot_t
 slot of aircraft
typedef struct itemsTmp_s itemsTmp_t
 A cargo of items collected after mission.
typedef enum aircraftStatus_s aircraftStatus_t
typedef struct aircraft_s aircraft_t
 An aircraft with all it's data.

Enumerations

enum  aircraftType_t { AIRCRAFT_TRANSPORTER, AIRCRAFT_INTERCEPTOR, AIRCRAFT_UFO }
 

All different types of aircraft.

More...
enum  aircraftSize_t { AIRCRAFT_SMALL = 1, AIRCRAFT_LARGE = 2 }
 

All different size of aircraft.

More...
enum  aircraftHangarType_t { AIRCRAFT_HANGAR_NONE = 0, AIRCRAFT_HANGAR_SMALL = 1, AIRCRAFT_HANGAR_BIG = 2, AIRCRAFT_HANGAR_ERROR }
 

All different Hangar size.

More...
enum  itemWeight_t { ITEM_LIGHT, ITEM_MEDIUM, ITEM_HEAVY }
 

different weight for aircraft items

More...
enum  itemPos_t {
  AIR_NOSE_LEFT, AIR_NOSE_CENTER, AIR_NOSE_RIGHT, AIR_WING_LEFT,
  AIR_WING_RIGHT, AIR_REAR_LEFT, AIR_REAR_CENTER, AIR_REAR_RIGHT,
  AIR_POSITIONS_MAX
}
 

different positions for aircraft items

More...
enum  aircraft_notifications_t { AIR_CANNOT_REFUEL, MAX_AIR_NOTIFICATIONS }
 

notification signals for aircraft events

More...
enum  aircraftStatus_s {
  AIR_NONE, AIR_REFUEL, AIR_HOME, AIR_IDLE,
  AIR_TRANSIT, AIR_MISSION, AIR_UFO, AIR_DROP,
  AIR_INTERCEPT, AIR_TRANSFER, AIR_CRASHED, AIR_RETURNING
}

Functions

aircraft_tAIR_Add (struct base_s *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.
qboolean AIR_Delete (struct base_s *base, const aircraft_t *aircraft)
 Will remove the given aircraft from the base.
aircraft_tAIR_GetNextFromBase (const struct base_s *base, aircraft_t *lastAircraft)
aircraft_tAIR_GetByIDX (int idx)
qboolean AIR_BaseHasAircraft (const struct base_s *base)
int AIR_GetAircraftIDXInBase (const aircraft_t *aircraft)
 Returns the index of the aircraft in the base->aircraft array.
aircraft_tAIR_GetAircraftFromBaseByIDXSafe (struct base_s *base, int index)
const char * AIR_AircraftStatusToName (const aircraft_t *aircraft)
 Translates the aircraft status id to a translatable string.
qboolean AIR_IsAircraftInBase (const aircraft_t *aircraft)
 Checks whether given aircraft is in its homebase.
qboolean AIR_IsAircraftOnGeoscape (const aircraft_t *aircraft)
 Checks whether given aircraft is on geoscape.
void AIR_DeleteAircraft (aircraft_t *aircraft)
 Removes an aircraft from its base and the game.
void AIR_DestroyAircraft (aircraft_t *aircraft)
 Removes an aircraft from its base and the game.
qboolean AIR_MoveAircraftIntoNewHomebase (aircraft_t *aircraft, struct base_s *base)
 Moves a given aircraft to a new base (also the employees and inventory).
void AIR_ResetAircraftTeam (aircraft_t *aircraft)
 Resets team in given aircraft.
qboolean AIR_AddToAircraftTeam (aircraft_t *aircraft, struct employee_s *employee)
 Adds given employee to given aircraft.
qboolean AIR_RemoveFromAircraftTeam (aircraft_t *aircraft, const struct employee_s *employee)
qboolean AIR_IsInAircraftTeam (const aircraft_t *aircraft, const struct employee_s *employee)
int AIR_GetTeamSize (const aircraft_t *aircraft)
 Counts the number of soldiers in given aircraft.
void CL_CampaignRunAircraft (int dt, qboolean updateRadarOverlay)
 Handles aircraft movement and actions in geoscape mode.
aircraft_tAIR_GetAircraftSilent (const char *name)
 Searches the global array of aircraft types for a given aircraft.
aircraft_tAIR_GetAircraft (const char *name)
 Searches the global array of aircraft types for a given aircraft.
aircraft_tAIR_AircraftGetFromIDX (int idx)
 Returns aircraft for a given global index.
qboolean AIR_AircraftMakeMove (int dt, aircraft_t *aircraft)
 Moves given aircraft.
void AIR_ParseAircraft (const char *name, const char **text, qboolean assignAircraftItems)
 Parses all aircraft that are defined in our UFO-scripts.
qboolean 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
qboolean AIR_AircraftHasEnoughFuelOneWay (const aircraft_t *aircraft, const vec2_t destination)
void AIR_AircraftReturnToBase (aircraft_t *aircraft)
 Calculates the way back to homebase for given aircraft and returns it.
qboolean AIR_SendAircraftToMission (aircraft_t *aircraft, struct mission_s *mission)
 Sends the specified aircraft to specified mission.
void AIR_GetDestinationWhilePursuing (const aircraft_t const *shooter, const aircraft_t const *target, vec2_t *dest)
 Calculates the point where aircraft should go to intecept a moving target.
qboolean AIR_SendAircraftPursuingUFO (aircraft_t *aircraft, aircraft_t *ufo)
 Make the specified aircraft purchasing a UFO.
void AIR_AircraftsNotifyUFORemoved (const aircraft_t *const ufo, qboolean destroyed)
 Notify that a UFO has been removed.
void AIR_AircraftsUFODisappear (const aircraft_t *const ufo)
 Notify that a UFO disappear from radars.
void AIR_UpdateHangarCapForAll (struct base_s *base)
 Updates current capacities for hangars in given base.
qboolean AIR_ScriptSanityCheck (void)
 Checks the parsed aircraft for errors.
int AIR_CalculateHangarStorage (const aircraft_t *aircraft, const struct base_s *base, int used) __attribute__((nonnull(1
int int CL_AircraftMenuStatsValues (const int value, const int stat)
 Some of the aircraft values needs special calculations when they are shown in the menus.
int AIR_CountTypeInBase (const struct base_s *base, aircraftType_t aircraftType)
const char * AIR_GetAircraftString (aircraftType_t aircraftType)
 Returns the string that matches the given aircraft type.
int AIR_GetAircraftWeaponRanges (const aircraftSlot_t *slot, int maxSlot, float *weaponRanges)
 Get the all the unique weapon ranges of this aircraft.
int AIR_GetCapacityByAircraftWeight (const aircraft_t *aircraft)
const char * AIR_CheckMoveIntoNewHomebase (const aircraft_t *aircraft, const struct base_s *base, const int capacity)
void AII_CollectItem (aircraft_t *aircraft, const objDef_t *item, int amount)
 Add an item to aircraft inventory.
void AII_CollectingItems (aircraft_t *aircraft, int won)
 Collect items from the battlefield.
void AIR_AutoAddPilotToAircraft (struct base_s *base, struct employee_s *pilot)
 Adds the pilot to the first available aircraft at the specified base.
void AIR_RemovePilotFromAssignedAircraft (struct base_s *base, const struct employee_s *pilot)
void AIR_RemoveEmployees (aircraft_t *aircraft)
 Removes all soldiers from an aircraft.
qboolean AIR_RemoveEmployee (struct employee_s *employee, aircraft_t *aircraft)
 Removes a soldier from an aircraft.
const aircraft_tAIR_IsEmployeeInAircraft (const struct employee_s *employee, const aircraft_t *aircraft)
void AIR_MoveEmployeeInventoryIntoStorage (const aircraft_t *aircraft, equipDef_t *equip)
 Move all the equipment carried by the team on the aircraft into the given equipment.
void AIM_AddEmployeeFromMenu (aircraft_t *aircraft, const int num)
 Adds or removes a soldier to/from an aircraft.
void AIR_AssignInitial (aircraft_t *aircraft)
 Assigns initial team of soldiers to aircraft.
qboolean AIR_CanIntercept (const aircraft_t *aircraft)
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.

Detailed Description

Header file for aircraft stuff.

Definition in file cp_aircraft.h.


Define Documentation

#define AIR_IsUFO ( aircraft   )     ((aircraft)->ufotype != UFO_MAX)
#define AIRCRAFT_INBASE_INVALID   -1

Invalid aircraft index in base-list of aircraft.

Definition at line 37 of file cp_aircraft.h.

Referenced by AIR_GetAircraftIDXInBase(), and B_LoadXML().

#define AIRCRAFT_INVALID   -1

Invalid aircraft index (global index).

Definition at line 35 of file cp_aircraft.h.

Referenced by AIRFIGHT_LoadXML().

#define AIRCRAFT_REFUEL_FACTOR   16

factor to speed up refuelling

Definition at line 40 of file cp_aircraft.h.

Referenced by AIR_Refuel().

#define LINE_DPHI   (M_PI / LINE_MAXSEG)

Definition at line 32 of file cp_aircraft.h.

#define LINE_MAXPTS   (LINE_MAXSEG + 2)
#define LINE_MAXSEG   64

Definition at line 30 of file cp_aircraft.h.

Referenced by MAP_MapCalcLine().

#define MAX_AIRCRAFT   64
#define MAX_AIRCRAFTITEMS   64

Definition at line 86 of file cp_aircraft.h.

#define MAX_AIRCRAFTSLOT   4
#define MAX_CARGO   32
#define MAX_HUMAN_AIRCRAFT_TYPE   AIRCRAFT_INTERCEPTOR

Definition at line 59 of file cp_aircraft.h.

Referenced by BaseSummary_Init().


Typedef Documentation

typedef struct aircraft_s aircraft_t

An aircraft with all it's data.

slot of aircraft

possible aircraft states

typedef struct aliensTmp_s aliensTmp_t

alien cargo in aircraft_t, carrying aliens and bodies from a mission to base

typedef struct itemsTmp_s itemsTmp_t

A cargo of items collected after mission.

typedef struct mapline_s mapline_t

A path on the map described by 2D points.


Enumeration Type Documentation

notification signals for aircraft events

Enumerator:
AIR_CANNOT_REFUEL 
MAX_AIR_NOTIFICATIONS 

Definition at line 103 of file cp_aircraft.h.

All different Hangar size.

Note:
for Phalanx aircraft and UFO.
Enumerator:
AIRCRAFT_HANGAR_NONE 
AIRCRAFT_HANGAR_SMALL 
AIRCRAFT_HANGAR_BIG 
AIRCRAFT_HANGAR_ERROR 

Definition at line 70 of file cp_aircraft.h.

All different size of aircraft.

Enumerator:
AIRCRAFT_SMALL 
AIRCRAFT_LARGE 

Definition at line 62 of file cp_aircraft.h.

possible aircraft states

Enumerator:
AIR_NONE 
AIR_REFUEL 

refill fuel

AIR_HOME 

in homebase

AIR_IDLE 

just sit there on geoscape

AIR_TRANSIT 

moving

AIR_MISSION 

moving to a mission

AIR_UFO 

pursuing a UFO - also used for ufos that are pursuing an aircraft

AIR_DROP 

ready to drop down

AIR_INTERCEPT 

ready to intercept

AIR_TRANSFER 

being transfered

AIR_CRASHED 

crashed

AIR_RETURNING 

returning to homebase

Definition at line 147 of file cp_aircraft.h.

All different types of aircraft.

Enumerator:
AIRCRAFT_TRANSPORTER 
AIRCRAFT_INTERCEPTOR 
AIRCRAFT_UFO 

Definition at line 53 of file cp_aircraft.h.

enum itemPos_t

different positions for aircraft items

Enumerator:
AIR_NOSE_LEFT 
AIR_NOSE_CENTER 
AIR_NOSE_RIGHT 
AIR_WING_LEFT 
AIR_WING_RIGHT 
AIR_REAR_LEFT 
AIR_REAR_CENTER 
AIR_REAR_RIGHT 
AIR_POSITIONS_MAX 

Definition at line 89 of file cp_aircraft.h.

different weight for aircraft items

Note:
values must go from the lightest to the heaviest item
Enumerator:
ITEM_LIGHT 
ITEM_MEDIUM 
ITEM_HEAVY 

Definition at line 80 of file cp_aircraft.h.


Function Documentation

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

Definition at line 349 of file cp_aircraft.c.

References item_s::a, AII_CarriedItems(), AII_CollectingAmmo(), AII_CollectItem(), itemsTmp_s::amount, ARMOUR, ccs, cls, Com_DPrintf(), DEBUG_CLIENT, FLOOR, i, itemsTmp_s::item, invList_s::item, missionResults_s::itemAmount, aircraft_s::itemcargo, missionResults_s::itemTypes, aircraft_s::itemTypes, LE_GetNextInUse(), LE_IsActor(), LE_IsDead, LE_IsItem, MAX_CARGO, ccs_s::missionResults, objDef_s::name, invList_s::next, objDef_s::reload, item_s::t, client_static_s::team, and le_s::team.

Referenced by GAME_CP_Results().

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

Add an item to aircraft inventory.

Parameters:
[in,out] aircraft Aircraft to load to
[in] item Item to add
amount Number of items to add
See also:
AL_AddAliens
AII_CollectingItems

Definition at line 286 of file cp_aircraft.c.

References itemsTmp_s::amount, Com_DPrintf(), DEBUG_CLIENT, i, objDef_s::idx, itemsTmp_s::item, aircraft_s::itemcargo, aircraft_s::itemTypes, and objDef_s::name.

Referenced by AII_CollectingAmmo(), AII_CollectingItems(), and AL_AddAliens().

void AIM_AddEmployeeFromMenu ( aircraft_t aircraft,
const int  num 
)

Adds or removes a soldier to/from an aircraft.

Parameters:
[in,out] aircraft Aircraft to add to/remove from
[in] num Index of Soldier (in menu) to add/remove
See also:
E_EmployeeHire_f

Definition at line 3208 of file cp_aircraft.c.

References AIR_AddEmployee(), AIR_IsEmployeeInAircraft(), AIR_RemoveEmployee(), Com_DPrintf(), Com_Error(), DEBUG_CLIENT, E_GetEmployeeByMenuIndex(), ERR_DROP, and employee_s::idx.

Referenced by AIR_AssignInitial(), and CL_AssignSoldier_f().

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] base The base to add the aircraft to
[in] aircraftTemplate The template to create the new aircraft from
Returns:
the newly added aircraft
See also:
AIR_Delete

Definition at line 759 of file cp_aircraft.c.

References base_s::aircraft, byte, ccs, data, aircraft_s::homebase, LIST_Add(), and ccs_s::numAircraft.

Referenced by AIR_LoadXML(), AIR_MoveAircraftIntoNewHomebase(), and AIR_NewAircraft().

qboolean AIR_AddToAircraftTeam ( aircraft_t aircraft,
employee_t employee 
)

Adds given employee to given aircraft.

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

Definition at line 2180 of file cp_aircraft.c.

References aircraft_s::acTeam, AIR_GetTeamSize(), Com_DPrintf(), DEBUG_CLIENT, employee_s::idx, LIST_AddPointer(), aircraft_s::maxTeamSize, qfalse, and qtrue.

Referenced by AIR_AddEmployee(), and CP_BaseAttackStartMission().

aircraft_t* AIR_AircraftGetFromIDX ( int  idx  ) 

Returns aircraft for a given global index.

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

Definition at line 1318 of file cp_aircraft.c.

References AIR_GetNextFromBase(), B_GetFoundedBaseByIDX(), ccs, Com_DPrintf(), DEBUG_CLIENT, base_s::idx, aircraft_s::idx, base_s::name, and ccs_s::numBases.

Referenced by AIR_LoadAircraftXML(), AIRFIGHT_LoadXML(), CP_LoadMissionsXML(), MAP_MultiSelectExecuteAction_f(), PR_UpdateProductionList(), TR_AircraftListSelect(), TR_CargoList(), TR_CheckAircraft(), TR_EmptyTransferCargo(), TR_TransferAliensFromMission_f(), TR_TransferListSelect_f(), TR_TransferSelect(), and TR_TransferStart().

qboolean 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] aircraft Pointer to the aircraft
[in] destination Pointer to the position the aircraft should go to
See also:
MAP_MapCalcLine
Returns:
qtrue if the aircraft can go to the position, qfalse else

Definition at line 592 of file cp_aircraft.c.

References AIR_GetRemainingRange(), GetDistanceOnGlobe(), aircraft_s::homebase, base_s::pos, aircraft_s::pos, and SECONDS_PER_HOUR.

Referenced by AIR_SendAircraftPursuingUFO(), AIR_SendAircraftToMission(), CL_CampaignRunAircraft(), CL_DisplayPopupInterceptUFO(), and MAP_MapClick().

qboolean AIR_AircraftHasEnoughFuelOneWay ( const aircraft_t aircraft,
const vec2_t  destination 
)
qboolean AIR_AircraftMakeMove ( int  dt,
aircraft_t aircraft 
)

Moves given aircraft.

Parameters:
[in] dt time delta
[in] aircraft Pointer to aircraft on its way.
Returns:
true if the aircraft reached its destination.

Definition at line 1108 of file cp_aircraft.c.

References AIR_STATS_SPEED, mapline_s::distance, aircraft_s::fuel, aircraft_s::hasMoved, int(), MAP_CheckPositionBoundaries(), aircraft_s::numInterpolationPoints, mapline_s::numPoints, mapline_s::point, aircraft_s::point, aircraft_s::pos, aircraft_s::projectedPos, qfalse, qtrue, aircraft_s::route, SECONDS_PER_HOUR, aircraft_s::stats, aircraft_s::time, and VectorSet.

Referenced by AIR_Move(), and UFO_CampaignRunUFOs().

void AIR_AircraftReturnToBase ( aircraft_t aircraft  ) 
void AIR_AircraftsNotifyUFORemoved ( const aircraft_t *const   ufo,
qboolean  destroyed 
)

Notify that a UFO has been removed.

Parameters:
[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 1832 of file cp_aircraft.c.

References AIR_AircraftReturnToBase(), AIR_GetNextFromBase(), AIR_UFO, aircraft_s::aircraftTarget, B_GetFoundedBaseByIDX(), base_s::batteries, base_s::lasers, base_s::numBatteries, base_s::numLasers, aircraft_s::status, 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.

Parameters:
[in] aircraft Aircraft to translate the status of
Returns:
Translation string of given status.

Definition at line 429 of file cp_aircraft.c.

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, BASE_UNDER_ATTACK, base_s::baseStatus, Com_Error(), ERR_DROP, aircraft_s::homebase, and aircraft_s::status.

Referenced by AIR_AircraftSelect(), CL_DisplayPopupInterceptMission(), CL_DisplayPopupInterceptUFO(), and MAP_GetAircraftText().

void AIR_AircraftsUFODisappear ( const aircraft_t *const   ufo  ) 

Notify that a UFO disappear from radars.

Parameters:
[in] ufo Pointer to a UFO that has disappeared.

Definition at line 1875 of file cp_aircraft.c.

References AIR_AircraftReturnToBase(), AIR_GetNextFromBase(), AIR_UFO, aircraft_s::aircraftTarget, B_GetBaseByIDX(), and aircraft_s::status.

Referenced by UFO_CampaignCheckEvents().

void AIR_AssignInitial ( aircraft_t aircraft  ) 

Assigns initial team of soldiers to aircraft.

Parameters:
[in,out] aircraft soldiers to add to

Definition at line 3236 of file cp_aircraft.c.

References AIM_AddEmployeeFromMenu(), Com_Printf(), E_GenerateHiredEmployeesList(), aircraft_s::homebase, and aircraft_s::maxTeamSize.

Referenced by B_SetUpFirstBase().

void AIR_AutoAddPilotToAircraft ( base_t base,
employee_t pilot 
)

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

Parameters:
[in] base Which base has aircraft to add the pilot to.
[in] pilot Which pilot to add.

Definition at line 2277 of file cp_aircraft.c.

References AIR_GetNextFromBase(), and aircraft_s::pilot.

Referenced by E_HireEmployee().

qboolean AIR_BaseHasAircraft ( const struct base_s base  ) 
int AIR_CalculateHangarStorage ( const aircraft_t aircraft,
const struct base_s base,
int  used 
)
qboolean AIR_CanIntercept ( const aircraft_t aircraft  ) 
Parameters:
aircraft The aircraft to check
Returns:
true if the given aircraft can go on interceptions

Definition at line 2914 of file cp_aircraft.c.

References AIRCRAFT_LARGE, AIRCRAFT_SMALL, B_GetBuildingStatus(), B_HANGAR, B_SMALL_HANGAR, aircraft_s::homebase, aircraft_s::pilot, qfalse, qtrue, and aircraft_s::size.

Referenced by CL_DisplayPopupInterceptMission(), and CL_DisplayPopupInterceptUFO().

const char* AIR_CheckMoveIntoNewHomebase ( const aircraft_t aircraft,
const struct base_s base,
const int  capacity 
)
int AIR_CountTypeInBase ( const struct base_s base,
aircraftType_t  aircraftType 
)
qboolean AIR_Delete ( base_t base,
const aircraft_t aircraft 
)

Will remove the given aircraft from the base.

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

Definition at line 774 of file cp_aircraft.c.

References base_s::aircraft, ccs, LIST_Remove(), and ccs_s::numAircraft.

Referenced by AIR_DeleteAircraft(), and AIR_MoveAircraftIntoNewHomebase().

void AIR_DeleteAircraft ( aircraft_t aircraft  ) 

Removes an aircraft from its base and the game.

Parameters:
[in] aircraft Pointer to aircraft that should be removed.
Note:
The assigned soldiers (if any) are removed/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.
Note:
This function has the side effect, that the base aircraft number is reduced by one, also the ccs.employees pointers are moved to fill the gap of the removed employee. Thus pointers like acTeam in the aircraft can point to wrong employees now. This has to be taken into account

Definition at line 1020 of file cp_aircraft.c.

References AII_RemoveItemFromSlot(), AIR_BaseHasAircraft(), AIR_Delete(), AIR_GetNextFromBase(), AIR_IsAircraftOnGeoscape(), AIR_RemoveEmployees(), AIR_UpdateHangarCapForAll(), base_s::aircraftCurrent, Cmd_ExecuteString(), Cvar_Set(), Cvar_SetValue(), aircraft_s::electronics, aircraft_s::homebase, i, MAP_NotifyAircraftRemoved(), MAX_AIRCRAFTSLOT, qfalse, RADAR_UpdateWholeRadarOverlay(), aircraft_s::shield, TR_NotifyAircraftRemoved(), and aircraft_s::weapons.

Referenced by AIR_DestroyAircraft(), B_RemoveAircraftExceedingCapacity(), BS_SellAircraft_f(), and TR_EmptyTransferCargo().

void AIR_DestroyAircraft ( aircraft_t aircraft  ) 

Removes an aircraft from its base and the game.

Parameters:
[in] aircraft Pointer to aircraft that should be removed.
Note:
aircraft and assigned soldiers (if any) are removed from game.
Todo:
Return status of deletion for better error handling.

Definition at line 1078 of file cp_aircraft.c.

References aircraft_s::acTeam, AIR_DeleteAircraft(), Com_Error(), linkedList_s::data, E_DeleteEmployee(), E_RemoveInventoryFromStorage(), ERR_DROP, aircraft_s::id, linkedList_s::next, aircraft_s::pilot, and employee_s::type.

Referenced by AIRFIGHT_ActionsAfterAirfight(), B_MoveAircraftOnGeoscapeToOtherBases(), and CP_MissionEndActions().

aircraft_t* AIR_GetAircraft ( const char *  name  ) 

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

Parameters:
[in] name Aircraft id.
Returns:
aircraft_t pointer or errors out (ERR_DROP)

Definition at line 724 of file cp_aircraft.c.

References AIR_GetAircraftSilent(), Com_Error(), and ERR_DROP.

Referenced by AIR_LoadAircraftXML(), AIR_NewAircraft(), AIR_ParseAircraft(), B_SetUpFirstBase(), BS_InitMarket(), CL_CampaignRunMarket(), PR_LoadXML(), RS_AssignTechLinks(), UFO_MissionResultToString(), UP_AircraftDescription(), UR_DialogInit_f(), and US_LoadXML().

aircraft_t* AIR_GetAircraftFromBaseByIDXSafe ( base_t base,
int  index 
)
Parameters:
base The base to get the aircraft from
index The index of the aircraft in the given base
Returns:
NULL if there is no such aircraft in the given base, or the aircraft pointer that belongs to the given index.

Definition at line 683 of file cp_aircraft.c.

References AIR_GetNextFromBase(), and i.

Referenced by AIM_SelectAircraft_f().

int AIR_GetAircraftIDXInBase ( const aircraft_t aircraft  ) 

Returns the index of the aircraft in the base->aircraft array.

Parameters:
[in] aircraft The aircraft to get the index for.
Returns:
The array index or AIRCRAFT_INBASE_INVALID on error.

Definition at line 655 of file cp_aircraft.c.

References AIR_GetNextFromBase(), AIRCRAFT_INBASE_INVALID, aircraft_s::homebase, and i.

Referenced by AIR_RemoveFromAircraftTeam(), and B_SaveXML().

aircraft_t* AIR_GetAircraftSilent ( const char *  name  ) 

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

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

Definition at line 705 of file cp_aircraft.c.

References ccs_s::aircraftTemplates, ccs, i, aircraft_s::id, and ccs_s::numAircraftTemplates.

Referenced by AIR_GetAircraft(), and GAME_CP_DisplayItemInfo().

const char* AIR_GetAircraftString ( aircraftType_t  aircraftType  ) 

Returns the string that matches the given aircraft type.

Definition at line 531 of file cp_aircraft.c.

References _, AIRCRAFT_INTERCEPTOR, AIRCRAFT_TRANSPORTER, and AIRCRAFT_UFO.

Referenced by BaseSummary_Init().

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

Get the all the unique weapon ranges of this aircraft.

Parameters:
[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.
Returns:
Number of unique weapons ranges.

Definition at line 2316 of file cp_aircraft.c.

References AIR_STATS_WRANGE, aircraftSlot_s::ammo, objDef_s::craftitem, MAX_AIRCRAFTSLOT, Q_FloatSort(), and craftitem_s::stats.

aircraft_t* AIR_GetByIDX ( int  idx  ) 
int AIR_GetCapacityByAircraftWeight ( const aircraft_t aircraft  ) 
void AIR_GetDestinationWhilePursuing ( const aircraft_t const *  shooter,
const aircraft_t const *  target,
vec2_t dest 
)

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

Parameters:
[in] shooter Pointer to shooting aircraft.
[in] target Pointer to target aircraft.
[out] dest Destination 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 2040 of file cp_aircraft.c.

References AIR_GetDestinationFindRoot(), AIR_STATS_SPEED, Com_DPrintf(), 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(), and UFO_SendPursuingAircraft().

aircraft_t* AIR_GetNextFromBase ( const struct base_s base,
aircraft_t lastAircraft 
)
int AIR_GetOperationRange ( const aircraft_t aircraft  ) 

Calculates the range an aircraft can fly on the geoscape.

Parameters:
aircraft The aircraft to calculate the range for
Returns:
The range

Definition at line 568 of file cp_aircraft.c.

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().

int AIR_GetRemainingRange ( const aircraft_t aircraft  ) 

Calculates the remaining range the aircraft can fly.

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

Definition at line 580 of file cp_aircraft.c.

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

Referenced by AIR_AircraftHasEnoughFuel(), and AIR_AircraftHasEnoughFuelOneWay().

int AIR_GetTeamSize ( const aircraft_t aircraft  ) 
qboolean AIR_IsAircraftInBase ( const aircraft_t aircraft  ) 

Checks whether given aircraft is in its homebase.

Parameters:
[in] aircraft Pointer to an aircraft.
Returns:
qtrue if given aircraft is in its homebase.
qfalse if given aircraft is not in its homebase.

Definition at line 474 of file cp_aircraft.c.

References AIR_HOME, AIR_REFUEL, qfalse, qtrue, and aircraft_s::status.

Referenced by AII_ReloadWeapon(), AII_RepairAircraft(), AII_UpdateInstallationDelay(), AIM_AircraftStart_f(), AIR_AircraftSelect(), AIR_AircraftStatusToName(), AIR_SendAircraftPursuingUFO(), AIR_SendAircraftToMission(), AIRFIGHT_ProjectileHits(), B_RemoveAircraftExceedingCapacity(), BS_SellAircraft_f(), CL_EquipSoldierState(), E_IsAwayFromBase(), MAP_DrawMap(), and TR_AircraftListSelect().

qboolean AIR_IsAircraftOnGeoscape ( const aircraft_t aircraft  ) 

Checks whether given aircraft is on geoscape.

Parameters:
[in] aircraft Pointer to an aircraft.
Note:
aircraft may be neither on geoscape, nor in base (like when it's transferred)
Returns:
qtrue if given aircraft is on geoscape.
qfalse if given aircraft is not on geoscape.

Definition at line 488 of file cp_aircraft.c.

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, Com_Error(), ERR_FATAL, qfalse, qtrue, and aircraft_s::status.

Referenced by AB_UpdateStealthForAllBase(), AIR_AircraftReturnToBase(), AIR_DeleteAircraft(), B_MoveAircraftOnGeoscapeToOtherBases(), B_RemoveAircraftExceedingCapacity(), CL_CampaignRunAircraft(), MAP_DrawMapMarkers(), MAP_GetGeoscapeAngle(), MAP_MapClick(), RADAR_AddDetectedUFOToEveryRadar(), RADAR_UpdateWholeRadarOverlay(), UFO_CampaignCheckEvents(), UFO_CheckShootBack(), and UFO_SearchAircraftTarget().

const aircraft_t* AIR_IsEmployeeInAircraft ( const struct employee_s employee,
const aircraft_t aircraft 
)
qboolean AIR_IsInAircraftTeam ( const aircraft_t aircraft,
const struct employee_s employee 
)
qboolean AIR_MoveAircraftIntoNewHomebase ( aircraft_t aircraft,
base_t base 
)
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] 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 3126 of file cp_aircraft.c.

References item_s::a, aircraft_s::acTeam, AIR_GetTeamSize(), objDef_s::ammo, employee_s::chr, Com_DPrintf(), Com_Printf(), CONTAINER, csi, linkedList_s::data, DEBUG_CLIENT, objDef_s::idx, INVDEF, invList_s::item, item_s::m, invList_s::next, next, linkedList_s::next, csi_s::numIDs, equipDef_s::numItems, equipDef_s::numItemsLoose, objDef_s::reload, item_s::t, and type.

Referenced by B_PackInitialEquipment().

void AIR_ParseAircraft ( const char *  name,
const char **  text,
qboolean  assignAircraftItems 
)

Parses all aircraft that are defined in our UFO-scripts.

See also:
CL_ParseClientData
CL_ParseScriptSecond
Note:
parses the aircraft into our aircraft_sample array to use as reference
This parsing function writes into two different memory pools one is the cp_campaignPool which is cleared on every new game, the other is cl_genericPool which is existant until you close the game

Definition at line 1468 of file cp_aircraft.c.

References AC_ITEM_ELECTRONICS, AC_ITEM_WEAPON, AII_InitialiseAircraftSlots(), AIR_GetAircraft(), AIR_HOME, AIR_POSITIONS_MAX, air_slot_type_strings, AIR_STATS_FUELSIZE, AIR_STATS_SPEED, AIRCRAFT_INTERCEPTOR, AIRCRAFT_LARGE, AIRCRAFT_SMALL, AIRCRAFT_TRANSPORTER, AIRCRAFT_UFO, ccs_s::aircraftTemplates, aircraftSlot_s::ammo, ccs, cl_genericPool, Com_DPrintf(), Com_EParse(), Com_EParseValue(), Com_Error(), Com_Parse(), Com_Printf(), Com_UFOShortNameToID(), DEBUG_CLIENT, aircraft_s::electronics, ERR_DROP, f, FS_SkipBlock(), 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, Mem_PoolStrDup, Mem_PoolStrDupTo, MEMBER_SIZEOF, aircraft_s::name, ccs_s::numAircraftTemplates, value_s::ofs, aircraftSlot_s::pos, technology_s::provides, Q_strncpyz(), aircraft_s::radar, RADAR_InitialiseUFOs(), RS_GetTechByID(), SECONDS_PER_HOUR, aircraft_s::shield, aircraft_s::size, value_s::size, aircraftSlot_s::size, aircraft_s::stats, aircraft_s::status, value_s::string, Sys_Error(), aircraft_s::tpl, value_s::type, aircraft_s::type, UFO_MAX, aircraft_s::ufotype, V_CLIENT_HUNK_STRING, V_INT, V_TRANSLATION_STRING, and aircraft_s::weapons.

Referenced by CL_ParseScriptFirst(), and CL_ParseScriptSecond().

qboolean AIR_RemoveEmployee ( employee_t employee,
aircraft_t aircraft 
)

Removes a soldier from an aircraft.

Parameters:
[in,out] employee The soldier to be removed from the aircraft.
[in,out] aircraft The aircraft to remove the soldier from. Use NULL to remove the soldier from any aircraft.
See also:
AIR_AddEmployee

Definition at line 3012 of file cp_aircraft.c.

References AIR_GetNextFromBase(), AIR_IsEmployeeInAircraft(), AIR_RemoveFromAircraftTeam(), B_GetFoundedBaseByIDX(), ccs, employee_s::chr, cls, Com_DPrintf(), DEBUG_CLIENT, inventoryInterface_s::DestroyInventory, aircraft_s::homebase, character_s::i, client_static_s::i, aircraft_s::idx, base_s::idx, ccs_s::numBases, and qfalse.

Referenced by AIM_AddEmployeeFromMenu(), AIR_RemoveEmployees(), CP_SpawnRescueMission(), and E_RemoveEmployeeFromBuildingOrAircraft().

void AIR_RemoveEmployees ( aircraft_t aircraft  ) 

Removes all soldiers from an aircraft.

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

Definition at line 3099 of file cp_aircraft.c.

References aircraft_s::acTeam, AIR_GetTeamSize(), AIR_RemoveEmployee(), Com_Error(), linkedList_s::data, ERR_DROP, linkedList_s::next, and aircraft_s::pilot.

Referenced by AIR_DeleteAircraft(), and TR_TransferStart().

qboolean AIR_RemoveFromAircraftTeam ( aircraft_t aircraft,
const struct employee_s employee 
)
void AIR_RemovePilotFromAssignedAircraft ( struct base_s base,
const struct employee_s pilot 
)
void AIR_ResetAircraftTeam ( aircraft_t aircraft  ) 

Resets team in given aircraft.

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

Definition at line 2169 of file cp_aircraft.c.

References aircraft_s::acTeam, and LIST_Delete().

Referenced by AIR_NewAircraft().

qboolean AIR_ScriptSanityCheck ( void   ) 
qboolean AIR_SendAircraftPursuingUFO ( aircraft_t aircraft,
aircraft_t ufo 
)
qboolean AIR_SendAircraftToMission ( aircraft_t aircraft,
mission_t mission 
)

Sends the specified aircraft to specified mission.

Parameters:
[in] aircraft Pointer to aircraft to send to mission.
[in] mission Pointer to given mission.
Returns:
qtrue if sending an aircraft to specified mission is possible.

Definition at line 1350 of file cp_aircraft.c.

void AIR_UpdateHangarCapForAll ( base_t base  ) 

Updates current capacities for hangars in given base.

Parameters:
[in,out] base The base we want to update.
Note:
Call this function whenever you sell/loss aircraft in given base.
See also:
BS_SellAircraft_f

Definition at line 135 of file cp_aircraft.c.

References AIR_GetNextFromBase(), AIR_UpdateHangarCapForOne(), CAP_AIRCRAFT_BIG, CAP_AIRCRAFT_SMALL, base_s::capacities, Com_DPrintf(), cap_maxcur_s::cur, DEBUG_CLIENT, aircraft_s::id, base_s::name, and aircraft_s::tpl.

Referenced by AIR_DeleteAircraft(), B_ResetAllStatusAndCapacities(), and CP_SpawnRescueMission().

int int CL_AircraftMenuStatsValues ( const int  value,
const int  stat 
)

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

See also:
CL_AircraftStatToName

Definition at line 549 of file cp_aircraft.c.

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

Referenced by AIR_AircraftSelect(), MAP_GetAircraftText(), MAP_GetUFOText(), UP_AircraftDescription(), and UP_AircraftItemDescription().

void CL_CampaignRunAircraft ( int  dt,
qboolean  updateRadarOverlay 
)

Handles aircraft movement and actions in geoscape mode.

See also:
CL_CampaignRun
Parameters:
[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)

Todo:
check if aircraft can go to a closer base with free space

Definition at line 1250 of file cp_aircraft.c.

References _, AII_ReloadWeapon(), AIR_AircraftHasEnoughFuel(), AIR_AircraftReturnToBase(), AIR_GetNextFromBase(), AIR_IDLE, AIR_IsAircraftOnGeoscape(), AIR_Move(), AIR_Refuel(), AIR_REFUEL, AIR_RETURNING, AIR_UFO, aircraft_s::aircraftTarget, AIRFIGHT_ExecuteActions(), aircraftSlot_s::ammoLeft, B_GetBaseByIDX(), aircraftSlot_s::delayNextShot, aircraft_s::fuel, aircraft_s::homebase, MAP_IsRadarOverlayActivated(), aircraft_s::maxWeapons, MS_AddNewMessage(), MSG_STANDARD, aircraft_s::name, aircraft_s::pos, qfalse, qtrue, RADAR_UpdateWholeRadarOverlay(), aircraft_s::status, va(), and aircraft_s::weapons.

Referenced by CL_CampaignFunctionPeriodicCall().


Generated by  doxygen 1.6.2