Loop through rebound packets until you found a good one or ran out of them

This commit is contained in:
Monster Iestyn 2017-05-19 11:52:50 +01:00
parent 5a1fc6098e
commit 1078a642df

View file

@ -1124,22 +1124,27 @@ boolean HGetPacket(void)
// Get a packet from self // Get a packet from self
if (rebound_tail != rebound_head) if (rebound_tail != rebound_head)
{ {
M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]); while (true) // loop until we found a valid packet, or we ran out of packets
doomcom->datalength = reboundsize[rebound_tail]; { // provided MAXREBOUND is not all that large this shouldn't take too long
if (netbuffer->packettype == PT_NODETIMEOUT) if (rebound_tail == rebound_head)
doomcom->remotenode = netbuffer->u.textcmd[0]; break; // just give up, none of them were any good somehow
else M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]);
doomcom->remotenode = 0; doomcom->datalength = reboundsize[rebound_tail];
if (netbuffer->packettype == PT_NODETIMEOUT)
doomcom->remotenode = netbuffer->u.textcmd[0];
else
doomcom->remotenode = 0;
rebound_tail = (rebound_tail+1) % MAXREBOUND; rebound_tail = (rebound_tail+1) % MAXREBOUND;
if (doomcom->remotenode == -1) // wait hang on what? if (doomcom->remotenode == -1) // wait hang on what?
return true; // there might still be packets from others though, so don't return false continue; // ignore it, look for the next packet
#ifdef DEBUGFILE #ifdef DEBUGFILE
if (debugfile) if (debugfile)
DebugPrintpacket("GETLOCAL"); DebugPrintpacket("GETLOCAL");
#endif #endif
return true; return true;
}
} }
if (!netgame) if (!netgame)