mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
engine: client: add feature to reupload logo if any of logo related cvars were changed
This commit is contained in:
@@ -1385,6 +1385,10 @@ static void CL_CreateResourceList( void )
|
||||
cl.num_resources = 0;
|
||||
memset( rgucMD5_hash, 0, sizeof( rgucMD5_hash ));
|
||||
|
||||
ClearBits( cl_logofile.flags, FCVAR_CHANGED );
|
||||
ClearBits( cl_logocolor.flags, FCVAR_CHANGED );
|
||||
ClearBits( cl_logoext.flags, FCVAR_CHANGED );
|
||||
|
||||
// sanitize cvar value
|
||||
if( Q_strcmp( cl_logoext.string, "bmp" ) && Q_strcmp( cl_logoext.string, "png" ))
|
||||
Cvar_DirectSet( &cl_logoext, "bmp" );
|
||||
@@ -1400,7 +1404,6 @@ static void CL_CreateResourceList( void )
|
||||
if( !fp )
|
||||
return;
|
||||
|
||||
MD5_HashFile( rgucMD5_hash, szFileName, NULL );
|
||||
nSize = FS_FileLength( fp );
|
||||
|
||||
if( nSize != 0 )
|
||||
@@ -1409,6 +1412,7 @@ static void CL_CreateResourceList( void )
|
||||
|
||||
if( pNewResource )
|
||||
{
|
||||
MD5_HashFile( rgucMD5_hash, szFileName, NULL );
|
||||
SetBits( pNewResource->ucFlags, RES_CUSTOM );
|
||||
memcpy( pNewResource->rgucMD5_hash, rgucMD5_hash, 16 );
|
||||
HPAK_AddLump( false, hpk_custom_file.string, pNewResource, NULL, fp );
|
||||
@@ -1418,6 +1422,42 @@ static void CL_CreateResourceList( void )
|
||||
FS_Close( fp );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_CheckLogoChanged
|
||||
|
||||
==================
|
||||
*/
|
||||
static void CL_CheckLogoChanged( void )
|
||||
{
|
||||
player_info_t *player;
|
||||
int i;
|
||||
|
||||
if( cls.state != ca_active )
|
||||
return;
|
||||
|
||||
if( !FBitSet( cl_logofile.flags | cl_logocolor.flags | cl_logoext.flags, FCVAR_CHANGED ))
|
||||
return;
|
||||
|
||||
CL_CreateResourceList();
|
||||
|
||||
if( cl.num_resources == 0 )
|
||||
return;
|
||||
|
||||
player = &cl.players[cl.playernum];
|
||||
COM_ClearCustomizationList( &player->customdata, true );
|
||||
|
||||
for( i = 0; i < cl.num_resources; i++ )
|
||||
{
|
||||
resource_t *pResource = &cl.resourcelist[i];
|
||||
|
||||
if( !COM_CreateCustomization( &player->customdata, pResource, cl.playernum, 0, NULL, NULL ))
|
||||
Con_Printf( "Unable to create custom decal\n" );
|
||||
}
|
||||
|
||||
CL_SendResourceList( cl.resourcelist, cl.num_resources );
|
||||
}
|
||||
|
||||
static qboolean CL_StringToProtocol( const char *s, connprotocol_t *proto )
|
||||
{
|
||||
if( !Q_stricmp( s, "current" ) || !Q_strcmp( s, "49" ))
|
||||
@@ -3589,6 +3629,9 @@ void Host_ClientBegin( void )
|
||||
// finalize connection process if needs
|
||||
CL_CheckClientState();
|
||||
|
||||
// check if logo cvars changed and re-upload if needed
|
||||
CL_CheckLogoChanged();
|
||||
|
||||
// tell the client.dll about client data
|
||||
CL_UpdateClientData();
|
||||
|
||||
|
||||
@@ -761,6 +761,7 @@ void CL_AddToResourceList( resource_t *pResource, resource_t *pList );
|
||||
void CL_RemoveFromResourceList( resource_t *pResource );
|
||||
void CL_MoveToOnHandList( resource_t *pResource );
|
||||
void CL_ClearResourceLists( void );
|
||||
void CL_SendResourceList( const resource_t *list, int count );
|
||||
|
||||
//
|
||||
// cl_debug.c
|
||||
|
||||
@@ -705,13 +705,35 @@ CL_ParseResourceRequest
|
||||
|
||||
==================
|
||||
*/
|
||||
static void CL_ParseResourceRequest( sizebuf_t *msg )
|
||||
void CL_SendResourceList( const resource_t *list, int count )
|
||||
{
|
||||
byte buffer[MAX_INIT_MSG];
|
||||
int i, arg, nStartIndex;
|
||||
sizebuf_t sbuf;
|
||||
int i;
|
||||
|
||||
MSG_Init( &sbuf, "ResourceBlock", buffer, sizeof( buffer ));
|
||||
MSG_BeginClientCmd( &sbuf, clc_resourcelist );
|
||||
MSG_WriteShort( &sbuf, count );
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
MSG_WriteString( &sbuf, list[i].szFileName );
|
||||
MSG_WriteByte( &sbuf, list[i].type );
|
||||
MSG_WriteShort( &sbuf, list[i].nIndex );
|
||||
MSG_WriteLong( &sbuf, list[i].nDownloadSize );
|
||||
MSG_WriteByte( &sbuf, list[i].ucFlags );
|
||||
|
||||
if( FBitSet( list[i].ucFlags, RES_CUSTOM ))
|
||||
MSG_WriteBytes( &sbuf, list[i].rgucMD5_hash, 16 );
|
||||
}
|
||||
|
||||
Netchan_CreateFragments( &cls.netchan, &sbuf );
|
||||
Netchan_FragSend( &cls.netchan );
|
||||
}
|
||||
|
||||
static void CL_ParseResourceRequest( sizebuf_t *msg )
|
||||
{
|
||||
int arg, nStartIndex;
|
||||
|
||||
arg = MSG_ReadLong( msg );
|
||||
nStartIndex = MSG_ReadLong( msg );
|
||||
@@ -719,31 +741,10 @@ static void CL_ParseResourceRequest( sizebuf_t *msg )
|
||||
if( cl.servercount != arg )
|
||||
return;
|
||||
|
||||
if( nStartIndex < 0 && nStartIndex > cl.num_resources )
|
||||
if( nStartIndex < 0 || nStartIndex >= cl.num_resources )
|
||||
return;
|
||||
|
||||
MSG_BeginClientCmd( &sbuf, clc_resourcelist );
|
||||
MSG_WriteShort( &sbuf, cl.num_resources );
|
||||
|
||||
for( i = nStartIndex; i < cl.num_resources; i++ )
|
||||
{
|
||||
MSG_WriteString( &sbuf, cl.resourcelist[i].szFileName );
|
||||
MSG_WriteByte( &sbuf, cl.resourcelist[i].type );
|
||||
MSG_WriteShort( &sbuf, cl.resourcelist[i].nIndex );
|
||||
MSG_WriteLong( &sbuf, cl.resourcelist[i].nDownloadSize );
|
||||
MSG_WriteByte( &sbuf, cl.resourcelist[i].ucFlags );
|
||||
|
||||
if( FBitSet( cl.resourcelist[i].ucFlags, RES_CUSTOM ))
|
||||
MSG_WriteBytes( &sbuf, cl.resourcelist[i].rgucMD5_hash, 16 );
|
||||
}
|
||||
|
||||
// a1ba: useless check? MSG_BeginClientCmd and MSG_WriteShort will always
|
||||
// write to the buffer
|
||||
// if( MSG_GetNumBytesWritten( &sbuf ) > 0 )
|
||||
{
|
||||
Netchan_CreateFragments( &cls.netchan, &sbuf );
|
||||
Netchan_FragSend( &cls.netchan );
|
||||
}
|
||||
CL_SendResourceList( &cl.resourcelist[nStartIndex], cl.num_resources - nStartIndex );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user