cl_team.c File Reference

Team management, name generation and parsing. More...

#include "client.h"
#include "cl_game.h"
#include "cl_team.h"
#include "battlescape/cl_localentity.h"
#include "battlescape/cl_actor.h"
#include "cl_inventory.h"
#include "battlescape/events/e_parse.h"
#include "ui/ui_data.h"
#include "ui/ui_nodes.h"
#include "battlescape/events/e_main.h"
#include "campaign/save/save_character.h"
#include "campaign/save/save_inventory.h"
Include dependency graph for cl_team.c:

Go to the source code of this file.

Functions

customSkin_tCom_AllocateCustomSkin (void)
 Allocate a skin from the cls structure.
static customSkin_tCom_GetCustomSkinByIDS (int idx)
 Get a customskin from idx.
static const char * CL_GetTeamSkinName (int id)
 Translate the skin id to skin name.
static void CL_CharacterSkillAndScoreCvars (const character_t *chr, const char *cvarPrefix)
static void CL_ActorCvars (const character_t *chr, const char *cvarPrefix)
 Updates the character cvars for the given character.
static void CL_UGVCvars (const character_t *chr)
 Updates the UGV cvars for the given "character".
void CL_UpdateCharacterValues (const character_t *chr, const char *cvarPrefix)
qboolean CL_SaveCharacterXML (mxml_node_t *p, const character_t *chr)
 saves a character to a given xml node
qboolean CL_LoadCharacterXML (mxml_node_t *p, character_t *chr)
 Loads a character from a given xml node.
static void CL_SaveItemXML (mxml_node_t *p, item_t item, containerIndex_t container, int x, int y)
 Save one item.
void CL_SaveInventoryXML (mxml_node_t *p, const inventory_t *i)
 Save callback for savegames in XML Format.
static void CL_LoadItemXML (mxml_node_t *n, item_t *item, containerIndex_t *container, int *x, int *y)
 Load one item.
void CL_LoadInventoryXML (mxml_node_t *p, inventory_t *i)
 Load callback for savegames in XML Format.
void CL_GenerateCharacter (character_t *chr, const char *teamDefName)
 Generates the skills and inventory for a character and for a 2x2 unit.
static void CL_InitSkin_f (void)
 Init skins into the GUI.
static int CL_FixCustomSkinIDX (int idx)
 Fix customskin idx accoding to game mode.
static void CL_ChangeSkin_f (void)
 Change the skin of the selected actor.
static void CL_ChangeSkinForWholeTeam_f (void)
 Use current skin for all team members onboard.
void TEAM_InitStartup (void)

Variables

chrList_t chrDisplayList
 List of currently displayed or equipeable characters.

Detailed Description

Team management, name generation and parsing.

Definition in file cl_team.c.


Function Documentation

static void CL_ActorCvars ( const character_t chr,
const char *  cvarPrefix 
) [static]

Updates the character cvars for the given character.

The models and stats that are displayed in the menu are stored in cvars. These cvars are updated here when you select another character.

Parameters:
[in] chr Pointer to character_t (may not be null)
[in] cvarPrefix 
See also:
CL_UGVCvars
CL_ActorSelect

Definition at line 138 of file cl_team.c.

References Cvar_Set(), invList_s::item, LEFT, objDef_s::model, RIGHT, item_s::t, and va().

Referenced by CL_UpdateCharacterValues().

static void CL_ChangeSkin_f ( void   )  [static]

Change the skin of the selected actor.

Todo:
Get the skin id from the model by using the customskin id
Todo:
Or remove skins from models and convert character_t->skin to string

Definition at line 545 of file cl_team.c.

References chr_list_s::chr, CL_FixCustomSkinIDX(), CL_GetTeamSkinName(), cl_selected, Cvar_GetInteger(), Cvar_Set(), Cvar_SetValue(), cvar_s::integer, chr_list_s::num, and character_s::skin.

Referenced by TEAM_InitStartup().

static void CL_ChangeSkinForWholeTeam_f ( void   )  [static]

Use current skin for all team members onboard.

Todo:
What happens if a model of a team member does not have the selected skin?
Todo:
Get the skin id from the model by using the customskin id
Todo:
Or remove skins from models and convert character_t->skin to string

Definition at line 567 of file cl_team.c.

References chr_list_s::chr, CL_FixCustomSkinIDX(), Cvar_GetInteger(), i, chr_list_s::num, and character_s::skin.

Referenced by TEAM_InitStartup().

static void CL_CharacterSkillAndScoreCvars ( const character_t chr,
const char *  cvarPrefix 
) [static]
static int CL_FixCustomSkinIDX ( int  idx  )  [static]

Fix customskin idx accoding to game mode.

TODO we should check somewhere there is at least 1 skin

Definition at line 526 of file cl_team.c.

References Com_GetCustomSkinByIDS(), GAME_IsMultiplayer, GAME_IsSingleplayer, customSkin_s::multiplayer, and customSkin_s::singleplayer.

Referenced by CL_ChangeSkin_f(), and CL_ChangeSkinForWholeTeam_f().

void CL_GenerateCharacter ( character_t chr,
const char *  teamDefName 
)

Generates the skills and inventory for a character and for a 2x2 unit.

Parameters:
[in] chr The employee to create character data for.
[in] teamDefName Which team to use for creation.

Definition at line 474 of file cl_team.c.

References ACTOR_HAND_NOT_SET, CHRSH_CharGenAbilitySkills(), CL_ActorSetShotSettings(), cls, Com_GetCharacterValues(), inventoryInterface_s::DestroyInventory, GAME_IsMultiplayer, character_s::i, client_static_s::i, client_static_s::nextUniqueCharacterNumber, and character_s::ucn.

Referenced by E_CreateEmployeeAtIndex(), and GAME_AppendTeamMember().

static const char* CL_GetTeamSkinName ( int  id  )  [static]

Translate the skin id to skin name.

Parameters:
[in] id The id of the skin
Returns:
Translated skin name

Definition at line 78 of file cl_team.c.

References Com_Error(), Com_GetCustomSkinByIDS(), ERR_DROP, and customSkin_s::name.

Referenced by CL_ChangeSkin_f(), and CL_CharacterSkillAndScoreCvars().

static void CL_InitSkin_f ( void   )  [static]
qboolean CL_LoadCharacterXML ( mxml_node_t p,
character_t chr 
)

Loads a character from a given xml node.

Parameters:
[in] p The node from which we should load the character.
[in] chr Pointer to the charcter we should load.

Definition at line 264 of file cl_team.c.

References chrScoreGlobal_s::assignedMissions, character_s::body, CL_LoadInventoryXML(), cls, Com_GetConstIntFromNamespace(), Com_GetTeamDefinitionByID(), Com_Printf(), Com_RegisterConstList(), Com_UnregisterConstList(), inventoryInterface_s::DestroyInventory, chrScoreGlobal_s::experience, character_s::fieldSize, character_s::gender, character_s::head, character_s::HP, character_s::i, client_static_s::i, chrScoreGlobal_s::initialSkills, chrScoreGlobal_s::kills, character_s::maxHP, character_s::morale, mxml_GetInt(), mxml_GetNextNode(), mxml_GetNode(), mxml_GetString(), character_s::name, character_s::path, Q_strncpyz(), qfalse, qtrue, chrScoreGlobal_s::rank, SAVE_CHARACTER_BODY, SAVE_CHARACTER_EXPERIENCE, SAVE_CHARACTER_FIELDSIZE, SAVE_CHARACTER_GENDER, SAVE_CHARACTER_HEAD, SAVE_CHARACTER_HP, SAVE_CHARACTER_INITSKILL, SAVE_CHARACTER_KILLED, SAVE_CHARACTER_KILLS, SAVE_CHARACTER_KILLTYPE, SAVE_CHARACTER_KILLTYPE_NAMESPACE, SAVE_CHARACTER_MAXHP, SAVE_CHARACTER_MORALE, SAVE_CHARACTER_NAME, SAVE_CHARACTER_PATH, SAVE_CHARACTER_SCORE_ASSIGNEDMISSIONS, SAVE_CHARACTER_SCORE_RANK, SAVE_CHARACTER_SCORES, SAVE_CHARACTER_SKILLIMPROVE, SAVE_CHARACTER_SKILLS, SAVE_CHARACTER_SKILLTYPE, SAVE_CHARACTER_SKILLTYPE_NAMESPACE, SAVE_CHARACTER_SKIN, SAVE_CHARACTER_STATE, SAVE_CHARACTER_STUN, SAVE_CHARACTER_STUNNED, SAVE_CHARACTER_TEAMDEF, SAVE_CHARACTER_UCN, SAVE_INVENTORY_INVENTORY, saveCharacterConstants, character_s::score, SKILL_NUM_TYPES, chrScoreGlobal_s::skills, character_s::skin, character_s::state, character_s::STUN, chrScoreGlobal_s::stuns, character_s::teamDef, type, and character_s::ucn.

Referenced by E_LoadXML(), and MP_LoadTeamMultiplayerInfo().

void CL_LoadInventoryXML ( mxml_node_t p,
inventory_t i 
)

Load callback for savegames in XML Format.

Parameters:
[in] p XML Node structure, where we load the information from
[out] i Pointerto the inventory
See also:
CL_SaveInventoryXML
CL_LoadItemXML
I_AddToInventory

Definition at line 454 of file cl_team.c.

References inventoryInterface_s::AddToInventory, CL_LoadItemXML(), cls, Com_Printf(), client_static_s::i, objDef_s::id, INVDEF, mxml_GetNextNode(), mxml_GetNode(), SAVE_INVENTORY_ITEM, and item_s::t.

Referenced by CL_LoadCharacterXML().

static void CL_LoadItemXML ( mxml_node_t n,
item_t item,
containerIndex_t container,
int *  x,
int *  y 
) [static]

Load one item.

Parameters:
[in] p XML Node structure, where we write the information to
[out] item Pointer to the item
[out] container Index of the container the item is in
[out] x Horizontal coordinate of the item in the container
[out] y Vertical coordinate of the item in the container
See also:
CL_SaveItemXML

Definition at line 412 of file cl_team.c.

References item_s::a, item_s::amount, Com_Printf(), csi, i, csi_s::ids, INVSH_GetItemByID(), item_s::m, mxml_GetInt(), mxml_GetString(), invDef_s::name, NONE_AMMO, csi_s::numIDs, item_s::rotated, SAVE_INVENTORY_AMMO, SAVE_INVENTORY_AMOUNT, SAVE_INVENTORY_CONTAINER, SAVE_INVENTORY_MUNITIONID, SAVE_INVENTORY_ROTATED, SAVE_INVENTORY_WEAPONID, SAVE_INVENTORY_X, SAVE_INVENTORY_Y, and item_s::t.

Referenced by CL_LoadInventoryXML().

qboolean CL_SaveCharacterXML ( mxml_node_t p,
const character_t chr 
)

saves a character to a given xml node

Parameters:
[in] p The node to which we should save the character
[in] chr The charcter we should save

Definition at line 192 of file cl_team.c.

References chrScoreGlobal_s::assignedMissions, character_s::body, CL_SaveInventoryXML(), Com_GetConstVariable(), Com_RegisterConstList(), Com_UnregisterConstList(), chrScoreGlobal_s::experience, character_s::fieldSize, character_s::gender, character_s::head, character_s::HP, character_s::i, teamDef_s::id, chrScoreGlobal_s::initialSkills, KILLED_NUM_TYPES, chrScoreGlobal_s::kills, character_s::maxHP, character_s::morale, mxml_AddInt(), mxml_AddIntValue(), mxml_AddNode(), mxml_AddString(), character_s::name, character_s::path, qtrue, chrScoreGlobal_s::rank, SAVE_CHARACTER_BODY, SAVE_CHARACTER_EXPERIENCE, SAVE_CHARACTER_FIELDSIZE, SAVE_CHARACTER_GENDER, SAVE_CHARACTER_HEAD, SAVE_CHARACTER_HP, SAVE_CHARACTER_INITSKILL, SAVE_CHARACTER_KILLED, SAVE_CHARACTER_KILLS, SAVE_CHARACTER_KILLTYPE, SAVE_CHARACTER_KILLTYPE_NAMESPACE, SAVE_CHARACTER_MAXHP, SAVE_CHARACTER_MORALE, SAVE_CHARACTER_NAME, SAVE_CHARACTER_PATH, SAVE_CHARACTER_SCORE_ASSIGNEDMISSIONS, SAVE_CHARACTER_SCORE_RANK, SAVE_CHARACTER_SCORES, SAVE_CHARACTER_SKILLIMPROVE, SAVE_CHARACTER_SKILLS, SAVE_CHARACTER_SKILLTYPE, SAVE_CHARACTER_SKILLTYPE_NAMESPACE, SAVE_CHARACTER_SKIN, SAVE_CHARACTER_STATE, SAVE_CHARACTER_STUN, SAVE_CHARACTER_STUNNED, SAVE_CHARACTER_TEAMDEF, SAVE_CHARACTER_UCN, SAVE_INVENTORY_INVENTORY, saveCharacterConstants, character_s::score, SKILL_NUM_TYPES, chrScoreGlobal_s::skills, character_s::skin, character_s::state, character_s::STUN, chrScoreGlobal_s::stuns, character_s::teamDef, and character_s::ucn.

Referenced by E_SaveXML(), and MP_SaveTeamMultiplayerInfo().

void CL_SaveInventoryXML ( mxml_node_t p,
const inventory_t i 
)

Save callback for savegames in XML Format.

Parameters:
[out] p XML Node structure, where we write the information to
[in] i Pointerto the inventory to save
See also:
CL_SaveItemXML
CL_LoadInventoryXML

Definition at line 385 of file cl_team.c.

References inventory_s::c, CL_SaveItemXML(), csi, INVDEF, invList_s::item, mxml_AddNode(), invList_s::next, csi_s::numIDs, SAVE_INVENTORY_ITEM, invList_s::x, and invList_s::y.

Referenced by CL_SaveCharacterXML().

static void CL_SaveItemXML ( mxml_node_t p,
item_t  item,
containerIndex_t  container,
int  x,
int  y 
) [static]

Save one item.

Parameters:
[out] p XML Node structure, where we write the information to
[in] item Pointer to the item to save
[in] container Index of the container the item is in
[in] x Horizontal coordinate of the item in the container
[in] y Vertical coordinate of the item in the container
See also:
CL_LoadItemXML

Todo:
: is there any case when amount != 1 for soldier inventory item?

Definition at line 361 of file cl_team.c.

References item_s::a, item_s::amount, csi, objDef_s::id, csi_s::ids, item_s::m, mxml_AddInt(), mxml_AddIntValue(), mxml_AddString(), invDef_s::name, NONE_AMMO, item_s::rotated, SAVE_INVENTORY_AMMO, SAVE_INVENTORY_AMOUNT, SAVE_INVENTORY_CONTAINER, SAVE_INVENTORY_MUNITIONID, SAVE_INVENTORY_ROTATED, SAVE_INVENTORY_WEAPONID, SAVE_INVENTORY_X, SAVE_INVENTORY_Y, and item_s::t.

Referenced by CL_SaveInventoryXML().

static void CL_UGVCvars ( const character_t chr  )  [static]

Updates the UGV cvars for the given "character".

The models and stats that are displayed in the menu are stored in cvars. These cvars are updated here when you select another character.

Parameters:
[in] chr Pointer to character_t (may not be null)
[in] cvarPrefix 
See also:
CL_ActorCvars
CL_ActorSelect

Definition at line 167 of file cl_team.c.

References ABILITY_MIND, CL_ActorGetSkillString(), Cvar_Set(), character_s::score, chrScoreGlobal_s::skills, and va().

Referenced by CL_UpdateCharacterValues().

void CL_UpdateCharacterValues ( const character_t chr,
const char *  cvarPrefix 
)
customSkin_t* Com_AllocateCustomSkin ( void   ) 

Allocate a skin from the cls structure.

Returns:
A customskin structure, only idx is initialized

Definition at line 46 of file cl_team.c.

References cls, client_static_s::customSkins, customSkin_s::idx, lengthof, client_static_s::numCustomSkins, and Sys_Error().

Referenced by CL_ParseCustomSkin().

static customSkin_t* Com_GetCustomSkinByIDS ( int  idx  )  [static]

Get a customskin from idx.

Returns:
A customskin, else NULL

Definition at line 66 of file cl_team.c.

References cls, client_static_s::customSkins, and client_static_s::numCustomSkins.

Referenced by CL_FixCustomSkinIDX(), CL_GetTeamSkinName(), and CL_InitSkin_f().

void TEAM_InitStartup ( void   ) 

Definition at line 585 of file cl_team.c.

References CL_ChangeSkin_f(), CL_ChangeSkinForWholeTeam_f(), CL_InitSkin_f(), and Cmd_AddCommand().

Referenced by CL_InitLocal().


Variable Documentation


Generated by  doxygen 1.6.2