diff --git a/src/d_clisrv.h b/src/d_clisrv.h index bd9382f7f994344bf7a426fecccd31ea07b48178..7e0fba0afc74f7ee369479efe70d943d48e57fed 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 987b46f88088ee9610ec31faa161022509a1fc31..6f07fad524d5b2b787a836af4dae45fa14cbc216 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) {