25 #include "../../../common/filesys.h"
26 #include "../../cl_shared.h"
40 if (
cgi->Cmd_Argc() < 1) {
47 Q_strcat(pathMask,
sizeof(pathMask),
"/*.savx");
49 cgi->FS_BuildFileList(pathMask);
59 cgi->UI_ExecuteConfunc(
"ui_add_savegame %i \"%s\" \"%s\" \"%s\" \"%s\"", idx++,
72 const char* error =
nullptr;
75 if (
cgi->Cmd_Argc() < 2) {
84 cgi->Com_Printf(
"savegame file '%s' doesn't exist or an empty file\n",
cgi->
Cmd_Argv(1));
93 cgi->Cmd_ExecuteString(
"game_exit");
94 cgi->Cmd_ExecuteString(
"game_setmode campaign");
95 cgi->UI_Popup(
_(
"Error"),
"%s\n%s",
_(
"Error loading game."), error ? error :
"");
106 const char* error =
nullptr;
108 if (
cgi->CL_OnBattlescape()) {
109 cgi->UI_PopWindow(
false);
117 cgi->UI_Popup(
_(
"Error"),
"%s\n%s",
_(
"Error loading game."), error ? error :
"");
118 cgi->Cmd_ExecuteString(
"game_exit");
122 cgi->UI_PopWindow(
false);
134 if (
cgi->Cmd_Argc() < 2) {
135 cgi->Com_Printf(
"Usage: %s <filename> <comment|*cvar>\n",
cgi->
Cmd_Argv(0));
141 if (
cgi->Cmd_Argc() > 2) {
146 char* error =
nullptr;
152 CP_Popup(
_(
"Note"),
"%s\n%s",
_(
"Error saving game."), error);
154 CP_Popup(
_(
"Note"),
"%s\n%s",
"%s\n",
_(
"Error saving game."));
162 if (
cgi->Cmd_Argc() != 2) {
172 cgi->FS_RemoveFile(buf);
181 if (
cgi->CL_OnBattlescape()) {
188 cgi->UI_PushWindow(
"quickload");
199 if (
cgi->CL_OnBattlescape())
202 char* error =
nullptr;
203 bool result =
SAV_GameSave(
"slotquick",
_(
"QuickSave"), &error);
205 cgi->Com_Printf(
"Error saving the xml game: %s\n", error ? error :
"");
216 const char* error =
nullptr;
218 if (
cgi->CL_OnBattlescape()) {
219 cgi->Com_Printf(
"Could not load the campaign while you are on the battlefield\n");
225 CP_Popup(
_(
"Error"),
"%s\n%s",
_(
"Error loading game."), error ? error :
"");
242 {
nullptr,
nullptr,
nullptr}
250 cgi->Cmd_TableAddList(saveCallbacks);
252 cl_lastsave =
cgi->
Cvar_Get(
"cl_lastsave",
"",
CVAR_ARCHIVE,
"Last saved slot - use for the continue-campaign function");
260 cgi->Cmd_TableRemoveList(saveCallbacks);
static void SAV_GameSave_f(void)
Console command binding for save function.
bool CP_IsRunning(void)
Checks whether a campaign mode game is running.
static const cmdList_t saveCallbacks[]
const char * Com_SkipPath(const char *pathname)
Returns just the filename from a given path.
static void SAV_GameQuickSave_f(void)
Saves to the quick save slot.
static void SAV_ListSaveGames_f(void)
Console command to list savegames.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
void SAV_InitCallbacks(void)
Register UI callbacks for the savegame-subsystem.
void Com_StripExtension(const char *in, char *out, const size_t size)
Removes the file extension from a filename.
void SAV_ShutdownCallbacks(void)
UnregisterUI callbacks for the savegame-subsystem.
#define SAVEGAME_EXTENSION
Defines some savefile structures.
const char *IMPORT * GetAbsoluteSavePath(char *buf, size_t bufSize)
const char *IMPORT * GetRelativeSavePath(char *buf, size_t bufSize)
Header file for Savegame UI callbacks.
static void SAV_GameQuickLoad_f(void)
Loads the quick save slot.
uiMessageListNodeMessage_t * MS_AddNewMessage(const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup, bool playSound)
Adds a new message to message stack.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
static cvar_t * cl_lastsave
const char *IMPORT * FS_NextFileFromFileList(const char *files)
bool SAV_LoadHeader(const char *filename, saveFileHeader_t *header)
Loads and verifies a savegame header.
void CP_CheckBaseAttacks(void)
Check and start baseattack missions.
static void SAV_GameDelete_f(void)
Removes savegame file.
const cgame_import_t * cgi
static void SAV_GameLoad_f(void)
Console command to load a savegame.
cvar_t *IMPORT * Cvar_Get(const char *varName, const char *value, int flags, const char *desc)
static void SAV_GameContinue_f(void)
Loads the last saved game.
bool SAV_GameSave(const char *filename, const char *comment, char **error)
This is a savegame function which stores the game in xml-Format.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
Header file for single player campaign control.
Campaign mission headers.
const char *IMPORT * Cmd_Argv(int n)
bool SAV_GameLoad(const char *file, const char **error)
Loads the given savegame from an xml File.
static void SAV_GameQuickLoadInit_f(void)
Checks whether there is a quicksave file and opens the quickload menu if there is one...