=============================================================================
*/
-void FS_Dir_f(void);
-void FS_Ls_f(void);
-void FS_Which_f(void);
+void FS_Dir_f(cmd_state_t *cmd);
+void FS_Ls_f(cmd_state_t *cmd);
+void FS_Which_f(cmd_state_t *cmd);
static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet);
static packfile_t* FS_AddFileToPack (const char* name, pack_t* pack,
gamedir_t *fs_all_gamedirs = NULL;
int fs_all_gamedirs_count = 0;
-cvar_t scr_screenshot_name = {CVAR_NORESETTODEFAULTS, "scr_screenshot_name","dp", "prefix name for saved screenshots (changes based on -game commandline, as well as which game mode is running; the date is encoded using strftime escapes)"};
-cvar_t fs_empty_files_in_pack_mark_deletions = {0, "fs_empty_files_in_pack_mark_deletions", "0", "if enabled, empty files in a pak/pk3 count as not existing but cancel the search in further packs, effectively allowing patch pak/pk3 files to 'delete' files"};
-cvar_t cvar_fs_gamedir = {CVAR_READONLY | CVAR_NORESETTODEFAULTS, "fs_gamedir", "", "the list of currently selected gamedirs (use the 'gamedir' command to change this)"};
+cvar_t scr_screenshot_name = {CVAR_CLIENT | CVAR_NORESETTODEFAULTS, "scr_screenshot_name","dp", "prefix name for saved screenshots (changes based on -game commandline, as well as which game mode is running; the date is encoded using strftime escapes)"};
+cvar_t fs_empty_files_in_pack_mark_deletions = {CVAR_CLIENT | CVAR_SERVER, "fs_empty_files_in_pack_mark_deletions", "0", "if enabled, empty files in a pak/pk3 count as not existing but cancel the search in further packs, effectively allowing patch pak/pk3 files to 'delete' files"};
+cvar_t cvar_fs_gamedir = {CVAR_CLIENT | CVAR_SERVER | CVAR_READONLY | CVAR_NORESETTODEFAULTS, "fs_gamedir", "", "the list of currently selected gamedirs (use the 'gamedir' command to change this)"};
/*
// 1st uint8 : general purpose bit flag
// Check bits 0 (encryption), 3 (data descriptor after the file), and 5 (compressed patched data (?))
//
- // LordHavoc: bit 3 would be a problem if we were scanning the archive
+ // LadyHavoc: bit 3 would be a problem if we were scanning the archive
// but is not a problem in the central directory where the values are
// always real.
//
============
*/
-static void FS_Path_f (void)
+static void FS_Path_f(cmd_state_t *cmd)
{
searchpath_t *s;
}
else
{
- Con_Printf("unable to load pak \"%s\"\n", pakfile);
+ Con_Errorf("unable to load pak \"%s\"\n", pakfile);
return false;
}
}
// -game <gamedir>
// Adds basedir/gamedir as an override game
- // LordHavoc: now supports multiple -game directories
+ // LadyHavoc: now supports multiple -game directories
// set the com_modname (reported in server info)
*gamedirbuf = 0;
for (i = 0;i < fs_numgamedirs;i++)
// look for the pop.lmp file and set registered to true if it is found
if (FS_FileExists("gfx/pop.lmp"))
- Cvar_Set ("registered", "1");
+ Cvar_SetValueQuick(®istered, 1);
switch(gamemode)
{
case GAME_NORMAL:
W_UnloadAll();
}
-static void FS_Rescan_f(void)
+static void FS_Rescan_f(cmd_state_t *cmd)
{
FS_Rescan();
}
if (cls.demoplayback)
{
- CL_Disconnect_f();
+ CL_Disconnect_f(&cmd_client);
cls.demonum = 0;
}
// unload all sounds so they will be reloaded from the new files as needed
- S_UnloadAllSounds_f();
+ S_UnloadAllSounds_f(&cmd_client);
// close down the video subsystem, it will start up again when the config finishes...
VID_Stop();
vid_opened = false;
// restart the video subsystem after the config is executed
- Cbuf_InsertText("\nloadconfig\nvid_restart\n\n");
+ Cbuf_InsertText(&cmd_client, "\nloadconfig\nvid_restart\n\n");
return true;
}
FS_GameDir_f
================
*/
-static void FS_GameDir_f (void)
+static void FS_GameDir_f(cmd_state_t *cmd)
{
int i;
int numgamedirs;
char gamedirs[MAX_GAMEDIRS][MAX_QPATH];
- if (Cmd_Argc() < 2)
+ if (Cmd_Argc(cmd) < 2)
{
Con_Printf("gamedirs active:");
for (i = 0;i < fs_numgamedirs;i++)
return;
}
- numgamedirs = Cmd_Argc() - 1;
+ numgamedirs = Cmd_Argc(cmd) - 1;
if (numgamedirs > MAX_GAMEDIRS)
{
Con_Printf("Too many gamedirs (%i > %i)\n", numgamedirs, MAX_GAMEDIRS);
}
for (i = 0;i < numgamedirs;i++)
- strlcpy(gamedirs[i], Cmd_Argv(i+1), sizeof(gamedirs[i]));
+ strlcpy(gamedirs[i], Cmd_Argv(cmd, i+1), sizeof(gamedirs[i]));
if ((cls.state == ca_connected && !cls.demoplayback) || sv.active)
{
p = FS_CheckGameDir(gamedirname1);
if(!p || p == fs_checkgamedir_missing)
- Con_Printf("WARNING: base gamedir %s%s/ not found!\n", fs_basedir, gamedirname1);
+ Con_Warnf("WARNING: base gamedir %s%s/ not found!\n", fs_basedir, gamedirname1);
if(gamedirname2)
{
p = FS_CheckGameDir(gamedirname2);
if(!p || p == fs_checkgamedir_missing)
- Con_Printf("WARNING: base gamedir %s%s/ not found!\n", fs_basedir, gamedirname2);
+ Con_Warnf("WARNING: base gamedir %s%s/ not found!\n", fs_basedir, gamedirname2);
}
// -game <gamedir>
// Adds basedir/gamedir as an override game
- // LordHavoc: now supports multiple -game directories
+ // LadyHavoc: now supports multiple -game directories
for (i = 1;i < com_argc && fs_numgamedirs < MAX_GAMEDIRS;i++)
{
if (!com_argv[i])
if(!p)
Sys_Error("Nasty -game name rejected: %s", com_argv[i]);
if(p == fs_checkgamedir_missing)
- Con_Printf("WARNING: -game %s%s/ not found!\n", fs_basedir, com_argv[i]);
+ Con_Warnf("WARNING: -game %s%s/ not found!\n", fs_basedir, com_argv[i]);
// add the gamedir to the list of active gamedirs
strlcpy (fs_gamedirs[fs_numgamedirs], com_argv[i], sizeof(fs_gamedirs[fs_numgamedirs]));
fs_numgamedirs++;
Cvar_RegisterVariable (&fs_empty_files_in_pack_mark_deletions);
Cvar_RegisterVariable (&cvar_fs_gamedir);
- Cmd_AddCommand ("gamedir", FS_GameDir_f, "changes active gamedir list (can take multiple arguments), not including base directory (example usage: gamedir ctf)");
- Cmd_AddCommand ("fs_rescan", FS_Rescan_f, "rescans filesystem for new pack archives and any other changes");
- Cmd_AddCommand ("path", FS_Path_f, "print searchpath (game directories and archives)");
- Cmd_AddCommand ("dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line");
- Cmd_AddCommand ("ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line");
- Cmd_AddCommand ("which", FS_Which_f, "accepts a file name as argument and reports where the file is taken from");
+ Cmd_AddCommand(&cmd_client, "gamedir", FS_GameDir_f, "changes active gamedir list (can take multiple arguments), not including base directory (example usage: gamedir ctf)");
+ Cmd_AddCommand(&cmd_client, "fs_rescan", FS_Rescan_f, "rescans filesystem for new pack archives and any other changes");
+ Cmd_AddCommand(&cmd_client, "path", FS_Path_f, "print searchpath (game directories and archives)");
+ Cmd_AddCommand(&cmd_client, "dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line");
+ Cmd_AddCommand(&cmd_client, "ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line");
+ Cmd_AddCommand(&cmd_client, "which", FS_Which_f, "accepts a file name as argument and reports where the file is taken from");
+
+ Cmd_AddCommand(&cmd_server, "gamedir", FS_GameDir_f, "changes active gamedir list (can take multiple arguments), not including base directory (example usage: gamedir ctf)");
+ Cmd_AddCommand(&cmd_server, "fs_rescan", FS_Rescan_f, "rescans filesystem for new pack archives and any other changes");
+ Cmd_AddCommand(&cmd_server, "path", FS_Path_f, "print searchpath (game directories and archives)");
+ Cmd_AddCommand(&cmd_server, "dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line");
+ Cmd_AddCommand(&cmd_server, "ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line");
+ Cmd_AddCommand(&cmd_server, "which", FS_Which_f, "accepts a file name as argument and reports where the file is taken from");
}
/*
opt = O_CREAT | O_APPEND;
break;
default:
- Con_Printf ("FS_SysOpen(%s, %s): invalid mode\n", filepath, mode);
+ Con_Errorf ("FS_SysOpen(%s, %s): invalid mode\n", filepath, mode);
return FILEDESC_INVALID;
}
for (ind = 1; mode[ind] != '\0'; ind++)
dolock = true;
break;
default:
- Con_Printf ("FS_SysOpen(%s, %s): unknown character in mode (%c)\n",
+ Con_Errorf ("FS_SysOpen(%s, %s): unknown character in mode (%c)\n",
filepath, mode, mode[ind]);
}
}
// No Zlib DLL = no compressed files
if (!zlib_dll && (pfile->flags & PACKFILE_FLAG_DEFLATED))
{
- Con_Printf("WARNING: can't open the compressed file %s\n"
+ Con_Warnf("WARNING: can't open the compressed file %s\n"
"You need the Zlib DLL to use compressed files\n",
pfile->name);
return NULL;
}
#endif
- // LordHavoc: FILEDESC_SEEK affects all duplicates of a handle so we do it before
+ // LadyHavoc: FILEDESC_SEEK affects all duplicates of a handle so we do it before
// the dup() call to avoid having to close the dup_handle on error here
if (FILEDESC_SEEK (pack->handle, pfile->offset, SEEK_SET) == -1)
{
{
if (FILEDESC_SEEK (file->handle, file->buff_ind - file->buff_len, SEEK_CUR) == -1)
{
- Con_Printf("WARNING: could not seek in %s.\n", file->filename);
+ Con_Warnf("WARNING: could not seek in %s.\n", file->filename);
}
}
FS_Purge (file);
// Write the buffer and update the position
- // LordHavoc: to hush a warning about passing size_t to an unsigned int parameter on Win64 we do this as multiple writes if the size would be too big for an integer (we never write that big in one go, but it's a theory)
+ // LadyHavoc: to hush a warning about passing size_t to an unsigned int parameter on Win64 we do this as multiple writes if the size would be too big for an integer (we never write that big in one go, but it's a theory)
while (written < (fs_offset_t)datasize)
{
// figure out how much to write in one chunk
buffer = (unsigned char *)Mem_Alloc (tempmempool, buffersize);
// Skip all data until we reach the requested offset
- while (offset > file->position)
+ while (offset > (file->position - file->buff_len + file->buff_ind))
{
- fs_offset_t diff = offset - file->position;
+ fs_offset_t diff = offset - (file->position - file->buff_len + file->buff_ind);
fs_offset_t count, len;
count = (diff > buffersize) ? buffersize : diff;
return (int)numfiles;
}
-static void FS_ListDirectoryCmd (const char* cmdname, int oneperline)
+static void FS_ListDirectoryCmd (cmd_state_t *cmd, const char* cmdname, int oneperline)
{
const char *pattern;
- if (Cmd_Argc() >= 3)
+ if (Cmd_Argc(cmd) >= 3)
{
Con_Printf("usage:\n%s [path/pattern]\n", cmdname);
return;
}
- if (Cmd_Argc() == 2)
- pattern = Cmd_Argv(1);
+ if (Cmd_Argc(cmd) == 2)
+ pattern = Cmd_Argv(cmd, 1);
else
pattern = "*";
if (!FS_ListDirectory(pattern, oneperline))
Con_Print("No files found.\n");
}
-void FS_Dir_f(void)
+void FS_Dir_f(cmd_state_t *cmd)
{
- FS_ListDirectoryCmd("dir", true);
+ FS_ListDirectoryCmd(cmd, "dir", true);
}
-void FS_Ls_f(void)
+void FS_Ls_f(cmd_state_t *cmd)
{
- FS_ListDirectoryCmd("ls", false);
+ FS_ListDirectoryCmd(cmd, "ls", false);
}
-void FS_Which_f(void)
+void FS_Which_f(cmd_state_t *cmd)
{
const char *filename;
int index;
searchpath_t *sp;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
- Con_Printf("usage:\n%s <file>\n", Cmd_Argv(0));
+ Con_Printf("usage:\n%s <file>\n", Cmd_Argv(cmd, 0));
return;
}
- filename = Cmd_Argv(1);
+ filename = Cmd_Argv(cmd, 1);
sp = FS_FindFile(filename, &index, true);
if (!sp) {
Con_Printf("%s isn't anywhere\n", filename);