mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
engine: client: GoldSrc voice chat support
- Added support for GoldSrc voice mode, including initialization and shutdown functions. - Implemented data size verification for the GoldSrc voice package. - Creation and processing of voice packets, CRC verification of data integrity. - Added a Steam ID field to the client_static_t structure - Automatic gain control has been introduced for voice samples. - The voice status structure has been updated. - Refactored voice data handling for better type consistency and maintainability. - Fixed ISO C90 compliance issues for better portability. - Fixed decoder index usage.
This commit is contained in:
@@ -2010,44 +2010,41 @@ CL_ParseVoiceData
|
||||
*/
|
||||
void CL_ParseVoiceData( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
int size, idx, frames;
|
||||
int size, idx, frames = 0;
|
||||
byte received[8192];
|
||||
|
||||
idx = MSG_ReadByte( msg ) + 1;
|
||||
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
{
|
||||
size = MSG_ReadShort( msg );
|
||||
MSG_SeekToBit( msg, size << 3, SEEK_CUR ); // skip the entire buf, not supported yet
|
||||
|
||||
#if 0 // shall we notify client.dll if nothing can be heard?
|
||||
// must notify through as both local player and normal client
|
||||
if( idx == cl.playernum + 1 )
|
||||
Voice_StatusAck( &voice.local, VOICE_LOOPBACK_INDEX );
|
||||
|
||||
Voice_StatusAck( &voice.players_status[idx], idx );
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
frames = MSG_ReadByte( msg );
|
||||
size = MSG_ReadShort( msg );
|
||||
size = Q_min( size, sizeof( received ));
|
||||
|
||||
MSG_ReadBytes( msg, received, size );
|
||||
|
||||
if ( idx <= 0 || idx > cl.maxclients )
|
||||
return;
|
||||
|
||||
// must notify through as both local player and normal client
|
||||
if( idx == cl.playernum + 1 )
|
||||
Voice_StatusAck( &voice.local, VOICE_LOOPBACK_INDEX );
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
{
|
||||
size = MSG_ReadShort( msg );
|
||||
if ( size > 4096 )
|
||||
{
|
||||
Con_Printf( S_ERROR "Voice data size is too large: %d bytes (max: %d)\n", size, VOICE_MAX_GS_DATA_SIZE );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
frames = MSG_ReadByte( msg );
|
||||
size = MSG_ReadShort( msg );
|
||||
if (size > 8192 )
|
||||
{
|
||||
Con_Printf( S_ERROR "Voice data size is too large: %d bytes (max: %d)\n", size, VOICE_MAX_DATA_SIZE );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Voice_StatusAck( &voice.players_status[idx], idx );
|
||||
size = Q_min( size, sizeof( received ));
|
||||
|
||||
if ( !size )
|
||||
return;
|
||||
|
||||
MSG_ReadBytes( msg, received, size );
|
||||
|
||||
Voice_AddIncomingData( idx, received, size, frames );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user