#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)
if(COM_CheckParm("-nohome"))
*userdir = 0;
-
+
if((i = COM_CheckParm("-userdir")) && i < com_argc - 1)
dpsnprintf(userdir, sizeof(userdir), "%s/", com_argv[i+1]);
}
}
- // halt demo playback to close the file
- CL_Disconnect();
-
Host_SaveConfig();
fs_numgamedirs = numgamedirs;
return;
}
+ // halt demo playback to close the file
+ CL_Disconnect();
+
FS_ChangeGameDirs(numgamedirs, gamedirs, true, true);
}
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 <gamedir>
// Adds basedir/gamedir as an override game
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++;
else
{
stringlist_t matchedSet, foundSet;
- int resultindex = 0;
const char *start = pattern;
stringlistinit(&matchedSet);
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;
start = nextseparator;
}
-
+
for (dirlistindex = 0;dirlistindex < matchedSet.numstrings;dirlistindex++)
{
const char *temp = matchedSet.strings[dirlistindex];