From f35bdf3bb79a6e5492ce6696c62df00fd08bb1c3 Mon Sep 17 00:00:00 2001 From: Wolfy Date: Mon, 13 Apr 2020 13:41:21 -0500 Subject: [PATCH] Revert basically every attempted join passwords fix --- src/d_clisrv.c | 37 ++------------------- src/d_net.c | 90 ++++++++++++-------------------------------------- src/i_tcp.c | 15 +-------- 3 files changed, 24 insertions(+), 118 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index cee7827ad..b0b23fc08 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -674,7 +674,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) static void resynch_read_player(resynch_pak *rsp) { INT32 i = rsp->playernum, j; - //mobj_t *savedmo = players[i].mo; + mobj_t *savedmo = players[i].mo; // Do not send anything visual related. // Only send data that we need to know for physics. @@ -767,17 +767,11 @@ static void resynch_read_player(resynch_pak *rsp) return; //...but keep old mo even if it is corrupt or null! - //players[i].mo = savedmo; + players[i].mo = savedmo; //Transfer important mo information if they have a valid mo. if (!rsp->hasmo) - { - // Get rid of their object if they aren't supposed to have one.....?? - if (players[i].mo) - P_RemoveMobj(players[i].mo); - return; - } //server thinks player has a body. //Give them a new body that can be then manipulated by the server's info. @@ -1030,7 +1024,6 @@ static void SV_SendResynch(INT32 node) return; } - resynch_inprogress[node] = false; // Let's see if there's REALLY anyone left to sync..... netbuffer->packettype = PT_RESYNCHING; for (i = 0, j = 0; i < MAXPLAYERS; ++i) { @@ -1038,24 +1031,10 @@ static void SV_SendResynch(INT32 node) if (!(resynch_status[node] & 1< TICRATE) - { - CONS_Alert(CONS_ERROR, "Node %d (%s) somehow had a stupidly-long resync delay?! (%d tics to resync player %d)\n", - node, player_names[nodetoplayer[node]], resynch_sent[node][i], i - ); - resynch_sent[node][i] = TICRATE; - } - continue; } @@ -1069,15 +1048,6 @@ static void SV_SendResynch(INT32 node) break; } - if (!resynch_inprogress[node]) - { - CONS_Alert(CONS_ERROR, "Node %d (%s) somehow had resync status for nonexistent players?! (%08x)\n", - node, player_names[nodetoplayer[node]], resynch_status[node] = 0x00 - ); - resynch_status[node] = 0x00; - resynch_inprogress[node] = true; // So they get the PT_RESYNCHEND... - } - if (resynch_score[node] > (unsigned)cv_resynchattempts.value*250) { XBOXSTATIC UINT8 buf[2]; @@ -2311,8 +2281,6 @@ static void CL_ConnectToServer(boolean viams) if (gamestate == GS_VOTING) Y_EndVote(); - resynch_local_inprogress = false; // Just in case this was never cleared... - DEBFILE(va("waiting %d nodes\n", doomcom->numnodes)); G_SetGamestate(GS_WAITINGPLAYERS); wipegamestate = GS_WAITINGPLAYERS; @@ -3411,7 +3379,6 @@ void D_QuitNetGame(void) HSendPacket(servernode, true, 0, 0); } - resynch_local_inprogress = false; // No more resyncing! D_CloseConnection(); ClearAdminPlayers(); diff --git a/src/d_net.c b/src/d_net.c index 6991fde12..3b1bad870 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -339,7 +339,6 @@ static boolean Processackpak(void) { UINT8 ack = netbuffer->ack; getackpacket++; - if (cmpack(ack, node->firstacktosend) <= 0) { DEBFILE(va("Discard(1) ack %d (duplicated)\n", ack)); @@ -362,7 +361,6 @@ static boolean Processackpak(void) // Is a good packet so increment the acknowledge number, // Then search for a "hole" in the queue UINT8 nextfirstack = (UINT8)(node->firstacktosend + 1); - if (!nextfirstack) nextfirstack = 1; @@ -781,8 +779,6 @@ static const char *packettypename[NUMPACKETTYPE] = { "NOTHING", "SERVERCFG", - - "CLIENTCMD", "CLIENTMIS", "CLIENT2CMD", @@ -803,9 +799,6 @@ static const char *packettypename[NUMPACKETTYPE] = "RESYNCHEND", "RESYNCHGET", - - - "CLIENT3CMD", "CLIENT3MIS", "CLIENT4CMD", @@ -813,20 +806,13 @@ static const char *packettypename[NUMPACKETTYPE] = "BASICKEEPALIVE", "FILEFRAGMENT", - "TEXTCMD", "TEXTCMD2", "TEXTCMD3", "TEXTCMD4", - "CLIENTJOIN", "NODETIMEOUT", "RESYNCHING", - - - "TELLFILESNEEDED", - "MOREFILESNEEDED", - "PING" }; @@ -1081,10 +1067,6 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen netbuffer->checksum = NetbufferChecksum(); sendbytes += packetheaderlength + doomcom->datalength; // For stat - // Joinpasswords close nodes, this may try to send to a waiting-to-close node, so cancel closing? - if (netbuffer->packettype == PT_CLIENTJOIN) - nodes[node].flags &= ~NF_CLOSE; - #ifdef PACKETDROP // Simulate internet :) //if (rand() >= (INT32)(RAND_MAX * (PACKETLOSSRATE / 100.f))) @@ -1121,7 +1103,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen // boolean HGetPacket(void) { - boolean nodejustjoined; + //boolean nodejustjoined; // Get a packet from self if (rebound_tail != rebound_head) @@ -1148,56 +1130,11 @@ boolean HGetPacket(void) while(true) { - nodejustjoined = I_NetGet(); - //I_NetGet(); + //nodejustjoined = I_NetGet(); + I_NetGet(); if (doomcom->remotenode == -1) // No packet received - { - if (nodejustjoined) // _This_ means we did receive a packet, but either from a node we couldn't allocate or a gone player ackreting... - continue; - else - return false; - } - - if (nodejustjoined) - { - // If a new node sends an unexpected packet, just ignore it - if (server - && !(netbuffer->packettype == PT_ASKINFO - || netbuffer->packettype == PT_SERVERINFO - || netbuffer->packettype == PT_PLAYERINFO - || netbuffer->packettype == PT_REQUESTFILE - || netbuffer->packettype == PT_ASKINFOVIAMS - || netbuffer->packettype == PT_CLIENTJOIN - || netbuffer->packettype == PT_TELLFILESNEEDED - || netbuffer->packettype == PT_CLIENTCMD)) - { - DEBFILE(va("New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype])); - CONS_Alert(CONS_NOTICE, "New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype]); - Net_CloseConnection(doomcom->remotenode | FORCECLOSE); - continue; - } - - // UGLY PROBABLY-BAD HACK: If we get PT_CLIENTJOIN, assume this is an in-order packet? - if (netbuffer->packettype == PT_CLIENTJOIN) - nodes[doomcom->remotenode].firstacktosend = (UINT8)((netbuffer->ack-1+MAXACKTOSEND) % MAXACKTOSEND); - - if (netbuffer->ack > 1 && !(server && netbuffer->packettype == PT_CLIENTJOIN)) - { - DEBFILE("New node sent a packet with an out-of-sequence ack. Ghost connection? Ignoring...\n"); - CONS_Alert(CONS_NOTICE, "New node sent a packet with an out-of-sequence ack. Ghost connection? Ignoring...\n"); - Net_CloseConnection(doomcom->remotenode | FORCECLOSE); - continue; - } - - // Reinitialize vars for the new node just in case there's anything left over from other players..... - InitNode(&nodes[doomcom->remotenode]); - SV_AbortSendFiles(doomcom->remotenode); - } - - // Joinpasswords close nodes, this may receive from a waiting-to-close node, so cancel closing? - if (netbuffer->packettype == PT_CLIENTJOIN) - nodes[doomcom->remotenode].flags &= ~NF_CLOSE; + return false; getbytes += packetheaderlength + doomcom->datalength; // For stat @@ -1212,8 +1149,8 @@ boolean HGetPacket(void) if (netbuffer->checksum != NetbufferChecksum()) { DEBFILE("Bad packet checksum\n"); - Net_CloseConnection(nodejustjoined ? (doomcom->remotenode | FORCECLOSE) : doomcom->remotenode); - //Net_CloseConnection(doomcom->remotenode); + //Net_CloseConnection(nodejustjoined ? (doomcom->remotenode | FORCECLOSE) : doomcom->remotenode); + Net_CloseConnection(doomcom->remotenode); continue; } @@ -1222,6 +1159,21 @@ boolean HGetPacket(void) DebugPrintpacket("GET"); #endif + /*// If a new node sends an unexpected packet, just ignore it + if (nodejustjoined && server + && !(netbuffer->packettype == PT_ASKINFO + || netbuffer->packettype == PT_SERVERINFO + || netbuffer->packettype == PT_PLAYERINFO + || netbuffer->packettype == PT_REQUESTFILE + || netbuffer->packettype == PT_ASKINFOVIAMS + || netbuffer->packettype == PT_CLIENTJOIN)) + { + DEBFILE(va("New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype])); + //CONS_Alert(CONS_NOTICE, "New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype]); + Net_CloseConnection(doomcom->remotenode | FORCECLOSE); + continue; + }*/ + // Proceed the ack and ackreturn field if (!Processackpak()) continue; // discarded (duplicated) diff --git a/src/i_tcp.c b/src/i_tcp.c index 7de94573d..f58aa22bc 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -508,8 +508,6 @@ static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask) return false; } -static void SOCK_FreeNodenum(INT32 numnode); - // This is a hack. For some reason, nodes aren't being freed properly. // This goes through and cleans up what nodes were supposed to be freed. /** \warning This function causes the file downloading to stop if someone joins. @@ -526,7 +524,7 @@ static void cleanupnodes(void) // Why can't I start at zero? for (j = 1; j < MAXNETNODES; j++) if (!(nodeingame[j] || SV_SendingFile(j))) - SOCK_FreeNodenum(j); // At least free this PROPERLY + nodeconnected[j] = false; } static SINT8 getfreenode(void) @@ -626,13 +624,6 @@ static boolean SOCK_Get(void) } // not found - if (netbuffer->packettype == PT_NOTHING) - { - DEBFILE(va("Ackret received from disconnected address:%s, ignoring...\n", SOCK_AddrToStr(&fromaddress))); - doomcom->remotenode = -1; // no packet - return true; - } - // find a free slot j = getfreenode(); if (j > 0) @@ -659,11 +650,7 @@ static boolean SOCK_Get(void) return true; } else - { DEBFILE("New node detected: No more free slots\n"); - doomcom->remotenode = -1; // no packet - return true; - } } }