engine: make LZSS compression optional for 49 protocol, disable it for local clients (singleplayer)
This commit is contained in:
parent
d29e53481d
commit
1e075d25b7
4 changed files with 14 additions and 7 deletions
|
@ -1597,6 +1597,9 @@ void CL_SetupNetchanForProtocol( connprotocol_t proto )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if( !Host_IsLocalClient( ))
|
||||||
|
SetBits( flags, NETCHAN_USE_LZSS );
|
||||||
|
|
||||||
cls.extensions = Q_atoi( Info_ValueForKey( Cmd_Argv( 1 ), "ext" ));
|
cls.extensions = Q_atoi( Info_ValueForKey( Cmd_Argv( 1 ), "ext" ));
|
||||||
|
|
||||||
if( FBitSet( cls.extensions, NET_EXT_SPLITSIZE ))
|
if( FBitSet( cls.extensions, NET_EXT_SPLITSIZE ))
|
||||||
|
|
|
@ -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->split = FBitSet( flags, NETCHAN_USE_LEGACY_SPLIT ) ? true : false;
|
||||||
chan->use_munge = FBitSet( flags, NETCHAN_USE_MUNGE ) ? true : false;
|
chan->use_munge = FBitSet( flags, NETCHAN_USE_MUNGE ) ? true : false;
|
||||||
chan->use_bz2 = FBitSet( flags, NETCHAN_USE_BZIP2 ) ? 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;
|
chan->gs_netchan = FBitSet( flags, NETCHAN_GOLDSRC ) ? true : false;
|
||||||
|
|
||||||
MSG_Init( &chan->message, "NetData", chan->message_buf, sizeof( chan->message_buf ));
|
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__ );
|
Host_Error( "%s: BZ2 compression is not supported for server", __func__ );
|
||||||
#endif
|
#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 uCompressedSize = 0;
|
||||||
uint uSourceSize = MSG_GetNumBytesWritten( msg );
|
uint uSourceSize = MSG_GetNumBytesWritten( msg );
|
||||||
|
@ -1173,7 +1174,7 @@ qboolean Netchan_CopyNormalFragments( netchan_t *chan, sizebuf_t *msg, size_t *l
|
||||||
p = n;
|
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
|
#if !XASH_DEDICATED
|
||||||
byte buf[0x10000];
|
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__ );
|
Host_Error( "%s: BZ2 compression is not supported for server\n", __func__ );
|
||||||
#endif
|
#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 );
|
uint uDecompressedLen = LZSS_GetActualSize( MSG_GetData( msg ), size );
|
||||||
byte buf[NET_MAX_MESSAGE];
|
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__ );
|
Host_Error( "%s: BZ2 compression is not supported for server", __func__ );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if( LZSS_IsCompressed( buffer, nsize + 1 ))
|
else if( chan->use_lzss && LZSS_IsCompressed( buffer, nsize + 1 ))
|
||||||
{
|
{
|
||||||
byte *uncompressedBuffer;
|
byte *uncompressedBuffer;
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,7 @@ typedef enum netchan_flags_e
|
||||||
NETCHAN_USE_MUNGE = BIT( 1 ),
|
NETCHAN_USE_MUNGE = BIT( 1 ),
|
||||||
NETCHAN_USE_BZIP2 = BIT( 2 ),
|
NETCHAN_USE_BZIP2 = BIT( 2 ),
|
||||||
NETCHAN_GOLDSRC = BIT( 3 ),
|
NETCHAN_GOLDSRC = BIT( 3 ),
|
||||||
|
NETCHAN_USE_LZSS = BIT( 4 ), // mutually exclusive with bzip2
|
||||||
} netchan_flags_t;
|
} netchan_flags_t;
|
||||||
|
|
||||||
// Network Connection Channel
|
// Network Connection Channel
|
||||||
|
@ -285,6 +286,7 @@ typedef struct netchan_s
|
||||||
qboolean split;
|
qboolean split;
|
||||||
qboolean use_munge;
|
qboolean use_munge;
|
||||||
qboolean use_bz2;
|
qboolean use_bz2;
|
||||||
|
qboolean use_lzss;
|
||||||
qboolean gs_netchan;
|
qboolean gs_netchan;
|
||||||
} netchan_t;
|
} netchan_t;
|
||||||
|
|
||||||
|
|
|
@ -305,6 +305,7 @@ static void SV_ConnectClient( netadr_t from )
|
||||||
int challenge;
|
int challenge;
|
||||||
const char *s;
|
const char *s;
|
||||||
int extensions;
|
int extensions;
|
||||||
|
uint netchan_flags = 0;
|
||||||
|
|
||||||
if( Cmd_Argc() < 5 )
|
if( Cmd_Argc() < 5 )
|
||||||
{
|
{
|
||||||
|
@ -431,7 +432,9 @@ static void SV_ConnectClient( netadr_t from )
|
||||||
newcl->listeners = -1;
|
newcl->listeners = -1;
|
||||||
|
|
||||||
// initailize netchan
|
// 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
|
MSG_Init( &newcl->datagram, "Datagram", newcl->datagram_buf, sizeof( newcl->datagram_buf )); // datagram buf
|
||||||
|
|
||||||
Q_strncpy( newcl->hashedcdkey, Info_ValueForKey( protinfo, "uuid" ), 32 );
|
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->delta_sequence = -1;
|
||||||
newcl->flags = 0;
|
newcl->flags = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// reset any remaining events
|
// reset any remaining events
|
||||||
memset( &newcl->events, 0, sizeof( newcl->events ));
|
memset( &newcl->events, 0, sizeof( newcl->events ));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue