UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_uforecovery.h File Reference

UFO recovery and storing. More...

#include "../../DateTime.h"
Include dependency graph for cp_uforecovery.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  storedUFO_t
 Structure for stored UFOs. More...

Macros

#define RECOVERY_DELAY   2.0f
#define US_Foreach(var)
#define US_UFOStored()
 returns if any UFOs are stored in UFO Yards

Enumerations

enum  storedUFOStatus_t { SUFO_RECOVERED , SUFO_STORED , SUFO_TRANSFERED , MAX_SUFO_STATUS }
 different statuses for a stored UFO More...

Functions

void UR_ProcessActive (void)
 Function to process active recoveries.
storedUFO_tUS_StoreUFO (const aircraft_t *ufoTemplate, installation_t *installation, DateTime &date, float condition)
 Adds an UFO to the storage.
storedUFO_tUS_GetStoredUFOByIDX (const int idx)
 Returns a stored ufo.
storedUFO_tUS_GetClosestStoredUFO (const aircraft_t *ufoTemplate, const base_t *base)
 get the closest stored ufo (of a type) from a base
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).
int US_StoredUFOCount (void)
 Returns the number of storedUFOs.
void US_RemoveUFOsExceedingCapacity (installation_t *installation)
 Removes ufos which are over the storing capacity.
bool US_TransferUFO (storedUFO_t *ufo, installation_t *ufoyard)
 Start transferring of a stored UFO.
void UR_InitStartup (void)
 Init actions for ufostoring-subsystem.
void UR_Shutdown (void)
 Closing actions for ufostoring-subsystem.

Detailed Description

UFO recovery and storing.

Definition in file cp_uforecovery.h.

Macro Definition Documentation

◆ RECOVERY_DELAY

#define RECOVERY_DELAY   2.0f

Definition at line 30 of file cp_uforecovery.h.

Referenced by UR_DialogStartStore_f(), and US_TransferUFO().

◆ US_Foreach

#define US_Foreach ( var)
Value:
LIST_Foreach(ccs.storedUFOs, storedUFO_t, var)
ccs_t ccs
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it's safe to delete the returned entry from the list while looping over ...
Definition list.h:41
Structure for stored UFOs.

Definition at line 65 of file cp_uforecovery.h.

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

◆ US_UFOStored

#define US_UFOStored ( )
Value:
(US_GetNext(nullptr) != nullptr)

returns if any UFOs are stored in UFO Yards

Definition at line 79 of file cp_uforecovery.h.

Enumeration Type Documentation

◆ storedUFOStatus_t

different statuses for a stored UFO

Note
If you change/reorder this change ufostatus_strings (cp_uforecovery.c) as well
Enumerator
SUFO_RECOVERED 

UFO just got recovered, it's being transported to the UFO Yard

SUFO_STORED 

UFO is in UFO Yard, nothing special

SUFO_TRANSFERED 

UFO is being transferred to another UFO Yard

MAX_SUFO_STATUS 

Definition at line 36 of file cp_uforecovery.h.

Function Documentation

◆ UR_InitStartup()

void UR_InitStartup ( void )

Init actions for ufostoring-subsystem.

See also
UI_InitStartup

Definition at line 489 of file cp_uforecovery.cpp.

References cgi, debugStoredUfosCmds, and UR_InitCallbacks().

Referenced by CP_InitStartup().

◆ UR_ProcessActive()

◆ UR_Shutdown()

void UR_Shutdown ( void )

Closing actions for ufostoring-subsystem.

Definition at line 498 of file cp_uforecovery.cpp.

References ccs, cgi, debugStoredUfosCmds, and UR_ShutdownCallbacks().

Referenced by CP_Shutdown().

◆ US_GetClosestStoredUFO()

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]ufoTemplatePointer to the aircraft (ufo) template to look for (nullptr for any type)
[in]basePointer to the base. If it's nullptr the function simply return the first stored UFO of type
Returns
Pointer to the first stored UFO matches the conditions

Definition at line 261 of file cp_uforecovery.cpp.

References GetDistanceOnGlobe(), base_t::pos, SUFO_STORED, and US_Foreach.

◆ US_GetStoredUFOByIDX()

storedUFO_t * US_GetStoredUFOByIDX ( const int idx)

Returns a stored ufo.

Parameters
[in]idxindex of the stored UFO
Returns
storedUFO_t Pointer

Definition at line 83 of file cp_uforecovery.cpp.

References US_Foreach.

Referenced by PR_LoadXML(), US_DestroyStoredUFO_f(), US_FillUFOTransfer_f(), US_SelectStoredUfo_f(), and US_TransferUFO_f().

◆ US_RemoveStoredUFO()

◆ US_RemoveUFOsExceedingCapacity()

void US_RemoveUFOsExceedingCapacity ( installation_t * installation)

Removes ufos which are over the storing capacity.

Parameters
[in]installationpointer to the ufoyard the ufos are stored in

Definition at line 202 of file cp_uforecovery.cpp.

References cgi, capacities_t::cur, ERR_DROP, capacities_t::max, installation_t::ufoCapacity, US_Foreach, and US_RemoveStoredUFO().

Referenced by INS_DestroyInstallation().

◆ US_StoredUFOCount()

int US_StoredUFOCount ( void )

Returns the number of storedUFOs.

Definition at line 288 of file cp_uforecovery.cpp.

References ccs, and cgi.

◆ US_StoreUFO()

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

Adds an UFO to the storage.

Parameters
[in]ufoTemplatePointer to the aircraft(ufo)Template to add
[in,out]installationPointer to the installation it should be added to
[in]dateDate when UFO is arrives to the storage (recovery || transfer)
[in]conditionCondition of the UFO to store (How much the UFO is damaged)
Returns
storedUFO_t pointer to the newly stored UFO (or nullptr if failed)

Definition at line 100 of file cp_uforecovery.cpp.

References storedUFO_t::arrive, ccs, cgi, storedUFO_t::comp, COMP_GetComponentsByID(), storedUFO_t::condition, capacities_t::cur, DEBUG_CLIENT, storedUFO_t::disassembly, aircraft_t::id, storedUFO_t::id, storedUFO_t::idx, storedUFO_t::installation, LIST_Add(), capacities_t::max, Q_strncpyz(), RS_MarkCollected(), storedUFO_t::status, SUFO_RECOVERED, SUFO_STORED, aircraft_t::tech, installation_t::ufoCapacity, and storedUFO_t::ufoTemplate.

Referenced by TEST_F(), TEST_F(), and UR_DialogStartStore_f().

◆ US_TransferUFO()

bool US_TransferUFO ( storedUFO_t * ufo,
installation_t * ufoyard )

Start transferring of a stored UFO.

Parameters
[in,out]ufoStored UFO to transfer
[in,out]ufoyardDestination of the UFO transfer
Returns
success or failure indicator

Definition at line 225 of file cp_uforecovery.cpp.

References _, storedUFO_t::arrive, ccs, cgi, Com_sprintf(), cp_messageBuffer, capacities_t::cur, storedUFO_t::disassembly, ERR_DROP, storedUFO_t::installation, capacities_t::max, MSG_TRANSFERFINISHED, MSO_CheckAddNewMessage(), installation_t::name, NT_TRANSFER_STARTED, RECOVERY_DELAY, storedUFO_t::status, SUFO_STORED, SUFO_TRANSFERED, and installation_t::ufoCapacity.

Referenced by US_TransferUFO_f().

◆ US_UFOsInStorage()

int US_UFOsInStorage ( const aircraft_t * ufoTemplate,
const installation_t * installation )

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

Parameters
[in]ufoTemplateaircraftTemplate of the ufo
[in]installationPointer to the installation to count at
Returns
the number of ufos stored of the given ufotype at given installation or overall
Note
installation == nullptr means count on every ufoyards

Definition at line 180 of file cp_uforecovery.cpp.

References count, SUFO_STORED, and US_Foreach.

Referenced by PR_UpdateProductionList(), and RS_RequirementsMet().