当前位置: 首页>>代码示例>>C++>>正文


C++ BYTEARRAY::push_back方法代码示例

本文整理汇总了C++中BYTEARRAY::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ BYTEARRAY::push_back方法的具体用法?C++ BYTEARRAY::push_back怎么用?C++ BYTEARRAY::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BYTEARRAY的用法示例。


在下文中一共展示了BYTEARRAY::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

BYTEARRAY CGameProtocol :: SEND_W3GS_REFRESHGAME( uint32_t players, uint32_t playerSlots )
{
    unsigned char HostCounter[]	= { 1, 0, 0, 0 };

    BYTEARRAY packet;
    packet.push_back( W3GS_HEADER_CONSTANT );			// W3GS header constant
    packet.push_back( W3GS_REFRESHGAME );				// W3GS_REFRESHGAME
    packet.push_back( 0 );								// packet length will be assigned later
    packet.push_back( 0 );								// packet length will be assigned later
    UTIL_AppendByteArray( packet, HostCounter, 4 );		// Host Counter
    UTIL_AppendByteArray( packet, players, false );		// Players
    UTIL_AppendByteArray( packet, playerSlots, false );	// Player Slots
    AssignLength( packet );
    // DEBUG_Print( "SENT W3GS_REFRESHGAME" );
    // DEBUG_Print( packet );
    return packet;
}
开发者ID:kr4uzi,项目名称:ghostlite,代码行数:17,代码来源:gameprotocol.cpp

示例2:

BYTEARRAY CGameProtocol :: SEND_W3GS_MAPPART( unsigned char fromPID, unsigned char toPID, uint32_t start, string *mapData )
{
    unsigned char Unknown[] = { 1, 0, 0, 0 };

    BYTEARRAY packet;

    if( start < mapData->size( ) )
    {
        packet.push_back( W3GS_HEADER_CONSTANT );				// W3GS header constant
        packet.push_back( W3GS_MAPPART );						// W3GS_MAPPART
        packet.push_back( 0 );									// packet length will be assigned later
        packet.push_back( 0 );									// packet length will be assigned later
        packet.push_back( toPID );								// to PID
        packet.push_back( fromPID );							// from PID
        UTIL_AppendByteArray( packet, Unknown, 4 );				// ???
        UTIL_AppendByteArray( packet, start, false );			// start position

        // calculate end position (don't send more than 1442 map bytes in one packet)

        uint32_t End = start + 1442;

        if( End > mapData->size( ) )
            End = mapData->size( );

        // calculate crc
        CCRC32* m_CRC = new CCRC32( );
        m_CRC->Initialize( );

        BYTEARRAY crc32 = UTIL_CreateByteArray( m_CRC->FullCRC( (unsigned char *)mapData->c_str( ) + start, End - start ), false );
        UTIL_AppendByteArray( packet, crc32 );

        delete m_CRC;

        // map data

        BYTEARRAY Data = UTIL_CreateByteArray( (unsigned char *)mapData->c_str( ) + start, End - start );
        UTIL_AppendByteArray( packet, Data );
        AssignLength( packet );
    }
    else
        CONSOLE_Print( "[GAMEPROTO] invalid parameters passed to SEND_W3GS_MAPPART" );

    // DEBUG_Print( "SENT W3GS_MAPPART" );
    // DEBUG_Print( packet );
    return packet;
}
开发者ID:RiseCakoPlusplus,项目名称:brtGHost,代码行数:46,代码来源:gameprotocol.cpp

示例3:

BYTEARRAY CBNETProtocol :: SEND_PROTOCOL_INITIALIZE_SELECTOR( )
{
    BYTEARRAY packet;
    packet.push_back( 1 );
    // DEBUG_Print( "SENT PROTOCOL_INITIALIZE_SELECTOR" );
    // DEBUG_Print( packet );
    return packet;
}
开发者ID:interkill,项目名称:brtghost,代码行数:8,代码来源:bnetprotocol.cpp

示例4:

BYTEARRAY CBNETProtocol :: SEND_SID_CHECKAD( )
{
    unsigned char Zeros[] = { 0, 0, 0, 0 };

    BYTEARRAY packet;
    packet.push_back( BNET_HEADER_CONSTANT );	// BNET header constant
    packet.push_back( SID_CHECKAD );			// SID_CHECKAD
    packet.push_back( 0 );						// packet length will be assigned later
    packet.push_back( 0 );						// packet length will be assigned later
    UTIL_AppendByteArray( packet, Zeros, 4 );	// ???
    UTIL_AppendByteArray( packet, Zeros, 4 );	// ???
    UTIL_AppendByteArray( packet, Zeros, 4 );	// ???
    UTIL_AppendByteArray( packet, Zeros, 4 );	// ???
    AssignLength( packet );
    
    return packet;
}
开发者ID:kr4uzi,项目名称:ghostlite,代码行数:17,代码来源:bnetprotocol.cpp

示例5: AddChatMessage

void CReplay :: AddChatMessage( unsigned char PID, unsigned char flags, uint32_t chatMode, string message )
{
    BYTEARRAY Block;
    Block.push_back( REPLAY_CHATMESSAGE );
    Block.push_back( PID );
    UTIL_AppendByteArray( Block, (uint16_t)0, false );
    Block.push_back( flags );
    UTIL_AppendByteArray( Block, chatMode, false );
    UTIL_AppendByteArrayFast( Block, message );

    // assign length

    BYTEARRAY LengthBytes = UTIL_CreateByteArray( (uint16_t)( Block.size( ) - 4 ), false );
    Block[2] = LengthBytes[0];
    Block[3] = LengthBytes[1];
    m_CompiledBlocks += string( Block.begin( ), Block.end( ) );
}
开发者ID:0x6d48,项目名称:ghostpp,代码行数:17,代码来源:replay.cpp

示例6: SendAuthAccept

BYTEARRAY CPUBProtocol :: SendAuthAccept( string login, string pass, string key, deque<CBotData> BotList )
{
    BYTEARRAY packet;

    packet.push_back( PUB_HEADER_CONSTANT );		// Auth header  1 byte
    packet.push_back( PUB_AUTH_ACCEPT );           // 1 byte

    packet.push_back( 0 ); // assign later
    packet.push_back( 0 ); // assign later

    packet.push_back( login.size( ) ); // 1 byte
    UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (unsigned char *)login.c_str( ), login.size( ) )); //

    packet.push_back( BotList.size() ); // 1 byte

    for (uint32_t i = 0; i < BotList.size(); i++)
    {
        packet.push_back(BotList[i].bot_ip.size( ));

        UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (unsigned char *)BotList[i].bot_ip.c_str( ), BotList[i].bot_ip.size( ) ));
        UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (uint16_t)(0) , false));
        UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (uint16_t)(BotList[i].bot_gameport) , false));
    }

    packet.push_back( key.size( ) ); // 1 byte
    UTIL_AppendByteArray(packet, UTIL_CreateByteArray( (unsigned char *)key.c_str( ), key.size( ) ));

    AssignLength(packet);

    return packet;
}
开发者ID:brunobnb,项目名称:brtGHost,代码行数:31,代码来源:pubprotocol.cpp

示例7: SendBotCreateGame

BYTEARRAY CPUBProtocol :: SendBotCreateGame( const string& creatorname, const string& gamename, const string& gamemode, vector<string> hold_list, uint16_t min_score, uint16_t max_score, bool is_ladder, bool is_balance )
{
    BYTEARRAY packet;

    packet.push_back( PUB_HEADER_CONSTANT );
    packet.push_back( PUB_BOTCREATEGAME );

    packet.push_back( 0 );
    packet.push_back( 0 );

    packet.push_back( is_ladder );
    packet.push_back( is_balance );
    packet.push_back( hold_list.size() );
    packet.push_back( 0 );

    UTIL_AppendByteArray(packet, min_score, false);
    UTIL_AppendByteArray(packet, max_score, false);

    UTIL_AppendByteArray(packet, gamemode, true);
    UTIL_AppendByteArray(packet, gamename, true);
    UTIL_AppendByteArray(packet, creatorname, true);

    for ( uint16_t i = 0; i < hold_list.size(); ++i)
        UTIL_AppendByteArray(packet, hold_list[i], true);

    AssignLength(packet);

    return packet;
}
开发者ID:brunobnb,项目名称:brtGHost,代码行数:29,代码来源:pubprotocol.cpp

示例8: GetByteArray

BYTEARRAY CGameSlot :: GetByteArray( ) const
{
    BYTEARRAY b;
    b.push_back( m_PID );
    b.push_back( m_DownloadStatus );
    b.push_back( m_SlotStatus );
    b.push_back( m_Computer );
    b.push_back( m_Team );
    b.push_back( m_Colour );
    b.push_back( m_Race );
    b.push_back( m_ComputerType );
    b.push_back( m_Handicap );
    return b;
}
开发者ID:kr4uzi,项目名称:ghostlite,代码行数:14,代码来源:gameslot.cpp

示例9: AssignLength

BYTEARRAY CBNETProtocol :: SEND_SID_LOGONRESPONSE( BYTEARRAY clientToken, BYTEARRAY serverToken, BYTEARRAY passwordHash, string accountName )
{
    // todotodo: check that the passed BYTEARRAY sizes are correct (don't know what they should be right now so I can't do this today)

    BYTEARRAY packet;
    packet.push_back( BNET_HEADER_CONSTANT );			// BNET header constant
    packet.push_back( SID_LOGONRESPONSE );				// SID_LOGONRESPONSE
    packet.push_back( 0 );								// packet length will be assigned later
    packet.push_back( 0 );								// packet length will be assigned later
    UTIL_AppendByteArrayFast( packet, clientToken );	// Client Token
    UTIL_AppendByteArrayFast( packet, serverToken );	// Server Token
    UTIL_AppendByteArrayFast( packet, passwordHash );	// Password Hash
    UTIL_AppendByteArrayFast( packet, accountName );	// Account Name
    AssignLength( packet );
    // DEBUG_Print( "SENT SID_LOGONRESPONSE" );
    // DEBUG_Print( packet );
    return packet;
}
开发者ID:Quji,项目名称:OHSystem,代码行数:18,代码来源:bnetprotocol.cpp

示例10: SendChatFromGame

BYTEARRAY CPUBProtocol :: SendChatFromGame(const string& login, const string& bot_ip, const string& gamename, uint16_t gameport, const string& message)
{
 	BYTEARRAY packet;
    packet.push_back( PUB_HEADER_CONSTANT );
    packet.push_back( this->PUB_CHATFROMGAME );
    packet.push_back( 0 );
    packet.push_back( 0 );

    UTIL_AppendByteArray( packet, gameport, false);
    UTIL_AppendByteArray( packet, bot_ip, true);
    UTIL_AppendByteArray( packet, gamename, true);

    UTIL_AppendByteArray( packet, login, true );
    UTIL_AppendByteArray( packet, message, true );

    AssignLength( packet );
    return packet;
}
开发者ID:brunobnb,项目名称:brtGHost,代码行数:18,代码来源:pubprotocol.cpp

示例11: GetTicks

BYTEARRAY CGameProtocol :: SEND_W3GS_STOP_LAG( CGamePlayer* player, bool loadInGame )
{
    BYTEARRAY packet;
    packet.push_back( W3GS_HEADER_CONSTANT );	// W3GS header constant
    packet.push_back( W3GS_STOP_LAG );			// W3GS_STOP_LAG
    packet.push_back( 0 );						// packet length will be assigned later
    packet.push_back( 0 );						// packet length will be assigned later
    packet.push_back( player->GetPID() );

    if( loadInGame )
        UTIL_AppendByteArray( packet, static_cast<uint32_t>(0), false );
    else
        UTIL_AppendByteArray( packet, GetTicks() - player->GetStartedLaggingTicks(), false );

    AssignLength( packet );
    
    return packet;
}
开发者ID:kr4uzi,项目名称:ghostlite,代码行数:18,代码来源:gameprotocol.cpp

示例12: ID

BYTEARRAY CGameProtocol :: SEND_W3GS_GAMEINFO( bool TFT, unsigned char war3Version, BYTEARRAY mapGameType, BYTEARRAY mapFlags, BYTEARRAY mapWidth, BYTEARRAY mapHeight, string gameName, string hostName, uint32_t upTime, string mapPath, BYTEARRAY mapCRC, uint32_t slotsTotal, uint32_t slotsOpen, uint16_t port, uint32_t hostCounter )
{
    unsigned char ProductID_ROC[]	= {          51, 82, 65, 87 };	// "WAR3"
    unsigned char ProductID_TFT[]	= {          80, 88, 51, 87 };	// "W3XP"
    unsigned char Version[]			= { war3Version,  0,  0,  0 };
    unsigned char Unknown1[]		= {           1,  2,  3,  4 };
    unsigned char Unknown2[]		= {           1,  0,  0,  0 };

    BYTEARRAY packet;

    if( mapGameType.size( ) == 4 && mapFlags.size( ) == 4 && mapWidth.size( ) == 2 && mapHeight.size( ) == 2 && !gameName.empty( ) && !hostName.empty( ) && !mapPath.empty( ) && mapCRC.size( ) == 4 )
    {
        // make the stat string

        BYTEARRAY StatString;
        UTIL_AppendByteArrayFast( StatString, mapFlags );
        StatString.push_back( 0 );
        UTIL_AppendByteArrayFast( StatString, mapWidth );
        UTIL_AppendByteArrayFast( StatString, mapHeight );
        UTIL_AppendByteArrayFast( StatString, mapCRC );
        UTIL_AppendByteArrayFast( StatString, mapPath );
        UTIL_AppendByteArrayFast( StatString, hostName );
        StatString.push_back( 0 );
        StatString = UTIL_EncodeStatString( StatString );

        // make the rest of the packet

        packet.push_back( W3GS_HEADER_CONSTANT );						// W3GS header constant
        packet.push_back( W3GS_GAMEINFO );								// W3GS_GAMEINFO
        packet.push_back( 0 );											// packet length will be assigned later
        packet.push_back( 0 );											// packet length will be assigned later

        if( TFT )
            UTIL_AppendByteArray( packet, ProductID_TFT, 4 );			// Product ID (TFT)
        else
            UTIL_AppendByteArray( packet, ProductID_ROC, 4 );			// Product ID (ROC)

        UTIL_AppendByteArray( packet, Version, 4 );						// Version
        UTIL_AppendByteArray( packet, hostCounter, false );				// Host Counter
        UTIL_AppendByteArray( packet, Unknown1, 4 );					// ??? (this varies wildly even between two identical games created one after another)
        UTIL_AppendByteArrayFast( packet, gameName );					// Game Name
        packet.push_back( 0 );											// ??? (maybe game password)
        UTIL_AppendByteArrayFast( packet, StatString );					// Stat String
        packet.push_back( 0 );											// Stat String null terminator (the stat string is encoded to remove all even numbers i.e. zeros)
        UTIL_AppendByteArray( packet, slotsTotal, false );				// Slots Total
        UTIL_AppendByteArrayFast( packet, mapGameType );				// Game Type
        UTIL_AppendByteArray( packet, Unknown2, 4 );					// ???
        UTIL_AppendByteArray( packet, slotsOpen, false );				// Slots Open
        UTIL_AppendByteArray( packet, upTime, false );					// time since creation
        UTIL_AppendByteArray( packet, port, false );					// port
        AssignLength( packet );
    }
    else
        CONSOLE_Print( "[GAMEPROTO] invalid parameters passed to SEND_W3GS_GAMEINFO" );

    // DEBUG_Print( "SENT W3GS_GAMEINFO" );
    // DEBUG_Print( packet );
    return packet;
}
开发者ID:brunobnb,项目名称:ghostcb,代码行数:59,代码来源:gameprotocol.cpp

示例13:

BYTEARRAY CBNLSProtocol :: SEND_BNLS_WARDEN_SEED( uint32_t cookie, uint32_t seed )
{
    unsigned char Client[] = {  80,  88,  51,  87 };	// "W3XP"

    BYTEARRAY packet;
    packet.push_back( 0 );								// packet length will be assigned later
    packet.push_back( 0 );								// packet length will be assigned later
    packet.push_back( BNLS_WARDEN );					// BNLS_WARDEN
    packet.push_back( 0 );								// BNLS_WARDEN_SEED
    UTIL_AppendByteArray( packet, cookie, false );		// cookie
    UTIL_AppendByteArray( packet, Client, 4 );			// Client
    UTIL_AppendByteArray( packet, (uint16_t)4, false );	// length of seed
    UTIL_AppendByteArray( packet, seed, false );		// seed
    packet.push_back( 0 );								// username is blank
    UTIL_AppendByteArray( packet, (uint16_t)0, false );	// password length
                                                        // password
    AssignLength( packet );
    return packet;
}
开发者ID:0x6d48,项目名称:ghostpp,代码行数:19,代码来源:bnlsprotocol.cpp

示例14: SendScorePlayer

BYTEARRAY CPUBProtocol :: SendScorePlayer( const string& login, const string& score, const uint32_t games_count)
{
    BYTEARRAY packet;

    packet.push_back( PUB_HEADER_CONSTANT );		// Auth header  1 byte
    packet.push_back( PUB_GETSCOREANS );           // 1 byte

    packet.push_back( 0 );           // 1 byte
    packet.push_back( 0 );           // 1 byte

    UTIL_AppendByteArray( packet, login, true);
    UTIL_AppendByteArray( packet, score, true);
    UTIL_AppendByteArray( packet, games_count, false );

    AssignLength(packet);

    return packet;

}
开发者ID:brunobnb,项目名称:brtGHost,代码行数:19,代码来源:pubprotocol.cpp

示例15: code

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
        cout << "[GAMEPROTO] invalid parameters passed to SEND_W3GS_PLAYERLEAVE_OTHERS\n";

    return packet;
}
开发者ID:kr4uzi,项目名称:ghostlite,代码行数:19,代码来源:gameprotocol.cpp


注:本文中的BYTEARRAY::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。