X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=fs.c;h=4b06a4e772ae3a7a15be76687a7d6f7c6ea5091c;hp=ad8066859b4a02eb8691ef699eac3a5c00ee60c8;hb=1468c2e8327918ba5dcf33f121f7fa484c8a02a8;hpb=1c83503f63868a30f2090ce88e0bc0d76dd6dc16 diff --git a/fs.c b/fs.c index ad806685..4b06a4e7 100644 --- a/fs.c +++ b/fs.c @@ -1020,7 +1020,6 @@ void FS_AddGameHierarchy (const char *dir) #ifdef WIN32 if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir) == S_OK) dpsnprintf(userdir, sizeof(userdir), "%s/My Games/%s/", mydocsdir, gameuserdirname); - fprintf(stderr, "userdir = %s\n", userdir); #else homedir = getenv ("HOME"); if(homedir) @@ -1041,7 +1040,7 @@ void FS_AddGameHierarchy (const char *dir) if(COM_CheckParm("-nohome")) *userdir = 0; - + if((i = COM_CheckParm("-userdir")) && i < com_argc - 1) dpsnprintf(userdir, sizeof(userdir), "%s/", com_argv[i+1]); @@ -1244,9 +1243,6 @@ qboolean FS_ChangeGameDirs(int numgamedirs, char gamedirs[][MAX_QPATH], qboolean } } - // halt demo playback to close the file - CL_Disconnect(); - Host_SaveConfig(); fs_numgamedirs = numgamedirs; @@ -1305,6 +1301,9 @@ void FS_GameDir_f (void) return; } + // halt demo playback to close the file + CL_Disconnect(); + FS_ChangeGameDirs(numgamedirs, gamedirs, true, true); } @@ -1379,10 +1378,10 @@ void FS_Init (void) strlcat(fs_basedir, "/", sizeof(fs_basedir)); if (!FS_CheckGameDir(gamedirname1)) - Sys_Error("base gamedir %s%s/ not found!\n", fs_basedir, gamedirname1); + Con_Printf("WARNING: base gamedir %s%s/ not found!\n", fs_basedir, gamedirname1); if (gamedirname2 && !FS_CheckGameDir(gamedirname2)) - Sys_Error("base gamedir %s%s/ not found!\n", fs_basedir, gamedirname2); + Con_Printf("WARNING: base gamedir %s%s/ not found!\n", fs_basedir, gamedirname2); // -game // Adds basedir/gamedir as an override game @@ -1397,7 +1396,7 @@ void FS_Init (void) if (FS_CheckNastyPath(com_argv[i], true)) Sys_Error("-game %s%s/ is a dangerous/non-portable path\n", fs_basedir, com_argv[i]); if (!FS_CheckGameDir(com_argv[i])) - Sys_Error("-game %s%s/ not found!\n", fs_basedir, com_argv[i]); + Con_Printf("WARNING: -game %s%s/ not found!\n", fs_basedir, com_argv[i]); // add the gamedir to the list of active gamedirs strlcpy (fs_gamedirs[fs_numgamedirs], com_argv[i], sizeof(fs_gamedirs[fs_numgamedirs])); fs_numgamedirs++; @@ -2596,7 +2595,6 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) else { stringlist_t matchedSet, foundSet; - int resultindex = 0; const char *start = pattern; stringlistinit(&matchedSet); @@ -2631,23 +2629,24 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) nextseparator = start + strlen( start ); } + // prevseparator points past the '/' right before the wildcard and nextseparator at the one following it (or at the end of the string) // copy everything up except nextseperator - strlcpy(subpattern, pattern, min(sizeof(subpattern), nextseparator - pattern + 1)); - // find the last / - prevseparator = strrchr( subpattern, '/' ) + 1; + strlcpy(subpattern, pattern, min(sizeof(subpattern), (size_t) (nextseparator - pattern + 1))); + // find the last '/' before the wildcard + prevseparator = strrchr( subpattern, '/' ); if (!prevseparator) - { prevseparator = subpattern; - } - // copy everything including the last '/' - strlcpy(subpath, start, min(sizeof(subpath), (prevseparator - subpattern) - (start - pattern) + 1)); + else + prevseparator++; + // copy everything from start to the previous including the '/' (before the wildcard) + // everything up to start is already included in the path of matchedSet's entries + strlcpy(subpath, start, min(sizeof(subpath), (size_t) ((prevseparator - subpattern) - (start - pattern) + 1))); - // prevseparator points to the one right before the wildcard and nextseparator to the one following it (or past the end of the string (at \0)) - // start to prevseparator can be opened now and added to the other resultset + // for each entry in matchedSet try to open the subdirectories specified in subpath for( dirlistindex = 0 ; dirlistindex < matchedSet.numstrings ; dirlistindex++ ) { strlcpy( temp, matchedSet.strings[ dirlistindex ], sizeof(temp) ); strlcat( temp, subpath, sizeof(temp) ); - listdirectory( &foundSet, searchpath->filename, temp ); + listdirectory( &foundSet, searchpath->filename, temp ); } if( dirlistindex == 0 ) { break; @@ -2665,7 +2664,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) start = nextseparator; } - + for (dirlistindex = 0;dirlistindex < matchedSet.numstrings;dirlistindex++) { const char *temp = matchedSet.strings[dirlistindex];