Quake II RTX doxygen
1.0 dev
|
|
Go to the source code of this file.
◆ SAVE_AUTO
#define SAVE_AUTO "save0" |
◆ SAVE_CURRENT
#define SAVE_CURRENT ".current" |
◆ SAVE_MAGIC1
#define SAVE_MAGIC1 (('2'<<24)|('V'<<16)|('S'<<8)|'S') |
◆ SAVE_MAGIC2
#define SAVE_MAGIC2 (('2'<<24)|('V'<<16)|('A'<<8)|'S') |
◆ SAVE_VERSION
◆ abort_func()
◆ copy_file()
static int copy_file |
( |
const char * |
src, |
|
|
const char * |
dst, |
|
|
const char * |
name |
|
) |
| |
|
static |
Definition at line 139 of file save.c.
141 char path[MAX_OSPATH];
148 if (len >= MAX_OSPATH)
151 ifp = fopen(path,
"rb");
156 if (len >= MAX_OSPATH)
162 ofp = fopen(path,
"wb");
167 len = fread(buf, 1,
sizeof(buf), ifp);
168 res = fwrite(buf, 1, len, ofp);
169 }
while (len ==
sizeof(buf) && res == len);
Referenced by copy_save_dir().
◆ copy_save_dir()
static int copy_save_dir |
( |
const char * |
src, |
|
|
const char * |
dst |
|
) |
| |
|
static |
◆ list_save_dir()
static void** list_save_dir |
( |
const char * |
dir, |
|
|
int * |
count |
|
) |
| |
|
static |
◆ read_binary_file()
static int read_binary_file |
( |
const char * |
name | ) |
|
|
static |
◆ read_level_file()
static int read_level_file |
( |
void |
| ) |
|
|
static |
Definition at line 403 of file save.c.
405 char name[MAX_OSPATH];
410 if (len >= MAX_QPATH)
430 if (index == MAX_CONFIGSTRINGS)
433 if (index < 0 || index > MAX_CONFIGSTRINGS)
434 Com_Error(ERR_DROP,
"Bad savegame configstring index");
436 maxlen = CS_SIZE(index);
439 Com_Error(ERR_DROP,
"Savegame configstring too long");
443 if (len > MAX_MAP_PORTAL_BYTES)
444 Com_Error(ERR_DROP,
"Savegame portalbits too long");
451 len =
Q_snprintf(name, MAX_OSPATH,
"%s/%s/%s/%s.sav",
453 if (len >= MAX_OSPATH)
454 Com_Error(ERR_DROP,
"Savegame path too long");
Referenced by SV_CheckForSavegame().
◆ read_server_file()
static int read_server_file |
( |
void |
| ) |
|
|
static |
Definition at line 316 of file save.c.
318 char name[MAX_OSPATH],
string[MAX_STRING_CHARS];
335 memset(&cmd, 0,
sizeof(cmd));
348 if (len >=
sizeof(cmd.
buffer))
370 if (len >= MAX_QPATH)
371 Com_Error(ERR_DROP,
"Savegame cvar name too long");
374 if (len >=
sizeof(
string))
375 Com_Error(ERR_DROP,
"Savegame cvar value too long");
384 if (!(
g_features->integer & GMF_ENHANCED_SAVEGAMES))
385 Com_Error(ERR_DROP,
"Game does not support enhanced savegames");
390 if (len >= MAX_OSPATH)
391 Com_Error(ERR_DROP,
"Savegame path too long");
Referenced by SV_Loadgame_f().
◆ remove_file()
static int remove_file |
( |
const char * |
dir, |
|
|
const char * |
name |
|
) |
| |
|
static |
Definition at line 186 of file save.c.
188 char path[MAX_OSPATH];
192 if (len >= MAX_OSPATH)
Referenced by wipe_save_dir().
◆ SV_AutoSaveBegin()
Definition at line 474 of file save.c.
476 byte bitmap[MAX_CLIENTS / CHAR_BIT];
492 memset(bitmap, 0,
sizeof(bitmap));
507 Com_EPrintf(
"Couldn't write level file.\n");
512 ent->inuse = Q_IsBitSet(bitmap, i);
Referenced by SV_Map().
◆ SV_AutoSaveEnd()
Definition at line 516 of file save.c.
527 Com_EPrintf(
"Couldn't write level file.\n");
533 Com_EPrintf(
"Couldn't write server file.\n");
539 Com_EPrintf(
"Couldn't wipe '%s' directory.\n",
SAVE_AUTO);
545 Com_EPrintf(
"Couldn't write '%s' directory.\n",
SAVE_AUTO);
Referenced by SV_Begin_f(), and SV_Map().
◆ SV_CheckForSavegame()
Definition at line 550 of file save.c.
559 Com_EPrintf(
"Couldn't read level file.\n");
572 for (i = 0; i < 100; i++)
Referenced by SV_SpawnServer().
◆ SV_GetSaveInfo()
char* SV_GetSaveInfo |
( |
const char * |
dir | ) |
|
Definition at line 260 of file save.c.
262 char name[MAX_QPATH], date[MAX_QPATH];
270 if (len >= MAX_QPATH)
289 return Z_CopyString(
va(
"ENTERING %s", name));
294 year = tm ? tm->tm_year : -1;
297 t = (time_t)timestamp;
299 if ((tm = localtime(&t)) != NULL) {
300 if (tm->tm_year == year)
301 len = strftime(date,
sizeof(date),
"%b %d %H:%M", tm);
303 len = strftime(date,
sizeof(date),
"%b %d %Y", tm);
308 return Z_CopyString(
va(
"%s %s", date, name));
Referenced by Savegame_Push().
◆ SV_Loadgame_f()
Definition at line 584 of file save.c.
589 Com_Printf(
"Usage: %s <directory>\n",
Cmd_Argv(0));
594 Com_Printf(
"Savegames are for listen servers only.\n");
600 Com_Printf(
"Bad savedir.\n");
605 if (!FS_FileExistsEx(
va(
"%s/%s/server.ssv",
sv_savedir->string, dir), FS_TYPE_REAL | FS_PATH_GAME) ||
606 !FS_FileExistsEx(
va(
"%s/%s/game.ssv",
sv_savedir->string, dir), FS_TYPE_REAL | FS_PATH_GAME)) {
607 Com_Printf (
"No such savegame: %s\n", dir);
613 Com_Printf(
"Couldn't wipe '%s' directory.\n",
SAVE_CURRENT);
619 Com_Printf(
"Couldn't read '%s' directory.\n", dir);
625 Com_Printf(
"Couldn't read server file.\n");
◆ SV_NoSaveGames()
◆ SV_RegisterSavegames()
◆ SV_Savegame_c()
static void SV_Savegame_c |
( |
genctx_t * |
ctx, |
|
|
int |
argnum |
|
) |
| |
|
static |
Definition at line 577 of file save.c.
580 FS_File_g(
"save", NULL, FS_SEARCH_DIRSONLY | FS_TYPE_REAL | FS_PATH_GAME, ctx);
◆ SV_Savegame_f()
Definition at line 630 of file save.c.
635 Com_Printf(
"You must be in a game to save.\n");
640 Com_Printf(
"Savegames are for listen servers only.\n");
645 if (!(
g_features->integer & GMF_ENHANCED_SAVEGAMES)) {
646 Com_Printf(
"Game does not support enhanced savegames.\n");
651 Com_Printf(
"Can't savegame in a deathmatch.\n");
656 Com_Printf(
"Can't savegame while dead!\n");
661 Com_Printf(
"Usage: %s <directory>\n",
Cmd_Argv(0));
667 Com_Printf(
"Bad savedir.\n");
675 Com_Printf(
"Couldn't write level file.\n");
681 Com_Printf(
"Couldn't write server file.\n");
687 Com_Printf(
"Couldn't wipe '%s' directory.\n", dir);
693 Com_Printf(
"Couldn't write '%s' directory.\n", dir);
697 Com_Printf(
"Game saved.\n");
◆ wipe_save_dir()
static int wipe_save_dir |
( |
const char * |
dir | ) |
|
|
static |
◆ write_level_file()
static int write_level_file |
( |
void |
| ) |
|
|
static |
Definition at line 85 of file save.c.
87 char name[MAX_OSPATH];
91 byte portalbits[MAX_MAP_PORTAL_BYTES];
99 for (i = 0; i < MAX_CONFIGSTRINGS; i++) {
109 MSG_WriteData(s, len);
116 MSG_WriteData(portalbits, len);
119 if (len >= MAX_QPATH)
132 if (len >= MAX_OSPATH)
135 ge->WriteLevel(name);
Referenced by SV_AutoSaveBegin(), SV_AutoSaveEnd(), and SV_Savegame_f().
◆ write_server_file()
static int write_server_file |
( |
qboolean |
autosave | ) |
|
|
static |
Definition at line 31 of file save.c.
33 char name[MAX_OSPATH];
43 timestamp = (uint64_t)time(NULL);
56 for (var =
cvar_vars; var; var = var->next) {
57 if (!(var->flags & CVAR_LATCH))
59 if (var->flags & CVAR_PRIVATE)
78 if (len >= MAX_OSPATH)
81 ge->WriteGame(name, autosave);
Referenced by SV_AutoSaveEnd(), and SV_Savegame_f().
◆ c_savegames
const cmdreg_t c_savegames[] |
|
static |
◆ sv_savedir
cvar_t* sv_savedir = NULL |
void SV_Shutdown(const char *finalmsg, error_type_t type)
#define MVD_SPAWN_DISABLED
void CM_FreeMap(cm_t *cm)
byte msg_read_buffer[MAX_MSGLEN]
size_t Q_snprintf(char *dest, size_t size, const char *fmt,...)
ssize_t FS_Read(void *buf, size_t len, qhandle_t f)
qboolean COM_IsPath(const char *s)
static const cmdreg_t c_savegames[]
static int copy_save_dir(const char *src, const char *dst)
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags)
void FS_FreeList(void **list)
void Com_AbortFunc(void(*func)(void *), void *arg)
static int read_level_file(void)
qerror_t FS_WriteFile(const char *path, const void *data, size_t len)
void MSG_WriteByte(int c)
void SZ_Init(sizebuf_t *buf, void *data, size_t size)
static void SV_Savegame_f(void)
static int wipe_save_dir(const char *dir)
ssize_t FS_FOpenFile(const char *name, qhandle_t *f, unsigned mode)
void Com_Error(error_type_t type, const char *fmt,...)
byte * MSG_ReadData(size_t len)
qboolean SV_ParseMapCmd(mapcmd_t *cmd)
void SV_SpawnServer(mapcmd_t *cmd)
static int copy_file(const char *src, const char *dst, const char *name)
char * va(const char *format,...)
void FS_File_g(const char *path, const char *ext, unsigned flags, genctx_t *ctx)
static int remove_file(const char *dir, const char *name)
int CM_WritePortalBits(cm_t *cm, byte *buffer)
void Cmd_Register(const cmdreg_t *reg)
void ** FS_ListFiles(const char *path, const char *filter, unsigned flags, int *count_p)
static void SV_Loadgame_f(void)
static int write_server_file(qboolean autosave)
static int read_server_file(void)
int Cvar_VariableInteger(const char *var_name)
void MSG_WriteShort(int c)
cvar_t * Cvar_UserSet(const char *var_name, const char *value)
static void abort_func(void *arg)
void MSG_WriteString(const char *string)
void MSG_WriteLong(int c)
static void SV_Savegame_c(genctx_t *ctx, int argnum)
void SV_InitGame(unsigned mvd_spawn)
size_t MSG_ReadString(char *dest, size_t size)
qerror_t FS_CreatePath(char *path)
void FS_FCloseFile(qhandle_t f)
char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]
static int write_level_file(void)
static void ** list_save_dir(const char *dir, int *count)
void CM_SetPortalStates(cm_t *cm, byte *buffer, int bytes)
char fs_gamedir[MAX_OSPATH]
static int read_binary_file(const char *name)
void SZ_Clear(sizebuf_t *buf)