2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

fix for split packets

This commit is contained in:
verimavcisi 2018-04-30 23:12:35 +03:00
parent 5fdafc1f3e
commit b8927fc6da

View File

@ -776,14 +776,6 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
gNetSplit.currentSequence = pHeader->sequenceNumber; gNetSplit.currentSequence = pHeader->sequenceNumber;
gNetSplit.splitCount = packetCount; gNetSplit.splitCount = packetCount;
#ifdef REHLDS_FIXES
gNetSplit.totalSize = 0;
// clear part's sequence
for (int i = 0; i < NET_WS_MAX_FRAGMENTS; i++)
gNetSplitFlags[i] = -1;
#endif
if (net_showpackets.value == 4.0f) if (net_showpackets.value == 4.0f)
Con_Printf("<-- Split packet restart %i count %i seq\n", gNetSplit.splitCount, sequenceNumber); Con_Printf("<-- Split packet restart %i count %i seq\n", gNetSplit.splitCount, sequenceNumber);
} }
@ -809,9 +801,6 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
if (SPLIT_SIZE * packetNumber + packetPayloadSize > MAX_UDP_PACKET) if (SPLIT_SIZE * packetNumber + packetPayloadSize > MAX_UDP_PACKET)
{ {
Con_NetPrintf("Malformed packet size (%i, %i)\n", SPLIT_SIZE * packetNumber, packetPayloadSize); Con_NetPrintf("Malformed packet size (%i, %i)\n", SPLIT_SIZE * packetNumber, packetPayloadSize);
#ifdef REHLDS_FIXES
gNetSplit.currentSequence = -1;
#endif
return FALSE; return FALSE;
} }
@ -833,9 +822,6 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
i + 1, i + 1,
gNetSplitFlags[i], gNetSplitFlags[i],
gNetSplit.currentSequence); gNetSplit.currentSequence);
#ifdef REHLDS_FIXES
gNetSplit.currentSequence = -1; // no more parts can be attached, clear it
#endif
return FALSE; return FALSE;
} }
} }
@ -850,9 +836,6 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
} }
else else
{ {
#ifdef REHLDS_FIXES
*outSize = 0;
#endif
Con_NetPrintf("Split packet too large! %d bytes\n", gNetSplit.totalSize); Con_NetPrintf("Split packet too large! %d bytes\n", gNetSplit.totalSize);
return FALSE; return FALSE;
} }
@ -928,6 +911,12 @@ qboolean NET_QueuePacket(netsrc_t sock)
{ {
return NET_LagPacket(TRUE, sock, &in_from, &in_message); return NET_LagPacket(TRUE, sock, &in_from, &in_message);
} }
#ifdef REHLDS_FIXES
else
{
return TRUE;
}
#endif
if (in_message.cursize < 9) if (in_message.cursize < 9)
{ {
@ -935,15 +924,6 @@ qboolean NET_QueuePacket(netsrc_t sock)
return FALSE; return FALSE;
} }
#ifdef REHLDS_FIXES
// Only server can send split packets, there is no server<->server communication, so server can't receive split packets
if (sock == NS_SERVER)
{
Con_NetPrintf("Someone tries to send split packet to the server\n");
return FALSE;
}
#endif
return NET_GetLong(in_message.data, ret, &in_message.cursize); return NET_GetLong(in_message.data, ret, &in_message.cursize);
} }