cp_installation.c File Reference

Handles everything that is located in or accessed through an installation. More...

#include "../cl_shared.h"
#include "../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_mapfightequip.h"
#include "cp_aircraft.h"
#include "cp_missions.h"
#include "cp_map.h"
#include "cp_ufo.h"
#include "cp_installation.h"
#include "cp_installation_callbacks.h"
#include "save/save_installation.h"
Include dependency graph for cp_installation.c:

Go to the source code of this file.

Functions

installationType_t INS_GetType (const installation_t *installation)
 Get the type of an installation.
installation_tINS_GetInstallationByIDX (int instIdx)
 Array bound check for the installation index.
installation_tINS_GetFoundedInstallationByIDX (int instIdx)
 Array bound check for the installation index.
installationTemplate_tINS_GetInstallationTemplateFromInstallationID (const char *id)
 Returns the installation Template for a given installation ID.
void INS_SetUpInstallation (installation_t *installation, installationTemplate_t *installationTemplate, vec2_t pos)
 Setup new installation.
installation_tINS_GetFirstUnfoundedInstallation (void)
 Get first not yet founded installation.
void INS_DestroyInstallation (installation_t *installation)
 Destroys an installation.
installation_tINS_GetCurrentSelectedInstallation (void)
 Returns the current selected installation.
void INS_SetCurrentSelectedInstallation (const installation_t *installation)
 Sets the currently selected intallation.
static void INS_FinishInstallation (installation_t *installation)
 Finishes an installation.
installation_tINS_GetFirstUFOYard (qboolean free)
 returns the first installation with (free) ufostoring capacity
void INS_InitStartup (void)
 Resets console commands.
void INS_UpdateInstallationData (void)
 Check if some installation are build.
void INS_ParseInstallations (const char *name, const char **text)
 Copies an entry from the installation description file into the list of installation templates.
qboolean INS_SaveXML (mxml_node_t *p)
 Save callback for savegames in xml.
qboolean INS_LoadXML (mxml_node_t *p)
 Load callback for savegames.

Variables

static const value_t installation_vals []

Detailed Description

Handles everything that is located in or accessed through an installation.

Note:
Installation functions prefix: INS_*

Definition in file cp_installation.c.


Function Documentation

void INS_DestroyInstallation ( installation_t installation  ) 
static void INS_FinishInstallation ( installation_t installation  )  [static]
installation_t* INS_GetCurrentSelectedInstallation ( void   ) 
installation_t* INS_GetFirstUFOYard ( qboolean  free  ) 

returns the first installation with (free) ufostoring capacity

Parameters:
[in] free On qtrue it gives the first UFO Yard with free space
Returns:
installation_t Pointer to the UFO Yard

Definition at line 335 of file cp_installation.c.

References ccs, cap_maxcur_s::cur, INS_GetFoundedInstallationByIDX(), INS_GetType(), INSTALLATION_UFOYARD, cap_maxcur_s::max, ccs_s::numInstallations, and installation_s::ufoCapacity.

installation_t* INS_GetFirstUnfoundedInstallation ( void   ) 

Get first not yet founded installation.

Returns:
installation Pointer to the first unfounded installation
Note:
it returns NULL if installation limit has reached

Definition at line 141 of file cp_installation.c.

References B_GetInstallationLimit(), ccs, INS_GetInstallationByIDX(), and ccs_s::numInstallations.

Referenced by INS_BuildInstallation_f().

installation_t* INS_GetFoundedInstallationByIDX ( int  instIdx  ) 
installation_t* INS_GetInstallationByIDX ( int  instIdx  ) 

Array bound check for the installation index.

Parameters:
[in] instIdx Instalation's index
Returns:
Pointer to the installation corresponding to instIdx.

Definition at line 61 of file cp_installation.c.

References ccs, ccs_s::installations, and MAX_INSTALLATIONS.

Referenced by CP_LoadMissionsXML(), INS_GetCurrentSelectedInstallation(), INS_GetFirstUnfoundedInstallation(), INS_GetFoundedInstallationByIDX(), INS_LoadXML(), INS_SaveXML(), and INS_SetCurrentSelectedInstallation().

installationTemplate_t* INS_GetInstallationTemplateFromInstallationID ( const char *  id  ) 

Returns the installation Template for a given installation ID.

Parameters:
[in] id ID of the installation template to find.
Returns:
corresponding installation Template, NULL if not found.

Definition at line 89 of file cp_installation.c.

References ccs, installationTemplate_s::id, ccs_s::installationTemplates, and ccs_s::numInstallationTemplates.

Referenced by INS_BuildInstallation_f(), INS_LoadXML(), and INS_SetInstallationTitle().

installationType_t INS_GetType ( const installation_t installation  ) 

Get the type of an installation.

Parameters:
[in] installation Pointer to the isntallation
Returns:
type of the installation
See also:
installationType_t

Definition at line 45 of file cp_installation.c.

References INSTALLATION_DEFENCE, INSTALLATION_RADAR, INSTALLATION_UFOYARD, installation_s::installationTemplate, installationTemplate_s::maxBatteries, and installationTemplate_s::maxUFOsStored.

Referenced by INS_GetFirstUFOYard().

void INS_InitStartup ( void   ) 
qboolean INS_LoadXML ( mxml_node_t p  ) 

Load callback for savegames.

Parameters:
[in] p XML Node structure, where we get the information from
See also:
INS_SaveXML
SAV_GameLoadXML
INS_LoadItemSlots

Definition at line 576 of file cp_installation.c.

References installation_s::alienInterest, B_LoadBaseSlotsXML(), installation_s::batteries, BDEF_InitialiseInstallationSlots(), installation_s::buildStart, ccs, Com_GetConstIntFromNamespace(), Com_Printf(), Com_RegisterConstList(), Com_UnregisterConstList(), cap_maxcur_s::cur, Cvar_Set(), installation_s::founded, installation_s::idx, INS_GetInstallationByIDX(), INS_GetInstallationIDX, INS_GetInstallationTemplateFromInstallationID(), INSTALLATION_WORKING, installation_s::installationDamage, installation_s::installationStatus, installation_s::installationTemplate, cap_maxcur_s::max, MAX_INSTALLATIONS, installationTemplate_s::maxBatteries, installationTemplate_s::maxUFOsStored, mxml_GetFloat(), mxml_GetInt(), mxml_GetNextNode(), mxml_GetNode(), mxml_GetPos3(), mxml_GetString(), installation_s::name, installation_s::numBatteries, ccs_s::numInstallations, installation_s::pos, Q_strncpyz(), qfalse, qtrue, installation_s::radar, RADAR_Initialise(), RADAR_InitialiseUFOs(), RADAR_UpdateInstallationRadarCoverage(), installationTemplate_s::radarRange, SAVE_INSTALLATION_ALIENINTEREST, SAVE_INSTALLATION_BATTERIES, SAVE_INSTALLATION_BUILDSTART, SAVE_INSTALLATION_DAMAGE, SAVE_INSTALLATION_INSTALLATION, SAVE_INSTALLATION_INSTALLATIONS, SAVE_INSTALLATION_NAME, SAVE_INSTALLATION_NUM, SAVE_INSTALLATION_POS, SAVE_INSTALLATION_STATUS, SAVE_INSTALLATION_TEMPLATEID, SAVE_INSTALLATIONSTATUS_NAMESPACE, saveInstallationConstants, installationTemplate_s::trackingRange, installation_s::ufoCapacity, and va().

Referenced by SAV_Init().

void INS_ParseInstallations ( const char *  name,
const char **  text 
)

Copies an entry from the installation description file into the list of installation templates.

Note:
Parses one "installation" entry in the installation.ufo file and writes it into the next free entry in installationTemplates.
Parameters:
[in] name Unique test-id of a installationTemplate_t.
[in] text the rest of the script file that is tokenized here

Definition at line 430 of file cp_installation.c.

References _, installationTemplate_s::buildTime, ccs, Com_DPrintf(), Com_EParse(), Com_EParseValue(), Com_Parse(), Com_Printf(), Com_sprintf(), installationTemplate_s::cost, cp_campaignPool, Cvar_Set(), DEBUG_CLIENT, installationTemplate_s::id, ccs_s::installationTemplates, MAX_INSTALLATION_TEMPLATES, MAX_VAR, Mem_PoolStrDup, Mem_PoolStrDupTo, installationTemplate_s::name, ngettext, ccs_s::numInstallationTemplates, value_s::ofs, Q_strcat(), value_s::size, value_s::string, value_s::type, V_CLIENT_HUNK_STRING, V_TRANSLATION_STRING, and va().

Referenced by CL_ParseScriptFirst().

qboolean INS_SaveXML ( mxml_node_t p  ) 
void INS_SetCurrentSelectedInstallation ( const installation_t installation  ) 
void INS_SetUpInstallation ( installation_t installation,
installationTemplate_t installationTemplate,
vec2_t  pos 
)
void INS_UpdateInstallationData ( void   ) 

Variable Documentation

const value_t installation_vals[] [static]
Initial value:
 {
    {"name", V_TRANSLATION_STRING, offsetof(installationTemplate_t, name), 0},
    {"description", V_TRANSLATION_STRING, offsetof(installationTemplate_t, description), 0},
    {"radar_range", V_INT, offsetof(installationTemplate_t, radarRange), MEMBER_SIZEOF(installationTemplate_t, radarRange)},
    {"radar_tracking_range", V_INT, offsetof(installationTemplate_t, trackingRange), MEMBER_SIZEOF(installationTemplate_t, trackingRange)},
    {"max_batteries", V_INT, offsetof(installationTemplate_t, maxBatteries), MEMBER_SIZEOF(installationTemplate_t, maxBatteries)},
    {"max_ufo_stored", V_INT, offsetof(installationTemplate_t, maxUFOsStored), MEMBER_SIZEOF(installationTemplate_t, maxUFOsStored)},
    {"max_damage", V_INT, offsetof(installationTemplate_t, maxDamage), MEMBER_SIZEOF(installationTemplate_t, maxDamage)},
    {"model", V_CLIENT_HUNK_STRING, offsetof(installationTemplate_t, model), 0},
    {"image", V_CLIENT_HUNK_STRING, offsetof(installationTemplate_t, image), 0},

    {NULL, 0, 0, 0}
}

Definition at line 409 of file cp_installation.c.


Generated by  doxygen 1.6.2