cp_uforecovery.c File Reference

UFO recovery and storing. More...

#include "../cl_shared.h"
#include "cp_campaign.h"
#include "cp_ufo.h"
#include "cp_map.h"
#include "cp_uforecovery.h"
#include "cp_uforecovery_callbacks.h"
#include "cp_aircraft.h"
#include "save/save_uforecovery.h"
Include dependency graph for cp_uforecovery.c:

Go to the source code of this file.

Functions

void UR_ProcessActive (void)
 Function to process active recoveries.
storedUFO_tUS_GetNext (storedUFO_t *lastUFO)
 Iterates through the stored UFOs.
storedUFO_tUS_GetStoredUFOByIDX (const int idx)
 Returns a stored ufo.
storedUFO_tUS_StoreUFO (const aircraft_t *ufoTemplate, installation_t *installation, date_t date, float condition)
 Adds an UFO to the storage.
void US_RemoveStoredUFO (storedUFO_t *ufo)
 Removes an UFO from the storage.
int US_UFOsInStorage (const aircraft_t *ufoTemplate, const installation_t *installation)
 Returns the number of UFOs stored (on an installation or anywhere).
void US_RemoveUFOsExceedingCapacity (installation_t *installation)
 Removes ufos which are over the storing capacity.
storedUFO_tUS_GetClosestStoredUFO (const aircraft_t *ufoTemplate, const base_t *base)
 get the closest stored ufo (of a type) from a base
int US_StoredUFOCount (void)
 Returns the number of storedUFOs.
qboolean US_SaveXML (mxml_node_t *p)
 Save callback for savegames in XML Format.
qboolean US_LoadXML (mxml_node_t *p)
 Load callback for xml savegames.

Detailed Description

UFO recovery and storing.

Note:
UFO recovery functions with UR_*
UFO storing functions with US_*

Definition in file cp_uforecovery.c.


Function Documentation

void UR_ProcessActive ( void   ) 
storedUFO_t* US_GetClosestStoredUFO ( const aircraft_t ufoTemplate,
const base_t base 
)

get the closest stored ufo (of a type) from a base

Parameters:
[in] ufoTemplate Pointer to the aircraft (ufo) template to look for (NULL for any type)
[in] base Pointer to the base. If it's NULL the function simply return the first stored UFO of type
Returns:
Pointer to the first stored UFO matches the conditions

Definition at line 244 of file cp_uforecovery.c.

References GetDistanceOnGlobe(), storedUFO_s::installation, base_s::pos, installation_s::pos, storedUFO_s::status, SUFO_STORED, storedUFO_s::ufoTemplate, and US_GetNext().

storedUFO_t* US_GetNext ( storedUFO_t lastUFO  ) 

Iterates through the stored UFOs.

Parameters:
[in] lastBase Pointer of the UFO to iterate from. call with NULL to get the first one.

Definition at line 74 of file cp_uforecovery.c.

References ccs, LIST_GetNext(), and ccs_s::storedUFOs.

Referenced by INS_DestroyInstallation(), PR_UpdateProductionList(), UR_ProcessActive(), US_GetClosestStoredUFO(), US_GetStoredUFOByIDX(), US_RemoveUFOsExceedingCapacity(), US_SaveXML(), and US_UFOsInStorage().

storedUFO_t* US_GetStoredUFOByIDX ( const int  idx  ) 

Returns a stored ufo.

Parameters:
[in] idx index of the stored UFO
Returns:
storedUFO_t Pointer

Definition at line 84 of file cp_uforecovery.c.

References storedUFO_s::idx, and US_GetNext().

Referenced by PR_LoadXML().

qboolean US_LoadXML ( mxml_node_t p  ) 
void US_RemoveStoredUFO ( storedUFO_t ufo  ) 
void US_RemoveUFOsExceedingCapacity ( installation_t installation  ) 

Removes ufos which are over the storing capacity.

Parameters:
[in] installation pointer to the ufoyard the ufos are stored in

Definition at line 214 of file cp_uforecovery.c.

References Com_Error(), cap_maxcur_s::cur, ERR_DROP, storedUFO_s::installation, cap_maxcur_s::max, installation_s::ufoCapacity, US_GetNext(), and US_RemoveStoredUFO().

Referenced by INS_DestroyInstallation().

qboolean US_SaveXML ( mxml_node_t p  ) 
int US_StoredUFOCount ( void   ) 

Returns the number of storedUFOs.

Definition at line 272 of file cp_uforecovery.c.

References ccs, LIST_Count(), and ccs_s::storedUFOs.

Referenced by STATS_LoadXML().

storedUFO_t* US_StoreUFO ( const aircraft_t ufoTemplate,
installation_t installation,
date_t  date,
float  condition 
)

Adds an UFO to the storage.

Parameters:
[in] ufoTemplate Pointer to the aircraft(ufo)Template to add
[in,out] installation Pointer to the installation it should be added to
[in] date Date when UFO is arrives to the storage (recovery || transfer)
[in] condition Condition of the UFO to store (How much the UFO is damaged)
[in] idx UFO's index. Call with negative value for
Returns:
storedUFO_t pointer to the newly stored UFO (or NULL if failed)

Definition at line 104 of file cp_uforecovery.c.

References storedUFO_s::arrive, ccs_s::campaignStats, ccs, CL_GetComponentsByID(), Com_DPrintf(), storedUFO_s::comp, storedUFO_s::condition, cap_maxcur_s::cur, data, ccs_s::date, date_s::day, DEBUG_CLIENT, storedUFO_s::disassembly, aircraft_s::id, storedUFO_s::id, storedUFO_s::idx, storedUFO_s::installation, LIST_Add(), cap_maxcur_s::max, Q_strncpyz(), RS_MarkCollected(), date_s::sec, storedUFO_s::status, ccs_s::storedUFOs, SUFO_RECOVERED, SUFO_STORED, aircraft_s::tech, installation_s::ufoCapacity, stats_s::ufosStored, and storedUFO_s::ufoTemplate.

Referenced by UR_DialogStartStore_f().

int US_UFOsInStorage ( const aircraft_t ufoTemplate,
const installation_t installation 
)

Returns the number of UFOs stored (on an installation or anywhere).

Parameters:
[in] ufoTemplate aircraftTemplate of the ufo
[in] installation Pointer to the installation to count at
Returns:
the number of ufos stored of the given ufotype at given installation or overall
Note:
installation == NULL means count on every ufoyards

Definition at line 191 of file cp_uforecovery.c.

References count, storedUFO_s::installation, storedUFO_s::status, SUFO_STORED, storedUFO_s::ufoTemplate, and US_GetNext().

Referenced by PR_UpdateProductionList(), RS_RequirementsMet(), and US_RemoveStoredUFO().


Generated by  doxygen 1.6.2