From aeff202074ca953ac875d4a9fe829805913cb1cc Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 16 Oct 2005 12:49:15 +0000 Subject: [PATCH] Added an option to restart the filesystem (to add pak files etc). This will be used by the various download functions. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1492 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/fs.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/engine/common/fs.c b/engine/common/fs.c index e5b0eff4d..1e697ee47 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -2008,6 +2008,68 @@ char *FS_GenerateClientPacksList(char *buffer, int maxlen, int basechecksum) return buffer; } +/* +================ +FS_ReloadPackFiles +================ + +Called when the client has downloaded a new pak/pk3 file +*/ +void FS_ReloadPackFiles(void) +{ + searchpath_t *oldpaths; + searchpath_t *oldbase; + searchpath_t *next; + + + //a lame way to fix pure paks +#ifndef SERVERONLY + if (cls.state) + { + CL_Disconnect_f(); + CL_Reconnect_f(); + } +#endif + + FS_FlushFSHash(); + + oldpaths = com_searchpaths; + com_searchpaths = NULL; + com_purepaths = NULL; + oldbase = com_base_searchpaths; + com_base_searchpaths = NULL; + + //invert the order + next = NULL; + while(oldpaths) + { + oldpaths->nextpure = next; + next = oldpaths; + oldpaths = oldpaths->next; + } + oldpaths = next; + + com_base_searchpaths = NULL; + + while(oldpaths) + { + next = oldpaths->nextpure; + + if (oldbase == oldpaths) + com_base_searchpaths = com_searchpaths; + + if (oldpaths->funcs == &osfilefuncs) + COM_AddGameDirectory(oldpaths->handle); + + oldpaths->funcs->ClosePath(oldpaths->handle); + Z_Free(oldpaths); + oldpaths = next; + } + + if (!com_base_searchpaths) + com_base_searchpaths = com_searchpaths; +} + /* ================ COM_InitFilesystem @@ -2023,6 +2085,8 @@ void COM_InitFilesystem (void) int gamenum=-1; + Cmd_AddCommand("fs_restart", FS_ReloadPackFiles); + // // -basedir // Overrides the system supplied base directory (under id1)