diff options
author | Christopher Schwarz <lakitu7@gmail.com> | 2009-10-12 19:17:00 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:48 +0000 |
commit | cf8d239dbe92720a24e8968c0b00ec2d4eec060f (patch) | |
tree | f587fcdfcd80f8e6e9e3342dde57d2172f4c7ec6 /src/client | |
parent | 244808767a99cc237a477262420c43c126732088 (diff) |
* (bug 4295) Add an option to view Tremulous news to the main menu
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/cl_main.c | 6 | ||||
-rw-r--r-- | src/client/cl_ui.c | 51 | ||||
-rw-r--r-- | src/client/client.h | 2 |
3 files changed, 57 insertions, 2 deletions
diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 09c42e63..0aafa529 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -1869,11 +1869,13 @@ void CL_DownloadsComplete( void ) { CL_cURL_Shutdown(); if( clc.cURLDisconnected ) { if(clc.downloadRestart) { - FS_Restart(clc.checksumFeed); + if( !clc.activeCURLNotGameRelated ) + FS_Restart(clc.checksumFeed); clc.downloadRestart = qfalse; } clc.cURLDisconnected = qfalse; - CL_Reconnect_f(); + if( !clc.activeCURLNotGameRelated ) + CL_Reconnect_f(); return; } } diff --git a/src/client/cl_ui.c b/src/client/cl_ui.c index 4c1ff9ed..caf55ef0 100644 --- a/src/client/cl_ui.c +++ b/src/client/cl_ui.c @@ -81,6 +81,52 @@ void LAN_SaveServersToCache( void ) { FS_FCloseFile(fileOut); } +/* +==================== +GetNews +==================== +*/ +qboolean GetNews( qboolean begin ) +{ +#ifdef USE_CURL + qboolean finished = qfalse; + fileHandle_t fileIn; + int readSize; + + if( begin ) { // if not already using curl, start the download + if( !clc.downloadCURLM ) { + if(!CL_cURL_Init()) { + Cvar_Set( "cl_newsString", "^1Error: Could not load cURL library" ); + return qtrue; + } + clc.activeCURLNotGameRelated = qtrue; + CL_cURL_BeginDownload("news.dat", + "http://tremulous.net/clientnews.txt"); + return qfalse; + } + } + + if ( !clc.downloadCURLM && FS_SV_FOpenFileRead("news.dat", &fileIn)) { + readSize = FS_Read(clc.newsString, sizeof( clc.newsString ), fileIn); + FS_FCloseFile(fileIn); + clc.newsString[ readSize ] = '\0'; + if( readSize > 0 ) { + finished = qtrue; + clc.cURLUsed = qfalse; + CL_cURL_Shutdown(); + clc.activeCURLNotGameRelated = qfalse; + } + } + if( !finished ) + strcpy( clc.newsString, "Retrieving..." ); +#else + Cvar_Set( "cl_newsString", + "^1You must compile your client with CURL support to use this feature" ); + return qtrue; +#endif + Cvar_Set( "cl_newsString", clc.newsString ); + return finished; +} /* ==================== @@ -907,6 +953,9 @@ intptr_t CL_UISystemCalls( intptr_t *args ) { case UI_LAN_SERVERSTATUS: return LAN_GetServerStatus( VMA(1), VMA(2), args[3] ); + case UI_GETNEWS: + return GetNews( args[1] ); + case UI_LAN_COMPARESERVERS: return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] ); @@ -1059,6 +1108,8 @@ void CL_InitUI( void ) { // reset any CVAR_CHEAT cvars registered by ui if ( !clc.demoplaying && !cl_connectedToCheatServer ) Cvar_SetCheatState(); + + clc.newsString[ 0 ] = '\0'; } /* diff --git a/src/client/client.h b/src/client/client.h index 206d5dd9..a6d61950 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -204,6 +204,7 @@ typedef struct { char downloadURL[MAX_OSPATH]; CURL *downloadCURL; CURLM *downloadCURLM; + qboolean activeCURLNotGameRelated; #endif /* USE_CURL */ int sv_allowDownload; char sv_dlURL[MAX_CVAR_VALUE_STRING]; @@ -213,6 +214,7 @@ typedef struct { int downloadSize; // how many bytes we got char downloadList[MAX_INFO_STRING]; // list of paks we need to download qboolean downloadRestart; // if true, we need to do another FS_Restart because we downloaded a pak + char newsString[ MAX_NEWS_STRING ]; // demo information char demoName[MAX_QPATH]; |