From 4b99ff0cc58f839f175f27a9295cb8f2bd0612c1 Mon Sep 17 00:00:00 2001 From: myT Date: Thu, 25 Jan 2018 05:29:53 +0100 Subject: [PATCH] added the fs_restart command --- changelog.txt | 2 ++ code/qcommon/cmd.cpp | 8 ++++++++ code/qcommon/files.cpp | 27 ++++++++++++++++----------- code/qcommon/qcommon.h | 3 ++- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/changelog.txt b/changelog.txt index 66d8136..6fc7879 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,8 @@ DD Mmm 18 - 1.50 +add: the fs_restart command to manually restart the file system + chg: during id downloads (cl_allowDownload -1), the time-out is 5 seconds instead of cl_timeout chg: the "nextdemo" cvar is now also used when playback stops before reaching the demo's end diff --git a/code/qcommon/cmd.cpp b/code/qcommon/cmd.cpp index 0eb2e9b..1e69990 100644 --- a/code/qcommon/cmd.cpp +++ b/code/qcommon/cmd.cpp @@ -773,6 +773,14 @@ void Cmd_RegisterTable( const cmdTableItem_t* cmds, int count, module_t module ) } +void Cmd_UnregisterTable( const cmdTableItem_t* cmds, int count ) +{ + for ( int i = 0; i < count; ++i ) { + Cmd_RemoveCommand( cmds[i].name ); + } +} + + void Cmd_SetModule( const char* cmd_name, module_t module ) { cmd_function_t* cmd; diff --git a/code/qcommon/files.cpp b/code/qcommon/files.cpp index 8435034..e8076b6 100644 --- a/code/qcommon/files.cpp +++ b/code/qcommon/files.cpp @@ -2478,6 +2478,21 @@ qbool FS_PakExists( unsigned int checksum ) } +static void FS_Restart_f() +{ + FS_Restart(fs_checksumFeed); +} + + +static const cmdTableItem_t fs_cmds[] = +{ + { "path", FS_Path_f, NULL, "prints info about the current search path" }, + { "dir", FS_Dir_f, NULL, "prints an extension-filtered file list" }, + { "fdir", FS_NewDir_f, NULL, "prints a pattern-filtered file list" }, + { "fs_restart", FS_Restart_f, NULL, "restarts the file system" } +}; + + /* ================ FS_Shutdown @@ -2513,9 +2528,7 @@ void FS_Shutdown( qbool closemfp ) { // any FS_ calls will now be an error until reinitialized fs_searchpaths = NULL; - Cmd_RemoveCommand( "path" ); - Cmd_RemoveCommand( "dir" ); - Cmd_RemoveCommand( "fdir" ); + Cmd_UnregisterArray( fs_cmds ); #ifdef FS_MISSING if (closemfp) { @@ -2565,14 +2578,6 @@ static void FS_ReorderPurePaks() } -static const cmdTableItem_t fs_cmds[] = -{ - { "path", FS_Path_f, NULL, "prints info about the current search path" }, - { "dir", FS_Dir_f, NULL, "prints an extension-filtered file list" }, - { "fdir", FS_NewDir_f, NULL, "prints a pattern-filtered file list" } -}; - - static void FS_Startup( const char *gameName ) { QSUBSYSTEM_INIT_START( "FileSystem" ); diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 86897a4..431ceb6 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -390,7 +390,8 @@ qbool Cmd_GetHelp( const char** desc, const char** help, const char* cmd_name ); void Cmd_RegisterTable( const cmdTableItem_t* cmds, int count, module_t module ); void Cmd_UnregisterTable( const cmdTableItem_t* cmds, int count ); -#define Cmd_RegisterArray(a, m) Cmd_RegisterTable( a, ARRAY_LEN(a), m ) +#define Cmd_RegisterArray( a, m ) Cmd_RegisterTable( a, ARRAY_LEN(a), m ) +#define Cmd_UnregisterArray( a ) Cmd_UnregisterTable( a, ARRAY_LEN(a) ) void Cmd_SetModule( const char* cmd_name, module_t module );