diff --git a/src/d_main.cpp b/src/d_main.cpp index 0b367f1d2..98acff85e 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1395,19 +1395,25 @@ 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, 256) != NULL) - srb2waddir = srb2path; + if (tempsrb2path[0]) + srb2waddir = tempsrb2path; else srb2waddir = "."; } +#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()) { diff --git a/src/d_netfil.c b/src/d_netfil.c index 061f587a0..a95767d5b 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -1764,23 +1764,29 @@ filestatus_t findfile(char *filename, const char *priorityfolder, const UINT8 *w filestatus_t homecheck; // store result of last file search boolean badmd5 = false; // store whether md5 was bad from either of the first two searches (if nothing was found in the third) - // first, check SRB2's "home" directory - homecheck = filesearch(filename, srb2home, priorityfolder, wantedmd5sum, completepath, 10); + // first, check SRB2's "home" directory (if non-'.') + if (strcmp(srb2home, ".")) + { + homecheck = filesearch(filename, srb2home, priorityfolder, 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, priorityfolder, wantedmd5sum, completepath, 10); + // next, check SRB2's "path" directory (also if non-'.') + if (strcmp(srb2path, ".")) + { + homecheck = filesearch(filename, srb2path, priorityfolder, 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, ".", priorityfolder, wantedmd5sum, completepath, 10);