Browse Source

engine: client: implement connectionprogress partially

pull/2/head
Alibek Omarov 5 years ago
parent
commit
cb417a3d51
  1. 20
      engine/client/cl_main.c
  2. 21
      engine/client/cl_parse.c
  3. 4
      engine/client/cl_qparse.c
  4. 1
      engine/client/cl_scrn.c
  5. 3
      engine/client/console.c
  6. 22
      engine/common/net_ws.c

20
engine/client/cl_main.c

@ -193,6 +193,8 @@ void CL_CheckClientState( void ) @@ -193,6 +193,8 @@ void CL_CheckClientState( void )
Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar
Netchan_ReportFlow( &cls.netchan );
UI_SetActiveMenu( false );
Con_DPrintf( "client connected at %.2f sec\n", Sys_DoubleTime() - cls.timestart );
if(( cls.demoplayback || cls.disable_servercount != cl.servercount ) && cl.video_prepped )
SCR_EndLoadingPlaque(); // get rid of loading plaque
@ -1141,6 +1143,12 @@ void CL_CheckForResend( void ) @@ -1141,6 +1143,12 @@ void CL_CheckForResend( void )
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 )
{
// too many fails use default connection method
@ -1249,10 +1257,6 @@ void CL_Connect_f( void ) @@ -1249,10 +1257,6 @@ void CL_Connect_f( void )
Con_Printf( "server %s\n", server );
CL_Disconnect();
// TESTTEST: a see console during connection
UI_SetActiveMenu( false );
Key_SetKeyDest( key_console );
cls.state = ca_connecting;
cls.legacymode = legacyconnect;
Q_strncpy( cls.servername, server, sizeof( cls.servername ));
@ -1503,6 +1507,8 @@ void CL_Disconnect( void ) @@ -1503,6 +1507,8 @@ void CL_Disconnect( void )
IN_LockInputDevices( false ); // unlock input devices
UI_ConnectionProgress_Disconnect();
cls.state = ca_disconnected;
memset( &cls.serveradr, 0, sizeof( cls.serveradr ) );
cls.set_lastdemo = false;
@ -1914,7 +1920,6 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) @@ -1914,7 +1920,6 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
}
CL_Reconnect( true );
UI_SetActiveMenu( cl.background );
}
else if( !Q_strcmp( c, "info" ))
{
@ -1995,7 +2000,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) @@ -1995,7 +2000,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
else
{
if( cls.connect_retry >= CL_TEST_RETRIES )
{
{
// too many fails use default connection method
Con_Printf( "hi-speed connection is failed, use default method\n" );
Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" );
@ -2408,6 +2413,7 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename ) @@ -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 ));
}
if( cls.legacymode )
{
if( host.downloadcount > 0 )
@ -2607,6 +2613,8 @@ qboolean CL_PrecacheResources( void ) @@ -2607,6 +2613,8 @@ qboolean CL_PrecacheResources( void )
{
resource_t *pRes;
UI_ConnectionProgress_Precache();
// NOTE: world need to be loaded as first model
for( pRes = cl.resourcesonhand.pNext; pRes && pRes != &cl.resourcesonhand; pRes = pRes->pNext )
{

21
engine/client/cl_parse.c

@ -904,7 +904,7 @@ void CL_ParseServerData( sizebuf_t *msg ) @@ -904,7 +904,7 @@ void CL_ParseServerData( sizebuf_t *msg )
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( va( "%c%s\n\n", 2, clgame.maptitle ));
}
@ -920,6 +920,9 @@ void CL_ParseServerData( sizebuf_t *msg ) @@ -920,6 +920,9 @@ void CL_ParseServerData( sizebuf_t *msg )
if( r_decals->value > mp_decals.value )
Cvar_SetValue( "r_decals", mp_decals.value );
if( !cls.demoplayback )
UI_ConnectionProgress_ParseServerInfo( "server" );
}
else Cvar_Reset( "r_decals" );
@ -943,7 +946,9 @@ void CL_ParseServerData( sizebuf_t *msg ) @@ -943,7 +946,9 @@ void CL_ParseServerData( sizebuf_t *msg )
}
if( !cls.changedemo )
UI_SetActiveMenu( cl.background );
{
// UI_SetActiveMenu( cl.background );
}
else if( !cls.demoplayback )
Key_SetKeyDest( key_menu );
@ -2131,6 +2136,7 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) @@ -2131,6 +2136,7 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
else cls.state = ca_connecting;
cl.background = old_background;
cls.connect_time = MAX_HEARTBEAT;
UI_ConnectionProgress_ChangeLevel();
}
break;
case svc_setview:
@ -2423,6 +2429,9 @@ void CL_ParseLegacyServerData( sizebuf_t *msg ) @@ -2423,6 +2429,9 @@ void CL_ParseLegacyServerData( sizebuf_t *msg )
if( r_decals->value > mp_decals.value )
Cvar_SetValue( "r_decals", mp_decals.value );
if( !cls.demoplayback )
UI_ConnectionProgress_ParseServerInfo( "server" );
}
else Cvar_Reset( "r_decals" );
@ -2446,7 +2455,9 @@ void CL_ParseLegacyServerData( sizebuf_t *msg ) @@ -2446,7 +2455,9 @@ void CL_ParseLegacyServerData( sizebuf_t *msg )
}
if( !cls.changedemo )
UI_SetActiveMenu( cl.background );
{
// UI_SetActiveMenu( cl.background );
}
else if( !cls.demoplayback )
Key_SetKeyDest( key_menu );
@ -2882,6 +2893,8 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message ) @@ -2882,6 +2893,8 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
else cls.state = ca_connecting;
cl.background = old_background;
cls.connect_time = MAX_HEARTBEAT;
UI_ConnectionProgress_ChangeLevel();
}
break;
case svc_setview:
@ -3117,6 +3130,8 @@ void CL_LegacyPrecache_f( void ) @@ -3117,6 +3130,8 @@ void CL_LegacyPrecache_f( void )
spawncount = Q_atoi( Cmd_Argv( 1 ));
UI_ConnectionProgress_Precache();
Con_Printf( "Setting up renderer...\n" );
// load tempent sprites (glowshell, muzzleflashes etc)

4
engine/client/cl_qparse.c

@ -248,7 +248,9 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg ) @@ -248,7 +248,9 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
S_StopBackgroundTrack ();
if( !cls.changedemo )
UI_SetActiveMenu( cl.background );
{
// UI_SetActiveMenu( cl.background );
}
else if( !cls.demoplayback )
Key_SetKeyDest( key_menu );

1
engine/client/cl_scrn.c

@ -350,7 +350,6 @@ void SCR_BeginLoadingPlaque( qboolean is_background ) @@ -350,7 +350,6 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
{
UI_SetActiveMenu( false );
if( cls.state == ca_disconnected )
SCR_UpdateScreen();
}

3
engine/client/console.c

@ -1937,8 +1937,9 @@ void Con_DrawDebug( void ) @@ -1937,8 +1937,9 @@ void Con_DrawDebug( void )
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",
host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart );
host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart );
x = refState.width - 500;
y = con.curFont->charHeight * 1.05f;
Con_DrawString( x, y, dlstring, g_color_table[7] );

22
engine/common/net_ws.c

@ -30,6 +30,7 @@ GNU General Public License for more details. @@ -30,6 +30,7 @@ GNU General Public License for more details.
#include <fcntl.h>
#endif
#include "common.h"
#include "client.h" // ConnectionProgress utilities
#include "netchan.h"
#include "mathlib.h"
@ -1812,6 +1813,8 @@ static struct http_static_s @@ -1812,6 +1813,8 @@ static struct http_static_s
// file and server lists
httpfile_t *first_file, *last_file;
httpserver_t *first_server, *last_server;
int fileCount;
} http;
@ -1850,6 +1853,8 @@ static void HTTP_FreeFile( httpfile_t *file, qboolean error ) @@ -1850,6 +1853,8 @@ static void HTTP_FreeFile( httpfile_t *file, qboolean error )
{
char incname[256];
http.fileCount--;
// Allways close file and socket
if( file->file )
FS_Close( file->file );
@ -2005,6 +2010,9 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile ) @@ -2005,6 +2010,9 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
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
begin += 4;
@ -2045,9 +2053,14 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile ) @@ -2045,9 +2053,14 @@ static qboolean HTTP_ProcessStream( httpfile_t *curfile )
// as after it will run in same frame
if( curfile->checktime > 5 )
{
float speed = (float)curfile->lastchecksize / ( 5.0 * 1024 );
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;
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 ) @@ -2095,6 +2108,7 @@ void HTTP_Run( void )
}
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 );
curfile->file = FS_Open( name, "wb", true );
@ -2190,6 +2204,8 @@ void HTTP_Run( void ) @@ -2190,6 +2204,8 @@ void HTTP_Run( void )
{
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 )
{
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 ) @@ -2279,6 +2295,8 @@ void HTTP_AddDownload( const char *path, int size, qboolean process )
Con_Reportf( "File %s queued to download\n", path );
http.fileCount++;
httpfile->size = size;
httpfile->downloaded = 0;
httpfile->socket = -1;
@ -2422,6 +2440,7 @@ Clear all queue @@ -2422,6 +2440,7 @@ Clear all queue
static void HTTP_Clear_f( void )
{
http.last_file = NULL;
http.fileCount = 0;
while( http.first_file )
{
@ -2522,6 +2541,7 @@ void HTTP_Init( void ) @@ -2522,6 +2541,7 @@ void HTTP_Init( void )
http.last_server = 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_skip", &HTTP_Skip_f, "skip current download server");

Loading…
Cancel
Save