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
This commit is contained in:
Boondorl 2025-03-24 09:55:40 -04:00 committed by Ricardo Luís Vaz Silva
parent 5b1023c447
commit 134e8f2d60

View file

@ -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)
{