Browse Source

engine: remove useless vprof for rcon

sanitize
nillerusr 2 years ago
parent
commit
1218fa659c
  1. 186
      engine/cl_rcon.cpp
  2. 46
      engine/cl_rcon.h
  3. 57
      engine/sv_remoteaccess.cpp
  4. 6
      public/tier0/vprof.h

186
engine/cl_rcon.cpp

@ -56,12 +56,10 @@ public: @@ -56,12 +56,10 @@ public:
// Immediately try to start vprofiling
// Also, enable cheats on this client only
Cmd_SetRptActive( true );
StartVProfData();
}
virtual void OnSocketClosed( SocketHandle_t hSocket, const netadr_t & netAdr, void* pData )
{
StopVProfData();
Cmd_SetRptActive( false );
BaseClass::OnSocketClosed( hSocket, netAdr, pData );
}
@ -98,135 +96,6 @@ static void RconAddressChanged_f( IConVar *pConVar, const char *pOldString, floa @@ -98,135 +96,6 @@ static void RconAddressChanged_f( IConVar *pConVar, const char *pOldString, floa
static ConVar rcon_address( "rcon_address", "", FCVAR_SERVER_CANNOT_QUERY|FCVAR_DONTRECORD, "Address of remote server if sending unconnected rcon commands (format x.x.x.x:p) ", RconAddressChanged_f );
//-----------------------------------------------------------------------------
// Implementation of remote vprof
//-----------------------------------------------------------------------------
CRConVProfExport::CRConVProfExport()
{
}
void CRConVProfExport::AddListener()
{
}
void CRConVProfExport::RemoveListener()
{
}
void CRConVProfExport::SetBudgetFlagsFilter( int filter )
{
}
int CRConVProfExport::GetNumBudgetGroups()
{
return m_Info.Count();
}
void CRConVProfExport::GetBudgetGroupInfos( CExportedBudgetGroupInfo *pInfos )
{
memcpy( pInfos, m_Info.Base(), GetNumBudgetGroups() * sizeof(CExportedBudgetGroupInfo) );
}
void CRConVProfExport::GetBudgetGroupTimes( float times[IVProfExport::MAX_BUDGETGROUP_TIMES] )
{
int nGroups = min( m_Times.Count(), (int)IVProfExport::MAX_BUDGETGROUP_TIMES );
memset( times, 0, nGroups * sizeof(float) );
nGroups = min( GetNumBudgetGroups(), nGroups );
memcpy( times, m_Times.Base(), nGroups * sizeof(float) );
}
void CRConVProfExport::PauseProfile()
{
// NOTE: This only has effect when testing on a listen server
// it shouldn't do anything in the wild. When drawing the budget panel
// this will cause the time spent doing so to not be counted
VProfExport_Pause();
}
void CRConVProfExport::ResumeProfile()
{
// NOTE: This only has effect when testing on a listen server
// it shouldn't do anything in the wild
VProfExport_Resume();
}
void CRConVProfExport::CleanupGroupData()
{
int nCount = m_Info.Count();
for ( int i = 0; i < nCount; ++i )
{
delete m_Info[i].m_pName;
}
m_Info.RemoveAll();
}
void CRConVProfExport::OnRemoteGroupData( const void *data, int len )
{
CUtlBuffer buf( data, len, CUtlBuffer::READ_ONLY );
int nFirstGroup = buf.GetInt();
if ( nFirstGroup == 0 )
{
CleanupGroupData();
}
else
{
Assert( nFirstGroup == m_Info.Count() );
}
// NOTE: See WriteRemoteVProfGroupData in vprof_engine.cpp
// to see the encoding of this data
int nGroupCount = buf.GetInt();
int nBase = m_Info.AddMultipleToTail( nGroupCount );
char temp[1024];
for ( int i = 0; i < nGroupCount; ++i )
{
CExportedBudgetGroupInfo *pInfo = &m_Info[nBase + i];
unsigned char red, green, blue, alpha;
red = buf.GetUnsignedChar( );
green = buf.GetUnsignedChar( );
blue = buf.GetUnsignedChar( );
alpha = buf.GetUnsignedChar( );
buf.GetString( temp );
int nLen = Q_strlen( temp );
pInfo->m_Color.SetColor( red, green, blue, alpha );
char *pBuf = new char[ nLen + 1 ];
pInfo->m_pName = pBuf;
memcpy( pBuf, temp, nLen+1 );
pInfo->m_BudgetFlags = 0;
}
}
void CRConVProfExport::OnRemoteData( const void *data, int len )
{
// NOTE: See WriteRemoteVProfData in vprof_engine.cpp
// to see the encoding of this data
int nCount = len / sizeof(float);
Assert( nCount == m_Info.Count() );
CUtlBuffer buf( data, len, CUtlBuffer::READ_ONLY );
m_Times.SetCount( nCount );
memcpy( m_Times.Base(), data, nCount * sizeof(float) );
}
CON_COMMAND( vprof_remote_start, "Request a VProf data stream from the remote server (requires authentication)" )
{
// TODO: Make this work (it might already!)
// RCONClient().StartVProfData();
}
CON_COMMAND( vprof_remote_stop, "Stop an existing remote VProf data request" )
{
// TODO: Make this work (it might already!)
// RCONClient().StopVProfData();
}
#ifdef ENABLE_RPT
CON_COMMAND_F( rpt_screenshot, "", FCVAR_HIDDEN | FCVAR_DONTRECORD )
{
@ -454,22 +323,6 @@ void CRConClient::ParseReceivedData() @@ -454,22 +323,6 @@ void CRConClient::ParseReceivedData()
}
break;
case SERVERDATA_VPROF_DATA:
{
int nDataSize = m_RecvBuffer.GetInt();
m_VProfExport.OnRemoteData( m_RecvBuffer.PeekGet(), nDataSize );
m_RecvBuffer.SeekGet( CUtlBuffer::SEEK_CURRENT, nDataSize );
}
break;
case SERVERDATA_VPROF_GROUPS:
{
int nDataSize = m_RecvBuffer.GetInt();
m_VProfExport.OnRemoteGroupData( m_RecvBuffer.PeekGet(), nDataSize );
m_RecvBuffer.SeekGet( CUtlBuffer::SEEK_CURRENT, nDataSize );
}
break;
case SERVERDATA_RESPONSE_STRING:
{
char pBuf[2048];
@ -706,45 +559,6 @@ void CRConClient::SendCmd( const char *msg ) @@ -706,45 +559,6 @@ void CRConClient::SendCmd( const char *msg )
SendResponse( response );
}
//-----------------------------------------------------------------------------
// Purpose: Start vprofiling
//-----------------------------------------------------------------------------
void CRConClient::StartVProfData()
{
if ( !IsConnected() )
{
if ( !ConnectSocket() )
return;
}
// Override the vprof export to point to our local profiling data
OverrideVProfExport( &m_VProfExport );
CUtlBuffer response;
BuildResponse( response, SERVERDATA_VPROF, "", "" );
SendResponse( response );
}
//-----------------------------------------------------------------------------
// Purpose: Stop vprofiling
//-----------------------------------------------------------------------------
void CRConClient::StopVProfData()
{
// Reset the vprof export to point to the normal profiling data
ResetVProfExport( &m_VProfExport );
// Don't bother restarting a connection to turn this off
if ( !IsConnected() )
return;
CUtlBuffer response;
BuildResponse( response, SERVERDATA_REMOVE_VPROF, "", "" );
SendResponse( response );
}
//-----------------------------------------------------------------------------
// Purpose: get data from the server
//-----------------------------------------------------------------------------

46
engine/cl_rcon.h

@ -27,47 +27,6 @@ @@ -27,47 +27,6 @@
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
abstract_class IVProfData
{
public:
virtual void OnRemoteGroupData( const void *data, int len ) = 0;
virtual void OnRemoteData( const void *data, int len ) = 0;
};
//-----------------------------------------------------------------------------
// Used to display client perf data in showbudget
//-----------------------------------------------------------------------------
class CRConVProfExport : public IVProfExport, public IVProfData
{
// Inherited from IVProfExport
public:
virtual void AddListener();
virtual void RemoveListener();
virtual void PauseProfile();
virtual void ResumeProfile();
virtual void SetBudgetFlagsFilter( int filter );
virtual int GetNumBudgetGroups();
virtual void GetBudgetGroupInfos( CExportedBudgetGroupInfo *pInfos );
virtual void GetBudgetGroupTimes( float times[MAX_BUDGETGROUP_TIMES] );
// Inherited from IVProfData
public:
virtual void OnRemoteGroupData( const void *data, int len );
virtual void OnRemoteData( const void *data, int len );
// Other public methods
public:
CRConVProfExport();
private:
void CleanupGroupData();
CUtlVector< CExportedBudgetGroupInfo > m_Info;
CUtlVector<float> m_Times; // Times from the most recent snapshot.
};
class CRConClient : public ISocketCreatorListener
{
public:
@ -89,10 +48,6 @@ public: @@ -89,10 +48,6 @@ public:
bool IsConnected() const;
bool IsAuthenticated() const { return m_bAuthenticated; }
void RegisterVProfDataCallback( IVProfData *callback );
void StopVProfData();
void StartVProfData();
void TakeScreenshot();
void GrabConsoleLog();
@ -116,7 +71,6 @@ private: @@ -116,7 +71,6 @@ private:
void SaveRemoteScreenshot( const void* pBuffer, int nBufLen );
void SaveRemoteConsoleLog( const void* pBuffer, int nBufLen );
CRConVProfExport m_VProfExport;
CSocketCreator m_Socket;
netadr_t m_Address;
int m_iAuthRequestID;

57
engine/sv_remoteaccess.cpp

@ -284,53 +284,6 @@ void CServerRemoteAccess::WriteDataRequest( CRConServer *pNetworkListener, ra_li @@ -284,53 +284,6 @@ void CServerRemoteAccess::WriteDataRequest( CRConServer *pNetworkListener, ra_li
#endif
}
break;
#ifdef VPROF_ENABLED
case SERVERDATA_VPROF:
{
char password[25];
if ( !GetStringHelper( cmd, password, sizeof(password) ) )
{
invalidRequest = true;
break;
}
if ( !GetStringHelper( cmd, password, sizeof(password) ) )
{
invalidRequest = true;
break;
}
if ( IsAuthenticated(listener) )
{
RegisterVProfDataListener( listener );
LogCommand( listener, "Remote VProf started!\n" );
RespondString( listener, requestID, "Remote VProf started!\n" );
}
}
break;
case SERVERDATA_REMOVE_VPROF:
{
char password[25];
if ( !GetStringHelper( cmd, password, sizeof(password) ) )
{
invalidRequest = true;
break;
}
if ( !GetStringHelper( cmd, password, sizeof(password) ) )
{
invalidRequest = true;
break;
}
if ( IsAuthenticated(listener) )
{
RemoveVProfDataListener( listener );
LogCommand( listener, "Remote VProf finished!\n" );
RespondString( listener, requestID, "Remote VProf finished!\n" );
}
}
break;
#endif
default:
Assert(!("Unknown requestType in CServerRemoteAccess::WriteDataRequest()"));
cmd.Purge();
@ -911,16 +864,6 @@ void CServerRemoteAccess::SendResponseToClient( ra_listener_id listenerID, Serve @@ -911,16 +864,6 @@ void CServerRemoteAccess::SendResponseToClient( ra_listener_id listenerID, Serve
response.Put( pData, nDataLen );
}
//-----------------------------------------------------------------------------
// Purpose: sends an opaque blob of data from VProf to a remote rcon listener
//-----------------------------------------------------------------------------
void CServerRemoteAccess::SendVProfData( ra_listener_id listenerID, bool bGroupData, void *data, int len )
{
Assert( listenerID != m_AdminUIID ); // only RCON clients support this right now
SendResponseToClient( listenerID, bGroupData ? SERVERDATA_VPROF_GROUPS : SERVERDATA_VPROF_DATA, data, len );
}
//-----------------------------------------------------------------------------
// Purpose: C function for rest of engine to access CServerRemoteAccess class
//-----------------------------------------------------------------------------

6
public/tier0/vprof.h

@ -15,9 +15,9 @@ @@ -15,9 +15,9 @@
#include "tier0/vprof_telemetry.h"
// VProf is enabled by default in all configurations -except- X360 Retail.
#if !( defined( _X360 ) && defined( _CERT ) )
#define VPROF_ENABLED
#endif
//#if !( defined( _X360 ) && defined( _CERT ) )
//#define VPROF_ENABLED
//#endif
#if defined(_X360) && defined(VPROF_ENABLED)
#include "tier0/pmc360.h"

Loading…
Cancel
Save