From 1568b7e3958bdf080a954b20951474301f46242a Mon Sep 17 00:00:00 2001 From: Boondorl Date: Mon, 24 Mar 2025 09:55:40 -0400 Subject: [PATCH 1/2] Fixed potential softlock in packet-server mode Make sure to send over the lowest player's data we got as the ack and not whatever the host specifically had --- src/d_net.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 2195d6d1c07..cb695bb9556 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -1409,16 +1409,31 @@ void NetUpdate(int tics) curState.Flags &= ~CF_MISSING; NetBuffer[1] = (curState.Flags & CF_RETRANSMIT_SEQ) ? curState.ResendID : CurrentLobbyID; + int lastSeq = curState.CurrentSequence; + int lastCon = curState.CurrentNetConsistency; + if (NetMode == NET_PacketServer && consoleplayer != Net_Arbitrator) + { + // If in packet-server mode, make sure to get the lowest sequence of all players + // since the host themselves might have gotten updated but someone else in the packet + // did not. That way the host knows to send over the correct tic. + for (auto cl : NetworkClients) + { + if (ClientStates[cl].CurrentSequence < lastSeq) + lastSeq = ClientStates[cl].CurrentSequence; + if (ClientStates[cl].CurrentNetConsistency < lastCon) + lastCon = ClientStates[cl].CurrentNetConsistency; + } + } // Last sequence we got from this client. - NetBuffer[2] = (curState.CurrentSequence >> 24); - NetBuffer[3] = (curState.CurrentSequence >> 16); - NetBuffer[4] = (curState.CurrentSequence >> 8); - NetBuffer[5] = curState.CurrentSequence; + NetBuffer[2] = (lastSeq >> 24); + NetBuffer[3] = (lastSeq >> 16); + NetBuffer[4] = (lastSeq >> 8); + NetBuffer[5] = lastSeq; // Last consistency we got from this client. - NetBuffer[6] = (curState.CurrentNetConsistency >> 24); - NetBuffer[7] = (curState.CurrentNetConsistency >> 16); - NetBuffer[8] = (curState.CurrentNetConsistency >> 8); - NetBuffer[9] = curState.CurrentNetConsistency; + NetBuffer[6] = (lastCon >> 24); + NetBuffer[7] = (lastCon >> 16); + NetBuffer[8] = (lastCon >> 8); + NetBuffer[9] = lastCon; if (curState.Flags & CF_RETRANSMIT_SEQ) { From 84654b804e73fd8732a71623e79d4ebee4754df7 Mon Sep 17 00:00:00 2001 From: Boondorl Date: Mon, 24 Mar 2025 10:23:36 -0400 Subject: [PATCH 2/2] Update all players' acks in packet-server mode Fixes potential issue when host switching in packet-server mode --- src/d_net.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_net.cpp b/src/d_net.cpp index cb695bb9556..98bf6002171 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -873,6 +873,9 @@ static void GetPackets() { pState.CurrentSequence = seq; } + // Update this so host switching doesn't have any hiccups in packet-server mode. + if (NetMode == NET_PacketServer && consoleplayer != Net_Arbitrator && pNum != Net_Arbitrator) + pState.SequenceAck = seq; } } }