mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-19 03:20:09 +00:00
engine: client: implement connectionprogress partially
This commit is contained in:
parent
01dcb52b4c
commit
cb417a3d51
@ -193,6 +193,8 @@ void CL_CheckClientState( void )
|
|||||||
Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar
|
Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar
|
||||||
Netchan_ReportFlow( &cls.netchan );
|
Netchan_ReportFlow( &cls.netchan );
|
||||||
|
|
||||||
|
UI_SetActiveMenu( false );
|
||||||
|
|
||||||
Con_DPrintf( "client connected at %.2f sec\n", Sys_DoubleTime() - cls.timestart );
|
Con_DPrintf( "client connected at %.2f sec\n", Sys_DoubleTime() - cls.timestart );
|
||||||
if(( cls.demoplayback || cls.disable_servercount != cl.servercount ) && cl.video_prepped )
|
if(( cls.demoplayback || cls.disable_servercount != cl.servercount ) && cl.video_prepped )
|
||||||
SCR_EndLoadingPlaque(); // get rid of loading plaque
|
SCR_EndLoadingPlaque(); // get rid of loading plaque
|
||||||
@ -1141,6 +1143,12 @@ void CL_CheckForResend( void )
|
|||||||
|
|
||||||
if( adr.port == 0 ) adr.port = MSG_BigShort( PORT_SERVER );
|
if( adr.port == 0 ) adr.port = MSG_BigShort( PORT_SERVER );
|
||||||
|
|
||||||
|
if( !cls.changelevel )
|
||||||
|
{
|
||||||
|
Cvar_SetValue( "scr_loading", scr_loading->value + 5.0f );
|
||||||
|
UI_ConnectionProgress_Connect( va( "#%d", cls.connect_retry ));
|
||||||
|
}
|
||||||
|
|
||||||
if( cls.connect_retry == CL_TEST_RETRIES_NORESPONCE )
|
if( cls.connect_retry == CL_TEST_RETRIES_NORESPONCE )
|
||||||
{
|
{
|
||||||
// too many fails use default connection method
|
// too many fails use default connection method
|
||||||
@ -1249,10 +1257,6 @@ void CL_Connect_f( void )
|
|||||||
Con_Printf( "server %s\n", server );
|
Con_Printf( "server %s\n", server );
|
||||||
CL_Disconnect();
|
CL_Disconnect();
|
||||||
|
|
||||||
// TESTTEST: a see console during connection
|
|
||||||
UI_SetActiveMenu( false );
|
|
||||||
Key_SetKeyDest( key_console );
|
|
||||||
|
|
||||||
cls.state = ca_connecting;
|
cls.state = ca_connecting;
|
||||||
cls.legacymode = legacyconnect;
|
cls.legacymode = legacyconnect;
|
||||||
Q_strncpy( cls.servername, server, sizeof( cls.servername ));
|
Q_strncpy( cls.servername, server, sizeof( cls.servername ));
|
||||||
@ -1503,6 +1507,8 @@ void CL_Disconnect( void )
|
|||||||
|
|
||||||
IN_LockInputDevices( false ); // unlock input devices
|
IN_LockInputDevices( false ); // unlock input devices
|
||||||
|
|
||||||
|
UI_ConnectionProgress_Disconnect();
|
||||||
|
|
||||||
cls.state = ca_disconnected;
|
cls.state = ca_disconnected;
|
||||||
memset( &cls.serveradr, 0, sizeof( cls.serveradr ) );
|
memset( &cls.serveradr, 0, sizeof( cls.serveradr ) );
|
||||||
cls.set_lastdemo = false;
|
cls.set_lastdemo = false;
|
||||||
@ -1914,7 +1920,6 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
|||||||
}
|
}
|
||||||
|
|
||||||
CL_Reconnect( true );
|
CL_Reconnect( true );
|
||||||
UI_SetActiveMenu( cl.background );
|
|
||||||
}
|
}
|
||||||
else if( !Q_strcmp( c, "info" ))
|
else if( !Q_strcmp( c, "info" ))
|
||||||
{
|
{
|
||||||
@ -1995,7 +2000,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( cls.connect_retry >= CL_TEST_RETRIES )
|
if( cls.connect_retry >= CL_TEST_RETRIES )
|
||||||
{
|
{
|
||||||
// too many fails use default connection method
|
// too many fails use default connection method
|
||||||
Con_Printf( "hi-speed connection is failed, use default method\n" );
|
Con_Printf( "hi-speed connection is failed, use default method\n" );
|
||||||
Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" );
|
Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" );
|
||||||
@ -2408,6 +2413,7 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename )
|
|||||||
{
|
{
|
||||||
Con_Printf( S_ERROR "server failed to transmit file '%s'\n", CL_CleanFileName( filename ));
|
Con_Printf( S_ERROR "server failed to transmit file '%s'\n", CL_CleanFileName( filename ));
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cls.legacymode )
|
if( cls.legacymode )
|
||||||
{
|
{
|
||||||
if( host.downloadcount > 0 )
|
if( host.downloadcount > 0 )
|
||||||
@ -2607,6 +2613,8 @@ qboolean CL_PrecacheResources( void )
|
|||||||
{
|
{
|
||||||
resource_t *pRes;
|
resource_t *pRes;
|
||||||
|
|
||||||
|
UI_ConnectionProgress_Precache();
|
||||||
|
|
||||||
// NOTE: world need to be loaded as first model
|
// NOTE: world need to be loaded as first model
|
||||||
for( pRes = cl.resourcesonhand.pNext; pRes && pRes != &cl.resourcesonhand; pRes = pRes->pNext )
|
for( pRes = cl.resourcesonhand.pNext; pRes && pRes != &cl.resourcesonhand; pRes = pRes->pNext )
|
||||||
{
|
{
|
||||||
|
@ -904,7 +904,7 @@ void CL_ParseServerData( sizebuf_t *msg )
|
|||||||
|
|
||||||
if( Con_FixedFont( ))
|
if( Con_FixedFont( ))
|
||||||
{
|
{
|
||||||
// seperate the printfs so the server message can have a color
|
// separate the printfs so the server message can have a color
|
||||||
Con_Print( "\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n" );
|
Con_Print( "\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n" );
|
||||||
Con_Print( va( "%c%s\n\n", 2, clgame.maptitle ));
|
Con_Print( va( "%c%s\n\n", 2, clgame.maptitle ));
|
||||||
}
|
}
|
||||||
@ -920,6 +920,9 @@ void CL_ParseServerData( sizebuf_t *msg )
|
|||||||
|
|
||||||
if( r_decals->value > mp_decals.value )
|
if( r_decals->value > mp_decals.value )
|
||||||
Cvar_SetValue( "r_decals", mp_decals.value );
|
Cvar_SetValue( "r_decals", mp_decals.value );
|
||||||
|
|
||||||
|
if( !cls.demoplayback )
|
||||||
|
UI_ConnectionProgress_ParseServerInfo( "server" );
|
||||||
}
|
}
|
||||||
else Cvar_Reset( "r_decals" );
|
else Cvar_Reset( "r_decals" );
|
||||||
|
|
||||||
@ -943,7 +946,9 @@ void CL_ParseServerData( sizebuf_t *msg )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( !cls.changedemo )
|
if( !cls.changedemo )
|
||||||
UI_SetActiveMenu( cl.background );
|
{
|
||||||
|
// UI_SetActiveMenu( cl.background );
|
||||||
|
}
|
||||||
else if( !cls.demoplayback )
|
else if( !cls.demoplayback )
|
||||||
Key_SetKeyDest( key_menu );
|
Key_SetKeyDest( key_menu );
|
||||||
|
|
||||||
@ -2131,6 +2136,7 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
|
|||||||
else cls.state = ca_connecting;
|
else cls.state = ca_connecting;
|
||||||
cl.background = old_background;
|
cl.background = old_background;
|
||||||
cls.connect_time = MAX_HEARTBEAT;
|
cls.connect_time = MAX_HEARTBEAT;
|
||||||
|
UI_ConnectionProgress_ChangeLevel();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case svc_setview:
|
case svc_setview:
|
||||||
@ -2423,6 +2429,9 @@ void CL_ParseLegacyServerData( sizebuf_t *msg )
|
|||||||
|
|
||||||
if( r_decals->value > mp_decals.value )
|
if( r_decals->value > mp_decals.value )
|
||||||
Cvar_SetValue( "r_decals", mp_decals.value );
|
Cvar_SetValue( "r_decals", mp_decals.value );
|
||||||
|
|
||||||
|
if( !cls.demoplayback )
|
||||||
|
UI_ConnectionProgress_ParseServerInfo( "server" );
|
||||||
}
|
}
|
||||||
else Cvar_Reset( "r_decals" );
|
else Cvar_Reset( "r_decals" );
|
||||||
|
|
||||||
@ -2446,7 +2455,9 @@ void CL_ParseLegacyServerData( sizebuf_t *msg )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( !cls.changedemo )
|
if( !cls.changedemo )
|
||||||
UI_SetActiveMenu( cl.background );
|
{
|
||||||
|
// UI_SetActiveMenu( cl.background );
|
||||||
|
}
|
||||||
else if( !cls.demoplayback )
|
else if( !cls.demoplayback )
|
||||||
Key_SetKeyDest( key_menu );
|
Key_SetKeyDest( key_menu );
|
||||||
|
|
||||||
@ -2882,6 +2893,8 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
|
|||||||
else cls.state = ca_connecting;
|
else cls.state = ca_connecting;
|
||||||
cl.background = old_background;
|
cl.background = old_background;
|
||||||
cls.connect_time = MAX_HEARTBEAT;
|
cls.connect_time = MAX_HEARTBEAT;
|
||||||
|
|
||||||
|
UI_ConnectionProgress_ChangeLevel();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case svc_setview:
|
case svc_setview:
|
||||||
@ -3117,6 +3130,8 @@ void CL_LegacyPrecache_f( void )
|
|||||||
|
|
||||||
spawncount = Q_atoi( Cmd_Argv( 1 ));
|
spawncount = Q_atoi( Cmd_Argv( 1 ));
|
||||||
|
|
||||||
|
UI_ConnectionProgress_Precache();
|
||||||
|
|
||||||
Con_Printf( "Setting up renderer...\n" );
|
Con_Printf( "Setting up renderer...\n" );
|
||||||
|
|
||||||
// load tempent sprites (glowshell, muzzleflashes etc)
|
// load tempent sprites (glowshell, muzzleflashes etc)
|
||||||
|
@ -248,7 +248,9 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
|
|||||||
S_StopBackgroundTrack ();
|
S_StopBackgroundTrack ();
|
||||||
|
|
||||||
if( !cls.changedemo )
|
if( !cls.changedemo )
|
||||||
UI_SetActiveMenu( cl.background );
|
{
|
||||||
|
// UI_SetActiveMenu( cl.background );
|
||||||
|
}
|
||||||
else if( !cls.demoplayback )
|
else if( !cls.demoplayback )
|
||||||
Key_SetKeyDest( key_menu );
|
Key_SetKeyDest( key_menu );
|
||||||
|
|
||||||
|
@ -350,7 +350,6 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
|
|||||||
|
|
||||||
if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
|
if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
|
||||||
{
|
{
|
||||||
UI_SetActiveMenu( false );
|
|
||||||
if( cls.state == ca_disconnected )
|
if( cls.state == ca_disconnected )
|
||||||
SCR_UpdateScreen();
|
SCR_UpdateScreen();
|
||||||
}
|
}
|
||||||
|
@ -1937,8 +1937,9 @@ void Con_DrawDebug( void )
|
|||||||
|
|
||||||
if( scr_download->value != -1.0f )
|
if( scr_download->value != -1.0f )
|
||||||
{
|
{
|
||||||
|
UI_ConnectionProgress_Download( host.downloadfile, "server", NULL, 1, host.downloadcount, "(direct)" );
|
||||||
Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs",
|
Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs",
|
||||||
host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart );
|
host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart );
|
||||||
x = refState.width - 500;
|
x = refState.width - 500;
|
||||||
y = con.curFont->charHeight * 1.05f;
|
y = con.curFont->charHeight * 1.05f;
|
||||||
Con_DrawString( x, y, dlstring, g_color_table[7] );
|
Con_DrawString( x, y, dlstring, g_color_table[7] );
|
||||||
|
@ -30,6 +30,7 @@ GNU General Public License for more details.
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "client.h" // ConnectionProgress utilities
|
||||||
#include "netchan.h"
|
#include "netchan.h"
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
|
|
||||||
@ -1812,6 +1813,8 @@ static struct http_static_s
|
|||||||
// file and server lists
|
// file and server lists
|
||||||
httpfile_t *first_file, *last_file;
|
httpfile_t *first_file, *last_file;
|
||||||
httpserver_t *first_server, *last_server;
|
httpserver_t *first_server, *last_server;
|
||||||
|
|
||||||
|
int fileCount;
|
||||||
} http;
|
} http;
|
||||||
|
|
||||||
|
|
||||||
@ -1850,6 +1853,8 @@ static void HTTP_FreeFile( httpfile_t *file, qboolean error )
|
|||||||
{
|
{
|
||||||
char incname[256];
|
char incname[256];
|
||||||
|
|
||||||
|
http.fileCount--;
|
||||||
|
|
||||||
// Allways close file and socket
|
// Allways close file and socket
|
||||||
if( file->file )
|
if( file->file )
|
||||||
FS_Close( file->file );
|
FS_Close( file->file );
|
||||||
@ -2005,6 +2010,9 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI_ConnectionProgress_Download( curfile->path, curfile->server->host, curfile->server->path,
|
||||||
|
curfile->id, http.fileCount, va( "(file size is %d)", curfile->size ) );
|
||||||
|
|
||||||
curfile->state = HTTP_RESPONSE_RECEIVED; // got response, let's start download
|
curfile->state = HTTP_RESPONSE_RECEIVED; // got response, let's start download
|
||||||
begin += 4;
|
begin += 4;
|
||||||
|
|
||||||
@ -2045,9 +2053,14 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
|
|||||||
// as after it will run in same frame
|
// as after it will run in same frame
|
||||||
if( curfile->checktime > 5 )
|
if( curfile->checktime > 5 )
|
||||||
{
|
{
|
||||||
|
float speed = (float)curfile->lastchecksize / ( 5.0 * 1024 );
|
||||||
|
|
||||||
curfile->checktime = 0;
|
curfile->checktime = 0;
|
||||||
Con_Reportf( "download speed %f KB/s\n", (float)curfile->lastchecksize / ( 5.0 * 1024 ) );
|
Con_Reportf( "download speed %.2f KB/s\n", speed );
|
||||||
curfile->lastchecksize = 0;
|
curfile->lastchecksize = 0;
|
||||||
|
|
||||||
|
UI_ConnectionProgress_Download( curfile->path, curfile->server->host, curfile->server->path,
|
||||||
|
curfile->id, http.fileCount, va( "(file size is %d, speed is %.2f KB/s)", curfile->size, speed ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2095,6 +2108,7 @@ void HTTP_Run( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
Con_Reportf( "HTTP: Starting download %s from %s\n", curfile->path, curfile->server->host );
|
Con_Reportf( "HTTP: Starting download %s from %s\n", curfile->path, curfile->server->host );
|
||||||
|
UI_ConnectionProgress_Download( curfile->path, curfile->server->host, curfile->server->path, curfile->id, http.fileCount, "(starting)");
|
||||||
Q_snprintf( name, sizeof( name ), "%s.incomplete", curfile->path );
|
Q_snprintf( name, sizeof( name ), "%s.incomplete", curfile->path );
|
||||||
|
|
||||||
curfile->file = FS_Open( name, "wb", true );
|
curfile->file = FS_Open( name, "wb", true );
|
||||||
@ -2190,6 +2204,8 @@ void HTTP_Run( void )
|
|||||||
{
|
{
|
||||||
qboolean wait = false;
|
qboolean wait = false;
|
||||||
|
|
||||||
|
UI_ConnectionProgress_Download( curfile->path, curfile->server->host, curfile->server->path, curfile->id, http.fileCount, "(sending request)");
|
||||||
|
|
||||||
while( curfile->bytes_sent < curfile->query_length )
|
while( curfile->bytes_sent < curfile->query_length )
|
||||||
{
|
{
|
||||||
res = send( curfile->socket, curfile->buf + curfile->bytes_sent, curfile->query_length - curfile->bytes_sent, 0 );
|
res = send( curfile->socket, curfile->buf + curfile->bytes_sent, curfile->query_length - curfile->bytes_sent, 0 );
|
||||||
@ -2279,6 +2295,8 @@ void HTTP_AddDownload( const char *path, int size, qboolean process )
|
|||||||
|
|
||||||
Con_Reportf( "File %s queued to download\n", path );
|
Con_Reportf( "File %s queued to download\n", path );
|
||||||
|
|
||||||
|
http.fileCount++;
|
||||||
|
|
||||||
httpfile->size = size;
|
httpfile->size = size;
|
||||||
httpfile->downloaded = 0;
|
httpfile->downloaded = 0;
|
||||||
httpfile->socket = -1;
|
httpfile->socket = -1;
|
||||||
@ -2422,6 +2440,7 @@ Clear all queue
|
|||||||
static void HTTP_Clear_f( void )
|
static void HTTP_Clear_f( void )
|
||||||
{
|
{
|
||||||
http.last_file = NULL;
|
http.last_file = NULL;
|
||||||
|
http.fileCount = 0;
|
||||||
|
|
||||||
while( http.first_file )
|
while( http.first_file )
|
||||||
{
|
{
|
||||||
@ -2522,6 +2541,7 @@ void HTTP_Init( void )
|
|||||||
http.last_server = NULL;
|
http.last_server = NULL;
|
||||||
|
|
||||||
http.first_file = http.last_file = NULL;
|
http.first_file = http.last_file = NULL;
|
||||||
|
http.fileCount = 0;
|
||||||
|
|
||||||
Cmd_AddCommand("http_download", &HTTP_Download_f, "add file to download queue");
|
Cmd_AddCommand("http_download", &HTTP_Download_f, "add file to download queue");
|
||||||
Cmd_AddCommand("http_skip", &HTTP_Skip_f, "skip current download server");
|
Cmd_AddCommand("http_skip", &HTTP_Skip_f, "skip current download server");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user