diff options
Diffstat (limited to 'src/client/cl_main.c')
-rw-r--r-- | src/client/cl_main.c | 131 |
1 files changed, 119 insertions, 12 deletions
diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 808553b9..aefbab8c 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -655,6 +655,9 @@ CL_ShutdownAll */ void CL_ShutdownAll(void) { +#if USE_CURL + CL_cURL_Shutdown(); +#endif // clear sounds S_DisableSounds(); // shutdown CGame @@ -1159,6 +1162,9 @@ void CL_Vid_Restart_f( void ) { CL_CloseAVI( ); } + if(clc.demorecording) + CL_StopRecord_f(); + // don't let them loop during the restart S_StopAllSounds(); // shutdown the UI @@ -1291,6 +1297,23 @@ Called when all downloading has been completed */ void CL_DownloadsComplete( void ) { +#if USE_CURL + // if we downloaded with cURL + if(clc.cURLUsed) { + clc.cURLUsed = qfalse; + CL_cURL_Shutdown(); + if( clc.cURLDisconnected ) { + if(clc.downloadRestart) { + FS_Restart(clc.checksumFeed); + clc.downloadRestart = qfalse; + } + clc.cURLDisconnected = qfalse; + CL_Reconnect_f(); + return; + } + } +#endif + // if we downloaded files we need to restart the file system if (clc.downloadRestart) { clc.downloadRestart = qfalse; @@ -1378,6 +1401,7 @@ A download completed or failed void CL_NextDownload(void) { char *s; char *remoteName, *localName; + qboolean useCURL = qfalse; // We are looking to start a download here if (*clc.downloadList) { @@ -1401,9 +1425,48 @@ void CL_NextDownload(void) { *s++ = 0; else s = localName + strlen(localName); // point at the nul byte - - CL_BeginDownload( localName, remoteName ); - +#if USE_CURL + if(!(cl_allowDownload->integer & DLF_NO_REDIRECT)) { + if(clc.sv_allowDownload & DLF_NO_REDIRECT) { + Com_Printf("WARNING: server does not " + "allow download redirection " + "(sv_allowDownload is %d)\n", + clc.sv_allowDownload); + } + else if(!*clc.sv_dlURL) { + Com_Printf("WARNING: server allows " + "download redirection, but does not " + "have sv_dlURL set\n"); + } + else if(!CL_cURL_Init()) { + Com_Printf("WARNING: could not load " + "cURL library\n"); + } + else { + CL_cURL_BeginDownload(localName, va("%s/%s", + clc.sv_dlURL, remoteName)); + useCURL = qtrue; + } + } + else if(!(clc.sv_allowDownload & DLF_NO_REDIRECT)) { + Com_Printf("WARNING: server allows download " + "redirection, but it disabled by client " + "configuration (cl_allowDownload is %d)\n", + cl_allowDownload->integer); + } +#endif /* USE_CURL */ + if(!useCURL) { + if((cl_allowDownload->integer & DLF_NO_UDP)) { + Com_Error(ERR_DROP, "UDP Downloads are " + "disabled on your client. " + "(cl_allowDownload is %d)", + cl_allowDownload->integer); + return; + } + else { + CL_BeginDownload( localName, remoteName ); + } + } clc.downloadRestart = qtrue; // move over the rest @@ -1426,7 +1489,7 @@ and determine if we need to download them void CL_InitDownloads(void) { char missingfiles[1024]; - if ( !cl_allowDownload->integer ) + if ( !(cl_allowDownload->integer & DLF_ENABLE) ) { // autodownload is disabled on the client // but it's possible that some referenced files on the server are missing @@ -1911,7 +1974,7 @@ void CL_CheckTimeout( void ) { // // check timeout // - if ( ( !cl_paused->integer || !sv_paused->integer ) + if ( ( !CL_CheckPaused() || !sv_paused->integer ) && cls.state >= CA_CONNECTED && cls.state != CA_CINEMATIC && cls.realtime - clc.lastPacketTime > cl_timeout->value*1000) { if (++cl.timeoutcount > 5) { // timeoutcount saves debugger @@ -1924,6 +1987,22 @@ void CL_CheckTimeout( void ) { } } +/* +================== +CL_CheckPaused +Check whether client has been paused. +================== +*/ +qboolean CL_CheckPaused(void) +{ + // if cl_paused->modified is set, the cvar has only been changed in + // this frame. Keep paused in this frame to ensure the server doesn't + // lag behind. + if(cl_paused->integer || cl_paused->modified) + return qtrue; + + return qfalse; +} //============================================================================ @@ -1935,19 +2014,19 @@ CL_CheckUserinfo */ void CL_CheckUserinfo( void ) { // don't add reliable commands when not yet connected - if ( cls.state < CA_CHALLENGING ) { + if(cls.state < CA_CHALLENGING) return; - } + // don't overflow the reliable command buffer when paused - if ( cl_paused->integer ) { + if(CL_CheckPaused()) return; - } + // send a reliable userinfo update if needed - if ( cvar_modifiedFlags & CVAR_USERINFO ) { + if(cvar_modifiedFlags & CVAR_USERINFO) + { cvar_modifiedFlags &= ~CVAR_USERINFO; CL_AddReliableCommand( va("userinfo \"%s\"", Cvar_InfoString( CVAR_USERINFO ) ) ); } - } /* @@ -1962,6 +2041,25 @@ void CL_Frame ( int msec ) { return; } +#if USE_CURL + if(clc.downloadCURLM) { + CL_cURL_PerformDownload(); + // we can't process frames normally when in disconnected + // download mode since the ui vm expects cls.state to be + // CA_CONNECTED + if(clc.cURLDisconnected) { + cls.realFrametime = msec; + cls.frametime = msec; + cls.realtime += cls.frametime; + SCR_UpdateScreen(); + S_Update(); + Con_RunConsole(); + cls.framecount++; + return; + } + } +#endif + if ( cls.state == CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_UI ) && !com_sv_running->integer ) { // if disconnected, bring up the menu @@ -2273,6 +2371,12 @@ void CL_Video_f( void ) char filename[ MAX_OSPATH ]; int i, last; + if( !clc.demoplaying ) + { + Com_Printf( "The video command can only be used when playing back demos\n" ); + return; + } + if( Cmd_Argc( ) == 2 ) { // explicit filename @@ -2404,6 +2508,9 @@ void CL_Init( void ) { cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0); cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE); +#if USE_CURL + cl_cURLLib = Cvar_Get("cl_cURLLib", DEFAULT_CURL_LIB, CVAR_ARCHIVE); +#endif cl_conXOffset = Cvar_Get ("cl_conXOffset", "0", 0); #ifdef MACOS_X @@ -2718,7 +2825,7 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { Q_strncpyz( info, MSG_ReadString( msg ), MAX_INFO_STRING ); if (strlen(info)) { if (info[strlen(info)-1] != '\n') { - strncat(info, "\n", sizeof(info)); + strncat(info, "\n", sizeof(info) - 1); } Com_Printf( "%s: %s", NET_AdrToString( from ), info ); } |