UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_save.cpp File Reference

Implements savegames. More...

#include "../../cl_shared.h"
#include "../cl_game.h"
#include "cp_campaign.h"
#include "cp_save.h"
#include "cp_time.h"
#include "cp_xvi.h"
#include "save/save.h"

Go to the source code of this file.

Functions

static bool SAV_GameActionsAfterLoad (void)
 Perform actions after loading a game for single player campaign. More...
 
static bool SAV_VerifyHeader (saveFileHeader_t const *const header)
 Tries to verify the Header of the savegame. More...
 
bool SAV_LoadHeader (const char *filename, saveFileHeader_t *header)
 Loads and verifies a savegame header. More...
 
bool SAV_GameLoad (const char *file, const char **error)
 Loads the given savegame from an xml File. More...
 
bool SAV_GameSaveAllowed (char **error=nullptr)
 Determines if saving is allowed. More...
 
bool SAV_GameSave (const char *filename, const char *comment, char **error)
 This is a savegame function which stores the game in xml-Format. More...
 
bool SAV_AddSubsystem (saveSubsystems_t *subsystem)
 Adds a subsystem to the saveSubsystems array. More...
 
void SAV_Init (void)
 Register all save-subsystems and init some cvars and commands. More...
 

Variables

static saveSubsystems_t saveSubsystems [MAX_SAVESUBSYSTEMS]
 
static int saveSubsystemsAmount
 
static cvar_tsave_compressed
 

Detailed Description

Implements savegames.

Definition in file cp_save.cpp.

Function Documentation

bool SAV_AddSubsystem ( saveSubsystems_t subsystem)

Adds a subsystem to the saveSubsystems array.

Note
The order is not important
See also
SAV_Init

Definition at line 394 of file cp_save.cpp.

References cgi, saveSubsystems_s::load, MAX_SAVESUBSYSTEMS, saveSubsystems_s::name, saveSubsystems_s::save, and saveSubsystemsAmount.

Referenced by SAV_Init().

static bool SAV_GameActionsAfterLoad ( void  )
static

Perform actions after loading a game for single player campaign.

See also
SAV_GameLoad

Definition at line 41 of file cp_save.cpp.

References AIR_PostLoadInit(), B_PostLoadInit(), CP_UpdateTime(), CP_UpdateXVIMapButton(), PR_PostLoadInit(), and RADAR_SetRadarAfterLoading().

Referenced by SAV_GameLoad().

bool SAV_GameLoad ( const char *  file,
const char **  error 
)

Loads the given savegame from an xml File.

Returns
true on load success false on failures
Parameters
[in]fileThe Filename to load from (without extension)
[out]errorOn failure an errormessage may be set.

Definition at line 152 of file cp_save.cpp.

References _, cgi, saveFileHeader_s::compressed, cp_campaignPool, f, FILE_READ, saveFileHeader_s::gameVersion, cgame_import_s::GetRelativeSavePath(), i, len, LittleLong, MAX_OSPATH, Mem_PoolAllocTypeN, name, Q_strcat(), SAV_GameActionsAfterLoad(), SAV_VerifyHeader(), SAVE_ROOTNODE, SAVEGAME_EXTENSION, saveSubsystemsAmount, va(), saveFileHeader_s::version, cgame_import_s::XML_GetNode(), cgame_import_s::XML_Parse(), xmlNode_t, and saveFileHeader_s::xmlSize.

Referenced by SAV_GameContinue_f(), SAV_GameLoad_f(), SAV_GameQuickLoad_f(), and TEST_F().

bool SAV_GameSaveAllowed ( char **  error = nullptr)

Determines if saving is allowed.

Definition at line 267 of file cp_save.cpp.

References _, B_AtLeastOneExists, cgi, and CP_IsRunning().

Referenced by SAV_GameSave().

bool SAV_LoadHeader ( const char *  filename,
saveFileHeader_t header 
)

Loads and verifies a savegame header.

Parameters
[in]filenameName of the file to load header from (without path and extension)
[out]headerPointer to the header structure to fill
Returns
true on success false on failure

Definition at line 114 of file cp_save.cpp.

References cgi, saveFileHeader_s::compressed, f, FILE_READ, cgame_import_s::GetRelativeSavePath(), LittleLong, MAX_OSPATH, Q_strcat(), SAV_VerifyHeader(), SAVEGAME_EXTENSION, saveFileHeader_s::version, and saveFileHeader_s::xmlSize.

Referenced by SAV_ListSaveGames_f().

static bool SAV_VerifyHeader ( saveFileHeader_t const *const  header)
static

Tries to verify the Header of the savegame.

Parameters
[in]headera pointer to the header to verify

Definition at line 65 of file cp_save.cpp.

References cgi, DEBUG_CLIENT, saveFileHeader_s::gameDate, saveFileHeader_s::gameVersion, len, saveFileHeader_s::name, saveFileHeader_s::realDate, SAVE_FILE_VERSION, saveSubsystemsAmount, saveFileHeader_s::subsystems, UFO_SIZE_T, saveFileHeader_s::version, and saveFileHeader_s::xmlSize.

Referenced by SAV_GameLoad(), and SAV_LoadHeader().

Variable Documentation

cvar_t* save_compressed
static

Definition at line 35 of file cp_save.cpp.

saveSubsystems_t saveSubsystems[MAX_SAVESUBSYSTEMS]
static

Definition at line 33 of file cp_save.cpp.

int saveSubsystemsAmount
static

Definition at line 34 of file cp_save.cpp.

Referenced by SAV_AddSubsystem(), SAV_GameLoad(), SAV_GameSave(), SAV_Init(), and SAV_VerifyHeader().