本文整理汇总了C++中CCommandPacket类的典型用法代码示例。如果您正苦于以下问题:C++ CCommandPacket类的具体用法?C++ CCommandPacket怎么用?C++ CCommandPacket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCommandPacket类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessPackets
void CBNLSClient :: ProcessPackets( )
{
while( !m_Packets.empty( ) )
{
CCommandPacket *Packet = m_Packets.front( );
m_Packets.pop( );
if( Packet->GetID( ) == CBNLSProtocol :: BNLS_WARDEN )
{
BYTEARRAY WardenResponse = m_Protocol->RECEIVE_BNLS_WARDEN( Packet->GetData( ) );
if( !WardenResponse.empty( ) )
m_WardenResponses.push( WardenResponse );
}
delete Packet;
}
}
示例2: ProcessPackets
void CBNLSClient :: ProcessPackets( )
{
while( !m_Packets.isEmpty( ) )
{
CCommandPacket *Packet = m_Packets.front( );
m_Packets.dequeue( );
if( Packet->GetID( ) == CBNLSProtocol :: BNLS_WARDEN )
{
QByteArray WardenResponse = m_Protocol->RECEIVE_BNLS_WARDEN( Packet->GetData( ) );
if( !WardenResponse.isEmpty( ) )
emit newWardenResponse(WardenResponse);
}
delete Packet;
}
}
示例3: ProcessPackets
void CPotentialPlayer :: ProcessPackets( )
{
if( !m_Socket )
return;
// process all the received packets in the m_Packets queue
while( !m_Packets.empty( ) )
{
CCommandPacket *Packet = m_Packets.front( );
m_Packets.pop( );
if( Packet->GetPacketType( ) == W3GS_HEADER_CONSTANT )
{
// the only packet we care about as a potential player is W3GS_REQJOIN, ignore everything else
switch( Packet->GetID( ) )
{
case CGameProtocol :: W3GS_REQJOIN:
delete m_IncomingJoinPlayer;
m_IncomingJoinPlayer = m_Protocol->RECEIVE_W3GS_REQJOIN( Packet->GetData( ) );
if( m_IncomingJoinPlayer )
m_Game->EventPlayerJoined( this, m_IncomingJoinPlayer );
// don't continue looping because there may be more packets waiting and this parent class doesn't handle them
// EventPlayerJoined creates the new player, NULLs the socket, and sets the delete flag on this object so it'll be deleted shortly
// any unprocessed packets will be copied to the new CGamePlayer in the constructor or discarded if we get deleted because the game is full
delete Packet;
return;
}
}
delete Packet;
}
}
示例4: ProcessPackets
void CPotentialPlayer :: ProcessPackets( )
{
if( !m_Socket )
return;
// process all the received packets in the m_Packets queue
while( !m_Packets.empty( ) )
{
CCommandPacket *Packet = m_Packets.front( );
m_Packets.pop( );
if( Packet->GetPacketType( ) == W3GS_HEADER_CONSTANT )
{
// the only packet we care about as a potential player is W3GS_REQJOIN, ignore everything else
switch( Packet->GetID( ) )
{
case CGameProtocol :: W3GS_REQJOIN:
delete m_IncomingJoinPlayer;
m_IncomingJoinPlayer = m_Protocol->RECEIVE_W3GS_REQJOIN( Packet->GetData( ) );
if( m_IncomingJoinPlayer && !m_Banned )
m_Game->EventPlayerJoined( this, m_IncomingJoinPlayer );
// don't continue looping because there may be more packets waiting and this parent class doesn't handle them
// EventPlayerJoined creates the new player, NULLs the socket, and sets the delete flag on this object so it'll be deleted shortly
// any unprocessed packets will be copied to the new CGamePlayer in the constructor or discarded if we get deleted because the game is full
delete Packet;
return;
}
}
else if( Packet->GetPacketType( ) == GCBI_HEADER_CONSTANT )
{
// if( Packet->GetID( ) == CGCBIProtocol :: GCBI_INIT && m_Game->m_GHost->IsLocal( GetExternalIPString( ) ) )
if( Packet->GetID( ) == CGCBIProtocol :: GCBI_INIT )
{
delete m_IncomingGarenaUser;
m_IncomingGarenaUser = m_Game->m_GHost->m_GCBIProtocol->RECEIVE_GCBI_INIT( Packet->GetData( ) );
string RoomID = UTIL_ToString(m_IncomingGarenaUser->GetRoomID( ));
m_RoomName = m_Game->m_GHost->GetRoomName( string( RoomID.begin( ), RoomID.end( ) ) );
CONSOLE_Print( "[GCBI] Garena user detected; userid=" + UTIL_ToString( m_IncomingGarenaUser->GetUserID( ) ) + ", roomid=" + RoomID + ", RoomName=" + m_RoomName + ", experience=" + UTIL_ToString( m_IncomingGarenaUser->GetUserExp( ) ) + ", country=" + m_IncomingGarenaUser->GetCountryCode( ) );
}
}
delete Packet;
}
}
示例5: ProcessPackets
void CGamePlayer :: ProcessPackets( )
{
if( !m_Socket )
return;
CIncomingAction *Action = NULL;
CIncomingChatPlayer *ChatPlayer = NULL;
CIncomingMapSize *MapSize = NULL;
bool HasMap = false;
uint32_t CheckSum = 0;
uint32_t Pong = 0;
// process all the received packets in the m_Packets queue
while( !m_Packets.empty( ) )
{
CCommandPacket *Packet = m_Packets.front( );
m_Packets.pop( );
if( Packet->GetPacketType( ) == W3GS_HEADER_CONSTANT )
{
switch( Packet->GetID( ) )
{
case CGameProtocol :: W3GS_LEAVEGAME:
m_Game->EventPlayerLeft( this, m_Protocol->RECEIVE_W3GS_LEAVEGAME( Packet->GetData( ) ) );
break;
case CGameProtocol :: W3GS_GAMELOADED_SELF:
if( m_Protocol->RECEIVE_W3GS_GAMELOADED_SELF( Packet->GetData( ) ) )
{
if( !m_FinishedLoading && m_Game->GetGameLoading( ) )
{
m_FinishedLoading = true;
m_FinishedLoadingTicks = GetTicks( );
m_Game->EventPlayerLoaded( this );
}
else
{
// we received two W3GS_GAMELOADED_SELF packets from this player!
}
}
break;
case CGameProtocol :: W3GS_OUTGOING_ACTION:
Action = m_Protocol->RECEIVE_W3GS_OUTGOING_ACTION( Packet->GetData( ), m_PID );
if( Action )
{
// don't delete Action here because the game is going to store it in a queue and delete it later
m_Game->EventPlayerAction( this, Action );
}
break;
case CGameProtocol :: W3GS_OUTGOING_KEEPALIVE:
CheckSum = m_Protocol->RECEIVE_W3GS_OUTGOING_KEEPALIVE( Packet->GetData( ) );
m_CheckSums.push( CheckSum );
++m_SyncCounter;
m_Game->EventPlayerKeepAlive( this, CheckSum );
break;
case CGameProtocol :: W3GS_CHAT_TO_HOST:
ChatPlayer = m_Protocol->RECEIVE_W3GS_CHAT_TO_HOST( Packet->GetData( ) );
if( ChatPlayer )
{
// determine if we should auto-mute this player
if( ChatPlayer->GetType( ) == CIncomingChatPlayer :: CTH_MESSAGE || ChatPlayer->GetType( ) == CIncomingChatPlayer :: CTH_MESSAGEEXTRA )
{
if( m_Level <= 1 &&! GetMuted( ) )
{
m_MuteMessages.push_back( GetTicks( ) );
if( m_MuteMessages.size( ) > 7 )
m_MuteMessages.erase( m_MuteMessages.begin( ) );
uint32_t RecentCount = 0;
for( unsigned int i = 0; i < m_MuteMessages.size( ); ++i )
{
if( GetTicks( ) - m_MuteMessages[i] < 5000 )
{
RecentCount++;
}
}
if( m_Game->m_OHBot->m_AutoMuteSpammer && RecentCount >= 7 )
{
m_Count++;
if( m_Count == 1 )
{
SetMuted( true );
m_MutedAuto = true;
m_Game->SendChat( m_PID, "["+m_Game->m_OHBot->m_BotManagerName+"] "+m_Game->m_OHBot->m_Language->SpamWarning( ) );
m_MuteMessages.clear( );
m_Game->SendAllChat( "["+m_Game->m_OHBot->m_BotManagerName+"] " + m_Game->m_OHBot->m_Language->UserWasMutedForReason( m_Name, "spamming" ) );
}
if( m_Count == 2 )
{
m_Game->SendAllChat( m_Game->m_OHBot->m_Language->UserIgnoerNotify( m_Name ) );
//.........这里部分代码省略.........
示例6: while
void CGProxy::processLocalPackets()
{
if(!m_LocalSocket || m_LocalSocket->state() != QTcpSocket::ConnectedState)
return;
while( !m_LocalPackets.empty( ) )
{
CCommandPacket *Packet = m_LocalPackets.front( );
m_LocalPackets.pop_front( );
QByteArray Data = Packet->GetData( );
QDataStream ds(Data);
ds.setByteOrder(QDataStream::LittleEndian);
if( Packet->GetPacketType( ) == W3GS_HEADER_CONSTANT )
{
if( Packet->GetID( ) == CGameProtocol :: W3GS_REQJOIN )
{
if( Data.size( ) >= 20 )
{
quint32 HostCounter;
quint32 EntryKey;
quint8 Unknown;
quint16 ListenPort;
quint32 PeerKey;
QString Name;
QByteArray Remainder;
ds.skipRawData(4);
ds >> HostCounter;
ds >> EntryKey;
ds >> Unknown;
ds >> ListenPort;
ds >> PeerKey;
Name = CGameProtocol::ExtractString(ds);
Remainder = QByteArray(Data.begin() + Name.size() + 20, Data.size() - (Name.size() + 20));
if(Remainder.size( ) == 18)
{
bool GameFound = false;
for(QVector<CGameInfo*>::iterator i = games.begin( ); i != games.end( ); ++i)
{
if((*i)->GetUniqueGameID() == EntryKey)
{
m_RemoteSocket->reset();
m_RemoteSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1);
m_RemoteSocket->connectToHost((*i)->GetIP(), (*i)->GetPort());
if(!m_RemoteSocket->waitForConnected(3000))
{
qDebug() << "[GPROXY] player requested to join an expired game. removing from list.";
m_RequesterSocket->writeDatagram(m_GameProtocol->SEND_W3GS_DECREATEGAME((*i)->GetUniqueGameID()), QHostAddress::Broadcast, 6112);
delete (*i);
games.erase(i);
break;
}
m_LastConnectionAttemptTime = GetTime();
m_RemoteServerIP = (*i)->GetIP();
m_GameIsReliable = (*i)->GetReliable();
m_GameStarted = false;
QByteArray DataRewritten;
QDataStream ds(&DataRewritten, QIODevice::ReadWrite);
ds.setByteOrder(QDataStream::LittleEndian);
ds << (quint8)W3GS_HEADER_CONSTANT;
ds << (quint8)Packet->GetID();
ds << (quint16)0;
ds << (*i)->GetHostCounter();
ds << (*i)->GetEntryKey();
ds << (quint8)Unknown;
ds << (quint16)ListenPort;
ds << (quint32)PeerKey;
ds.writeRawData(Name.toUtf8(), Name.length());
ds << (quint8)0;
ds.writeRawData(Remainder.data(), Remainder.length());
CGameProtocol::AssignLength(DataRewritten);
Data = DataRewritten;
GameFound = true;
emit joinedGame((*i)->GetIP(), (*i)->GetGameName());
break;
}
}
if(!GameFound)
{
qDebug() << "[GPROXY] local player requested unknown game (expired?) sending decreate.";
m_RequesterSocket->writeDatagram(m_GameProtocol->SEND_W3GS_DECREATEGAME(EntryKey), QHostAddress::Broadcast, 6112);
m_LocalSocket->disconnectFromHost();
}
}
else
qDebug() << "[GPROXY] received invalid join request from local player (invalid remainder)";
}
else
qDebug() << "[GPROXY] received invalid join request from local player (too short)";
//.........这里部分代码省略.........
示例7: ProcessPackets
void CBNET :: ProcessPackets( )
{
CIncomingGameHost* GameHost = NULL;
CIncomingChatEvent* ChatEvent = NULL;
BYTEARRAY WardenData;
vector<CIncomingFriendList*> Friends;
vector<CIncomingClanList*> Clans;
// process all the received packets in the m_Packets queue
// this normally means sending some kind of response
while( !m_Packets.empty() )
{
CCommandPacket* Packet = m_Packets.front();
m_Packets.pop();
if( Packet->GetPacketType() == BNET_HEADER_CONSTANT )
{
switch( Packet->GetID() )
{
case CBNETProtocol :: SID_NULL:
// warning: we do not respond to NULL packets with a NULL packet of our own
// this is because PVPGN servers are programmed to respond to NULL packets so it will create a vicious cycle of useless traffic
// official battle.net servers do not respond to NULL packets
m_Protocol->RECEIVE_SID_NULL( Packet->GetData() );
break;
case CBNETProtocol :: SID_GETADVLISTEX:
GameHost = m_Protocol->RECEIVE_SID_GETADVLISTEX( Packet->GetData() );
if( GameHost )
cout << "[BNET: " << m_ServerAlias << "] joining game [" << GameHost->GetGameName() << "]\n";
delete GameHost;
GameHost = NULL;
break;
case CBNETProtocol :: SID_ENTERCHAT:
if( m_Protocol->RECEIVE_SID_ENTERCHAT( Packet->GetData() ) )
{
cout << "[BNET: " << m_ServerAlias << "] joining channel [" << m_FirstChannel << "]\n";
m_InChat = true;
m_Socket->PutBytes( m_Protocol->SEND_SID_JOINCHANNEL(m_FirstChannel) );
}
break;
case CBNETProtocol :: SID_CHATEVENT:
ChatEvent = m_Protocol->RECEIVE_SID_CHATEVENT( Packet->GetData() );
if( ChatEvent )
ProcessChatEvent( ChatEvent );
delete ChatEvent;
ChatEvent = NULL;
break;
case CBNETProtocol :: SID_CHECKAD:
m_Protocol->RECEIVE_SID_CHECKAD( Packet->GetData() );
break;
case CBNETProtocol :: SID_STARTADVEX3:
if( m_Protocol->RECEIVE_SID_STARTADVEX3( Packet->GetData() ) )
{
m_InChat = false;
m_GHost->EventBNETGameRefreshed( this );
}
else
{
cout << "[BNET: " << m_ServerAlias << "] startadvex3 failed\n";
m_GHost->EventBNETGameRefreshFailed( this );
}
break;
case CBNETProtocol :: SID_PING:
m_Socket->PutBytes( m_Protocol->SEND_SID_PING( m_Protocol->RECEIVE_SID_PING( Packet->GetData() ) ) );
break;
case CBNETProtocol :: SID_AUTH_INFO:
if( m_Protocol->RECEIVE_SID_AUTH_INFO( Packet->GetData() ) )
{
if( m_BNCSUtil->HELP_SID_AUTH_CHECK( m_GHost->m_TFT, m_GHost->m_Warcraft3Path, m_CDKeyROC, m_CDKeyTFT,
m_Protocol->GetValueStringFormulaString(), m_Protocol->GetIX86VerFileNameString(),
m_Protocol->GetClientToken(), m_Protocol->GetServerToken() ) )
{
// override the exe information generated by bncsutil if specified in the config file
// apparently this is useful for pvpgn users
if( m_EXEVersion.size() == 4 )
{
cout << "[BNET: " << m_ServerAlias << "] using custom exe version bnet_custom_exeversion = "
<< m_EXEVersion[0] << " " << m_EXEVersion[1] << " " + m_EXEVersion[2] << " " << m_EXEVersion[3] << '\n';
m_BNCSUtil->SetEXEVersion( m_EXEVersion );
}
if( m_EXEVersionHash.size() == 4 )
{
cout << "[BNET: " << m_ServerAlias << "] using custom exe version hash bnet_custom_exeversionhash = "
//.........这里部分代码省略.........