本文整理汇总了C++中CBuffer::findl方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::findl方法的具体用法?C++ CBuffer::findl怎么用?C++ CBuffer::findl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::findl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ListServer_Main
void ListServer_Main()
{
if ( listServerFields[5] == "localhost" ) return;
if (!lsConnected) return;
static CBuffer packetBuffer;
CBuffer receiveBuff;
CStringList lines;
if (listServer.receiveBytes(receiveBuff, 65536) < 0)
{
errorOut("serverlog.txt", "Disconnected from list server.");
lsConnected = false;
return;
}
packetBuffer << receiveBuff;
// Search for a packet. If none is found, break out of the loop.
int lineEnd = packetBuffer.findl( '\n' );
if ( lineEnd == -1 ) return;
// Copy the packet out and remove the \n
CBuffer line = packetBuffer.copy( 0, lineEnd + 1 );
packetBuffer.remove(0, line.length());
// Process the packet.
lines.load( line.text(), "\n" );
//lines.load(receiveBuff.text(), "\n");
for (int i = 0; i < lines.count(); i++)
{
CPacket line = CPacket() << lines[i];
int messageId = line.readByte1();
switch (messageId)
{
case GSVOLD:
{
printf("[%s] SERVER VERSION CHECK - Current: %i, Latest: %i - Old version, please upgrade.\n", getTimeStr(1).text(), GSERVER_BUILD, line.readByte2());
break;
}
case GSVCURRENT:
{
printf("[%s] SERVER VERSION CHECK - Current: %i, Latest: %i - You are up to date :)\n", getTimeStr(1).text(), GSERVER_BUILD, GSERVER_BUILD);
break;
}
case GSVACCOUNT:
{
CString accountName = line.readChars(line.readByte1());
CString errorMsg = line.readString("");
for (int i = 0; i < newPlayers.count(); i++)
{
CPlayer *player = (CPlayer *)newPlayers[i];
if (player->accountName == accountName)
{
if (errorMsg == "SUCCESS")
{
player->sendAccount();
}
else
{
player->sendPacket(CPacket() << (char)DISMESSAGE << errorMsg);
player->deleteMe = true;
}
break;
}
}
break;
}
case GSVGUILD:
{
int playerId = line.readByte2();
CPlayer *player = (CPlayer *)playerIds[playerId];
if (player != NULL)
{
CString nick = line.readChars((unsigned char)line.readByte1());
CString guild = nick.copy( nick.findl( '(' ) ).remove( ")" );
if ( globalGuilds == false )
{
if ( globalGuildList.find( guild ) != -1 )
player->setNick(nick, false);
}
else
player->setNick(nick, false);
}
break;
}
case GSVFILEC:
{
//.........这里部分代码省略.........