mirror of
https://github.com/celisej567/source-engine.git
synced 2026-09-13 20:13:45 +03:00
upload "kind" alien swarm
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "voice_status.h"
|
||||
#include "r_efx.h"
|
||||
#include <vgui_controls/TextImage.h>
|
||||
#include <vgui/MouseCode.h>
|
||||
#include <vgui/mousecode.h>
|
||||
#include "cdll_client_int.h"
|
||||
#include "hud_macros.h"
|
||||
#include "c_playerresource.h"
|
||||
@@ -24,11 +24,12 @@
|
||||
#include <vgui_controls/Controls.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include "vgui_bitmapimage.h"
|
||||
#include "vgui_BitmapImage.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "tier0/dbg.h"
|
||||
#include "cdll_int.h"
|
||||
#include <vgui/IPanel.h>
|
||||
#include "con_nprint.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
@@ -44,6 +45,10 @@ extern int cam_thirdperson;
|
||||
|
||||
ConVar voice_modenable( "voice_modenable", "1", FCVAR_ARCHIVE | FCVAR_CLIENTCMD_CAN_EXECUTE, "Enable/disable voice in this mod." );
|
||||
ConVar voice_clientdebug( "voice_clientdebug", "0" );
|
||||
ConVar voice_head_icon_size( "voice_head_icon_size", "6", FCVAR_NONE, "Size of voice icon over player heads in inches" );
|
||||
ConVar voice_head_icon_height( "voice_head_icon_height", "20", FCVAR_NONE, "Voice icons are this many inches over player eye positions" );
|
||||
ConVar voice_local_icon( "voice_local_icon", "0", FCVAR_NONE, "Draw local player's voice icon" );
|
||||
ConVar voice_all_icons( "voice_all_icons", "0", FCVAR_NONE, "Draw all players' voice icons" );
|
||||
|
||||
// ---------------------------------------------------------------------- //
|
||||
// The voice manager for the client.
|
||||
@@ -74,6 +79,22 @@ void ClientVoiceMgr_Shutdown()
|
||||
g_VoiceStatus = NULL;
|
||||
}
|
||||
|
||||
void ClientVoiceMgr_LevelInit()
|
||||
{
|
||||
if ( g_VoiceStatus )
|
||||
{
|
||||
g_VoiceStatus->LevelInit();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientVoiceMgr_LevelShutdown()
|
||||
{
|
||||
if ( g_VoiceStatus )
|
||||
{
|
||||
g_VoiceStatus->LevelShutdown();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------- //
|
||||
// CVoiceStatus.
|
||||
// ---------------------------------------------------------------------- //
|
||||
@@ -103,11 +124,14 @@ CVoiceStatus::CVoiceStatus()
|
||||
m_bBanMgrInitialized = false;
|
||||
m_LastUpdateServerState = 0;
|
||||
|
||||
m_bTalking = m_bServerAcked = false;
|
||||
for ( int k = 0; k < MAX_SPLITSCREEN_CLIENTS; ++ k )
|
||||
{
|
||||
m_bTalking[k] = false;
|
||||
m_bServerAcked[k] = false;
|
||||
m_bAboveThreshold[k] = false;
|
||||
|
||||
#ifdef VOICE_VOX_ENABLE
|
||||
m_bAboveThresholdTimer.Invalidate();
|
||||
#endif // VOICE_VOX_ENABLE
|
||||
m_bAboveThresholdTimer[k].Invalidate();
|
||||
}
|
||||
|
||||
m_bServerModEnable = -1;
|
||||
|
||||
@@ -159,8 +183,12 @@ int CVoiceStatus::Init(
|
||||
m_pHelper = pHelper;
|
||||
m_pParentPanel = pParentPanel;
|
||||
|
||||
HOOK_MESSAGE(VoiceMask);
|
||||
HOOK_MESSAGE(RequestState);
|
||||
for ( int hh = 0; hh < MAX_SPLITSCREEN_PLAYERS; ++hh )
|
||||
{
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh );
|
||||
HOOK_MESSAGE(VoiceMask);
|
||||
HOOK_MESSAGE(RequestState);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -177,6 +205,28 @@ void CVoiceStatus::VidInit()
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::LevelInit( void )
|
||||
{
|
||||
for ( int k = 0; k < MAX_SPLITSCREEN_CLIENTS; ++ k )
|
||||
{
|
||||
m_bTalking[k] = false;
|
||||
m_bAboveThreshold[k] = false;
|
||||
m_bAboveThresholdTimer[k].Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::LevelShutdown( void )
|
||||
{
|
||||
for ( int k = 0; k < MAX_SPLITSCREEN_CLIENTS; ++ k )
|
||||
{
|
||||
m_bTalking[k] = false;
|
||||
m_bAboveThreshold[k] = false;
|
||||
m_bAboveThresholdTimer[k].Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::Frame(double frametime)
|
||||
{
|
||||
// check server banned players once per second
|
||||
@@ -188,7 +238,6 @@ void CVoiceStatus::Frame(double frametime)
|
||||
|
||||
|
||||
float g_flHeadOffset = 35;
|
||||
float g_flHeadIconSize = 8;
|
||||
|
||||
|
||||
void CVoiceStatus::SetHeadLabelOffset( float offset )
|
||||
@@ -204,10 +253,26 @@ float CVoiceStatus::GetHeadLabelOffset( void ) const
|
||||
|
||||
void CVoiceStatus::DrawHeadLabels()
|
||||
{
|
||||
if ( m_bHeadLabelsDisabled )
|
||||
return;
|
||||
if ( voice_all_icons.GetBool() )
|
||||
{
|
||||
for(int i=0; i < VOICE_MAX_PLAYERS; i++)
|
||||
{
|
||||
IClientNetworkable *pClient = cl_entitylist->GetClientEntity( i+1 );
|
||||
|
||||
if ( GameRules() && ( GameRules()->ShouldDrawHeadLabels() == false ) )
|
||||
// Don't show an icon if the player is not in our PVS.
|
||||
if ( !pClient || pClient->IsDormant() )
|
||||
continue;
|
||||
|
||||
m_VoicePlayers[i] = voice_all_icons.GetInt() > 0;
|
||||
}
|
||||
}
|
||||
else if ( voice_local_icon.GetBool() )
|
||||
{
|
||||
C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
m_VoicePlayers[ localPlayer->entindex() - 1 ] = IsLocalPlayerSpeakingAboveThreshold( localPlayer->GetSplitScreenPlayerSlot() );
|
||||
}
|
||||
|
||||
if ( m_bHeadLabelsDisabled )
|
||||
return;
|
||||
|
||||
if( !m_pHeadLabelMaterial )
|
||||
@@ -234,9 +299,9 @@ void CVoiceStatus::DrawHeadLabels()
|
||||
if( pPlayer->IsPlayerDead() )
|
||||
continue;
|
||||
|
||||
// Place it 20 units above his head.
|
||||
Vector vOrigin = pPlayer->WorldSpaceCenter();
|
||||
vOrigin.z += g_flHeadOffset;
|
||||
// Place it a fixed height above his head.
|
||||
Vector vOrigin = pPlayer->EyePosition( );
|
||||
vOrigin.z += voice_head_icon_height.GetFloat();
|
||||
|
||||
|
||||
// Align it so it never points up or down.
|
||||
@@ -249,7 +314,7 @@ void CVoiceStatus::DrawHeadLabels()
|
||||
VectorNormalize( vRight );
|
||||
|
||||
|
||||
float flSize = g_flHeadIconSize;
|
||||
float flSize = voice_head_icon_size.GetFloat();
|
||||
|
||||
pRenderContext->Bind( pPlayer->GetHeadLabelMaterial() );
|
||||
IMesh *pMesh = pRenderContext->GetDynamicMesh();
|
||||
@@ -281,41 +346,107 @@ void CVoiceStatus::DrawHeadLabels()
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::UpdateSpeakerStatus(int entindex, bool bTalking)
|
||||
void CVoiceStatus::UpdateSpeakerStatus(int entindex, int iSsSlot, bool bTalking)
|
||||
{
|
||||
if(!m_pParentPanel)
|
||||
if( !m_pParentPanel )
|
||||
return;
|
||||
|
||||
if( voice_clientdebug.GetInt() )
|
||||
if( voice_clientdebug.GetInt() == 1 )
|
||||
{
|
||||
Msg( "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, bTalking );
|
||||
Msg( "CVoiceStatus::UpdateSpeakerStatus: ent %d ss[%d] talking = %d\n",
|
||||
entindex, iSsSlot, bTalking );
|
||||
}
|
||||
else if ( voice_clientdebug.GetInt() == 2 )
|
||||
{
|
||||
con_nprint_t np;
|
||||
np.index = 0;
|
||||
np.color[0] = 1.0f;
|
||||
np.color[1] = 1.0f;
|
||||
np.color[2] = 1.0f;
|
||||
np.time_to_live = 2.0f;
|
||||
np.fixed_width_font = true;
|
||||
|
||||
int numActiveChannels = VOICE_MAX_PLAYERS;
|
||||
engine->Con_NXPrintf ( &np, "Total Players: %i", numActiveChannels);
|
||||
|
||||
for ( int i = 1; i <= numActiveChannels; i++ )
|
||||
{
|
||||
np.index++;
|
||||
np.color[0] = np.color[1] = np.color[2] = ( i % 2 == 0 ? 0.9f : 0.7f );
|
||||
|
||||
if ( !IsPlayerBlocked( i ) && IsPlayerAudible( i ) && IsPlayerSpeaking( i ) )
|
||||
{
|
||||
np.color[0] = 0.0f;
|
||||
np.color[1] = 1.0f;
|
||||
np.color[2] = 0.0f;
|
||||
}
|
||||
|
||||
engine->Con_NXPrintf ( &np, "%02i enabled(%s) blocked(%s) audible(%s) speaking(%s)",
|
||||
i,
|
||||
m_VoiceEnabledPlayers[ i - 1 ] != 0 ? "YES" : " NO",
|
||||
IsPlayerBlocked( i ) ? "YES" : " NO",
|
||||
IsPlayerAudible( i ) ? "YES" : " NO",
|
||||
IsPlayerSpeaking( i ) ? "YES" : " NO" );
|
||||
}
|
||||
|
||||
np.color[0] = 1.0f;
|
||||
np.color[1] = 1.0f;
|
||||
np.color[2] = 1.0f;
|
||||
|
||||
np.index += 2;
|
||||
numActiveChannels = MAX_SPLITSCREEN_CLIENTS;
|
||||
engine->Con_NXPrintf ( &np, "Local Players: %i", numActiveChannels);
|
||||
|
||||
for ( int i = 0; i < numActiveChannels; i++ )
|
||||
{
|
||||
np.index++;
|
||||
np.color[0] = np.color[1] = np.color[2] = ( i % 2 == 0 ? 0.9f : 0.7f );
|
||||
|
||||
if ( IsLocalPlayerSpeaking( i ) && IsLocalPlayerSpeakingAboveThreshold( i ) )
|
||||
{
|
||||
np.color[0] = 0.0f;
|
||||
np.color[1] = 1.0f;
|
||||
np.color[2] = 0.0f;
|
||||
}
|
||||
|
||||
engine->Con_NXPrintf ( &np, "%02i speaking(%s) above_threshold(%s)",
|
||||
i,
|
||||
IsLocalPlayerSpeaking( i ) ? "YES" : " NO",
|
||||
IsLocalPlayerSpeakingAboveThreshold( i ) ? "YES" : " NO" );
|
||||
}
|
||||
}
|
||||
|
||||
// Is it the local player talking?
|
||||
if( entindex == -1 )
|
||||
if( entindex == -1 && iSsSlot >= 0 )
|
||||
{
|
||||
m_bTalking = !!bTalking;
|
||||
m_bTalking[ iSsSlot ] = !!bTalking;
|
||||
if( bTalking )
|
||||
{
|
||||
// Enable voice for them automatically if they try to talk.
|
||||
engine->ClientCmd( "voice_modenable 1" );
|
||||
char chClientCmd[0xFF];
|
||||
Q_snprintf( chClientCmd, sizeof( chClientCmd ),
|
||||
"cmd%d voice_modenable 1", iSsSlot + 1 );
|
||||
engine->ClientCmd( chClientCmd );
|
||||
}
|
||||
}
|
||||
else if( entindex == -2 )
|
||||
|
||||
if( entindex == -2 && iSsSlot >= 0 )
|
||||
{
|
||||
m_bServerAcked = !!bTalking;
|
||||
m_bServerAcked[ iSsSlot ] = !!bTalking;
|
||||
}
|
||||
#ifdef VOICE_VOX_ENABLE
|
||||
else if( entindex == -3 )
|
||||
|
||||
if ( entindex == -3 && iSsSlot >= 0 )
|
||||
{
|
||||
m_bAboveThreshold[ iSsSlot ] = !!bTalking;
|
||||
|
||||
if ( bTalking )
|
||||
{
|
||||
const float AboveThresholdMinDuration = 0.5f;
|
||||
m_bAboveThresholdTimer.Start( AboveThresholdMinDuration );
|
||||
m_bAboveThresholdTimer[ iSsSlot ].Start( AboveThresholdMinDuration );
|
||||
}
|
||||
}
|
||||
#endif // VOICE_VOX_ENABLE
|
||||
else if(entindex > 0 && entindex <= VOICE_MAX_PLAYERS)
|
||||
|
||||
if( entindex > 0 && entindex <= VOICE_MAX_PLAYERS )
|
||||
{
|
||||
int iClient = entindex - 1;
|
||||
if(iClient < 0)
|
||||
@@ -339,7 +470,7 @@ void CVoiceStatus::UpdateServerState(bool bForce)
|
||||
// Can't do anything when we're not in a level.
|
||||
if( !g_bLevelInitialized )
|
||||
{
|
||||
if( voice_clientdebug.GetInt() )
|
||||
if( voice_clientdebug.GetInt() == 1 )
|
||||
{
|
||||
Msg( "CVoiceStatus::UpdateServerState: g_bLevelInitialized\n" );
|
||||
}
|
||||
@@ -354,9 +485,13 @@ void CVoiceStatus::UpdateServerState(bool bForce)
|
||||
|
||||
char str[256];
|
||||
Q_snprintf(str, sizeof(str), "VModEnable %d", m_bServerModEnable);
|
||||
engine->ServerCmd(str);
|
||||
|
||||
{
|
||||
HACK_GETLOCALPLAYER_GUARD( "CVoiceStatus::UpdateServerState" );
|
||||
engine->ServerCmd(str);
|
||||
}
|
||||
|
||||
if( voice_clientdebug.GetInt() )
|
||||
if( voice_clientdebug.GetInt() == 1 )
|
||||
{
|
||||
Msg( "CVoiceStatus::UpdateServerState: Sending '%s'\n", str );
|
||||
}
|
||||
@@ -399,13 +534,13 @@ void CVoiceStatus::UpdateServerState(bool bForce)
|
||||
|
||||
// Ok, the server needs to be updated.
|
||||
char numStr[512];
|
||||
Q_snprintf(numStr, sizeof(numStr), " %lx", banMask);
|
||||
Q_snprintf(numStr,sizeof(numStr), " %x", banMask);
|
||||
Q_strncat(str, numStr, sizeof(str), COPY_ALL_CHARACTERS);
|
||||
}
|
||||
|
||||
if(bChange || bForce)
|
||||
{
|
||||
if( voice_clientdebug.GetInt() )
|
||||
if( voice_clientdebug.GetInt() == 1 )
|
||||
{
|
||||
Msg( "CVoiceStatus::UpdateServerState: Sending '%s'\n", str );
|
||||
}
|
||||
@@ -414,7 +549,7 @@ void CVoiceStatus::UpdateServerState(bool bForce)
|
||||
}
|
||||
else
|
||||
{
|
||||
if( voice_clientdebug.GetInt() )
|
||||
if( voice_clientdebug.GetInt() == 1 )
|
||||
{
|
||||
Msg( "CVoiceStatus::UpdateServerState: no change\n" );
|
||||
}
|
||||
@@ -425,17 +560,17 @@ void CVoiceStatus::UpdateServerState(bool bForce)
|
||||
|
||||
void CVoiceStatus::HandleVoiceMaskMsg(bf_read &msg)
|
||||
{
|
||||
unsigned int dw;
|
||||
unsigned long dw;
|
||||
for(dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++)
|
||||
{
|
||||
m_AudiblePlayers.SetDWord(dw, (unsigned long)msg.ReadLong());
|
||||
m_ServerBannedPlayers.SetDWord(dw, (unsigned long)msg.ReadLong());
|
||||
|
||||
if( voice_clientdebug.GetInt())
|
||||
if( voice_clientdebug.GetInt() == 1 )
|
||||
{
|
||||
Msg("CVoiceStatus::HandleVoiceMaskMsg\n");
|
||||
Msg(" - m_AudiblePlayers[%d] = %u\n", dw, m_AudiblePlayers.GetDWord(dw));
|
||||
Msg(" - m_ServerBannedPlayers[%d] = %u\n", dw, m_ServerBannedPlayers.GetDWord(dw));
|
||||
Msg(" - m_AudiblePlayers[%d] = %lu\n", dw, m_AudiblePlayers.GetDWord(dw));
|
||||
Msg(" - m_ServerBannedPlayers[%d] = %lu\n", dw, m_ServerBannedPlayers.GetDWord(dw));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +579,7 @@ void CVoiceStatus::HandleVoiceMaskMsg(bf_read &msg)
|
||||
|
||||
void CVoiceStatus::HandleReqStateMsg(bf_read &msg)
|
||||
{
|
||||
if(voice_clientdebug.GetInt())
|
||||
if( voice_clientdebug.GetInt() == 1 )
|
||||
{
|
||||
Msg("CVoiceStatus::HandleReqStateMsg\n");
|
||||
}
|
||||
@@ -507,43 +642,6 @@ bool CVoiceStatus::IsPlayerBlocked(int iPlayer)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns true if the player can't hear the other client due to game rules (eg. the other team)
|
||||
// Input : playerID -
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CVoiceStatus::IsPlayerAudible(int iPlayer)
|
||||
{
|
||||
return !!m_AudiblePlayers[iPlayer-1];
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// returns true if the player is currently speaking
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CVoiceStatus::IsPlayerSpeaking(int iPlayerIndex)
|
||||
{
|
||||
return m_VoicePlayers[iPlayerIndex-1] != 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// returns true if the local player is attempting to speak
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CVoiceStatus::IsLocalPlayerSpeaking( void )
|
||||
{
|
||||
#ifdef VOICE_VOX_ENABLE
|
||||
if ( voice_vox.GetBool() )
|
||||
{
|
||||
if ( m_bAboveThresholdTimer.IsElapsed() == true )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif // VOICE_VOX_ENABLE
|
||||
|
||||
return m_bTalking;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: blocks/unblocks the target client from being heard
|
||||
// Input : playerID -
|
||||
@@ -551,7 +649,7 @@ bool CVoiceStatus::IsLocalPlayerSpeaking( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
void CVoiceStatus::SetPlayerBlockedState(int iPlayer, bool blocked)
|
||||
{
|
||||
if (voice_clientdebug.GetInt())
|
||||
if ( voice_clientdebug.GetInt() == 1 )
|
||||
{
|
||||
Msg( "CVoiceStatus::SetPlayerBlockedState part 1\n" );
|
||||
}
|
||||
@@ -560,13 +658,13 @@ void CVoiceStatus::SetPlayerBlockedState(int iPlayer, bool blocked)
|
||||
if ( !engine->GetPlayerInfo( iPlayer, &pi ) )
|
||||
return;
|
||||
|
||||
if (voice_clientdebug.GetInt())
|
||||
if ( voice_clientdebug.GetInt() == 1 )
|
||||
{
|
||||
Msg( "CVoiceStatus::SetPlayerBlockedState part 2\n" );
|
||||
}
|
||||
|
||||
// Squelch or (try to) unsquelch this player.
|
||||
if (voice_clientdebug.GetInt())
|
||||
if ( voice_clientdebug.GetInt() == 1 )
|
||||
{
|
||||
Msg("CVoiceStatus::SetPlayerBlockedState: setting player %d ban to %d\n", iPlayer, !m_BanMgr.GetPlayerBan(pi.guid));
|
||||
}
|
||||
@@ -588,4 +686,4 @@ void CVoiceStatus::SetHeadLabelMaterial( const char *pszMaterial )
|
||||
|
||||
m_pHeadLabelMaterial = materials->FindMaterial( pszMaterial, TEXTURE_GROUP_VGUI );
|
||||
m_pHeadLabelMaterial->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user