]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Fix bugs in ModList_RebuildList such that it no longer lists files in the quake direc...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 23 Apr 2017 20:25:39 +0000 (20:25 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 23 Apr 2017 20:25:39 +0000 (20:25 +0000)
These bugs were previously hidden by a different behavior in FS_CheckNastyPath until 20140716 where directories with a period in their name were skipped, but that was not a complete solution.

Thanks to klichka for bug report.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12329 d7cf8633-e32d-0410-b094-e92efae38249

menu.c

diff --git a/menu.c b/menu.c
index f7abc2d19515aa55cea4c035303c8fde70ff40dc..d09872ddc493ae4f87811d230c6f71b87b3ee555 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -4535,21 +4535,27 @@ static void ModList_RebuildList(void)
 {
        int i,j;
        stringlist_t list;
 {
        int i,j;
        stringlist_t list;
+       const char *description;
 
        stringlistinit(&list);
        listdirectory(&list, fs_basedir, "");
        stringlistsort(&list, true);
        modlist_count = 0;
        modlist_numenabled = fs_numgamedirs;
 
        stringlistinit(&list);
        listdirectory(&list, fs_basedir, "");
        stringlistsort(&list, true);
        modlist_count = 0;
        modlist_numenabled = fs_numgamedirs;
-       for (i = 0;i < list.numstrings;i++)
+       for (i = 0;i < list.numstrings && modlist_count < MODLIST_TOTALSIZE;i++)
        {
        {
-               if (modlist_count >= MODLIST_TOTALSIZE) break;
-               // check all dirs to see if they "appear" to be mods
+               // quickly skip names with dot characters - generally these are files, not directories
+               if (strchr(list.strings[i], '.')) continue;
+
                // reject any dirs that are part of the base game
                if (gamedirname1 && !strcasecmp(gamedirname1, list.strings[i])) continue;
                //if (gamedirname2 && !strcasecmp(gamedirname2, list.strings[i])) continue;
                // reject any dirs that are part of the base game
                if (gamedirname1 && !strcasecmp(gamedirname1, list.strings[i])) continue;
                //if (gamedirname2 && !strcasecmp(gamedirname2, list.strings[i])) continue;
-               if (FS_CheckNastyPath (list.strings[i], true)) continue;
-               if (!FS_CheckGameDir(list.strings[i])) continue;
+
+               // check if we can get a description of the gamedir (from modinfo.txt),
+               // or if the directory is valid but has no description (fs_checkgamedir_missing)
+               // otherwise this isn't a valid gamedir
+               description = FS_CheckGameDir(list.strings[i]);
+               if (description == NULL || description == fs_checkgamedir_missing) continue;
 
                strlcpy (modlist[modlist_count].dir, list.strings[i], sizeof(modlist[modlist_count].dir));
                //check currently loaded mods
 
                strlcpy (modlist[modlist_count].dir, list.strings[i], sizeof(modlist[modlist_count].dir));
                //check currently loaded mods