Skip to content

Fixed potential softlock in packet-server mode #3022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions src/d_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -1409,16 +1412,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)
{
Expand Down