mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
debugfile: replace mixed string/control character notation with hexdump
Example of old notation:
[10]O[0,0]jartha[0,254,142,131]c[133]hL^{[170][[251,199]+E[181]U+t[247,183,129,165,152]#$[164,22,10,169]r[150,212,3,232,3,0,0,2,0,0,0,8,0]0[8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,9,2,0,0,1,0,217,161,192] D[0,0,0,0,0,0,0]
Example of new notation:
0: 01 0e 6a 61 72 74 68 61 00 57 00 09 5a 00 42 00 ..jartha.W..Z.B.
16: 02 01 00 b7 6a d4 20 6f 2b 45 b5 ....j. o+E.
This commit is contained in:
parent
d2482287a9
commit
3ad30c0c7a
1 changed files with 29 additions and 22 deletions
41
src/d_net.c
41
src/d_net.c
|
|
@ -731,39 +731,46 @@ static UINT32 NetbufferChecksum(void)
|
||||||
|
|
||||||
#ifdef DEBUGFILE
|
#ifdef DEBUGFILE
|
||||||
|
|
||||||
static void fprintfstring(char *s, size_t len)
|
static void fprintfline(char *s, size_t len)
|
||||||
{
|
{
|
||||||
INT32 mode = 0;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < 16; ++i)
|
||||||
if (s[i] < 32)
|
|
||||||
{
|
{
|
||||||
if (!mode)
|
if (i < len)
|
||||||
{
|
{
|
||||||
fprintf(debugfile, "[%d", (UINT8)s[i]);
|
fprintf(debugfile, "%02x%s",
|
||||||
mode = 1;
|
((unsigned char*)s)[i],
|
||||||
}
|
i % 4 == 3 ? " " : " ");
|
||||||
else
|
|
||||||
fprintf(debugfile, ",%d", (UINT8)s[i]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mode)
|
fprintf(debugfile, "%*s", i % 4 == 3 ? 4 : 3, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
fprintf(debugfile, "]");
|
fprintf(debugfile, "%c", isprint(s[i]) ? s[i] : '.');
|
||||||
mode = 0;
|
|
||||||
}
|
}
|
||||||
fprintf(debugfile, "%c", s[i]);
|
|
||||||
|
fprintf(debugfile, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void fprintfstring(char *s, size_t len)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i += 16)
|
||||||
|
{
|
||||||
|
fprintf(debugfile, "%10s: ", sizeu1(i));
|
||||||
|
fprintfline(&s[i], min(len - i, 16));
|
||||||
}
|
}
|
||||||
if (mode)
|
|
||||||
fprintf(debugfile, "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fprintfstringnewline(char *s, size_t len)
|
static void fprintfstringnewline(char *s, size_t len)
|
||||||
{
|
{
|
||||||
fprintfstring(s, len);
|
fprintfstring(s, len);
|
||||||
fprintf(debugfile, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \warning Keep this up-to-date if you add/remove/rename packet types
|
/// \warning Keep this up-to-date if you add/remove/rename packet types
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue