Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

重建分包的时候,没有考虑来包顺序混乱的问题导致 包的数据会出错。 #122

Open
qtx0213 opened this issue Nov 21, 2017 · 2 comments

Comments

@qtx0213
Copy link

qtx0213 commented Nov 21, 2017

把 ReliabilityLayer 的 BuildPacketFromSplitPacketList 改成下面这样就可以了。`
InternalPacket * ReliabilityLayer::BuildPacketFromSplitPacketList( SplitPacketChannel *splitPacketChannel, CCTimeType time )
{
#if PREALLOCATE_LARGE_MESSAGES==1
InternalPacket *returnedPacket=splitPacketChannel->returnedPacket;
RakNet::OP_DELETE(splitPacketChannel, FILE, LINE);
(void) time;
return returnedPacket;
#else
unsigned int j;
InternalPacket * internalPacket, *splitPacket;
// int splitPacketPartLength;

// Reconstruct
internalPacket = CreateInternalPacketCopy( splitPacketChannel->splitPacketList[0], 0, 0, time );
internalPacket->dataBitLength=0;
for (j=0; j < splitPacketChannel->splitPacketList.Size(); j++)
	internalPacket->dataBitLength+=splitPacketChannel->splitPacketList[j]->dataBitLength;
// splitPacketPartLength=BITS_TO_BYTES(splitPacketChannel->firstPacket->dataBitLength);

internalPacket->data = (unsigned char*) rakMalloc_Ex( (size_t) BITS_TO_BYTES( internalPacket->dataBitLength ), _FILE_AND_LINE_ );
internalPacket->allocationScheme=InternalPacket::NORMAL;

BitSize_t offset = 0; 

int itt = 0;
while (itt < splitPacketChannel->splitPacketList.Size())
{
	for (j = 0; j < splitPacketChannel->splitPacketList.Size(); j++)
	{
		splitPacket = splitPacketChannel->splitPacketList[j];
		if (itt == splitPacket->splitPacketIndex)
		{
			memcpy(internalPacket->data + BITS_TO_BYTES(offset), splitPacket->data, (size_t)BITS_TO_BYTES(splitPacketChannel->splitPacketList[j]->dataBitLength));
			offset += splitPacketChannel->splitPacketList[j]->dataBitLength;
			break;
		}
	}

	itt++;
}

for (j=0; j < splitPacketChannel->splitPacketList.Size(); j++)
{
	FreeInternalPacketData(splitPacketChannel->splitPacketList[j], _FILE_AND_LINE_ );
	ReleaseToInternalPacketPool(splitPacketChannel->splitPacketList[j]);
}
RakNet::OP_DELETE(splitPacketChannel, __FILE__, __LINE__);

return internalPacket;

#endif
}``

@wwqly12
Copy link

wwqly12 commented Aug 4, 2018

you are right

@cgoxopx
Copy link

cgoxopx commented Feb 16, 2019

发pr吧

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants