fixed cl_allowDownload 1 using the current directory instead of fs_basepath

This commit is contained in:
myT 2018-01-16 05:20:46 +01:00
parent c0ab2063d0
commit 04c765f46c
2 changed files with 10 additions and 4 deletions

View file

@ -6,6 +6,8 @@ chg: on Windows, a fatal error will move the early console window to the foregro
chg: com_hunkMegs doesn't have a maximum value anymore
a value too high would reset it and the engine might fail to load with the default value
fix: cl_allowDownload 1 was using the current directory instead of fs_basepath
fix: jitter due to snapshots piling up with the same server timestamp for loopback and LAN clients
fix: the Windows crash handler would incorrectly consider certain exceptions as fatal

View file

@ -304,7 +304,9 @@ static qbool Download_Rename( mapDownload_t* dl )
}
// try with the desired name
Com_sprintf(dl->finalPath, sizeof(dl->finalPath), "%s%s.pk3", dir, name);
const char* const fs_basepath = Cvar_VariableString("fs_basepath");
const char* finalPath = FS_BuildOSPath(fs_basepath, "baseq3", va("%s.pk3", name));
Q_strncpyz(dl->finalPath, finalPath, sizeof(dl->finalPath));
if (RenameFile(dl->tempPath, dl->finalPath))
return qtrue;
@ -314,7 +316,8 @@ static qbool Download_Rename( mapDownload_t* dl )
const unsigned int suffix0 = (unsigned int)rand() % (1 << 12);
const unsigned int suffix1 = (unsigned int)rand() % (1 << 12);
const unsigned int suffix = suffix0 | (suffix1 << 12);
Com_sprintf(dl->finalPath, sizeof(dl->finalPath), "%s%s_%06x.pk3", dir, name, suffix);
finalPath = FS_BuildOSPath(fs_basepath, "baseq3", va("%s_%06x.pk3", name, suffix));
Q_strncpyz(dl->finalPath, finalPath, sizeof(dl->finalPath));
if (RenameFile(dl->tempPath, dl->finalPath))
return qtrue;
}
@ -427,14 +430,15 @@ static qbool Download_Begin( mapDownload_t* dl, int port, const char* server, co
return qfalse;
}
const char* const tempPathBase = FS_BuildOSPath(Cvar_VariableString("fs_basepath"), "baseq3", "");
#if defined(_WIN32)
if (GetTempFileNameA("baseq3", "", 0, dl->tempPath) == 0) {
if (GetTempFileNameA(tempPathBase, "", 0, dl->tempPath) == 0) {
PrintError(dl, "Couldn't create a file name");
return qfalse;
}
dl->file = fopen(dl->tempPath, "wb");
#else
Q_strncpyz(dl->tempPath, "baseq3/XXXXXX.tmp", sizeof(dl->tempPath));
Com_sprintf(dl->tempPath, sizeof(dl->tempPath), "%s/XXXXXX.tmp", tempPathBase);
const int fd = mkstemps(dl->tempPath, 4);
dl->file = fd != -1 ? fdopen(fd, "wb") : NULL;
#endif