Browse Source

engine: client: fixed players voice state changing

pull/2/head
SNMetamorph 2 years ago committed by Alibek Omarov
parent
commit
c5d7e3c783
  1. 4
      engine/client/cl_parse.c
  2. 30
      engine/client/voice.c
  3. 6
      engine/client/voice.h

4
engine/client/cl_parse.c

@ -1714,8 +1714,10 @@ void CL_ParseVoiceData( sizebuf_t *msg ) @@ -1714,8 +1714,10 @@ void CL_ParseVoiceData( sizebuf_t *msg )
if ( idx <= 0 || idx > cl.maxclients )
return;
if ( idx == cl.playernum + 1 )
if( idx == cl.playernum + 1 )
Voice_LocalPlayerTalkingAck();
else
Voice_PlayerTalkingAck( idx );
if ( !size )
return;

30
engine/client/voice.c

@ -171,6 +171,8 @@ uint Voice_GetCompressedData( byte *out, uint maxsize, uint *frames ) @@ -171,6 +171,8 @@ uint Voice_GetCompressedData( byte *out, uint maxsize, uint *frames )
void Voice_Idle( float frametime )
{
int i;
if ( !voice_enable.value )
{
Voice_DeInit();
@ -180,13 +182,26 @@ void Voice_Idle( float frametime ) @@ -180,13 +182,26 @@ void Voice_Idle( float frametime )
if ( voice.talking_ack )
{
voice.talking_timeout += frametime;
if ( voice.talking_timeout > 0.2f )
if( voice.talking_timeout > 0.2f )
{
voice.talking_ack = false;
Voice_Status( -2, false );
}
}
for ( i = 0; i < 32; i++ )
{
if ( voice.players_status[i].talking_ack )
{
voice.players_status[i].talking_timeout += frametime;
if ( voice.players_status[i].talking_timeout > 0.2f )
{
voice.players_status[i].talking_ack = false;
if ( i < cl.maxclients )
Voice_Status( i, false );
}
}
}
}
qboolean Voice_IsRecording( void )
@ -286,6 +301,17 @@ void Voice_LocalPlayerTalkingAck( void ) @@ -286,6 +301,17 @@ void Voice_LocalPlayerTalkingAck( void )
voice.talking_timeout = 0.0f;
}
void Voice_PlayerTalkingAck(int playerIndex)
{
if( !voice.players_status[playerIndex].talking_ack )
{
Voice_Status( playerIndex, true );
}
voice.players_status[playerIndex].talking_ack = true;
voice.players_status[playerIndex].talking_timeout = 0.0f;
}
void Voice_StartChannel( uint samples, byte *data, int entnum )
{
SND_ForceInitMouth( entnum );

6
engine/client/voice.h

@ -19,6 +19,11 @@ typedef struct voice_state_s @@ -19,6 +19,11 @@ typedef struct voice_state_s
qboolean talking_ack;
float talking_timeout;
struct {
qboolean talking_ack;
float talking_timeout;
} players_status[32];
// opus stuff
OpusEncoder *encoder;
OpusDecoder *decoder;
@ -51,6 +56,7 @@ void Voice_RecordStart( void ); @@ -51,6 +56,7 @@ void Voice_RecordStart( void );
void Voice_AddIncomingData( int ent, byte *data, uint size, uint frames );
qboolean Voice_GetLoopback( void );
void Voice_LocalPlayerTalkingAck( void );
void Voice_PlayerTalkingAck( int playerIndex );
void Voice_StartChannel( uint samples, byte *data, int entnum );
#endif // VOICE_H

Loading…
Cancel
Save