diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 47c00a99..c2486c65 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1597,6 +1597,9 @@ void CL_SetupNetchanForProtocol( connprotocol_t proto ) } break; default: + if( !Host_IsLocalClient( )) + SetBits( flags, NETCHAN_USE_LZSS ); + cls.extensions = Q_atoi( Info_ValueForKey( Cmd_Argv( 1 ), "ext" )); if( FBitSet( cls.extensions, NET_EXT_SPLITSIZE )) diff --git a/engine/common/net_chan.c b/engine/common/net_chan.c index 29f7c904..cdfbb350 100644 --- a/engine/common/net_chan.c +++ b/engine/common/net_chan.c @@ -341,6 +341,7 @@ void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, voi chan->split = FBitSet( flags, NETCHAN_USE_LEGACY_SPLIT ) ? true : false; chan->use_munge = FBitSet( flags, NETCHAN_USE_MUNGE ) ? true : false; chan->use_bz2 = FBitSet( flags, NETCHAN_USE_BZIP2 ) ? true : false; + chan->use_lzss = FBitSet( flags, NETCHAN_USE_LZSS ) ? true : false; chan->gs_netchan = FBitSet( flags, NETCHAN_GOLDSRC ) ? true : false; MSG_Init( &chan->message, "NetData", chan->message_buf, sizeof( chan->message_buf )); @@ -766,7 +767,7 @@ static void Netchan_CreateFragments_( netchan_t *chan, sizebuf_t *msg ) Host_Error( "%s: BZ2 compression is not supported for server", __func__ ); #endif } - else if( !chan->use_bz2 && !LZSS_IsCompressed( MSG_GetData( msg ), MSG_GetMaxBytes( msg ))) + else if( chan->use_lzss && !LZSS_IsCompressed( MSG_GetData( msg ), MSG_GetMaxBytes( msg ))) { uint uCompressedSize = 0; uint uSourceSize = MSG_GetNumBytesWritten( msg ); @@ -1173,7 +1174,7 @@ qboolean Netchan_CopyNormalFragments( netchan_t *chan, sizebuf_t *msg, size_t *l p = n; } - if( chan->use_bz2 && !memcmp( MSG_GetData( msg ), "BZ2", 4 ) ) + if( chan->use_bz2 && !memcmp( MSG_GetData( msg ), "BZ2", 4 )) { #if !XASH_DEDICATED byte buf[0x10000]; @@ -1194,7 +1195,7 @@ qboolean Netchan_CopyNormalFragments( netchan_t *chan, sizebuf_t *msg, size_t *l Host_Error( "%s: BZ2 compression is not supported for server\n", __func__ ); #endif } - else if( !chan->use_bz2 && LZSS_IsCompressed( MSG_GetData( msg ), size )) + else if( chan->use_lzss && LZSS_IsCompressed( MSG_GetData( msg ), size )) { uint uDecompressedLen = LZSS_GetActualSize( MSG_GetData( msg ), size ); byte buf[NET_MAX_MESSAGE]; @@ -1345,7 +1346,7 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg ) Host_Error( "%s: BZ2 compression is not supported for server", __func__ ); #endif } - else if( LZSS_IsCompressed( buffer, nsize + 1 )) + else if( chan->use_lzss && LZSS_IsCompressed( buffer, nsize + 1 )) { byte *uncompressedBuffer; diff --git a/engine/common/netchan.h b/engine/common/netchan.h index c06391b1..b7f55e30 100644 --- a/engine/common/netchan.h +++ b/engine/common/netchan.h @@ -214,6 +214,7 @@ typedef enum netchan_flags_e NETCHAN_USE_MUNGE = BIT( 1 ), NETCHAN_USE_BZIP2 = BIT( 2 ), NETCHAN_GOLDSRC = BIT( 3 ), + NETCHAN_USE_LZSS = BIT( 4 ), // mutually exclusive with bzip2 } netchan_flags_t; // Network Connection Channel @@ -285,6 +286,7 @@ typedef struct netchan_s qboolean split; qboolean use_munge; qboolean use_bz2; + qboolean use_lzss; qboolean gs_netchan; } netchan_t; diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index 5cd5bb20..d819bb6d 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -305,6 +305,7 @@ static void SV_ConnectClient( netadr_t from ) int challenge; const char *s; int extensions; + uint netchan_flags = 0; if( Cmd_Argc() < 5 ) { @@ -431,7 +432,9 @@ static void SV_ConnectClient( netadr_t from ) newcl->listeners = -1; // initailize netchan - Netchan_Setup( NS_SERVER, &newcl->netchan, from, qport, newcl, SV_GetFragmentSize, 0 ); + if( !Host_IsLocalClient( )) + SetBits( netchan_flags, NETCHAN_USE_LZSS ); + Netchan_Setup( NS_SERVER, &newcl->netchan, from, qport, newcl, SV_GetFragmentSize, netchan_flags ); MSG_Init( &newcl->datagram, "Datagram", newcl->datagram_buf, sizeof( newcl->datagram_buf )); // datagram buf Q_strncpy( newcl->hashedcdkey, Info_ValueForKey( protinfo, "uuid" ), 32 ); @@ -450,8 +453,6 @@ static void SV_ConnectClient( netadr_t from ) newcl->delta_sequence = -1; newcl->flags = 0; - - // reset any remaining events memset( &newcl->events, 0, sizeof( newcl->events ));