engine: request file from server if HTTP locations failed
This commit is contained in:
parent
cff8ee13e6
commit
fa1e92b127
5 changed files with 31 additions and 11 deletions
|
@ -74,7 +74,7 @@ qboolean CL_CheckFile( sizebuf_t *msg, resource_t *pResource )
|
||||||
|
|
||||||
if( cl.http_download )
|
if( cl.http_download )
|
||||||
{
|
{
|
||||||
HTTP_AddDownload( filepath, pResource->nDownloadSize, true );
|
HTTP_AddDownload( filepath, pResource->nDownloadSize, true, pResource );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -295,7 +295,7 @@ static void CL_LegacyParseResourceList( sizebuf_t *msg )
|
||||||
continue; // already exists
|
continue; // already exists
|
||||||
|
|
||||||
host.downloadcount++;
|
host.downloadcount++;
|
||||||
HTTP_AddDownload( path, -1, true );
|
HTTP_AddDownload( path, -1, true, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !host.downloadcount )
|
if( !host.downloadcount )
|
||||||
|
|
|
@ -49,11 +49,6 @@ const char *CL_MsgInfo( int cmd )
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CL_ProcessFile( qboolean successfully_received, const char *filename )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int GAME_EXPORT CL_Active( void )
|
int GAME_EXPORT CL_Active( void )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2258,6 +2258,7 @@ typedef struct httpfile_s
|
||||||
int id;
|
int id;
|
||||||
enum connectionstate state;
|
enum connectionstate state;
|
||||||
qboolean process;
|
qboolean process;
|
||||||
|
resource_t *resource;
|
||||||
|
|
||||||
string query_backup;
|
string query_backup;
|
||||||
|
|
||||||
|
@ -2339,9 +2340,28 @@ static void HTTP_FreeFile( httpfile_t *file, qboolean error )
|
||||||
Con_Printf( "cannot download %s from any server. "
|
Con_Printf( "cannot download %s from any server. "
|
||||||
"You may remove %s now\n", file->path, incname ); // Warn about trash file
|
"You may remove %s now\n", file->path, incname ); // Warn about trash file
|
||||||
|
|
||||||
|
#if !XASH_DEDICATED
|
||||||
if( file->process )
|
if( file->process )
|
||||||
|
{
|
||||||
|
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
|
CL_ProcessFile( false, file->path ); // Process file, increase counter
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif // !XASH_DEDICATED
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Success, rename and process file
|
// Success, rename and process file
|
||||||
|
@ -2350,11 +2370,15 @@ static void HTTP_FreeFile( httpfile_t *file, qboolean error )
|
||||||
Q_snprintf( name, sizeof( name ), DEFAULT_DOWNLOADED_DIRECTORY "%s", file->path );
|
Q_snprintf( name, sizeof( name ), DEFAULT_DOWNLOADED_DIRECTORY "%s", file->path );
|
||||||
FS_Rename( incname, name );
|
FS_Rename( incname, name );
|
||||||
|
|
||||||
|
#if !XASH_DEDICATED
|
||||||
if( file->process )
|
if( file->process )
|
||||||
CL_ProcessFile( true, name );
|
CL_ProcessFile( true, name );
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
Con_Printf( "successfully downloaded %s, processing disabled!\n", name );
|
Con_Printf( "successfully downloaded %s, processing disabled!\n", name );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
file->state = HTTP_FREE;
|
file->state = HTTP_FREE;
|
||||||
}
|
}
|
||||||
|
@ -2765,12 +2789,13 @@ HTTP_AddDownload
|
||||||
Add new download to end of queue
|
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 ));
|
httpfile_t *httpfile = Z_Calloc( sizeof( httpfile_t ));
|
||||||
|
|
||||||
Con_Reportf( "File %s queued to download\n", path );
|
Con_Reportf( "File %s queued to download\n", path );
|
||||||
|
|
||||||
|
httpfile->resource = res;
|
||||||
httpfile->size = size;
|
httpfile->size = size;
|
||||||
httpfile->downloaded = 0;
|
httpfile->downloaded = 0;
|
||||||
httpfile->socket = -1;
|
httpfile->socket = -1;
|
||||||
|
@ -2812,7 +2837,7 @@ static void HTTP_Download_f( void )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTP_AddDownload( Cmd_Argv( 1 ), -1, false );
|
HTTP_AddDownload( Cmd_Argv( 1 ), -1, false, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -88,7 +88,7 @@ int CL_GetSplitSize( void );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void HTTP_AddCustomServer( const char *url );
|
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_ClearCustomServers( void );
|
||||||
void HTTP_Shutdown( void );
|
void HTTP_Shutdown( void );
|
||||||
void HTTP_ResetProcessState( void );
|
void HTTP_ResetProcessState( void );
|
||||||
|
|
Loading…
Add table
Reference in a new issue