From 134e8f2d607b01fa11e5ae2a5dad7975e2aa15c7 Mon Sep 17 00:00:00 2001 From: Boondorl Date: Mon, 24 Mar 2025 09:55:40 -0400 Subject: [PATCH] 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 2195d6d1c0..cb695bb955 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) {