Merge remote-tracking branch 'origin/packetstat' into Saturn-Next

This commit is contained in:
Alug committed 2024-07-10 04:49:58 +02:00
commit c7bd402e54
3 files changed
+31 -2

No files matched your search

+20
View File
@@ -76,6 +76,8 @@
#define MAX_REASONLENGTH 30
#define FORCECLOSE 0x8000
static long long unsigned packetstat[NUMPACKETTYPE+1] = {0};
boolean server = true; // true or false but !server == client
#define client (!server)
boolean nodownload = false;
@@ -3116,6 +3118,17 @@ static void Command_connect(void)
botskin = 0;
CL_ConnectToServer();
}
static void Command_Packetstat(void)
{
CONS_Printf("Number of packets handled:\n");
for (UINT8 i = 0; i <= NUMPACKETTYPE; ++i)
{
CONS_Printf("%16s: %llu%s", Net_GetPacketName(i), packetstat[i], (i % 2 == 1) ? "\n" : "\t|\t");
}
}
#endif
static void ResetNode(INT32 node);
@@ -3281,6 +3294,7 @@ void CL_Reset(void)
// make sure we don't leave any fileneeded gunk over from a failed join
fileneedednum = 0;
memset(fileneeded, 0, sizeof(fileneeded));
memset(packetstat, 0, sizeof(packetstat));
#ifndef NONET
totalfilesrequestednum = 0;
@@ -4035,6 +4049,7 @@ void D_ClientServerInit(void)
COM_AddCommand("connect", Command_connect);
COM_AddCommand("nodes", Command_Nodes);
COM_AddCommand("listplayers", Command_Listplayers);
COM_AddCommand("packetstat", Command_Packetstat);
#ifdef HAVE_CURL
COM_AddCommand("set_http_login", Command_set_http_login);
COM_AddCommand("list_http_logins", Command_list_http_logins);
@@ -4133,6 +4148,7 @@ void SV_ResetServer(void)
// clear server_context
memset(server_context, '-', 8);
memset(packetstat, 0, sizeof(packetstat));
DEBFILE("\n-=-=-=-=-=-=-= Server Reset =-=-=-=-=-=-=-\n\n");
}
@@ -5532,6 +5548,10 @@ static void GetPackets(void)
if (netbuffer->packettype == PT_PLAYERINFO)
continue; // We do nothing with PLAYERINFO, that's for the MS browser.
// We also count unknown packets, hence "<="
if (netbuffer->packettype <= NUMPACKETTYPE)
++packetstat[netbuffer->packettype];
// Packet received from someone already playing
if (nodeingame[node])
HandlePacketFromPlayer(node);
+10 -2
View File
@@ -793,7 +793,7 @@ static void fprintfstringnewline(char *s, size_t len)
}
/// \warning Keep this up-to-date if you add/remove/rename packet types
static const char *packettypename[NUMPACKETTYPE] =
const char *packettypename[NUMPACKETTYPE] =
{
"NOTHING",
"SERVERCFG",
@@ -838,11 +838,19 @@ static const char *packettypename[NUMPACKETTYPE] =
"PING"
};
const char *Net_GetPacketName(UINT8 packettype)
{
if (packettype >= NUMPACKETTYPE)
return "UNKNOWN";
return packettypename[packettype];
}
static void DebugPrintpacket(const char *header)
{
fprintf(debugfile, "%-12s (node %d,ack %d,ackret %d,size %d) type(%d) : %s\n",
header, doomcom->remotenode, netbuffer->ack, netbuffer->ackreturn, doomcom->datalength,
netbuffer->packettype, packettypename[netbuffer->packettype]);
netbuffer->packettype, Net_GetPacketName(netbuffer->packettype));
switch (netbuffer->packettype)
{
+1
View File
@@ -65,5 +65,6 @@ void Net_ConnectionTimeout(INT32 node);
void Net_AbortPacketType(UINT8 packettype);
void Net_SendAcks(INT32 node);
void Net_WaitAllAckReceived(UINT32 timeout);
const char *Net_GetPacketName(UINT8 packettype);
#endif