cp_save.c File Reference

Implements savegames. More...

#include "../client.h"
#include "../cl_game.h"
#include "../ui/ui_main.h"
#include "../ui/ui_popup.h"
#include "cp_campaign.h"
#include "cp_save.h"
#include "cp_time.h"
#include "save/save.h"
Include dependency graph for cp_save.c:

Go to the source code of this file.

Data Structures

struct  saveFileHeader_s
struct  saveSubsystems_s

Defines

#define SAVEGAME_EXTENSION   "savx"

Typedefs

typedef struct saveFileHeader_s saveFileHeader_t
typedef struct saveSubsystems_s saveSubsystems_t

Functions

static qboolean SAV_GameActionsAfterLoad (void)
 Perform actions after loading a game for single player campaign.
static qboolean SAV_VerifyHeader (saveFileHeader_t const *const header)
 Tries to verify the Header of the savegame.
static qboolean SAV_GameLoad (const char *file, char **error)
 Loads the given savegame from an xml File.
static qboolean SAV_GameSave (const char *filename, const char *comment, char **error)
 This is a savegame function which stores the game in xml-Format.
static void SAV_GameSave_f (void)
 Console command binding for save function.
static void SAV_GameReadGameComment (const int idx)
 Init menu cvar for one savegame slot given by actual index.
static void SAV_GameReadGameComments_f (void)
 Console commands to read the comments from savegames.
static void SAV_GameLoad_f (void)
 Console command to load a savegame.
static void SAV_GameContinue_f (void)
 Loads the last saved game.
static qboolean SAV_AddSubsystem (saveSubsystems_t *subsystem)
 Adds a subsystem to the saveSubsystems array.
static void SAV_GameSaveNameCleanup_f (void)
 Set the mn_slotX cvar to the comment (remove the date string) for clean editing of the save comment.
qboolean SAV_QuickSave (void)
 Quick save the current campaign.
static void SAV_GameQuickLoadInit_f (void)
 Checks whether there is a quicksave file at all - otherwise close the quickload menu.
static void SAV_GameQuickSave_f (void)
 Saves to the quick save slot.
static void SAV_GameQuickLoad_f (void)
 Loads the quick save slot.
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.c.


Define Documentation

#define SAVEGAME_EXTENSION   "savx"

Typedef Documentation


Function Documentation

static qboolean SAV_AddSubsystem ( saveSubsystems_t subsystem  )  [static]

Adds a subsystem to the saveSubsystems array.

Note:
The order is _not_ important
See also:
SAV_Init

Definition at line 505 of file cp_save.c.

References Com_Printf(), saveSubsystems_s::load, MAX_SAVESUBSYSTEMS, saveSubsystems_s::name, qfalse, qtrue, saveSubsystems_s::save, and saveSubsystemsAmount.

Referenced by SAV_Init().

static qboolean SAV_GameActionsAfterLoad ( void   )  [static]

Perform actions after loading a game for single player campaign.

Parameters:
[out] error On failure an errormessage may be set.
Note:
error parameter not used actually
See also:
SAV_GameLoad

Definition at line 64 of file cp_save.c.

References AIR_PostLoadInit(), B_PostLoadInit(), CL_UpdateTime(), qtrue, and RADAR_SetRadarAfterLoading().

Referenced by SAV_GameLoad().

static void SAV_GameContinue_f ( void   )  [static]

Loads the last saved game.

Note:
At saving the archive cvar cl_lastsave was set to the latest savegame
See also:
SAV_GameLoad

Definition at line 477 of file cp_save.c.

References _, Cbuf_Execute(), cl_lastsave, CL_OnBattlescape(), Cmd_ExecuteString(), Com_sprintf(), CP_IsRunning(), error(), popupText, qfalse, SAV_GameLoad(), cvar_s::string, UI_Popup(), and UI_PopWindow().

Referenced by SAV_Init().

static qboolean SAV_GameLoad ( const char *  file,
char **  error 
) [static]
static void SAV_GameLoad_f ( void   )  [static]

Console command to load a savegame.

See also:
SAV_GameLoad

Definition at line 443 of file cp_save.c.

References _, Cbuf_Execute(), Cmd_Argc(), Cmd_Argv(), Cmd_ExecuteString(), Com_DPrintf(), Com_Printf(), Com_sprintf(), Cvar_FindVar(), DEBUG_CLIENT, error(), popupText, SAV_GameLoad(), cvar_s::string, UI_Popup(), and va().

Referenced by SAV_Init().

static void SAV_GameQuickLoad_f ( void   )  [static]
static void SAV_GameQuickLoadInit_f ( void   )  [static]

Checks whether there is a quicksave file at all - otherwise close the quickload menu.

Definition at line 577 of file cp_save.c.

References qFILE_s::f, f, FILE_READ, FS_CloseFile(), FS_OpenFile(), SAVEGAME_EXTENSION, UI_PushWindow(), va(), and qFILE_s::z.

Referenced by SAV_Init().

static void SAV_GameQuickSave_f ( void   )  [static]

Saves to the quick save slot.

See also:
SAV_GameQuickLoad_f

Definition at line 592 of file cp_save.c.

References _, Com_Printf(), CP_IsRunning(), MS_AddNewMessage(), MSG_INFO, qfalse, and SAV_QuickSave().

Referenced by SAV_Init().

static void SAV_GameReadGameComment ( const int  idx  )  [static]

Init menu cvar for one savegame slot given by actual index.

Parameters:
[in] idx the savegame slot to retrieve gamecomment for
See also:
SAV_GameReadGameComments_f

Definition at line 389 of file cp_save.c.

References Com_Printf(), qFILE_s::f, f, FILE_READ, FS_CloseFile(), FS_OpenFile(), FS_Read(), saveFileHeader_s::gameDate, header, saveFileHeader_s::name, saveFileHeader_s::realDate, SAV_VerifyHeader(), SAVEGAME_EXTENSION, UI_ExecuteConfunc(), va(), and qFILE_s::z.

Referenced by SAV_GameReadGameComments_f().

static void SAV_GameReadGameComments_f ( void   )  [static]

Console commands to read the comments from savegames.

Note:
The comment is the part of the savegame header that you type in at saving for reidentifying the savegame
See also:
SAV_GameLoad_f
SAV_GameLoad
SAV_GameSaveNameCleanup_f
SAV_GameReadGameComment

Definition at line 417 of file cp_save.c.

References Cmd_Argc(), Cmd_Argv(), CP_IsRunning(), i, qfalse, SAV_GameReadGameComment(), and UI_PopWindow().

Referenced by SAV_Init().

static qboolean SAV_GameSave ( const char *  filename,
const char *  comment,
char **  error 
) [static]
static void SAV_GameSave_f ( void   )  [static]

Console command binding for save function.

See also:
SAV_GameSave
Note:
called via 'game_save' command

Definition at line 351 of file cp_save.c.

References _, Cmd_Argc(), Cmd_Argv(), Com_Printf(), Com_sprintf(), CP_IsRunning(), error(), MAX_VAR, popupText, Q_strncpyz(), SAV_GameSave(), and UI_Popup().

Referenced by SAV_Init().

static void SAV_GameSaveNameCleanup_f ( void   )  [static]

Set the mn_slotX cvar to the comment (remove the date string) for clean editing of the save comment.

See also:
SAV_GameReadGameComments_f

Definition at line 524 of file cp_save.c.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Com_sprintf(), Cvar_Set(), qFILE_s::f, f, FILE_READ, FS_CloseFile(), FS_OpenFile(), FS_Read(), header, saveFileHeader_s::name, SAVEGAME_EXTENSION, va(), and qFILE_s::z.

Referenced by SAV_Init().

void SAV_Init ( void   ) 
qboolean SAV_QuickSave ( void   ) 

Quick save the current campaign.

See also:
CP_StartMissionMap

Definition at line 558 of file cp_save.c.

References _, CL_OnBattlescape(), Com_Printf(), error(), qfalse, qtrue, and SAV_GameSave().

Referenced by B_AssembleMap(), CP_StartMissionMap(), and SAV_GameQuickSave_f().

static qboolean SAV_VerifyHeader ( saveFileHeader_t const *const   header  )  [static]

Tries to verify the Header of the savegame.

Parameters:
[in] header a pointer to the header to verify

Definition at line 82 of file cp_save.c.

References Com_DPrintf(), Com_Printf(), DEBUG_CLIENT, saveFileHeader_s::gameDate, saveFileHeader_s::gameVersion, len, saveFileHeader_s::name, qfalse, qtrue, saveFileHeader_s::realDate, SAVE_FILE_VERSION, UFO_SIZE_T, saveFileHeader_s::version, and saveFileHeader_s::xmlSize.

Referenced by SAV_GameLoad(), and SAV_GameReadGameComment().


Variable Documentation

Definition at line 56 of file cp_save.c.

saveSubsystems_t saveSubsystems[MAX_SAVESUBSYSTEMS] [static]

Definition at line 54 of file cp_save.c.

int saveSubsystemsAmount [static]

Definition at line 55 of file cp_save.c.

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


Generated by  doxygen 1.6.2