本文整理汇总了C++中raknet::BitStream::IgnoreBits方法的典型用法代码示例。如果您正苦于以下问题:C++ BitStream::IgnoreBits方法的具体用法?C++ BitStream::IgnoreBits怎么用?C++ BitStream::IgnoreBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raknet::BitStream
的用法示例。
在下文中一共展示了BitStream::IgnoreBits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunTest
//.........这里部分代码省略.........
case ID_DISCONNECTION_NOTIFICATION:
if (isVerbose)
{
printf("We have been disconnected.\n");
DebugTools::ShowError("Test failed.\n",!noPauses && isVerbose,__LINE__,__FILE__);
}
return 3;
break;
case ID_CONNECTION_LOST:
allConnected=false;
connectionAmount[i]--;
if (isVerbose)
{
printf("Connection lost.\n");
DebugTools::ShowError("Test failed.\n",!noPauses && isVerbose,__LINE__,__FILE__);
}
return 3;
break;
default:
if (packet->data[0]==ID_USER_PACKET_ENUM+1)
{
int thePeerNum;
int sequenceNum;
bitStream.Reset();
bitStream.Write((char*)packet->data, packet->length);
bitStream.IgnoreBits(8);
bitStream.Read(sequenceNum);
bitStream.Read(thePeerNum);
if (isVerbose)
printf("Message %i from %i\n",sequenceNum,thePeerNum );
if (thePeerNum>=0&&thePeerNum<peerNum)
{
if (lastNumberReceivedFromList[i][thePeerNum]==sequenceNum)
{
lastNumberReceivedFromList[i][thePeerNum]++;
}
else
{
if (isVerbose)
{
printf("Packets out of order");
DebugTools::ShowError("Test failed.\n",!noPauses && isVerbose,__LINE__,__FILE__);
}
return 4;
}
recievedFromList[i][thePeerNum]++;}
}
break;
}
peerList[i]->DeallocatePacket(packet);
// Stay in the loop as long as there are more packets.
packet = peerList[i]->Receive();
示例2: RunTest
//.........这里部分代码省略.........
RakNetStatistics *rssSender;
rssSender=sender->GetStatistics(sender->GetSystemAddressFromIndex(0));
if (isVerbose)
printf("Snd: %i.\n", packetNumberSender[streamNumberSender]);
nextSend+=sendInterval;
// Test halting
// if (rand()%20==0)
// nextSend+=1000;
}
packet = receiver->Receive();
while (packet)
{
switch(packet->data[0])
{
case ID_NEW_INCOMING_CONNECTION:
if (isVerbose)
printf("ID_NEW_INCOMING_CONNECTION\n");
break;
case ID_DISCONNECTION_NOTIFICATION:
if (isVerbose)
printf("ID_DISCONNECTION_NOTIFICATION\n");
break;
case ID_CONNECTION_LOST:
if (isVerbose)
printf("ID_CONNECTION_LOST\n");
break;
case ID_USER_PACKET_ENUM+1:
bitStream.Reset();
bitStream.Write((char*)packet->data, packet->length);
bitStream.IgnoreBits(8); // Ignore ID_USER_PACKET_ENUM+1
bitStream.Read(receivedPacketNumberReceiver);
bitStream.Read(streamNumberReceiver);
bitStream.Read(receivedTimeReceiver);
if (receivedPacketNumberReceiver!=packetNumberReceiver[streamNumberReceiver])
{
//WARNING: If you modify the below code make sure the whole string remains in bounds, sprintf will NOT do it for you.
//The error string is 512 in length
//Note: Removed buffer checking because chance is insignificant, left code if wanted in future. Needs limits.h ISO C standard.
/*
int maxIntWorkingCopy= INT_MAX;
int maxIntCharLen =0;
while (maxIntWorkingCopy>0)
{maxIntCharLen++;
maxIntWorkingCopy/=10;
}
if (strlen(lastError)>maxIntCharLen* 3 +27)//512 should be a good len for now
{*/
sprintf(lastError,"Expecting %i got %i (channel %i).",packetNumberReceiver[streamNumberReceiver], receivedPacketNumberReceiver, streamNumberReceiver);
/*
}
else
{
sprintf(lastError,"Did not get what was expected. More details can be given if the error string buffer size is increased.");