From: havoc Date: Sun, 23 Apr 2017 20:25:39 +0000 (+0000) Subject: Fix bugs in ModList_RebuildList such that it no longer lists files in the quake direc... X-Git-Tag: xonotic-v0.8.5~86 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=360452cf7e3c6d203c3aed9ddf3f3f1993f46be4;p=xonotic%2Fdarkplaces.git Fix bugs in ModList_RebuildList such that it no longer lists files in the quake directory as gamedirs. 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 ::stable-branch::merge=6fb644eee19956bee121e1f2430d2b84067dc056 --- diff --git a/menu.c b/menu.c index f7abc2d1..d09872dd 100644 --- a/menu.c +++ b/menu.c @@ -4535,21 +4535,27 @@ static void ModList_RebuildList(void) { 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; - 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; - 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