]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fs.c
close packs when clearing search path
[xonotic/darkplaces.git] / fs.c
diff --git a/fs.c b/fs.c
index 89e290ae990de8baf6d54b4a053e269d59418850..916bb960f98d21e4bfbe54f6a7f31aba0667cdf9 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1079,12 +1079,18 @@ FS_ClearSearchPath
 */
 void FS_ClearSearchPath (void)
 {
+       // unload all packs and directory information, close all pack files
+       // (if a qfile is still reading a pack it won't be harmed because it used
+       //  dup() to get its own handle already)
        while (fs_searchpaths)
        {
                searchpath_t *search = fs_searchpaths;
                fs_searchpaths = search->next;
                if (search->pack)
                {
+                       // close the file
+                       close(search->pack->handle);
+                       // free any memory associated with it
                        if (search->pack->files)
                                Mem_Free(search->pack->files);
                        Mem_Free(search->pack);
@@ -1230,8 +1236,8 @@ qboolean FS_ChangeGameDirs(int numgamedirs, char gamedirs[][MAX_QPATH], qboolean
        // exec the new config
        Host_LoadConfig_f();
 
-       // reinitialize the loaded sounds
-       S_Reload_f();
+       // unload all sounds so they will be reloaded from the new files as needed
+       S_UnloadAllSounds_f();
 
        // reinitialize renderer (this reloads hud/console background/etc)
        R_Modules_Restart();