findfile aggressive optimisation: If srb2home and srb2path are the current working directory, don't search in them
srb2path will report "." while this optimisation is in play, but this can be disabled if necessary by modifying the small #if (1) in IdentifyVersion
This commit is contained in:
1 parent
1da376e777
commit
956fc099ad
2 files changed
+33
-21
No files matched your search
+13
-7
@@ -1272,21 +1272,27 @@ static void IdentifyVersion(void)
|
||||
srb2waddir = I_LocateWad();
|
||||
#endif
|
||||
|
||||
char tempsrb2path[256] = ".";
|
||||
getcwd(tempsrb2path, 256);
|
||||
|
||||
// get the current directory (possible problem on NT with "." as current dir)
|
||||
if (srb2waddir)
|
||||
if (!srb2waddir)
|
||||
{
|
||||
strlcpy(srb2path, srb2waddir, sizeof(srb2path));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getcwd(srb2path, sizeof(srb2path)))
|
||||
srb2waddir = srb2path;
|
||||
if (tempsrb2path[0])
|
||||
srb2waddir = tempsrb2path;
|
||||
else
|
||||
{
|
||||
srb2waddir = srb2path;
|
||||
}
|
||||
}
|
||||
|
||||
#if (1) // reduce the amount of findfile by only using full cwd in this func
|
||||
if (strcmp(tempsrb2path, srb2waddir))
|
||||
#endif
|
||||
{
|
||||
strlcpy(srb2path, srb2waddir, sizeof (srb2path));
|
||||
}
|
||||
|
||||
// Load the IWAD
|
||||
if (!AddIWAD())
|
||||
{
|
||||
|
||||
+20
-14
@@ -1208,23 +1208,29 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet
|
||||
// if not found at all, just move on without doing anything
|
||||
}
|
||||
|
||||
// next, check SRB2's "home" directory
|
||||
homecheck = filesearch(filename, srb2home, wantedmd5sum, completepath, 10);
|
||||
// next, check SRB2's "home" directory (if non-'.')
|
||||
if (strcmp(srb2home, "."))
|
||||
{
|
||||
homecheck = filesearch(filename, srb2home, wantedmd5sum, completepath, 10);
|
||||
|
||||
if (homecheck == FS_FOUND) // we found the file, so return that we have :)
|
||||
return FS_FOUND;
|
||||
else if (homecheck == FS_MD5SUMBAD) // file has a bad md5; move on and look for a file with the right md5
|
||||
badmd5 = true;
|
||||
// if not found at all, just move on without doing anything
|
||||
if (homecheck == FS_FOUND) // we found the file, so return that we have :)
|
||||
return FS_FOUND;
|
||||
else if (homecheck == FS_MD5SUMBAD) // file has a bad md5; move on and look for a file with the right md5
|
||||
badmd5 = true;
|
||||
// if not found at all, just move on without doing anything
|
||||
}
|
||||
|
||||
// next, check SRB2's "path" directory
|
||||
homecheck = filesearch(filename, srb2path, wantedmd5sum, completepath, 10);
|
||||
// next, check SRB2's "path" directory (also if non-'.')
|
||||
if (strcmp(srb2path, "."))
|
||||
{
|
||||
homecheck = filesearch(filename, srb2path, wantedmd5sum, completepath, 10);
|
||||
|
||||
if (homecheck == FS_FOUND) // we found the file, so return that we have :)
|
||||
return FS_FOUND;
|
||||
else if (homecheck == FS_MD5SUMBAD) // file has a bad md5; move on and look for a file with the right md5
|
||||
badmd5 = true;
|
||||
// if not found at all, just move on without doing anything
|
||||
if (homecheck == FS_FOUND) // we found the file, so return that we have :)
|
||||
return FS_FOUND;
|
||||
else if (homecheck == FS_MD5SUMBAD) // file has a bad md5; move on and look for a file with the right md5
|
||||
badmd5 = true;
|
||||
// if not found at all, just move on without doing anything
|
||||
}
|
||||
|
||||
// finally check "." directory
|
||||
homecheck = filesearch(filename, ".", wantedmd5sum, completepath, 10);
|
||||
|
||||
Reference in new issue
Block a user