39#define TEAM_SAVE_FILE_VERSION 4
44typedef struct teamSaveFileHeader_s {
55 for (
int i = 0;
i < teamSize;
i++)
96 if (ucn == chrTmp->ucn) {
148 Q_strncpyz(pattern, relSavePath,
sizeof(pattern));
149 Q_strcat(pattern,
sizeof(pattern),
"*.mpt");
156 const char* savePath =
va(
"%s/%s", relSavePath,
filename);
163 const int clen =
sizeof(header);
164 if (
FS_Read(&header, clen, &
f) != clen) {
165 Com_Printf(
"Warning: Could not read %i bytes from savefile\n", clen);
238 for (
int i = 0;
i <
csi.numODs;
i++) {
248 buf = mxmlSaveAllocString(topNode,
nullptr);
251 Com_Printf(
"Error: Could not allocate enough memory to save this game\n");
254 int requiredBufferLength = strlen(
buf) + 1;
258 memcpy(fbuf, &header,
sizeof(header));
259 memcpy(fbuf +
sizeof(header),
buf, requiredBufferLength);
281 for (
int num = 0; num < 100; num++) {
301 UI_Popup(
_(
"Note"),
_(
"Error saving team. Nothing to save yet."));
307 name =
_(
"New Team");
311 UI_Popup(
_(
"Note"),
_(
"Error saving team. Too many teams!"));
316 UI_Popup(
_(
"Note"),
_(
"Error saving team. Check free disk space!"));
334 if (
FS_Read(cbuf, clen, &
f) != clen) {
335 Com_Printf(
"Warning: Could not read %i bytes from savefile\n", clen);
341 memcpy(&header, cbuf,
sizeof(header));
357 Com_Printf(
"Error: Failure in loading the xml data!");
441 cls.teamSaveSlotIndex = 0;
539 if (ucn == chrTmp->ucn) {
568 assert(item->
def() !=
nullptr);
594 Item* item =
nullptr;
628 Com_Printf(
"Invalid container id '%s'\n", contID);
633 if (item->
def() ==
nullptr) {
672 if (item.
def() ==
nullptr)
675 if (
INVDEF(container)->temp)
676 Com_Error(
ERR_DROP,
"GAME_LoadInventory failed, tried to add '%s' to a temp container %i", item.
def()->
id, container);
679 Com_Printf(
"GAME_LoadInventory: Item %s exceeds weight capacity\n", item.
def()->
id);
681 if (!
cls.i.addToInventory(inv, &item,
INVDEF(container), x, y, 1))
682 Com_Printf(
"Could not add item '%s' to inventory\n", item.
def() ? item.
def()->
id :
"nullptr");
714 for (
int i = 0;
i < implants;
i++) {
716 if (implant.
def ==
nullptr)
742 || (k < SKILL_NUM_TYPES && score->skills[k])) {
751 const int skills = *(score->
skills + k);
752 const int improve = skills - initial;
794 chr->
bodySkin = std::min(maxSkins, bodySkin);
817 if (bodyPartId[0] !=
'\0') {
823 Com_Printf(
"GAME_LoadCharacter: Body part id not found while loading character wounds, must be an old save\n");
827 Com_Printf(
"GAME_LoadCharacter: Invalid body part id '%s' for %s (ucn: %i)\n", bodyPartId, chr->
name, chr->
ucn);
893 cls.i.destroyInventory(&chr->
inv);
const char * CHRSH_CharGetBody(const character_t *const chr)
Returns the body model for the soldiers for armoured and non armoured soldiers.
const char * CHRSH_CharGetHead(const character_t *const chr)
Returns the head model for the soldiers for armoured and non armoured soldiers.
equipDef_t * GAME_GetEquipmentDefinition(void)
bool GAME_IsTeamEmpty(void)
const char * GAME_GetAbsoluteSavePath(char *buf, size_t bufSize)
size_t GAME_GetCharacterArraySize(void)
void GAME_GenerateTeam(const char *teamDefID, const equipDef_t *ed, int teamMembers)
character_t * GAME_GetCharacter(int index)
Returns a character that can be used to store the game type specific character values.
int GAME_GetChrMaxLoad(const character_t *chr)
Returns the max weight the given character can carry.
const char * GAME_GetTeamDef(void)
void GAME_ResetCharacters(void)
Reset all characters in the static character array.
const char * GAME_GetRelativeSavePath(char *buf, size_t bufSize)
Shared game type headers.
bool GAME_SaveCharacter(xmlNode_t *p, const character_t *chr)
saves a character to a given xml node
static Inventory game_inventory
void GAME_SaveTeam_f(void)
Stores a team in a specified teamslot.
static void GAME_GetEquipment(void)
Get the equipment definition (from script files) for the current selected team and updates the equipm...
bool GAME_TeamGetFreeFilename(char *filename, size_t size)
Searches a free team filename.
void GAME_UpdateTeamMenuParameters_f(void)
Displays actor info and equipment and unused items in proper (filter) category.
void GAME_AutoTeam_f(void)
static bool GAME_LoadTeam(const char *filename)
Load a team from an xml file.
static void GAME_LoadInventory(xmlNode_t *p, Inventory *inv, int maxLoad)
Load callback for savegames in XML Format.
static bool GAME_SaveTeam(const char *filename, const char *name)
Saves a team in xml format.
void GAME_SaveTeamState_f(void)
Will remove those actors that should not be used in the team.
static bool characterActive[MAX_ACTIVETEAM]
void GAME_TeamDelete_f(void)
Removes a user created team.
static void GAME_SaveItem(xmlNode_t *p, const Item *item, containerIndex_t container, int x, int y)
Save one item.
void GAME_TeamSlotComments_f(void)
Reads the comments from team files.
static void GAME_SaveInventory(xmlNode_t *p, const Inventory *inv)
Save callback for savegames in XML Format.
#define TEAM_SAVE_FILE_VERSION
bool GAME_LoadDefaultTeam(bool force)
static void GAME_LoadTeamInfo(xmlNode_t *p)
Loads the wholeTeam from the xml file.
void GAME_ActorSelect_f(void)
static void GAME_SaveTeamInfo(xmlNode_t *p)
Stores the wholeTeam into a xml structure.
void GAME_AutoTeam(const char *equipmentDefinitionID, int teamMembers)
void GAME_ToggleActorForTeam_f(void)
This will activate/deactivate the actor for the team.
static bool GAME_LoadItem(xmlNode_t *n, Item *item, containerIndex_t *container, int *x, int *y)
Load one item.
void GAME_LoadTeam_f(void)
Loads the selected teamslot.
bool GAME_GetTeamFileName(unsigned int index, char *filename, size_t filenameLength)
Get the filename for the xth team in the file system.
bool GAME_LoadCharacter(xmlNode_t *p, character_t *chr)
Loads a character from a given xml node.
static void GAME_UpdateInventory(Inventory *inv, const equipDef_t *ed)
static void GAME_UpdateActiveTeamList(void)
cgame team management headers.
#define NO_TEAM_SLOT_LOADED
const equipDef_t * INV_GetEquipmentDefinitionByID(const char *name)
Gets equipment definition by id.
Header file for inventory handling and Equipment menu.
memPool_t * cl_genericPool
#define INVDEF(containerID)
void CL_UpdateCharacterValues(const character_t *chr)
linkedList_t * chrDisplayList
List of currently displayed or equipable characters.
unsigned int CL_GetActorSkinCount(void)
Get number of registered actorskins.
short numBodyParts(void) const
const char * id(void) const
Item * getNextItem(const Item *prev) const
inventory definition with all its containers
bool canHoldItemWeight(containerIndex_t from, containerIndex_t to, const Item &item, int maxWeight) const
Check that adding an item to the inventory won't exceed the max permitted weight.
void setContainer(const containerIndex_t idx, Item *cont)
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
item instance data, with linked list capability
const objDef_t * ammoDef(void) const
void setAmount(int value)
void setAmmoDef(const objDef_t *od)
void setDef(const objDef_t *objDef)
const objDef_t * def(void) const
bool isReloadable() const
void setAmmoLeft(int value)
Primary header for client.
const char * Cmd_Argv(int arg)
Returns a given argument.
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
void FS_RemoveFile(const char *osPath)
int FS_CheckFile(const char *fmt,...)
Just returns the filelength and -1 if the file wasn't found.
const char * FS_NextFileFromFileList(const char *files)
Returns the next file that is found in the virtual filesystem identified by the given file pattern.
int FS_WriteFile(const void *buffer, size_t len, const char *filename)
int FS_FileLength(qFILE *f)
Returns the size of a given file or -1 if no file is opened.
int FS_Read(void *buffer, int len, qFILE *f)
int FS_OpenFile(const char *filename, qFILE *file, filemode_t mode)
Finds and opens the file in the search path.
int FS_BuildFileList(const char *fileList)
Build a filelist.
bool FS_FileExists(const char *filename,...)
Checks whether a file exists (not in virtual filesystem).
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
const implantDef_t * INVSH_GetImplantByID(const char *id)
Returns the implant that belongs to the given id or nullptr if it wasn't found.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
int LIST_Count(const linkedList_t *list)
void LIST_AddPointer(linkedList_t **listDest, void *data)
Adds just a pointer to a new or to an already existing linked list.
bool LIST_Remove(linkedList_t **list, const void *data)
bool LIST_IsEmpty(const linkedList_t *list)
Checks whether the given list is empty.
#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 ...
#define Mem_PoolAllocTypeN(type, n, pool)
Shared parsing functions.
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
bool R_ModelExists(const char *name)
XML tag constants for savegame.
#define SAVE_CHARACTER_SCORES
#define SAVE_CHARACTER_SCORE_ASSIGNEDMISSIONS
#define SAVE_CHARACTER_WOUNDSEVERITY
#define SAVE_CHARACTER_IMPLANT
#define SAVE_CHARACTER_KILLTYPE
#define SAVE_CHARACTER_INJURIES
#define SAVE_CHARACTER_KILLED
#define SAVE_CHARACTER_SKILLIMPROVE
#define SAVE_CHARACTER_HP
#define SAVE_CHARACTER_IMPLANT_IMPLANT
#define SAVE_CHARACTER_IMPLANT_INSTALLEDTIME
#define SAVE_CHARACTER_SKILLTYPE_NAMESPACE
#define SAVE_CHARACTER_MORALE
#define SAVE_CHARACTER_PATH
#define SAVE_CHARACTER_HEAD_SKIN
#define SAVE_CHARACTER_KILLS
#define SAVE_CHARACTER_EXPERIENCE
#define SAVE_CHARACTER_IMPLANT_REMOVETIME
#define SAVE_CHARACTER_FIELDSIZE
#define SAVE_CHARACTER_INITSKILL
#define SAVE_CHARACTER_HEAD
#define SAVE_CHARACTER_STATE
#define SAVE_CHARACTER_KILLTYPE_NAMESPACE
#define SAVE_CHARACTER_MAXHP
#define SAVE_CHARACTER_STUN
#define SAVE_CHARACTER_WOUNDTYPE
#define SAVE_CHARACTER_NAME
#define SAVE_CHARACTER_STUNNED
#define SAVE_CHARACTER_SKILLS
#define SAVE_CHARACTER_BODY
#define SAVE_CHARACTER_BDOY_SKIN
#define SAVE_CHARACTER_IMPLANTS
#define SAVE_CHARACTER_SKILLTYPE
#define SAVE_CHARACTER_UCN
#define SAVE_CHARACTER_SCORE_RANK
#define SAVE_CHARACTER_WOUNDEDPART
#define SAVE_CHARACTER_TEAMDEF
#define SAVE_CHARACTER_WOUND
static const constListEntry_t saveCharacterConstants[]
#define SAVE_CHARACTER_GENDER
XML tag constants for savegame.
#define SAVE_INVENTORY_MUNITIONID
#define SAVE_INVENTORY_AMMO
#define SAVE_INVENTORY_ITEM
#define SAVE_INVENTORY_WEAPONID
#define SAVE_INVENTORY_ROTATED
#define SAVE_INVENTORY_AMOUNT
#define SAVE_INVENTORY_CONTAINER
#define SAVE_INVENTORY_INVENTORY
XML tag constants for team savegame.
#define SAVE_TEAM_NUMLOOSE
#define SAVE_TEAM_ROOTNODE
#define SAVE_TEAM_EQUIPMENT
#define SAVE_TEAM_CHARACTER
const teamDef_t * Com_GetTeamDefinitionByID(const char *team)
Returns the teamDef pointer for the searched team id - or nullptr if not found in the teamDef array.
bool Com_UnregisterConstList(const constListEntry_t constList[])
Unregisters a list of string aliases.
bool Com_GetCharacterModel(character_t *chr)
bool Com_GetConstIntFromNamespace(const char *space, const char *variable, int *value)
Searches whether a given value was registered as a string to int mapping.
const char * Com_GetConstVariable(const char *space, int value)
Searches the mapping variable for a given integer value and a namespace.
void Com_RegisterConstList(const constListEntry_t constList[])
Registers a list of string aliases.
bool Q_strnull(const char *string)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
Describes a character with all its attributes.
const teamDef_t * teamDef
actorSizeEnum_t fieldSize
implant_t implants[MAX_CHARACTER_IMPLANTS]
Structure of all stats collected for an actor over time.
int initialSkills[SKILL_NUM_TYPES+1]
int stuns[KILLED_NUM_TYPES]
int kills[KILLED_NUM_TYPES]
int skills[SKILL_NUM_TYPES]
int experience[SKILL_NUM_TYPES+1]
int numItems[MAX_OBJDEFS]
byte numItemsLoose[MAX_OBJDEFS]
Defines all attributes of objects used in the inventory.
const BodyData * bodyTemplate
int treatmentLevel[BODYPART_MAXTYPE]
void UI_ResetData(int dataId)
Reset a shared data. Type became NONE and value became nullptr.
void UI_ExecuteConfunc(const char *fmt,...)
Executes confunc - just to identify those confuncs in the code - in this frame.
void UI_ContainerNodeUpdateEquipment(Inventory *inv, const equipDef_t *ed)
Fills the ground container of the ui_inventory with unused items from a given equipment definition.
xmlNode_t * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
Get next Node of the XML tree by name.
void XML_AddString(xmlNode_t *parent, const char *name, const char *value)
add a String attribute to the XML Node
void XML_AddIntValue(xmlNode_t *parent, const char *name, int value)
add a non-zero Int attribute to the XML Node
int XML_GetInt(xmlNode_t *parent, const char *name, const int defaultval)
retrieve an Int attribute from an XML Node
const char * XML_GetString(xmlNode_t *parent, const char *name)
retrieve a String attribute from an XML Node
xmlNode_t * XML_Parse(const char *buffer)
xmlNode_t * XML_AddNode(xmlNode_t *parent, const char *name)
add a new node to the XML tree
void XML_AddInt(xmlNode_t *parent, const char *name, int value)
add an Int attribute to the XML Node
xmlNode_t * XML_GetNode(xmlNode_t *parent, const char *name)
Get first Node of the XML tree by name.