client map download fixes

never start a DL when starting a listen server
to see if a map exists on the local FS, check in baseq3/maps too
This commit is contained in:
myT 2017-12-28 05:48:49 +01:00
parent 76afc77856
commit 2a2fb8a946
3 changed files with 22 additions and 5 deletions

View File

@ -1156,6 +1156,13 @@ void CL_NextDownload(void) {
}
// qtrue if found in either "$(fs_gamedir)" or in "baseq3"
static qbool MapDL_FileExists( const char* path )
{
return FS_FileExistsEx( path, qtrue ) || FS_FileExistsEx( path, qfalse );
}
// returns qtrue if a download started
static qbool CL_StartDownloads()
{
@ -1164,6 +1171,10 @@ static qbool CL_StartDownloads()
mode = 1;
}
// never launch a download when starting a listen server...
if (com_sv_running->integer)
return qfalse;
// downloads disabled
if (mode == 0) {
// autodownload is disabled on the client
@ -1202,7 +1213,7 @@ static qbool CL_StartDownloads()
const char* const serverInfo = cl.gameState.stringData + cl.gameState.stringOffsets[CS_SERVERINFO];
const char* const mapName = Info_ValueForKey(serverInfo, "mapname");
const char* const mapPath = va("maps/%s.bsp", mapName);
if ((!exactMatch && FS_FileExists(mapPath)) || FS_FileIsInPAK(mapPath, NULL, NULL))
if ((!exactMatch && MapDL_FileExists(mapPath)) || FS_FileIsInPAK(mapPath, NULL, NULL))
return qfalse;
// generate a checksum list of all the pure paks we're missing
@ -1967,7 +1978,7 @@ static void CL_DownloadMap( qbool forceDL )
const char* const mapName = Cmd_Argv(1);
if ( !forceDL ) {
const char* const mapPath = va( "maps/%s.bsp", mapName );
if ( FS_FileExists(mapPath) || FS_FileIsInPAK(mapPath, NULL, NULL) ) {
if ( MapDL_FileExists(mapPath) || FS_FileIsInPAK(mapPath, NULL, NULL) ) {
Com_Printf( "Map already exists! To force the download, use /%sf\n", Cmd_Argv(0) );
return;
}

View File

@ -474,7 +474,12 @@ NOTE TTimo: this goes with FS_FOpenFileWrite for opening the file afterwards
*/
qbool FS_FileExists( const char* file )
{
const char* testpath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, file );
return FS_FileExistsEx( file, qtrue );
}
qbool FS_FileExistsEx( const char* file, qbool curGameDir )
{
const char* testpath = FS_BuildOSPath( fs_homepath->string, curGameDir ? fs_gamedir : "baseq3", file );
FILE* f = fopen( testpath, "rb" );
if (f) {
fclose( f );
@ -490,7 +495,7 @@ FS_SV_FileExists
Tests if the file exists
================
*/
qbool FS_SV_FileExists( const char *file )
static qbool FS_SV_FileExists( const char *file )
{
FILE *f;
char *testpath;

View File

@ -637,7 +637,8 @@ char **FS_ListFiles( const char *directory, const char *extension, int *numfiles
void FS_FreeFileList( char **list );
qbool FS_FileExists( const char *file );
qbool FS_FileExists( const char *file ); // checks in current game dir
qbool FS_FileExistsEx( const char *file, qbool curGameDir ); // if curGameDir is qfalse, checks in "baseq3"
char* FS_BuildOSPath( const char *base, const char *game, const char *qpath );