UFO: Alien Invasion
Loading...
Searching...
No Matches
cl_game_team.cpp File Reference

cgame team management. More...

#include "../client.h"
#include "cl_game.h"
#include "cl_game_team.h"
#include "../cl_inventory.h"
#include "../../shared/parse.h"
#include "../cl_team.h"
#include "../ui/ui_main.h"
#include "../ui/ui_popup.h"
#include "../ui/node/ui_node_container.h"
#include "save_team.h"
#include "save_character.h"
#include "save_inventory.h"
Include dependency graph for cl_game_team.cpp:

Go to the source code of this file.

Data Structures

struct  teamSaveFileHeader_t

Macros

#define TEAM_SAVE_FILE_VERSION   4

Functions

static void GAME_UpdateActiveTeamList (void)
void GAME_AutoTeam (const char *equipmentDefinitionID, int teamMembers)
void GAME_AutoTeam_f (void)
void GAME_ToggleActorForTeam_f (void)
 This will activate/deactivate the actor for the team.
void GAME_SaveTeamState_f (void)
 Will remove those actors that should not be used in the team.
void GAME_TeamDelete_f (void)
 Removes a user created team.
void GAME_TeamSlotComments_f (void)
 Reads the comments from team files.
static void GAME_SaveTeamInfo (xmlNode_t *p)
 Stores the wholeTeam into a xml structure.
static void GAME_LoadTeamInfo (xmlNode_t *p)
 Loads the wholeTeam from the xml file.
static bool GAME_SaveTeam (const char *filename, const char *name)
 Saves a team in xml format.
bool GAME_TeamGetFreeFilename (char *filename, size_t size)
 Searches a free team filename.
void GAME_SaveTeam_f (void)
 Stores a team in a specified teamslot.
static bool GAME_LoadTeam (const char *filename)
 Load a team from an xml file.
bool GAME_GetTeamFileName (unsigned int index, char *filename, size_t filenameLength)
 Get the filename for the xth team in the file system.
bool GAME_LoadDefaultTeam (bool force)
void GAME_LoadTeam_f (void)
 Loads the selected teamslot.
static void GAME_UpdateInventory (Inventory *inv, const equipDef_t *ed)
static void GAME_GetEquipment (void)
 Get the equipment definition (from script files) for the current selected team and updates the equipment inventory containers.
void GAME_UpdateTeamMenuParameters_f (void)
 Displays actor info and equipment and unused items in proper (filter) category.
void GAME_ActorSelect_f (void)
static void GAME_SaveItem (xmlNode_t *p, const Item *item, containerIndex_t container, int x, int y)
 Save one item.
static void GAME_SaveInventory (xmlNode_t *p, const Inventory *inv)
 Save callback for savegames in XML Format.
static bool GAME_LoadItem (xmlNode_t *n, Item *item, containerIndex_t *container, int *x, int *y)
 Load one item.
static void GAME_LoadInventory (xmlNode_t *p, Inventory *inv, int maxLoad)
 Load callback for savegames in XML Format.
bool GAME_SaveCharacter (xmlNode_t *p, const character_t *chr)
 saves a character to a given xml node
bool GAME_LoadCharacter (xmlNode_t *p, character_t *chr)
 Loads a character from a given xml node.

Variables

static Inventory game_inventory
static bool characterActive [MAX_ACTIVETEAM]

Detailed Description

cgame team management.

Definition in file cl_game_team.cpp.

Macro Definition Documentation

◆ TEAM_SAVE_FILE_VERSION

#define TEAM_SAVE_FILE_VERSION   4

< ui_inventory

Definition at line 39 of file cl_game_team.cpp.

Referenced by GAME_LoadTeam(), GAME_SaveTeam(), and GAME_TeamSlotComments_f().

Function Documentation

◆ GAME_ActorSelect_f()

◆ GAME_AutoTeam()

void GAME_AutoTeam ( const char * equipmentDefinitionID,
int teamMembers )

◆ GAME_AutoTeam_f()

◆ GAME_GetEquipment()

void GAME_GetEquipment ( void )
static

Get the equipment definition (from script files) for the current selected team and updates the equipment inventory containers.

Definition at line 494 of file cl_game_team.cpp.

References Cvar_GetString(), GAME_GetEquipmentDefinition(), game_inventory, GAME_UpdateInventory(), and INV_GetEquipmentDefinitionByID().

Referenced by GAME_UpdateTeamMenuParameters_f().

◆ GAME_GetTeamFileName()

bool GAME_GetTeamFileName ( unsigned int index,
char * filename,
size_t filenameLength )

Get the filename for the xth team in the file system.

Note
We are only dealing with indices to identify a team, thus we have to loop the team list each time we need a filename of a team.
Parameters
[in]indexThe index of the team we are looking for in the filesystem
[out]filenameThe filename of the team. This value is only set or valid if this function returned true.
[in]filenameLengthThe length of the filename buffer.
Returns
true if the filename for the given index was found, false otherwise (e.g. invalid index)

Definition at line 410 of file cl_game_team.cpp.

References Com_DPrintf(), Com_sprintf(), DEBUG_CLIENT, FS_BuildFileList(), FS_NextFileFromFileList(), GAME_GetRelativeSavePath(), index, and MAX_OSPATH.

Referenced by GAME_LoadDefaultTeam(), and GAME_LoadTeam_f().

◆ GAME_LoadCharacter()

bool GAME_LoadCharacter ( xmlNode_t * p,
character_t * chr )

Loads a character from a given xml node.

Parameters
[in]pThe node from which we should load the character.
[in]chrPointer to the character we should load.
Todo
Fallback compatibility code for older saves

Definition at line 782 of file cl_game_team.cpp.

References chrScoreGlobal_t::assignedMissions, character_t::body, character_t::bodySkin, teamDef_t::bodyTemplate, CHRSH_CharGetBody(), CHRSH_CharGetHead(), CL_GetActorSkinCount(), cls, Com_GetCharacterModel(), Com_GetConstIntFromNamespace(), Com_GetTeamDefinitionByID(), Com_Printf(), Com_RegisterConstList(), Com_UnregisterConstList(), implant_t::def, chrScoreGlobal_t::experience, character_t::fieldSize, GAME_GetChrMaxLoad(), GAME_LoadInventory(), character_t::gender, character_t::head, character_t::headSkin, character_t::HP, BodyData::id(), character_t::implants, chrScoreGlobal_t::initialSkills, implant_t::installedTime, character_t::inv, INVSH_GetImplantByID(), chrScoreGlobal_t::kills, character_t::maxHP, character_t::morale, character_t::name, NONE, BodyData::numBodyParts(), character_t::path, Q_streq, Q_strncpyz(), R_ModelExists(), chrScoreGlobal_t::rank, implant_t::removedTime, SAVE_CHARACTER_BDOY_SKIN, SAVE_CHARACTER_BODY, SAVE_CHARACTER_EXPERIENCE, SAVE_CHARACTER_FIELDSIZE, SAVE_CHARACTER_GENDER, SAVE_CHARACTER_HEAD, SAVE_CHARACTER_HEAD_SKIN, SAVE_CHARACTER_HP, SAVE_CHARACTER_IMPLANT, SAVE_CHARACTER_IMPLANT_IMPLANT, SAVE_CHARACTER_IMPLANT_INSTALLEDTIME, SAVE_CHARACTER_IMPLANT_REMOVETIME, SAVE_CHARACTER_IMPLANTS, SAVE_CHARACTER_INITSKILL, SAVE_CHARACTER_INJURIES, 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_STATE, SAVE_CHARACTER_STUN, SAVE_CHARACTER_STUNNED, SAVE_CHARACTER_TEAMDEF, SAVE_CHARACTER_UCN, SAVE_CHARACTER_WOUND, SAVE_CHARACTER_WOUNDEDPART, SAVE_CHARACTER_WOUNDSEVERITY, SAVE_CHARACTER_WOUNDTYPE, SAVE_INVENTORY_INVENTORY, saveCharacterConstants, character_t::score, SKILL_NUM_TYPES, chrScoreGlobal_t::skills, character_t::state, character_t::STUN, chrScoreGlobal_t::stuns, character_t::teamDef, woundInfo_t::treatmentLevel, type, character_t::ucn, character_t::wounds, XML_GetInt(), XML_GetNextNode(), XML_GetNode(), XML_GetString(), and xmlNode_t.

Referenced by cgame_import_t::bool(), GAME_GetImportData(), and GAME_LoadTeamInfo().

◆ GAME_LoadDefaultTeam()

bool GAME_LoadDefaultTeam ( bool force)

◆ GAME_LoadInventory()

void GAME_LoadInventory ( xmlNode_t * p,
Inventory * inv,
int maxLoad )
static

Load callback for savegames in XML Format.

Parameters
[in]pXML Node structure, where we load the information from
[in,out]invPointer to the inventory
[in]maxLoadThe max load for this inventory.
See also
GAME_SaveInventory
GAME_LoadItem
I_AddToInventory

Definition at line 663 of file cl_game_team.cpp.

References Inventory::canHoldItemWeight(), CID_EQUIP, cls, Com_Error(), Com_Printf(), Item::def(), ERR_DROP, GAME_LoadItem(), objDef_t::id, INVDEF, SAVE_INVENTORY_ITEM, XML_GetNextNode(), XML_GetNode(), and xmlNode_t.

Referenced by GAME_LoadCharacter().

◆ GAME_LoadItem()

bool GAME_LoadItem ( xmlNode_t * n,
Item * item,
containerIndex_t * container,
int * x,
int * y )
static

Load one item.

Parameters
[in]nXML Node structure, where we write the information to
[out]itemPointer to the item
[out]containerIndex of the container the item is in
[out]xHorizontal coordinate of the item in the container
[out]yVertical coordinate of the item in the container
See also
GAME_SaveItem

Definition at line 611 of file cl_game_team.cpp.

References Item::ammoDef(), CID_MAX, Com_Printf(), csi, Item::def(), Item::getAmmoLeft(), i, INVSH_GetItemByID(), Item::isReloadable(), NONE_AMMO, OBJZERO, Q_streq, Item::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, Item::setAmmoDef(), Item::setAmmoLeft(), Item::setAmount(), Item::setDef(), XML_GetInt(), XML_GetString(), and xmlNode_t.

Referenced by GAME_LoadInventory().

◆ GAME_LoadTeam()

◆ GAME_LoadTeam_f()

void GAME_LoadTeam_f ( void )

Loads the selected teamslot.

Definition at line 458 of file cl_game_team.cpp.

References cls, Cmd_Argc(), Cmd_Argv(), Com_Printf(), GAME_GetTeamFileName(), GAME_IsTeamEmpty(), GAME_LoadTeam(), index, MAX_OSPATH, and NO_TEAM_SLOT_LOADED.

Referenced by GAME_InitStartup().

◆ GAME_LoadTeamInfo()

◆ GAME_SaveCharacter()

bool GAME_SaveCharacter ( xmlNode_t * p,
const character_t * chr )

saves a character to a given xml node

Parameters
[in]pThe node to which we should save the character
[in]chrThe character we should save

Definition at line 691 of file cl_game_team.cpp.

References chrScoreGlobal_t::assignedMissions, character_t::body, character_t::bodySkin, teamDef_t::bodyTemplate, Com_GetConstVariable(), Com_RegisterConstList(), Com_UnregisterConstList(), implant_t::def, chrScoreGlobal_t::experience, character_t::fieldSize, GAME_SaveInventory(), character_t::gender, character_t::head, character_t::headSkin, character_t::HP, i, BodyData::id(), implantDef_t::id, teamDef_t::id, character_t::implants, chrScoreGlobal_t::initialSkills, implant_t::installedTime, character_t::inv, KILLED_NUM_TYPES, chrScoreGlobal_t::kills, lengthof, character_t::maxHP, character_t::morale, character_t::name, BodyData::numBodyParts(), character_t::path, chrScoreGlobal_t::rank, implant_t::removedTime, SAVE_CHARACTER_BDOY_SKIN, SAVE_CHARACTER_BODY, SAVE_CHARACTER_EXPERIENCE, SAVE_CHARACTER_FIELDSIZE, SAVE_CHARACTER_GENDER, SAVE_CHARACTER_HEAD, SAVE_CHARACTER_HEAD_SKIN, SAVE_CHARACTER_HP, SAVE_CHARACTER_IMPLANT, SAVE_CHARACTER_IMPLANT_IMPLANT, SAVE_CHARACTER_IMPLANT_INSTALLEDTIME, SAVE_CHARACTER_IMPLANT_REMOVETIME, SAVE_CHARACTER_IMPLANTS, SAVE_CHARACTER_INITSKILL, SAVE_CHARACTER_INJURIES, 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_STATE, SAVE_CHARACTER_STUN, SAVE_CHARACTER_STUNNED, SAVE_CHARACTER_TEAMDEF, SAVE_CHARACTER_UCN, SAVE_CHARACTER_WOUND, SAVE_CHARACTER_WOUNDEDPART, SAVE_CHARACTER_WOUNDSEVERITY, SAVE_INVENTORY_INVENTORY, saveCharacterConstants, character_t::score, SKILL_NUM_TYPES, chrScoreGlobal_t::skills, character_t::state, character_t::STUN, chrScoreGlobal_t::stuns, character_t::teamDef, woundInfo_t::treatmentLevel, character_t::ucn, character_t::wounds, XML_AddInt(), XML_AddIntValue(), XML_AddNode(), XML_AddString(), and xmlNode_t.

Referenced by cgame_import_t::bool(), GAME_GetImportData(), and GAME_SaveTeamInfo().

◆ GAME_SaveInventory()

void GAME_SaveInventory ( xmlNode_t * p,
const Inventory * inv )
static

Save callback for savegames in XML Format.

Parameters
[out]pXML Node structure, where we write the information to
[in]invPointer to the inventory to save
See also
GAME_SaveItem
GAME_LoadInventory

Definition at line 590 of file cl_game_team.cpp.

References GAME_SaveItem(), Inventory::getNextCont(), Container::getNextItem(), Item::getX(), Item::getY(), Container::id, SAVE_INVENTORY_ITEM, XML_AddNode(), and xmlNode_t.

Referenced by GAME_SaveCharacter().

◆ GAME_SaveItem()

void GAME_SaveItem ( xmlNode_t * p,
const Item * item,
containerIndex_t container,
int x,
int y )
static

Save one item.

Parameters
[out]pXML Node structure, where we write the information to
[in]itemPointer to the item to save
[in]containerIndex of the container the item is in
[in]x,yCoordinates of the item in the container
See also
GAME_LoadItem
Todo
: is there any case when amount != 1 for soldier inventory item?

Definition at line 566 of file cl_game_team.cpp.

References Item::ammoDef(), Item::def(), Item::getAmmoLeft(), Item::getAmount(), objDef_t::id, INVDEF, name, NONE_AMMO, Item::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, XML_AddInt(), XML_AddIntValue(), XML_AddString(), and xmlNode_t.

Referenced by GAME_SaveInventory().

◆ GAME_SaveTeam()

◆ GAME_SaveTeam_f()

void GAME_SaveTeam_f ( void )

Stores a team in a specified teamslot.

Definition at line 293 of file cl_game_team.cpp.

References _, chrDisplayList, Cmd_Argc(), Cmd_Argv(), Com_Printf(), GAME_SaveTeam(), GAME_TeamGetFreeFilename(), LIST_IsEmpty(), MAX_OSPATH, name, Q_strnull(), and UI_Popup().

Referenced by GAME_InitStartup().

◆ GAME_SaveTeamInfo()

void GAME_SaveTeamInfo ( xmlNode_t * p)
static

Stores the wholeTeam into a xml structure.

Note
Called by GAME_SaveTeam to store the team info
See also
GAME_SendCurrentTeamSpawningInfo

Definition at line 186 of file cl_game_team.cpp.

References chrDisplayList, GAME_SaveCharacter(), LIST_Foreach, SAVE_TEAM_CHARACTER, XML_AddNode(), and xmlNode_t.

Referenced by GAME_SaveTeam().

◆ GAME_SaveTeamState_f()

void GAME_SaveTeamState_f ( void )

Will remove those actors that should not be used in the team.

See also
GAME_ToggleActorForTeam_f

Definition at line 112 of file cl_game_team.cpp.

References characterActive, chrDisplayList, i, LIST_Foreach, and LIST_Remove().

Referenced by GAME_InitStartup().

◆ GAME_TeamDelete_f()

void GAME_TeamDelete_f ( void )

Removes a user created team.

Definition at line 124 of file cl_game_team.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), FS_RemoveFile(), GAME_GetAbsoluteSavePath(), MAX_OSPATH, and Q_strcat().

Referenced by GAME_InitStartup().

◆ GAME_TeamGetFreeFilename()

bool GAME_TeamGetFreeFilename ( char * filename,
size_t size )

Searches a free team filename.

Parameters
[out]filenameThe team filename that can be used.
[in]sizeThe size of the filename buffer.
Returns
true if a valid team name was found, false otherwise. In the latter case, don't use anything from the filename buffer

Definition at line 276 of file cl_game_team.cpp.

References Com_sprintf(), FS_CheckFile(), GAME_GetRelativeSavePath(), and MAX_OSPATH.

Referenced by GAME_SaveTeam_f().

◆ GAME_TeamSlotComments_f()

◆ GAME_ToggleActorForTeam_f()

void GAME_ToggleActorForTeam_f ( void )

This will activate/deactivate the actor for the team.

See also
GAME_SaveTeamState_f

Definition at line 83 of file cl_game_team.cpp.

References characterActive, chrDisplayList, Cmd_Argc(), Cmd_Argv(), Com_Printf(), i, and LIST_Foreach.

Referenced by GAME_InitStartup().

◆ GAME_UpdateActiveTeamList()

void GAME_UpdateActiveTeamList ( void )
static

Definition at line 51 of file cl_game_team.cpp.

References characterActive, chrDisplayList, i, LIST_Count(), and OBJZERO.

Referenced by GAME_AutoTeam_f(), and GAME_LoadTeamInfo().

◆ GAME_UpdateInventory()

void GAME_UpdateInventory ( Inventory * inv,
const equipDef_t * ed )
static

◆ GAME_UpdateTeamMenuParameters_f()

void GAME_UpdateTeamMenuParameters_f ( void )

Displays actor info and equipment and unused items in proper (filter) category.

Note
This function is called every time the team equipment screen for the team pops up.

Definition at line 511 of file cl_game_team.cpp.

References characterActive, chrDisplayList, Cvar_Set(), GAME_GetEquipment(), i, LIST_Foreach, TEXT_STANDARD, UI_ExecuteConfunc(), and UI_ResetData().

Referenced by GAME_InitStartup().

Variable Documentation

◆ characterActive

◆ game_inventory

Inventory game_inventory
static

Definition at line 41 of file cl_game_team.cpp.

Referenced by GAME_GetEquipment().