diff --git a/engine/client/cl_custom.c b/engine/client/cl_custom.c index 03912768..73fb45f7 100644 --- a/engine/client/cl_custom.c +++ b/engine/client/cl_custom.c @@ -74,7 +74,7 @@ qboolean CL_CheckFile( sizebuf_t *msg, resource_t *pResource ) if( cl.http_download ) { - HTTP_AddDownload( filepath, pResource->nDownloadSize, true ); + HTTP_AddDownload( filepath, pResource->nDownloadSize, true, pResource ); } else { diff --git a/engine/client/cl_parse_48.c b/engine/client/cl_parse_48.c index 9a33cf94..a1081ca7 100644 --- a/engine/client/cl_parse_48.c +++ b/engine/client/cl_parse_48.c @@ -295,7 +295,7 @@ static void CL_LegacyParseResourceList( sizebuf_t *msg ) continue; // already exists host.downloadcount++; - HTTP_AddDownload( path, -1, true ); + HTTP_AddDownload( path, -1, true, NULL ); } if( !host.downloadcount ) diff --git a/engine/common/dedicated.c b/engine/common/dedicated.c index db883f4d..075c8e51 100644 --- a/engine/common/dedicated.c +++ b/engine/common/dedicated.c @@ -49,11 +49,6 @@ const char *CL_MsgInfo( int cmd ) return sz; } -void CL_ProcessFile( qboolean successfully_received, const char *filename ) -{ - -} - int GAME_EXPORT CL_Active( void ) { return false; diff --git a/engine/common/net_ws.c b/engine/common/net_ws.c index d7080ccf..81427705 100644 --- a/engine/common/net_ws.c +++ b/engine/common/net_ws.c @@ -2258,6 +2258,7 @@ typedef struct httpfile_s int id; enum connectionstate state; qboolean process; + resource_t *resource; string query_backup; @@ -2339,8 +2340,27 @@ static void HTTP_FreeFile( httpfile_t *file, qboolean error ) Con_Printf( "cannot download %s from any server. " "You may remove %s now\n", file->path, incname ); // Warn about trash file +#if !XASH_DEDICATED if( file->process ) - CL_ProcessFile( false, file->path ); // Process file, increase counter + { + if( file->resource ) + { + char buf[1024]; + sizebuf_t msg; + + MSG_Init( &msg, "DlFile", buf, sizeof( buf )); + MSG_BeginClientCmd( &msg, clc_stringcmd ); + MSG_WriteStringf( &msg, "dlfile %s", file->path ); + + Netchan_CreateFragments( &cls.netchan, &msg ); + Netchan_FragSend( &cls.netchan ); + } + else + { + CL_ProcessFile( false, file->path ); // Process file, increase counter + } + } +#endif // !XASH_DEDICATED } else { @@ -2350,10 +2370,14 @@ static void HTTP_FreeFile( httpfile_t *file, qboolean error ) Q_snprintf( name, sizeof( name ), DEFAULT_DOWNLOADED_DIRECTORY "%s", file->path ); FS_Rename( incname, name ); +#if !XASH_DEDICATED if( file->process ) CL_ProcessFile( true, name ); else +#endif + { Con_Printf( "successfully downloaded %s, processing disabled!\n", name ); + } } file->state = HTTP_FREE; @@ -2765,12 +2789,13 @@ HTTP_AddDownload Add new download to end of queue =================== */ -void HTTP_AddDownload( const char *path, int size, qboolean process ) +void HTTP_AddDownload( const char *path, int size, qboolean process, resource_t *res ) { httpfile_t *httpfile = Z_Calloc( sizeof( httpfile_t )); Con_Reportf( "File %s queued to download\n", path ); + httpfile->resource = res; httpfile->size = size; httpfile->downloaded = 0; httpfile->socket = -1; @@ -2812,7 +2837,7 @@ static void HTTP_Download_f( void ) return; } - HTTP_AddDownload( Cmd_Argv( 1 ), -1, false ); + HTTP_AddDownload( Cmd_Argv( 1 ), -1, false, NULL ); } /* diff --git a/engine/common/net_ws.h b/engine/common/net_ws.h index 8b763f12..2ced5452 100644 --- a/engine/common/net_ws.h +++ b/engine/common/net_ws.h @@ -88,7 +88,7 @@ int CL_GetSplitSize( void ); #endif void HTTP_AddCustomServer( const char *url ); -void HTTP_AddDownload( const char *path, int size, qboolean process ); +void HTTP_AddDownload( const char *path, int size, qboolean process, resource_t *res ); void HTTP_ClearCustomServers( void ); void HTTP_Shutdown( void ); void HTTP_ResetProcessState( void );