Use str_hex() for CServer::ProcessClientPacket() debug output

This commit is contained in:
Alexander Akulich 2021-09-14 20:49:50 +03:00
parent 6aaaaf1ab4
commit 92abe8d545

View file

@ -1716,16 +1716,8 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
{ {
if(g_Config.m_Debug) if(g_Config.m_Debug)
{ {
char aHex[] = "0123456789ABCDEF";
char aBuf[512]; char aBuf[512];
str_hex(aBuf, sizeof(aBuf), pPacket->m_pData, minimum(pPacket->m_DataSize, 32));
for(int b = 0; b < pPacket->m_DataSize && b < 32; b++)
{
aBuf[b * 3] = aHex[((const unsigned char *)pPacket->m_pData)[b] >> 4];
aBuf[b * 3 + 1] = aHex[((const unsigned char *)pPacket->m_pData)[b] & 0xf];
aBuf[b * 3 + 2] = ' ';
aBuf[b * 3 + 3] = 0;
}
char aBufMsg[256]; char aBufMsg[256];
str_format(aBufMsg, sizeof(aBufMsg), "strange message ClientID=%d msg=%d data_size=%d", ClientID, Msg, pPacket->m_DataSize); str_format(aBufMsg, sizeof(aBufMsg), "strange message ClientID=%d msg=%d data_size=%d", ClientID, Msg, pPacket->m_DataSize);