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"
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_t * | save_compressed |
Implements savegames.
Definition in file cp_save.c.
#define SAVEGAME_EXTENSION "savx" |
Definition at line 35 of file cp_save.c.
Referenced by SAV_GameLoad(), SAV_GameQuickLoadInit_f(), SAV_GameReadGameComment(), SAV_GameSave(), and SAV_GameSaveNameCleanup_f().
typedef struct saveFileHeader_s saveFileHeader_t |
typedef struct saveSubsystems_s saveSubsystems_t |
static qboolean SAV_AddSubsystem | ( | saveSubsystems_t * | subsystem | ) | [static] |
Adds a subsystem to the saveSubsystems array.
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.
[out] | error | On failure an errormessage may be set. |
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.
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] |
Loads the given savegame from an xml File.
[in] | file | The Filename to load from (without extension) |
[out] | error | On failure an errormessage may be set. |
Definition at line 128 of file cp_save.c.
References _, byte, cl_genericPool, Com_Printf(), saveFileHeader_s::compressed, qFILE_s::f, f, FILE_READ, FS_CloseFile(), FS_FileLength(), FS_OpenFile(), FS_Read(), GAME_ReloadMode(), saveFileHeader_s::gameVersion, header, i, len, LittleLong(), MAX_OSPATH, Mem_Free, Mem_PoolAlloc, mxml_GetNode(), mxml_ufo_type_cb(), mxmlDelete(), mxmlLoadString(), name, Q_strncpyz(), qfalse, qtrue, SAV_GameActionsAfterLoad(), SAV_VerifyHeader(), SAVE_ROOTNODE, SAVEGAME_EXTENSION, saveSubsystemsAmount, UI_InitStack(), va(), saveFileHeader_s::version, and saveFileHeader_s::xmlSize.
Referenced by SAV_GameContinue_f(), SAV_GameLoad_f(), and SAV_GameQuickLoad_f().
static void SAV_GameLoad_f | ( | void | ) | [static] |
Console command to load a savegame.
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] |
Loads the quick save slot.
Definition at line 607 of file cp_save.c.
References _, Cbuf_Execute(), CL_OnBattlescape(), Cmd_ExecuteString(), Com_Printf(), Com_sprintf(), error(), MS_AddNewMessage(), MSG_INFO, popupText, qfalse, SAV_GameLoad(), and UI_Popup().
Referenced by SAV_Init().
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.
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.
[in] | idx | the savegame slot to retrieve gamecomment for |
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.
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] |
This is a savegame function which stores the game in xml-Format.
[in] | filename | The Filename to save to (without extension) |
[in] | comment | Description of the savegame |
[out] | error | On failure an errormessage may be set. |
Definition at line 242 of file cp_save.c.
References _, byte, ccs, CL_DateConvertLong(), cl_genericPool, Com_MakeTimestamp(), Com_Printf(), Com_sprintf(), saveFileHeader_s::compressed, CP_IsRunning(), ccs_s::date, Date_GetMonthName(), dateLong_s::day, FS_WriteFile(), saveFileHeader_s::gameDate, saveFileHeader_s::gameVersion, header, i, cvar_s::integer, LittleLong(), MAX_OSPATH, Mem_Free, Mem_PoolAlloc, dateLong_s::month, mxml_AddInt(), mxml_AddNode(), mxml_AddString(), MXML_NO_CALLBACK, mxmlDelete(), mxmlNewXML(), mxmlSaveString(), saveFileHeader_s::name, name, ccs_s::numBases, Q_strncpyz(), qfalse, qtrue, saveFileHeader_s::realDate, save(), SAVE_COMMENT, SAVE_FILE_VERSION, SAVE_GAMEDATE, SAVE_REALDATE, SAVE_ROOTNODE, SAVE_SAVEVERSION, SAVE_UFOVERSION, SAVEGAME_EXTENSION, saveSubsystemsAmount, UFO_VERSION, saveFileHeader_s::version, saveFileHeader_s::xmlSize, and dateLong_s::year.
Referenced by SAV_GameSave_f(), and SAV_QuickSave().
static void SAV_GameSave_f | ( | void | ) | [static] |
Console command binding for save function.
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.
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 | ) |
Register all save-subsystems and init some cvars and commands.
Definition at line 631 of file cp_save.c.
References _, AB_LoadXML(), AB_SaveXML(), AC_LoadXML(), AC_SaveXML(), AIR_LoadXML(), AIR_SaveXML(), B_LoadXML(), B_SaveXML(), BS_LoadXML(), BS_SaveXML(), Cmd_AddCommand(), Com_Printf(), CP_LoadInterestsXML(), CP_LoadMissionsXML(), CP_LoadXML(), CP_SaveInterestsXML(), CP_SaveMissionsXML(), CP_SaveXML(), CVAR_ARCHIVE, Cvar_Get(), E_LoadXML(), E_SaveXML(), HOS_LoadXML(), HOS_SaveXML(), INS_LoadXML(), INS_SaveXML(), MS_LoadXML(), MS_SaveXML(), MSO_LoadXML(), MSO_SaveXML(), NAT_LoadXML(), NAT_SaveXML(), PR_LoadXML(), PR_SaveXML(), RS_LoadXML(), RS_SaveXML(), SAV_AddSubsystem(), SAV_GameContinue_f(), SAV_GameLoad_f(), SAV_GameQuickLoad_f(), SAV_GameQuickLoadInit_f(), SAV_GameQuickSave_f(), SAV_GameReadGameComments_f(), SAV_GameSave_f(), SAV_GameSaveNameCleanup_f(), saveSubsystemsAmount, STATS_LoadXML(), STATS_SaveXML(), TR_LoadXML(), TR_SaveXML(), US_LoadXML(), US_SaveXML(), XVI_LoadXML(), and XVI_SaveXML().
Referenced by CP_InitStartup().
qboolean SAV_QuickSave | ( | void | ) |
Quick save the current campaign.
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.
[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().
cvar_t* save_compressed [static] |
saveSubsystems_t saveSubsystems[MAX_SAVESUBSYSTEMS] [static] |
int saveSubsystemsAmount [static] |
Definition at line 55 of file cp_save.c.
Referenced by SAV_AddSubsystem(), SAV_GameLoad(), SAV_GameSave(), and SAV_Init().