From: Holger Schemel Date: Wed, 22 Aug 2018 09:22:47 +0000 (+0200) Subject: added function to dump network message buffer (for debugging) X-Git-Tag: 4.1.1.0~64 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f3d8a0f54214645e629310041927daa9028cfef5;p=rocksndiamonds.git added function to dump network message buffer (for debugging) --- diff --git a/src/netserv.c b/src/netserv.c index 551772a0..9ebfc4e0 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -312,6 +312,25 @@ void putNetworkBufferString(struct NetworkBuffer *nb, char *s) nb->size = nb->pos; } +void dumpNetworkBuffer(struct NetworkBuffer *nb) +{ + int i; + + printf("::: network buffer maximum size: %d\n", nb->max_size); + printf("::: network buffer size: %d\n", nb->size); + printf("::: network buffer position : %d\n", nb->pos); + + for (i = 0; i < nb->size; i++) + { + if ((i % 16) == 0) + printf("\n::: "); + + printf("%02x ", nb->buffer[i]); + } + + printf("\n"); +} + static void SendNetworkBufferToAllButOne(struct NetworkBuffer *nb, struct NetworkServerPlayerInfo *except) { diff --git a/src/netserv.h b/src/netserv.h index 6017557a..df016684 100644 --- a/src/netserv.h +++ b/src/netserv.h @@ -73,6 +73,8 @@ void putNetworkBuffer32BitInteger(struct NetworkBuffer *, int); char *getNetworkBufferString(struct NetworkBuffer *); void putNetworkBufferString(struct NetworkBuffer *, char *); +void dumpNetworkBuffer(struct NetworkBuffer *); + int NetworkServerThread(void *); void NetworkServer(int, int);