UFO: Alien Invasion
Loading...
Searching...
No Matches
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"
Include dependency graph for cp_save.cpp:

Go to the source code of this file.

Functions

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

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

◆ SAV_AddSubsystem()

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 391 of file cp_save.cpp.

References cgi, saveSubsystems_t::load, MAX_SAVESUBSYSTEMS, saveSubsystems_t::name, saveSubsystems_t::save, saveSubsystems, and saveSubsystemsAmount.

Referenced by SAV_Init().

◆ SAV_GameActionsAfterLoad()

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().

◆ 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_t::compressed, cp_campaignPool, f, FILE_READ, saveFileHeader_t::gameVersion, i, len, LittleLong, MAX_OSPATH, Mem_PoolAllocTypeN, name, Q_strcat(), SAV_GameActionsAfterLoad(), SAV_VerifyHeader(), SAVE_ROOTNODE, SAVEGAME_EXTENSION, saveSubsystems, saveSubsystemsAmount, va(), saveFileHeader_t::version, xmlNode_t, and saveFileHeader_t::xmlSize.

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

◆ SAV_GameSave()

◆ SAV_GameSaveAllowed()

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(), and SAV_GameSaveAllowed_f().

◆ SAV_Init()

◆ SAV_LoadHeader()

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_t::compressed, f, FILE_READ, LittleLong, MAX_OSPATH, Q_strcat(), SAV_VerifyHeader(), SAVEGAME_EXTENSION, saveFileHeader_t::version, and saveFileHeader_t::xmlSize.

Referenced by SAV_ListSaveGames_f().

◆ SAV_VerifyHeader()

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_t::gameDate, saveFileHeader_t::gameVersion, len, saveFileHeader_t::name, saveFileHeader_t::realDate, SAVE_FILE_VERSION, saveSubsystemsAmount, saveFileHeader_t::subsystems, UFO_SIZE_T, saveFileHeader_t::version, and saveFileHeader_t::xmlSize.

Referenced by SAV_GameLoad(), and SAV_LoadHeader().

Variable Documentation

◆ save_compressed

cvar_t* save_compressed
static

Definition at line 35 of file cp_save.cpp.

Referenced by SAV_GameSave(), and SAV_Init().

◆ saveSubsystems

saveSubsystems_t saveSubsystems[MAX_SAVESUBSYSTEMS]
static

Definition at line 33 of file cp_save.cpp.

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

◆ saveSubsystemsAmount

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().