mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #4163
4163: CServer::ProcessClientPacket(): Refactor the debug on unknown message received r=def- a=Kaffeine <!-- What is the motivation for the changes of this pull request --> I knew that there is `str_hex()` in `system.h` and then I accidentally noticed `char aHex[] = "0123456789ABCDEF";` here in CServer. I compiled the server and checked that it works as before this change. However, I've not triggered/checked this debug message. ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Alexander Akulich <akulichalexander@gmail.com>
This commit is contained in:
commit
f179d21e70
|
@ -1716,16 +1716,9 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
{
|
{
|
||||||
if(g_Config.m_Debug)
|
if(g_Config.m_Debug)
|
||||||
{
|
{
|
||||||
char aHex[] = "0123456789ABCDEF";
|
constexpr int MaxDumpedDataSize = 32;
|
||||||
char aBuf[512];
|
char aBuf[MaxDumpedDataSize * 3 + 1];
|
||||||
|
str_hex(aBuf, sizeof(aBuf), pPacket->m_pData, minimum(pPacket->m_DataSize, MaxDumpedDataSize));
|
||||||
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);
|
||||||
|
|
Loading…
Reference in a new issue