Skip to content

Commit 5a5ab42

Browse files
committed
Client: only store download names in client static
Not in client connection and client static. This was some oversight in transitioning from ioq3/q3e downloads which moves all download data only into client connection which may be causing some weird issues in our client. Most likely unrelated to server illegible error issue.
1 parent 34c516f commit 5a5ab42

4 files changed

Lines changed: 25 additions & 28 deletions

File tree

src/client/cl_input.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,15 +805,15 @@ static qboolean CL_ReadyToSendPacket( void ) {
805805
}
806806

807807
// If we are downloading, we send no less than 50ms between packets
808-
if ( *clc.downloadTempName && cls.realtime - clc.lastPacketSentTime < 50 ) {
808+
if ( *cls.downloadTempName && cls.realtime - clc.lastPacketSentTime < 50 ) {
809809
return qfalse;
810810
}
811811

812812
// if we don't have a valid gamestate yet, only send
813813
// one packet a second
814814
if ( cls.state != CA_ACTIVE &&
815815
cls.state != CA_PRIMED &&
816-
!*clc.downloadTempName &&
816+
!*cls.downloadTempName &&
817817
cls.realtime - clc.lastPacketSentTime < 1000 ) {
818818
return qfalse;
819819
}

src/client/cl_main.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ qboolean CL_Disconnect( qboolean showMainMenu ) {
14011401
FS_FCloseFile( clc.download );
14021402
clc.download = FS_INVALID_HANDLE;
14031403
}
1404-
*clc.downloadTempName = *clc.downloadName = '\0';
1404+
*cls.downloadTempName = *cls.downloadName = '\0';
14051405
Cvar_Set( "cl_downloadName", "" );
14061406
}
14071407

@@ -2208,9 +2208,7 @@ static void CL_BeginDownload( const char *localName, const char *remoteName ) {
22082208
"Remotename: %s\n"
22092209
"****************************\n", localName, remoteName);
22102210

2211-
Q_strncpyz ( clc.downloadName, localName, sizeof(clc.downloadName) );
22122211
Q_strncpyz ( cls.downloadName, localName, sizeof(cls.downloadName) );
2213-
Com_sprintf( clc.downloadTempName, sizeof(clc.downloadTempName), "%s.tmp", localName );
22142212
Com_sprintf( cls.downloadTempName, sizeof(cls.downloadTempName), "%s.tmp", localName );
22152213

22162214
// Set so UI gets access to it
@@ -2239,15 +2237,15 @@ void CL_NextDownload( void )
22392237
char *remoteName, *localName;
22402238

22412239
// A download has finished, check whether this matches a referenced checksum
2242-
if(*clc.downloadName)
2240+
if(*cls.downloadName)
22432241
{
2244-
const char *zippath = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), clc.downloadName, NULL );
2242+
const char *zippath = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), cls.downloadName, NULL );
22452243

22462244
if(!FS_CompareZipChecksum(zippath))
2247-
Com_Error(ERR_DROP, "Incorrect checksum for file: %s", clc.downloadName);
2245+
Com_Error(ERR_DROP, "Incorrect checksum for file: %s", cls.downloadName);
22482246
}
22492247

2250-
*clc.downloadTempName = *clc.downloadName = '\0';
2248+
*cls.downloadTempName = *cls.downloadName = '\0';
22512249
Cvar_Set("cl_downloadName", "");
22522250

22532251
// We are looking to start a download here
@@ -2330,7 +2328,7 @@ void CL_InitDownloads( void ) {
23302328
// if autodownloading is not enabled on the server
23312329
cls.state = CA_CONNECTED;
23322330

2333-
*clc.downloadTempName = *clc.downloadName = '\0';
2331+
*cls.downloadTempName = *cls.downloadName = '\0';
23342332
Cvar_Set( "cl_downloadName", "" );
23352333

23362334
CL_NextDownload();
@@ -2340,7 +2338,7 @@ void CL_InitDownloads( void ) {
23402338
}
23412339

23422340
#ifdef USE_CURL
2343-
if ( cl_mapAutoDownload->integer && ( clc.demoplaying || (clc.download == FS_INVALID_HANDLE && !*clc.downloadName) ) )
2341+
if ( cl_mapAutoDownload->integer && ( clc.demoplaying || (clc.download == FS_INVALID_HANDLE && !*cls.downloadName) ) )
23442342
{
23452343
const char *info, *mapname, *bsp;
23462344

@@ -3254,8 +3252,8 @@ void CL_WWWDownload( void ) {
32543252
// just to be safe
32553253
Com_Printf( "ERROR: redirectedList overflow (%s)\n", clc.redirectedList );
32563254
} else {
3257-
strcat( clc.redirectedList, "@" );
3258-
strcat( clc.redirectedList, cls.originalDownloadName );
3255+
Q_strcat( clc.redirectedList, sizeof( clc.redirectedList), "@" );
3256+
Q_strcat( clc.redirectedList, sizeof( clc.redirectedList), cls.originalDownloadName );
32593257
}
32603258
}
32613259
} else
@@ -3299,8 +3297,8 @@ qboolean CL_WWWBadChecksum( const char *pakname ) {
32993297
Com_Printf( "ERROR: badChecksumList overflowed (%s)\n", clc.badChecksumList );
33003298
return qfalse;
33013299
}
3302-
strcat( clc.badChecksumList, "@" );
3303-
strcat( clc.badChecksumList, pakname );
3300+
Q_strcat( clc.badChecksumList, sizeof(clc.badChecksumList), "@" );
3301+
Q_strcat( clc.badChecksumList, sizeof(clc.badChecksumList), pakname );
33043302
Com_DPrintf( "bad checksums: %s\n", clc.badChecksumList );
33053303
return qtrue;
33063304
}

src/client/cl_parse.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -929,11 +929,11 @@ A download message has been received from the server
929929
=====================
930930
*/
931931
static void CL_ParseDownload( msg_t *msg ) {
932-
int size;
932+
int size, dummy;
933933
unsigned char data[ MAX_MSGLEN ];
934934
uint16_t block;
935935

936-
if (!*clc.downloadTempName) {
936+
if (!*cls.downloadTempName) {
937937
Com_Printf("Server sending download, but no download was requested\n");
938938
CL_AddReliableCommand( "stopdl", qfalse );
939939
return;
@@ -944,11 +944,12 @@ static void CL_ParseDownload( msg_t *msg ) {
944944
}
945945

946946
// read the data
947-
block = MSG_ReadShort ( msg );
947+
dummy = MSG_ReadShort ( msg );
948+
block = (uint16_t)dummy;
948949

949950
// TTimo - www dl
950951
// if we haven't acked the download redirect yet
951-
if ( block == UINT16_MAX ) {
952+
if ( dummy == -1 ) {
952953
if ( !clc.bWWWDl ) {
953954
// server is sending us a www download
954955
Q_strncpyz( cls.originalDownloadName, cls.downloadName, sizeof( cls.originalDownloadName ) );
@@ -1037,17 +1038,17 @@ static void CL_ParseDownload( msg_t *msg ) {
10371038
{
10381039
if ( !CL_ValidPakSignature( data, size ) )
10391040
{
1040-
Com_Printf( S_COLOR_YELLOW "Invalid pak signature for %s\n", clc.downloadName );
1041+
Com_Printf( S_COLOR_YELLOW "Invalid pak signature for %s\n", cls.downloadName );
10411042
CL_AddReliableCommand( "stopdl", qfalse );
10421043
CL_NextDownload();
10431044
return;
10441045
}
10451046

1046-
clc.download = FS_SV_FOpenFileWrite( clc.downloadTempName );
1047+
clc.download = FS_SV_FOpenFileWrite( cls.downloadTempName );
10471048

10481049
if ( clc.download == FS_INVALID_HANDLE )
10491050
{
1050-
Com_Printf( "Could not create %s\n", clc.downloadTempName );
1051+
Com_Printf( "Could not create %s\n", cls.downloadTempName );
10511052
CL_AddReliableCommand( "stopdl", qfalse );
10521053
CL_NextDownload();
10531054
return;
@@ -1065,13 +1066,13 @@ static void CL_ParseDownload( msg_t *msg ) {
10651066
// So UI gets access to it
10661067
Cvar_SetIntegerValue( "cl_downloadCount", clc.downloadCount );
10671068

1068-
if (!size) { // A zero length block means EOF
1069+
if ( size == 0 ) { // A zero length block means EOF
10691070
if ( clc.download != FS_INVALID_HANDLE ) {
10701071
FS_FCloseFile( clc.download );
10711072
clc.download = FS_INVALID_HANDLE;
10721073

10731074
// rename the file
1074-
FS_SV_Rename( clc.downloadTempName, clc.downloadName );
1075+
FS_SV_Rename( cls.downloadTempName, cls.downloadName );
10751076
}
10761077
*cls.downloadTempName = *cls.downloadName = '\0';
10771078
Cvar_Set( "cl_downloadName", "" );

src/client/client.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ typedef struct {
258258

259259
// file transfer from server
260260
fileHandle_t download;
261-
char downloadName[MAX_OSPATH];
262-
char downloadTempName[MAX_OSPATH + 4]; // downloadName + ".tmp"
263261
int downloadNumber;
264262
int downloadBlock; // block we are waiting for
265263
int downloadCount; // how many bytes we got
@@ -270,8 +268,8 @@ typedef struct {
270268
// www downloading
271269
qboolean bWWWDl; // we have a www download going
272270
qboolean bWWWDlAborting; // disable the CL_WWWDownload until server gets us a gamestate (used for aborts)
273-
char redirectedList[MAX_INFO_STRING]; // list of files that we downloaded through a redirect since last FS_ComparePaks
274-
char badChecksumList[MAX_INFO_STRING]; // list of files for which wwwdl redirect is broken (wrong checksum)
271+
char redirectedList[BIG_INFO_STRING]; // list of files that we downloaded through a redirect since last FS_ComparePaks
272+
char badChecksumList[BIG_INFO_STRING]; // list of files for which wwwdl redirect is broken (wrong checksum)
275273

276274
// demo information
277275
char demoName[MAX_OSPATH];

0 commit comments

Comments
 (0)