cp_aliencont.c File Reference

Deals with the Alien Containment stuff. More...

#include "../client.h"
#include "cp_campaign.h"
#include "cp_aliencont_callbacks.h"
#include "save/save_aliencont.h"
Include dependency graph for cp_aliencont.c:

Go to the source code of this file.

Functions

static int AL_GetCargoIndexForTeamDefintion (const aircraft_t *aircraft, const teamDef_t *teamDef)
 Searches an existing index in the alien cargo of an aircraft, or returns the next free index of the alien cargo if the team definition wasn't found in the current alien cargo.
qboolean AL_AddAlienTypeToAircraftCargo (aircraft_t *aircraft, const teamDef_t *teamDef, int amount, qboolean dead)
 Adds an alientype to an aircraft cargo.
void AL_FillInContainment (base_t *base)
 Prepares Alien Containment - names, states, and zeroed amount.
const char * AL_AlienTypeToName (int teamDefIdx)
 Index of alien race to its name.
void AL_CollectingAliens (aircraft_t *aircraft)
 Collecting stunned aliens and alien bodies after the mission.
void AL_AddAliens (aircraft_t *aircraft)
 Puts alien cargo into Alien Containment.
void AL_RemoveAliens (base_t *base, const teamDef_t *alienType, int amount, const alienCalcType_t action)
 Removes alien(s) from Alien Containment.
static int AL_GetAlienIDX (const teamDef_t *alienType)
 Get index of alien.
int AL_GetAlienGlobalIDX (int idx)
 Returns global alien index.
int AL_GetAlienAmount (const teamDef_t *alienType, requirementType_t reqtype, const base_t *base)
 Get amount of live aliens or alien bodies stored in Containment.
int AL_CountInBase (const base_t *base)
 Counts live aliens in base.
void AL_ChangeAliveAlienNumber (base_t *base, aliensCont_t *containment, int num)
 Add / Remove live aliens to Alien Containment.
qboolean AL_CheckAliveFreeSpace (const base_t *base, const aliensCont_t *containment, const int num)
 Check if live aliens can be added/removed to Alien Containment.
int AL_CountAll (void)
 Counts live aliens in all bases.
void AC_KillAll (base_t *base)
 Kill all aliens in given base.
void AC_InitStartup (void)
 Defines commands and cvars for the alien containment menu(s).
qboolean AC_SaveXML (mxml_node_t *parent)
 Savecallback for saving in XML Format.
qboolean AC_LoadXML (mxml_node_t *parent)
 Load callback for savin in XML Format.
qboolean AC_ContainmentAllowed (const base_t *base)
 Returns true if the current base is able to handle captured aliens.

Detailed Description

Deals with the Alien Containment stuff.

Note:
Collecting and managing aliens functions prefix: AL_
Alien Containment menu functions prefix: AC_

Definition in file cp_aliencont.c.


Function Documentation

qboolean AC_ContainmentAllowed ( const base_t base  ) 

Returns true if the current base is able to handle captured aliens.

See also:
B_BaseInit_f
Note:
Alien cont. must be accessible during base attack to kill aliens.

Definition at line 791 of file cp_aliencont.c.

References B_ALIEN_CONTAINMENT, B_GetBuildingStatus(), qfalse, and qtrue.

Referenced by AC_SaveXML(), B_BaseInit_f(), B_BuildingOpenAfterClick(), CP_TransferOfAliensToOtherBaseNeeded(), and TR_TransferAliensFromMission_f().

void AC_InitStartup ( void   ) 

Defines commands and cvars for the alien containment menu(s).

See also:
UI_InitStartup

Definition at line 687 of file cp_aliencont.c.

References AC_InitCallbacks(), and Cmd_AddCommand().

Referenced by CP_InitStartup().

void AC_KillAll ( base_t base  ) 

Kill all aliens in given base.

Parameters:
[in] base The base in which you want to kill all aliens
See also:
AC_KillAll_f

Definition at line 601 of file cp_aliencont.c.

References AL_KILL, AL_RemoveAliens(), base_s::alienscont, aliensCont_s::amountAlive, ccs, i, ccs_s::numAliensTD, qfalse, and qtrue.

Referenced by AC_KillAll_f(), and B_UpdateOneBaseBuildingStatusOnDisable().

qboolean AC_LoadXML ( mxml_node_t parent  ) 
qboolean AC_SaveXML ( mxml_node_t parent  ) 
void AL_AddAliens ( aircraft_t aircraft  ) 
qboolean AL_AddAlienTypeToAircraftCargo ( aircraft_t aircraft,
const teamDef_t teamDef,
int  amount,
qboolean  dead 
)

Adds an alientype to an aircraft cargo.

Parameters:
[in] aircraft The aircraft that owns the alien cargo to add the alien race to
[in] teamDef The team definition of the alien race to add to the alien cargo container of the given aircraft
[in] amount The amount of aliens of the given race (teamDef ) that should be added to the alien cargo
[in] dead true for cases where the aliens should be added as dead to the alien cargo - false for living aliens
Todo:
Return false for cases where the alien race could not be added to the alien cargo of the aircraft
Returns:
Currently always true

Definition at line 72 of file cp_aliencont.c.

References AL_GetAircraftAlienCargo, AL_GetAircraftAlienCargoTypes, AL_GetCargoIndexForTeamDefintion(), AL_SetAircraftAlienCargoTypes, aliensTmp_s::amountAlive, aliensTmp_s::amountDead, qtrue, and aliensTmp_s::teamDef.

Referenced by AL_CollectingAliens(), and CL_AutoMissionAlienCollect().

const char* AL_AlienTypeToName ( int  teamDefIdx  ) 

Index of alien race to its name.

Parameters:
[in] teamDefIdx Index of alien race in teamDef array.
Returns:
name (untranslated) or NULL if no definition found.

Definition at line 133 of file cp_aliencont.c.

References Com_Printf(), csi, teamDef_s::name, csi_s::numTeamDefs, and csi_s::teamDef.

Referenced by TR_CargoList(), and TR_TransferSelect().

void AL_ChangeAliveAlienNumber ( base_t base,
aliensCont_t containment,
int  num 
)

Add / Remove live aliens to Alien Containment.

Parameters:
[in] base Pointer to the base where Alien Cont. should be checked.
[in] containment Pointer to the containment
[in] num Number of alien to be added/removed
Precondition:
free space has already been checked
Todo:
handle containment[j].amountDead++; in case the num is negative?

Definition at line 515 of file cp_aliencont.c.

References AL_CheckAliveFreeSpace(), AL_CountInBase(), aliensCont_s::amountAlive, B_ALIEN_CONTAINMENT, B_GetBuildingStatus(), CAP_ALIENS, base_s::capacities, Com_Error(), Com_Printf(), cap_maxcur_s::cur, ERR_DROP, and cap_maxcur_s::max.

Referenced by AL_AddAliens(), AL_RemoveAliens(), TR_CargoListSelect_f(), TR_EmptyTransferCargo(), TR_TransferListClear_f(), and TR_TransferListSelect_f().

qboolean AL_CheckAliveFreeSpace ( const base_t base,
const aliensCont_t containment,
const int  num 
)

Check if live aliens can be added/removed to Alien Containment.

Parameters:
[in] base Pointer to the base where Alien Cont. should be checked.
[in] containment Pointer to the containment (may be NULL when adding aliens or if you don't care about alien type of alien you're removing)
[in] num Number of alien to be added/removed
Returns:
qtrue if action may be performed in base

Definition at line 544 of file cp_aliencont.c.

References aliensCont_s::amountAlive, B_ALIEN_CONTAINMENT, B_GetBuildingStatus(), CAP_ALIENS, base_s::capacities, cap_maxcur_s::cur, cap_maxcur_s::max, qfalse, and qtrue.

Referenced by AL_AddAliens(), AL_ChangeAliveAlienNumber(), CP_TransferOfAliensToOtherBaseNeeded(), and TR_CheckAlien().

void AL_CollectingAliens ( aircraft_t aircraft  ) 

Collecting stunned aliens and alien bodies after the mission.

Parameters:
[in] aircraft Pointer to the aircraft with cargo.
See also:
CL_ParseResults
CL_GameAutoGo

Definition at line 148 of file cp_aliencont.c.

References AL_AddAlienTypeToAircraftCargo(), LE_GetNextInUse(), LE_IsActor(), LE_IsAlien, LE_IsDead, LE_IsStunned, qfalse, qtrue, and le_s::teamDef.

Referenced by GAME_CP_Results().

int AL_CountAll ( void   ) 

Counts live aliens in all bases.

Menu functions

Note:
This should be called whenever you add or remove
aliens from alien containment.
Returns:
amount of all live aliens stored in containments
See also:
B_AircraftReturnedToHomeBase
AC_Init_f

Definition at line 577 of file cp_aliencont.c.

References base_s::alienscont, aliensCont_s::amountAlive, B_ALIEN_CONTAINMENT, B_GetBuildingStatus(), B_GetFoundedBaseByIDX(), ccs, i, MAX_BASES, ccs_s::numAliensTD, and aliensCont_s::teamDef.

Referenced by RS_RequirementsMet().

int AL_CountInBase ( const base_t base  ) 

Counts live aliens in base.

Parameters:
[in] base Pointer to the base
Returns:
amount of all live aliens stored in containment
Note:
must not return 0 if hasBuilding[B_ALIEN_CONTAINMENT] is qfalse: used to update capacity
See also:
AL_ChangeAliveAlienNumber
B_ResetAllStatusAndCapacities_f

Definition at line 492 of file cp_aliencont.c.

References base_s::alienscont, aliensCont_s::amountAlive, ccs, ccs_s::numAliensTD, and aliensCont_s::teamDef.

Referenced by AL_ChangeAliveAlienNumber(), and B_ResetAllStatusAndCapacities().

void AL_FillInContainment ( base_t base  ) 

Prepares Alien Containment - names, states, and zeroed amount.

General Collecting aliens functions

Parameters:
[in] base Pointer to the base with AC.
See also:
B_BuildBase
AL_AddAliens

Definition at line 100 of file cp_aliencont.c.

References base_s::alienscont, aliensCont_s::amountAlive, aliensCont_s::amountDead, CAP_ALIENS, base_s::capacities, ccs, CHRSH_IsTeamDefAlien(), Com_DPrintf(), Com_Error(), csi, cap_maxcur_s::cur, DEBUG_CLIENT, ERR_DROP, i, technology_s::idx, teamDef_s::idx, MAX_ALIENCONT_CAP, teamDef_s::name, csi_s::numTeamDefs, td, aliensCont_s::teamDef, csi_s::teamDef, ccs_s::teamDefTechs, and aliensCont_s::tech.

Referenced by AC_LoadXML(), and B_BuildBase_f().

int AL_GetAlienAmount ( const teamDef_t alienType,
requirementType_t  reqtype,
const base_t base 
)

Get amount of live aliens or alien bodies stored in Containment.

Parameters:
[in] alienType The alien type to check for
[in] base The base to count in
[in] reqtype Requirement type (RS_LINK_ALIEN/RS_LINK_ALIEN_DEAD).
Returns:
Amount of desired alien/body.
See also:
RS_RequirementsMet
RS_CheckCollected

Definition at line 463 of file cp_aliencont.c.

References AL_GetAlienIDX(), base_s::alienscont, aliensCont_s::amountAlive, aliensCont_s::amountDead, RS_LINK_ALIEN, and RS_LINK_ALIEN_DEAD.

Referenced by RS_RequirementsMet().

int AL_GetAlienGlobalIDX ( int  idx  ) 

Returns global alien index.

Parameters:
[in] idx Alien index in Alien Containment.
Returns:
Global alien index in csi.teamDef array.
See also:
AL_GetAlienIDX

Definition at line 439 of file cp_aliencont.c.

References CHRSH_IsTeamDefAlien(), Com_Printf(), csi, i, csi_s::numTeamDefs, and csi_s::teamDef.

Referenced by TR_CargoList(), and TR_TransferSelect().

static int AL_GetAlienIDX ( const teamDef_t alienType  )  [static]

Get index of alien.

Parameters:
[in] alienType Pointer to alien type.
Returns:
Index of alien in alien containment (so less than ccs.numAliensTD)
Note:
It does NOT return the global team index from csi.teamDef array. That would be alienType->idx
See also:
RS_AssignTechLinks
AL_GetAlienGlobalIDX

Definition at line 417 of file cp_aliencont.c.

References CHRSH_IsTeamDefAlien(), Com_Printf(), csi, i, teamDef_s::id, csi_s::numTeamDefs, and csi_s::teamDef.

Referenced by AL_GetAlienAmount().

static int AL_GetCargoIndexForTeamDefintion ( const aircraft_t aircraft,
const teamDef_t teamDef 
) [inline, static]

Searches an existing index in the alien cargo of an aircraft, or returns the next free index of the alien cargo if the team definition wasn't found in the current alien cargo.

Collecting aliens functions for aircraft

Parameters:
[in] aircraft The aircraft that should have the given team definition in its alien cargo
[in] teamDef The team definition that should be searched for
Returns:
The index of the team definition in the alien cargo of the given aircraft

Definition at line 44 of file cp_aliencont.c.

References AL_GetAircraftAlienCargo, AL_GetAircraftAlienCargoTypes, i, MAX_CARGO, and aliensTmp_s::teamDef.

Referenced by AL_AddAlienTypeToAircraftCargo().

void AL_RemoveAliens ( base_t base,
const teamDef_t alienType,
int  amount,
const alienCalcType_t  action 
)

Removes alien(s) from Alien Containment.

Parameters:
[in,out] base Pointer to the base where we will perform action (remove, add, ... aliens).
[in] alienType Type of the alien (a teamDef_t pointer)
[in] amount Amount of aliens to be removed.
[in] action Type of action (see alienCalcType_t).
See also:
AC_KillAll_f
AC_KillOne_f
Note:
Call with NULL name when no matters what type to remove.
Todo:
integrate this with research system

Definition at line 296 of file cp_aliencont.c.

References AL_ChangeAliveAlienNumber(), AL_KILL, AL_KILLONE, AL_RESEARCH, base_s::alienscont, aliensCont_s::amountAlive, aliensCont_s::amountDead, ccs, Com_Printf(), ccs_s::numAliensTD, and Sys_Error().

Referenced by AC_KillAll(), AC_KillOne_f(), and B_BuildingOnDestroy_f().


Generated by  doxygen 1.6.2