Engine: reimplement netmsg debuggers

Reimplement logic for cvars: "net_showmsg", "net_blockmsg", "net_showpeaks".
This commit is contained in:
Kawe Mazidjatari 2024-03-31 15:20:29 +02:00
parent b1b80d3be0
commit b942db837c
3 changed files with 51 additions and 1 deletions

View File

@ -111,6 +111,10 @@ ConVar* net_usesocketsforloopback;
ConVar* net_data_block_enabled = nullptr;
ConVar* net_datablock_networkLossForSlowSpeed = nullptr;
ConVar* net_compressDataBlock = nullptr;
ConVar* net_showmsg = nullptr;
ConVar* net_blockmsg = nullptr;
ConVar* net_showpeaks = nullptr;
//-----------------------------------------------------------------------------
// RUI |
#ifndef DEDICATED
@ -183,6 +187,10 @@ void ConVar_InitShipped(void)
net_datablock_networkLossForSlowSpeed = g_pCVar->FindVar("net_datablock_networkLossForSlowSpeed");
net_usesocketsforloopback = g_pCVar->FindVar("net_usesocketsforloopback");
net_showmsg = g_pCVar->FindVar("net_showmsg");
net_blockmsg = g_pCVar->FindVar("net_blockmsg");
net_showpeaks = g_pCVar->FindVar("net_showpeaks");
#ifndef CLIENT_DLL
sv_stats = g_pCVar->FindVar("sv_stats");

View File

@ -98,6 +98,10 @@ extern ConVar* net_data_block_enabled;
extern ConVar* net_datablock_networkLossForSlowSpeed;
extern ConVar* net_compressDataBlock;
extern ConVar* net_showmsg;
extern ConVar* net_blockmsg;
extern ConVar* net_showpeaks;
extern ConVar ssl_verify_peer;
extern ConVar curl_timeout;
extern ConVar curl_debug;

View File

@ -417,7 +417,25 @@ bool CNetChan::_ProcessMessages(CNetChan* pChan, bf_read* pBuf)
bool CNetChan::ProcessMessages(bf_read* buf)
{
m_bStopProcessing = false;
//const double flStartTime = Plat_FloatTime();
const char* showMsgName = net_showmsg->GetString();
const char* blockMsgName = net_blockmsg->GetString();
const int netPeak = net_showpeaks->GetInt();
if (*showMsgName == '0')
{
showMsgName = NULL; // dont do strcmp all the time
}
if (*blockMsgName == '0')
{
blockMsgName = NULL; // dont do strcmp all the time
}
if (netPeak > 0 && netPeak < buf->GetNumBytesLeft())
{
showMsgName = "1"; // show messages for this packet only
}
while (true)
{
@ -457,6 +475,26 @@ bool CNetChan::ProcessMessages(bf_read* buf)
return false;
}
if (showMsgName)
{
if ((*showMsgName == '1') || !Q_stricmp(showMsgName, netMsg->GetName()))
{
Msg(eDLL_T::ENGINE, "%s(%s): Received: %s\n",
__FUNCTION__, GetAddress(), netMsg->ToString());
}
}
if (blockMsgName)
{
if ((*blockMsgName == '1') || !Q_stricmp(blockMsgName, netMsg->GetName()))
{
Msg(eDLL_T::ENGINE, "%s(%s): Blocked: %s\n",
__FUNCTION__, GetAddress(), netMsg->ToString());
continue;
}
}
// Netmessage calls the Process function that was registered by
// it's MessageHandler.
m_bProcessingMessages = true;