2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-01 01:25:38 +03:00

Merge pull request #652 from WPMGPRoSToTeMa/fix-net-queuepacket-workflow

Fixed NET_QueuePacket workflow
This commit is contained in:
theAsmodai 2018-09-19 13:46:45 +03:00 committed by GitHub
commit 83f53fb5c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -859,6 +859,10 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
} }
qboolean NET_QueuePacket(netsrc_t sock) qboolean NET_QueuePacket(netsrc_t sock)
{
#ifdef REHLDS_FIXES
while (true)
#endif // REHLDS_FIXES
{ {
int ret = -1; int ret = -1;
unsigned char buf[MAX_UDP_PACKET]; unsigned char buf[MAX_UDP_PACKET];
@ -917,10 +921,21 @@ qboolean NET_QueuePacket(netsrc_t sock)
Con_NetPrintf("%s: Oversize packet from %s\n", __func__, NET_AdrToString(in_from)); Con_NetPrintf("%s: Oversize packet from %s\n", __func__, NET_AdrToString(in_from));
} }
#ifdef REHLDS_FIXES
if (ret == -1)
{
return NET_LagPacket(FALSE, sock, NULL, NULL);
}
if (ret == MAX_UDP_PACKET)
{
continue;
}
#else // REHLDS_FIXES
if (ret == -1 || ret == MAX_UDP_PACKET) if (ret == -1 || ret == MAX_UDP_PACKET)
{ {
return NET_LagPacket(FALSE, sock, NULL, NULL); return NET_LagPacket(FALSE, sock, NULL, NULL);
} }
#endif // REHLDS_FIXES
NET_TransferRawData(&in_message, buf, ret); NET_TransferRawData(&in_message, buf, ret);
@ -932,7 +947,11 @@ qboolean NET_QueuePacket(netsrc_t sock)
if (in_message.cursize < 9) if (in_message.cursize < 9)
{ {
Con_NetPrintf("Invalid split packet length %i\n", in_message.cursize); Con_NetPrintf("Invalid split packet length %i\n", in_message.cursize);
#ifdef REHLDS_FIXES
continue;
#else // REHLDS_FIXES
return FALSE; return FALSE;
#endif // REHLDS_FIXES
} }
#ifdef REHLDS_FIXES #ifdef REHLDS_FIXES
@ -940,11 +959,21 @@ qboolean NET_QueuePacket(netsrc_t sock)
if (sock == NS_SERVER) if (sock == NS_SERVER)
{ {
Con_NetPrintf("Someone tries to send split packet to the server\n"); Con_NetPrintf("Someone tries to send split packet to the server\n");
return FALSE; continue;
} }
#endif #endif
#ifdef REHLDS_FIXES
if (!NET_GetLong(in_message.data, ret, &in_message.cursize))
{
continue;
}
return TRUE;
#else // REHLDS_FIXES
return NET_GetLong(in_message.data, ret, &in_message.cursize); return NET_GetLong(in_message.data, ret, &in_message.cursize);
#endif // REHLDS_FIXES
}
} }
DLL_EXPORT int NET_Sleep_Timeout() DLL_EXPORT int NET_Sleep_Timeout()