本文整理汇总了C++中BYTEARRAY类的典型用法代码示例。如果您正苦于以下问题:C++ BYTEARRAY类的具体用法?C++ BYTEARRAY怎么用?C++ BYTEARRAY使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BYTEARRAY类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SEND_W3GS_GAMELOADED_OTHERS
BYTEARRAY CGameProtocol :: SEND_W3GS_GAMELOADED_OTHERS( unsigned char PID )
{
BYTEARRAY packet;
if( PID != 255 )
{
packet.push_back( W3GS_HEADER_CONSTANT ); // W3GS header constant
packet.push_back( W3GS_GAMELOADED_OTHERS ); // W3GS_GAMELOADED_OTHERS
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( PID ); // PID
AssignLength( packet );
}
else
CONSOLE_Print( "[GAMEPROTO] invalid parameters passed to SEND_W3GS_GAMELOADED_OTHERS" );
// DEBUG_Print( "SENT W3GS_GAMELOADED_OTHERS" );
// DEBUG_Print( packet );
return packet;
}
示例2: SEND_SID_AUTH_ACCOUNTLOGONPROOF
BYTEARRAY CBNETProtocol :: SEND_SID_AUTH_ACCOUNTLOGONPROOF( BYTEARRAY clientPasswordProof )
{
BYTEARRAY packet;
if( clientPasswordProof.size( ) == 20 )
{
packet.push_back( BNET_HEADER_CONSTANT ); // BNET header constant
packet.push_back( SID_AUTH_ACCOUNTLOGONPROOF ); // SID_AUTH_ACCOUNTLOGONPROOF
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( 0 ); // packet length will be assigned later
UTIL_AppendByteArrayFast( packet, clientPasswordProof ); // Client Password Proof
AssignLength( packet );
}
else
CONSOLE_Print( "[BNETPROTO] invalid parameters passed to SEND_SID_AUTH_ACCOUNTLOGON" );
// DEBUG_Print( "SENT SID_AUTH_ACCOUNTLOGONPROOF" );
// DEBUG_Print( packet );
return packet;
}
示例3: Broadcast
bool CUDPSocket :: Broadcast( uint16_t port, BYTEARRAY message )
{
if( m_Socket == INVALID_SOCKET || m_HasError )
return false;
struct sockaddr_in sin;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = m_BroadcastTarget.s_addr;
sin.sin_port = htons( port );
string MessageString = string( message.begin( ), message.end( ) );
if( sendto( m_Socket, MessageString.c_str( ), MessageString.size( ), 0, (struct sockaddr *)&sin, sizeof( sin ) ) == -1 )
{
//CONSOLE_Print( "[UDPSOCKET] failed to broadcast packet (port " + UTIL_ToString( port ) + ", size " + UTIL_ToString( MessageString.size( ) ) + " bytes)" );
return false;
}
return true;
}
示例4: SendBotCreateSavedGame
BYTEARRAY CPUBProtocol :: SendBotCreateSavedGame( const string& gamename, const string& savefilename, BYTEARRAY nMagicNumber, const string& owner, const string& saveData )
{
BYTEARRAY packet;
packet.push_back( PUB_HEADER_CONSTANT );
packet.push_back( PUB_CREATE_SAVEDGAME );
packet.push_back( 0 );
packet.push_back( 0 );
UTIL_AppendByteArray(packet, gamename, true);
UTIL_AppendByteArray(packet, savefilename, true);
UTIL_AppendByteArray(packet, nMagicNumber);
UTIL_AppendByteArray(packet, owner, true);
UTIL_AppendByteArray(packet, saveData, false);
AssignLength(packet);
return packet;
}
示例5: SEND_SID_PING
BYTEARRAY CBNETProtocol :: SEND_SID_PING( BYTEARRAY pingValue )
{
BYTEARRAY packet;
if( pingValue.size( ) == 4 )
{
packet.push_back( BNET_HEADER_CONSTANT ); // BNET header constant
packet.push_back( SID_PING ); // SID_PING
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( 0 ); // packet length will be assigned later
UTIL_AppendByteArrayFast( packet, pingValue ); // Ping Value
AssignLength( packet );
}
else
CONSOLE_Print( "[BNETPROTO] invalid parameters passed to SEND_SID_PING" );
// DEBUG_Print( "SENT SID_PING" );
// DEBUG_Print( packet );
return packet;
}
示例6: RECEIVE_SID_AUTH_CHECK
bool CBNETProtocol :: RECEIVE_SID_AUTH_CHECK( BYTEARRAY data )
{
// DEBUG_Print( "RECEIVED SID_AUTH_CHECK" );
// DEBUG_Print( data );
// 2 bytes -> Header
// 2 bytes -> Length
// 4 bytes -> KeyState
// null terminated string -> KeyStateDescription
if( ValidateLength( data ) && data.size( ) >= 9 )
{
m_KeyState = BYTEARRAY( data.begin( ) + 4, data.begin( ) + 8 );
m_KeyStateDescription = UTIL_ExtractCString( data, 8 );
if( UTIL_ByteArrayToUInt32( m_KeyState, false ) == KR_GOOD )
return true;
}
return false;
}
示例7: SEND_SID_AUTH_ACCOUNTLOGON
BYTEARRAY CBNETProtocol :: SEND_SID_AUTH_ACCOUNTLOGON( BYTEARRAY clientPublicKey, string accountName )
{
BYTEARRAY packet;
if( clientPublicKey.size( ) == 32 )
{
packet.push_back( BNET_HEADER_CONSTANT ); // BNET header constant
packet.push_back( SID_AUTH_ACCOUNTLOGON ); // SID_AUTH_ACCOUNTLOGON
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( 0 ); // packet length will be assigned later
UTIL_AppendByteArrayFast( packet, clientPublicKey ); // Client Key
UTIL_AppendByteArrayFast( packet, accountName ); // Account Name
AssignLength( packet );
}
else
CONSOLE_Print( "[BNETPROTO] invalid parameters passed to SEND_SID_AUTH_ACCOUNTLOGON" );
// DEBUG_Print( "SENT SID_AUTH_ACCOUNTLOGON" );
// DEBUG_Print( packet );
return packet;
}
示例8: SEND_W3GS_PLAYERLEAVE_OTHERS
BYTEARRAY CGameProtocol :: SEND_W3GS_PLAYERLEAVE_OTHERS( unsigned char PID, uint32_t leftCode )
{
BYTEARRAY packet;
if( PID != 255 )
{
packet.push_back( W3GS_HEADER_CONSTANT ); // W3GS header constant
packet.push_back( W3GS_PLAYERLEAVE_OTHERS ); // W3GS_PLAYERLEAVE_OTHERS
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( PID ); // PID
UTIL_AppendByteArray( packet, leftCode, false ); // left code (see PLAYERLEAVE_ constants in gameprotocol.h)
AssignLength( packet );
}
else
CONSOLE_Print( "[GAMEPROTO] invalid parameters passed to SEND_W3GS_PLAYERLEAVE_OTHERS" );
// DEBUG_Print( "SENT W3GS_PLAYERLEAVE_OTHERS" );
// DEBUG_Print( packet );
return packet;
}
示例9: SEND_SID_JOINCHANNEL
BYTEARRAY CBNETProtocol :: SEND_SID_JOINCHANNEL( string channel )
{
unsigned char NoCreateJoin[] = { 2, 0, 0, 0 };
unsigned char FirstJoin[] = { 1, 0, 0, 0 };
BYTEARRAY packet;
packet.push_back( BNET_HEADER_CONSTANT ); // BNET header constant
packet.push_back( SID_JOINCHANNEL ); // SID_JOINCHANNEL
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( 0 ); // packet length will be assigned later
if( channel.size( ) > 0 )
UTIL_AppendByteArray( packet, NoCreateJoin, 4 ); // flags for no create join
else
UTIL_AppendByteArray( packet, FirstJoin, 4 ); // flags for first join
UTIL_AppendByteArrayFast( packet, channel );
AssignLength( packet );
return packet;
}
示例10: GetExternalIPString
string CPotentialPlayer :: GetExternalIPString( )
{
BYTEARRAY IP;
string EIP;
if( m_Socket )
{
bool local=m_LAN;
if (!m_LANSet)
{
IP= m_Socket->GetIP( );
if (IP.size()>=2)
{
if (IP[0]==10 && IP[1]==0)
local=true;
if (IP[0]==10 && IP[1]==1)
local=true;
if (IP[0]==192 && IP[1]==168)
local=true;
if (IP[0]==169 && IP[1]==254)
local=true;
if (IP[0]==8 && IP[1]==0)
local=true;
if (IP[0]==5)
local=true;
}
if (UTIL_IsLocalIP(IP, m_Game->m_GHost->m_LocalAddresses))
local = true;
m_LANSet = true;
m_LAN = local;
}
EIP=m_Socket->GetIPString( );
if (local && !m_Game->m_Config->m_ExternalIP.empty())
{
EIP = m_Game->m_Config->m_ExternalIP;
}
return EIP;
}
return string( );
}
示例11: RECEIVE_SID_AUTH_INFO
bool CBNETProtocol :: RECEIVE_SID_AUTH_INFO( BYTEARRAY data )
{
// DEBUG_Print( "RECEIVED SID_AUTH_INFO" );
// DEBUG_Print( data );
// 2 bytes -> Header
// 2 bytes -> Length
// 4 bytes -> LogonType
// 4 bytes -> ServerToken
// 4 bytes -> ???
// 8 bytes -> MPQFileTime
// null terminated string -> IX86VerFileName
// null terminated string -> ValueStringFormula
if( ValidateLength( data ) && data.size( ) >= 25 )
{
m_LogonType = BYTEARRAY( data.begin( ) + 4, data.begin( ) + 8 );
m_ServerToken = BYTEARRAY( data.begin( ) + 8, data.begin( ) + 12 );
m_MPQFileTime = BYTEARRAY( data.begin( ) + 16, data.begin( ) + 24 );
m_IX86VerFileName = UTIL_ExtractCString( data, 24 );
m_ValueStringFormula = UTIL_ExtractCString( data, m_IX86VerFileName.size( ) + 25 );
return true;
}
return false;
}
示例12: SEND_W3GS_START_LAG
BYTEARRAY CGameProtocol :: SEND_W3GS_START_LAG( vector<CGamePlayer *> players, bool loadInGame )
{
BYTEARRAY packet;
unsigned char NumLaggers = 0;
for( vector<CGamePlayer*> :: iterator i = players.begin(); i != players.end(); ++i )
{
if( loadInGame )
{
if( !(*i)->GetFinishedLoading() )
++NumLaggers;
}
else
{
if( (*i)->GetLagging() )
++NumLaggers;
}
}
if( NumLaggers > 0 )
{
packet.push_back( W3GS_HEADER_CONSTANT ); // W3GS header constant
packet.push_back( W3GS_START_LAG ); // W3GS_START_LAG
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( NumLaggers );
for( vector<CGamePlayer*>::iterator i = players.begin(); i != players.end(); ++i )
{
if( loadInGame )
{
if( !(*i)->GetFinishedLoading() )
{
packet.push_back( (*i)->GetPID() );
UTIL_AppendByteArray( packet, static_cast<uint32_t>(0), false );
}
}
else
{
if( (*i)->GetLagging() )
{
packet.push_back( (*i)->GetPID() );
UTIL_AppendByteArray( packet, GetTicks() - (*i)->GetStartedLaggingTicks(), false );
}
}
}
AssignLength( packet );
}
else
cout << "[GAMEPROTO] no laggers passed to SEND_W3GS_START_LAG\n";
return packet;
}
示例13: SEND_W3GS_INCOMING_ACTION
BYTEARRAY CGameProtocol :: SEND_W3GS_INCOMING_ACTION( queue<CIncomingAction *> actions, uint16_t sendInterval )
{
BYTEARRAY packet;
packet.push_back( W3GS_HEADER_CONSTANT ); // W3GS header constant
packet.push_back( W3GS_INCOMING_ACTION ); // W3GS_INCOMING_ACTION
packet.push_back( 0 ); // packet length will be assigned later
packet.push_back( 0 ); // packet length will be assigned later
UTIL_AppendByteArray( packet, sendInterval, false ); // send interval
// create subpacket
if( !actions.empty( ) )
{
BYTEARRAY subpacket;
while( !actions.empty( ) )
{
CIncomingAction *Action = actions.front( );
actions.pop( );
subpacket.push_back( Action->GetPID( ) );
UTIL_AppendByteArray( subpacket, (uint16_t)Action->GetAction( )->size( ), false );
UTIL_AppendByteArrayFast( subpacket, *Action->GetAction( ) );
}
// calculate crc (we only care about the first 2 bytes though)
BYTEARRAY crc32 = UTIL_CreateByteArray( m_GHost->m_CRC->FullCRC( (unsigned char *)string( subpacket.begin( ), subpacket.end( ) ).c_str( ), subpacket.size( ) ), false );
crc32.resize( 2 );
// finish subpacket
UTIL_AppendByteArrayFast( packet, crc32 ); // crc
UTIL_AppendByteArrayFast( packet, subpacket ); // subpacket
}
AssignLength( packet );
// DEBUG_Print( "SENT W3GS_INCOMING_ACTION" );
// DEBUG_Print( packet );
return packet;
}
示例14: RECEIVE_W3GS_REQJOIN
CIncomingJoinPlayer *CGameProtocol :: RECEIVE_W3GS_REQJOIN( BYTEARRAY data )
{
// DEBUG_Print( "RECEIVED W3GS_REQJOIN" );
// DEBUG_Print( data );
// 2 bytes -> Header
// 2 bytes -> Length
// 4 bytes -> Host Counter (Game ID)
// 4 bytes -> Entry Key (used in LAN)
// 1 byte -> ???
// 2 bytes -> Listen Port
// 4 bytes -> Peer Key
// null terminated string -> Name
// 4 bytes -> ???
// 2 bytes -> InternalPort (???)
// 4 bytes -> InternalIP
if( ValidateLength( data ) && data.size( ) >= 20 )
{
uint32_t HostCounter = UTIL_ByteArrayToUInt32( data, false, 4 );
BYTEARRAY Name = UTIL_ExtractCString( data, 19 );
if( !Name.empty( ) && data.size( ) >= Name.size( ) + 30 )
{
BYTEARRAY InternalIP = BYTEARRAY( data.begin( ) + Name.size( ) + 26, data.begin( ) + Name.size( ) + 30 );
return new CIncomingJoinPlayer( HostCounter, string( Name.begin( ), Name.end( ) ), InternalIP );
}
}
return NULL;
}
示例15: SendLobbyPlayers
BYTEARRAY CPUBProtocol :: SendLobbyPlayers( const string& gamename, const string& bot_ip, uint16_t gameport, vector<CGamePlayer>& nPlayers )
{
BYTEARRAY packet;
packet.push_back( PUB_HEADER_CONSTANT ); // Auth header 1 byte
packet.push_back( PUB_GAMEPLAYERS ); // 1 byte
packet.push_back( 0 ); // 1 byte
packet.push_back( 0 ); // 1 byte
UTIL_AppendByteArray( packet, gameport, false);
UTIL_AppendByteArray( packet, bot_ip, true);
UTIL_AppendByteArray( packet, gamename, true);
packet.push_back( nPlayers.size() );
for (vector<CGamePlayer>::iterator i = nPlayers.begin(); i != nPlayers.end(); ++i)
UTIL_AppendByteArray( packet, (*i).GetName(), true );
AssignLength(packet);
return packet;
}