summaryrefslogtreecommitdiff
path: root/source/sv_user.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2009-02-05 12:56:45 +0000
committerAndrey Nazarov <skuller@skuller.net>2009-02-05 12:56:45 +0000
commitcb1f4461911154e547a15480ef98199832a2cbf7 (patch)
treecd3b36d543b775268c7a5a4a72ece7c14b2195f0 /source/sv_user.c
parent5dea48daf494adbf28c75cb74e478e5bc15fbff4 (diff)
Report download size/done percentage in the output of ‘status d’ command.
Fixed a small memory leak possible when client was requesting another download without stopping the previous one. Properly exit dedicated server running as Win32 service given a ‘quit’ command. No longer assume ‘portalopen’ array indices to be mapped directly into ‘areaportals’ array. No longer error out when CM_SetAreaPortalState is called on the areaportal inside MAX_MAP_AREAPORTALS range but not referenced anywhere on the map. Flush server logfile on Com_Error. Changed default value of ‘uf’ cvar to include UF_LOCALFOV (from 0 to 4). Added ‘cl_lag’ macro expanding to server to client packetloss percentage.
Diffstat (limited to 'source/sv_user.c')
-rw-r--r--source/sv_user.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/source/sv_user.c b/source/sv_user.c
index 1249cbe..61ac62c 100644
--- a/source/sv_user.c
+++ b/source/sv_user.c
@@ -515,6 +515,19 @@ void SV_Begin_f( void ) {
#define MAX_DOWNLOAD_CHUNK 1024
+void SV_CloseDownload( client_t *client ) {
+ if( client->download ) {
+ Z_Free( client->download );
+ client->download = NULL;
+ }
+ if( client->downloadname ) {
+ Z_Free( client->downloadname );
+ client->downloadname = NULL;
+ }
+ client->downloadsize = 0;
+ client->downloadcount = 0;
+}
+
/*
==================
SV_NextDownload_f
@@ -544,10 +557,7 @@ static void SV_NextDownload_f( void ) {
MSG_WriteData( sv_client->download + sv_client->downloadcount - r, r );
if( sv_client->downloadcount == sv_client->downloadsize ) {
- Z_Free( sv_client->download );
- sv_client->download = NULL;
- Z_Free( sv_client->downloadname );
- sv_client->downloadname = NULL;
+ SV_CloseDownload( sv_client );
}
SV_ClientAddMessage( sv_client, MSG_RELIABLE|MSG_CLEAR );
@@ -631,8 +641,7 @@ static void SV_BeginDownload_f( void ) {
if( sv_client->download ) {
Com_DPrintf( "Closing existing download for %s (should not happen)\n", sv_client->name );
- FS_FreeFile( sv_client->download );
- sv_client->download = NULL;
+ SV_CloseDownload( sv_client );
}
downloadsize = FS_LoadFileEx( name, NULL, 0, TAG_SERVER );
@@ -699,10 +708,7 @@ static void SV_StopDownload_f( void ) {
Com_DPrintf( "Download of %s to %s stopped by user request\n",
sv_client->downloadname, sv_client->name );
- Z_Free( sv_client->download );
- sv_client->download = NULL;
- Z_Free( sv_client->downloadname );
- sv_client->downloadname = NULL;
+ SV_CloseDownload( sv_client );
}
//============================================================================