int ignorecase; ///< PK3 ignores case
int numfiles;
qbool vpack;
+ qbool dlcache;
packfile_t *files;
} pack_t;
//@}
* plain directories.
*
*/
-static qbool FS_AddPack_Fullpath(const char *pakfile, const char *shortname, qbool *already_loaded, qbool keep_plain_dirs)
+static qbool FS_AddPack_Fullpath(const char *pakfile, const char *shortname, qbool *already_loaded, qbool keep_plain_dirs, qbool dlcache)
{
searchpath_t *search;
pack_t *pak = NULL;
fs_searchpaths = search;
}
search->pack = pak;
+ search->pack->dlcache = dlcache;
if(pak->vpack)
{
dpsnprintf(search->filename, sizeof(search->filename), "%s/", pakfile);
* If keep_plain_dirs is set, the pack will be added AFTER the first sequence of
* plain directories.
*/
-qbool FS_AddPack(const char *pakfile, qbool *already_loaded, qbool keep_plain_dirs)
+qbool FS_AddPack(const char *pakfile, qbool *already_loaded, qbool keep_plain_dirs, qbool dlcache)
{
char fullpath[MAX_OSPATH];
int index;
dpsnprintf(fullpath, sizeof(fullpath), "%s%s", search->filename, pakfile);
- return FS_AddPack_Fullpath(fullpath, pakfile, already_loaded, keep_plain_dirs);
+ return FS_AddPack_Fullpath(fullpath, pakfile, already_loaded, keep_plain_dirs, dlcache);
}
{
if (!strcasecmp(FS_FileExtension(list.strings[i]), "pak"))
{
- FS_AddPack_Fullpath(list.strings[i], list.strings[i] + strlen(dir), NULL, false);
+ FS_AddPack_Fullpath(list.strings[i], list.strings[i] + strlen(dir), NULL, false, false);
}
}
if (!strcasecmp(FS_FileExtension(list.strings[i]), "pk3") || !strcasecmp(FS_FileExtension(list.strings[i]), "obb") || !strcasecmp(FS_FileExtension(list.strings[i]), "pk3dir")
|| !strcasecmp(FS_FileExtension(list.strings[i]), "dpk") || !strcasecmp(FS_FileExtension(list.strings[i]), "dpkdir"))
{
- FS_AddPack_Fullpath(list.strings[i], list.strings[i] + strlen(dir), NULL, false);
+ FS_AddPack_Fullpath(list.strings[i], list.strings[i] + strlen(dir), NULL, false, false);
}
}
}
}
+/*
+================
+FS_UnloadPacks_dlcache
+
+Like FS_ClearSearchPath() but unloads only the packs loaded from dlcache
+so we don't need to use a full FS_Rescan() to prevent
+content from the previous server and/or map from interfering with the next
+================
+*/
+void FS_UnloadPacks_dlcache(void)
+{
+ searchpath_t *search = fs_searchpaths, *searchprev = fs_searchpaths, *searchnext;
+
+ while (search)
+ {
+ searchnext = search->next;
+ if (search->pack && search->pack->dlcache)
+ {
+ Con_DPrintf("Unloading pack: %s\n", search->pack->shortname);
+
+ // remove it from the search path list
+ if (search == fs_searchpaths)
+ fs_searchpaths = search->next;
+ else
+ searchprev->next = search->next;
+
+ // close the file
+ FILEDESC_CLOSE(search->pack->handle);
+ // free any memory associated with it
+ if (search->pack->files)
+ Mem_Free(search->pack->files);
+ Mem_Free(search->pack);
+ Mem_Free(search);
+ }
+ else
+ searchprev = search;
+ search = searchnext;
+ }
+}
+
static void FS_AddSelfPack(void)
{
if(fs_selfpack)
// IMPORTANT: the file path is automatically prefixed by the current game directory for
// each file created by FS_WriteFile, or opened in "write" or "append" mode by FS_OpenRealFile
-qbool FS_AddPack(const char *pakfile, qbool *already_loaded, qbool keep_plain_dirs); // already_loaded may be NULL if caller does not care
+qbool FS_AddPack(const char *pakfile, qbool *already_loaded, qbool keep_plain_dirs, qbool dlcache); // already_loaded may be NULL if caller does not care
const char *FS_WhichPack(const char *filename);
void FS_CreatePath (char *path);
int FS_SysOpenFD(const char *filepath, const char *mode, qbool nonblocking); // uses absolute path
qbool FS_ChangeGameDirs(int numgamedirs, char gamedirs[][MAX_QPATH], qbool complain, qbool failmissing);
qbool FS_IsRegisteredQuakePack(const char *name);
int FS_CRCFile(const char *filename, size_t *filesizepointer);
+void FS_UnloadPacks_dlcache(void);
void FS_Rescan(void);
typedef struct fssearch_s
if(ok && di->loadtype == LOADTYPE_PAK)
{
- ok = FS_AddPack(di->filename, NULL, true);
+ ok = FS_AddPack(di->filename, NULL, true, true);
if(!ok)
CLEAR_AND_RETRY();
}
if(loadtype == LOADTYPE_PAK)
{
qbool already_loaded;
- if(FS_AddPack(fn, &already_loaded, true))
+ if(FS_AddPack(fn, &already_loaded, true, true))
{
Con_DPrintf("%s already exists, not downloading!\n", fn);
if(already_loaded)