From a2ad924e53483a1a8ecc45bfafdf3f637d5a4af6 Mon Sep 17 00:00:00 2001 From: JTE <jason.the.echidna@gmail.com> Date: Sat, 7 Mar 2015 10:14:11 -0500 Subject: [PATCH] Cleaned up DebugPrintpacket and PT_ enum. Moved PT_CANFAIL to an explicit index so there's more room to actually add packets before it without breaking things. :| Removed NUMPACKETTYPE (no longer used, and would be completely nonsensical) Added NEWPING to DebugPrintpacket. --- src/d_clisrv.h | 17 ++++++----------- src/d_net.c | 14 ++++++++++---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index bd9382f7f9..7e0fba0afc 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -30,14 +30,12 @@ // // Packet structure // -typedef enum -{ +typedef enum { PT_NOTHING, // To send a nop through the network. ^_~ PT_SERVERCFG, // Server config used in start game - // (must stay 1 for backwards compatibility). // This is a positive response to a CLIENTJOIN request. PT_SERVERREFUSE, // Server refuses joiner (reason inside). - PT_SERVERSHUTDOWN, + PT_SERVERSHUTDOWN,// Server is exiting. PT_CLIENTQUIT, // Client closes the connection. PT_ASKINFO, // Anyone can ask info of the server. @@ -47,20 +45,17 @@ typedef enum PT_ASKINFOVIAMS, // Packet from the MS requesting info be sent to new client. // If this ID changes, update masterserver definition. - // Add non-PT_CANFAIL packet types here to avoid breaking MS compatibility. - - PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL - // allows HSendPacket(,true,,) to return false. - // In addition, this packet can't occupy all the available slots. + PT_CANFAIL = 0x40, // This is kind of a priority. Anything >= PT_CANFAIL + // allows HSendPacket(,true,,) to return false. + // In addition, this packet can't occupy all the available slots. PT_FILEFRAGMENT = PT_CANFAIL, // A part of a file. PT_CLIENTJOIN, // Client wants to join; used in start game. PT_NODETIMEOUT, // Packet sent to self if the connection times out. #ifdef NEWPING - PT_PING, // Packet sent to tell clients the other client's latency to server. + PT_PING // Packet sent to tell clients the other client's latency to server. #endif - NUMPACKETTYPE } packettype_t; #if defined(_MSC_VER) diff --git a/src/d_net.c b/src/d_net.c index 987b46f880..6f07fad524 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -724,7 +724,8 @@ static void fprintfstring(char *s, size_t len) fprintf(debugfile, "\n"); } -static const char *packettypename[NUMPACKETTYPE] = +// Matches packet structure PT_ enum in d_clisrv.h +static const char *packettypename[] = { "NOTHING", "SERVERCFG", @@ -735,19 +736,24 @@ static const char *packettypename[NUMPACKETTYPE] = "ASKINFO", "SERVERINFO", "REQUESTFILE", - "ASKINFOVIAMS", + "ASKINFOVIAMS" +}; - "PLAYERCONFIGS", +static const char *failtypename[] = +{ "FILEFRAGMENT", "CLIENTJOIN", "NODETIMEOUT", +#ifdef NEWPING + "PING" +#endif }; 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, netbuffer->packettype < PT_CANFAIL ? packettypename[netbuffer->packettype] : failtypename[netbuffer->packettype - PT_CANFAIL]); switch (netbuffer->packettype) { -- GitLab