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


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

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


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

示例1: CIncomingChatEvent

CIncomingChatEvent *CBNETProtocol :: RECEIVE_SID_CHATEVENT( BYTEARRAY data )
{
	// DEBUG_Print( "RECEIVED SID_CHATEVENT" );
	// DEBUG_Print( data );

	// 2 bytes					-> Header
	// 2 bytes					-> Length
	// 4 bytes					-> EventID
	// 4 bytes					-> UserFlags
	// 4 bytes					-> Ping
	// 12 bytes					-> ???
	// null terminated string	-> User
	// null terminated string	-> Message

	if( ValidateLength( data ) && data.size( ) >= 29 )
	{
		BYTEARRAY EventID = BYTEARRAY( data.begin( ) + 4, data.begin( ) + 8 );
		BYTEARRAY UserFlags = BYTEARRAY( data.begin( ) + 8, data.begin( ) + 12 );
		BYTEARRAY Ping = BYTEARRAY( data.begin( ) + 12, data.begin( ) + 16 );
		BYTEARRAY User = UTIL_ExtractCString( data, 28 );
		BYTEARRAY Message = UTIL_ExtractCString( data, User.size( ) + 29 );

		switch( UTIL_ByteArrayToUInt32( EventID, false ) )
		{
		case CBNETProtocol :: EID_SHOWUSER:
		case CBNETProtocol :: EID_JOIN:
		case CBNETProtocol :: EID_LEAVE:
		case CBNETProtocol :: EID_WHISPER:
		case CBNETProtocol :: EID_TALK:
		case CBNETProtocol :: EID_BROADCAST:
		case CBNETProtocol :: EID_CHANNEL:
		case CBNETProtocol :: EID_USERFLAGS:
		case CBNETProtocol :: EID_WHISPERSENT:
		case CBNETProtocol :: EID_CHANNELFULL:
		case CBNETProtocol :: EID_CHANNELDOESNOTEXIST:
		case CBNETProtocol :: EID_CHANNELRESTRICTED:
		case CBNETProtocol :: EID_INFO:
		case CBNETProtocol :: EID_ERROR:
		case CBNETProtocol :: EID_EMOTE:
			return new CIncomingChatEvent(	(CBNETProtocol :: IncomingChatEvent)UTIL_ByteArrayToUInt32( EventID, false ),
												UTIL_ByteArrayToUInt32( UserFlags, false ),
												UTIL_ByteArrayToUInt32( Ping, false ),
												string( User.begin( ), User.end( ) ),
												string( Message.begin( ), Message.end( ) ) );
		}

	}

	return NULL;
}
开发者ID:svn2github,项目名称:ghostplusplus,代码行数:50,代码来源:bnetprotocol.cpp

示例2: while

vector<CIncomingFriendList *> CBNETProtocol :: RECEIVE_SID_FRIENDSLIST( BYTEARRAY data )
{
    // DEBUG_Print( "RECEIVED SID_FRIENDSLIST" );
    // DEBUG_Print( data );

    // 2 bytes					-> Header
    // 2 bytes					-> Length
    // 1 byte					-> Total
    // for( 1 .. Total )
    //		null term string	-> Account
    //		1 byte				-> Status
    //		1 byte				-> Area
    //		4 bytes				-> ???
    //		null term string	-> Location

    vector<CIncomingFriendList *> Friends;

    if( ValidateLength( data ) && data.size( ) >= 5 )
    {
        unsigned int i = 5;
        unsigned char Total = data[4];

        while( Total > 0 )
        {
            Total--;

            if( data.size( ) < i + 1 )
                break;

            BYTEARRAY Account = UTIL_ExtractCString( data, i );
            i += Account.size( ) + 1;

            if( data.size( ) < i + 7 )
                break;

            unsigned char Status = data[i];
            unsigned char Area = data[i + 1];
            i += 6;
            BYTEARRAY Location = UTIL_ExtractCString( data, i );
            i += Location.size( ) + 1;
            Friends.push_back( new CIncomingFriendList(	string( Account.begin( ), Account.end( ) ),
                               Status,
                               Area,
                               string( Location.begin( ), Location.end( ) ) ) );
        }
    }

    return Friends;
}
开发者ID:Quji,项目名称:OHSystem,代码行数:49,代码来源:bnetprotocol.cpp

示例3: BYTEARRAY

BYTEARRAY CBNLSProtocol :: RECEIVE_BNLS_WARDEN( BYTEARRAY data )
{
	// 2 bytes					-> Length
	// 1 byte					-> ID
	// (BYTE)					-> Usage
	// (DWORD)					-> Cookie
	// (BYTE)					-> Result
	// (WORD)					-> Length of data
	// (VOID)					-> Data

	if( ValidateLength( data ) && data.size( ) >= 11 )
	{
		unsigned char Usage = data[3];
		uint32_t Cookie = UTIL_ByteArrayToUInt32( data, false, 4 );
		unsigned char Result = data[8];
		uint16_t Length = UTIL_ByteArrayToUInt16( data, false, 10 );

		if( Result == 0x00 )
			return BYTEARRAY( data.begin( ) + 11, data.end( ) );
		else
			CONSOLE_Print( "[BNLSPROTO] received error code " + UTIL_ToString( data[8] ) );
	}

	return BYTEARRAY( );
}
开发者ID:0x6d48,项目名称:ghostpp,代码行数:25,代码来源:bnlsprotocol.cpp

示例4: CIncomingGarenaUser

CIncomingGarenaUser *CGCBIProtocol :: RECEIVE_GCBI_INIT( BYTEARRAY data )
{
	// 2 bytes					-> Header
	// 2 bytes					-> Length
	// 4 bytes					-> actual IP address (big endian)
	// 4 bytes					-> Garena user ID (big endian)
	// 4 bytes					-> Garena room ID (big endian)
	// 4 bytes					-> Garena user experience (big endian)
	// 2 bytes					-> country string from Garena

	if( ValidateLength( data ) && data.size( ) == 22 )
	{
		BYTEARRAY IP = BYTEARRAY( data.begin( ) + 4, data.begin( ) + 8 );
		BYTEARRAY UserID = BYTEARRAY( data.begin( ) + 8, data.begin( ) + 12 );
		BYTEARRAY RoomID = BYTEARRAY( data.begin( ) + 12, data.begin( ) + 16 );
		BYTEARRAY UserExp = BYTEARRAY( data.begin( ) + 16, data.begin( ) + 20 );
		BYTEARRAY Country = BYTEARRAY( data.begin( ) + 20, data.begin( ) + 22 );
		
		return new CIncomingGarenaUser(UTIL_ByteArrayToUInt32( IP, true ),
											UTIL_ByteArrayToUInt32( UserID, true ),
											UTIL_ByteArrayToUInt32( RoomID, true ),
											UTIL_ByteArrayToUInt32( UserExp, true ),
											string( Country.begin( ), Country.end( ) ) );
	}

	return NULL;
}
开发者ID:DJexpert,项目名称:ohsystem,代码行数:27,代码来源:gcbiprotocol.cpp

示例5: ExtractPackets

void CBNLSClient :: ExtractPackets( )
{
	string *RecvBuffer = m_Socket->GetBytes( );
	BYTEARRAY Bytes = UTIL_CreateByteArray( (unsigned char *)RecvBuffer->c_str( ), RecvBuffer->size( ) );

	while( Bytes.size( ) >= 3 )
	{
		uint16_t Length = UTIL_ByteArrayToUInt16( Bytes, false );

		if( Length >= 3 )
		{
			if( Bytes.size( ) >= Length )
			{
				m_Packets.push( new CCommandPacket( 0, Bytes[2], BYTEARRAY( Bytes.begin( ), Bytes.begin( ) + Length ) ) );
				*RecvBuffer = RecvBuffer->substr( Length );
				Bytes = BYTEARRAY( Bytes.begin( ) + Length, Bytes.end( ) );
			}
			else
				return;
		}
		else
		{
			CONSOLE_Print( "[BNLSC: " + m_Server + ":" + UTIL_ToString( m_Port ) + ":C" + UTIL_ToString( m_WardenCookie ) + "] error - received invalid packet from BNLS server (bad length), disconnecting" );
			m_Socket->Disconnect( );
			return;
		}
	}
}
开发者ID:uakfdotb,项目名称:pychop,代码行数:28,代码来源:bnlsclient.cpp

示例6: CIncomingClanList

CIncomingClanList *CBNETProtocol :: RECEIVE_SID_CLANMEMBERSTATUSCHANGE( BYTEARRAY data )
{
    // DEBUG_Print( "RECEIVED SID_CLANMEMBERSTATUSCHANGE" );
    // DEBUG_Print( data );

    // 2 bytes					-> Header
    // 2 bytes					-> Length
    // null terminated string	-> Name
    // 1 byte					-> Rank
    // 1 byte					-> Status
    // null terminated string	-> Location

    if( ValidateLength( data ) && data.size( ) >= 5 )
    {
        BYTEARRAY Name = UTIL_ExtractCString( data, 4 );

        if( data.size( ) >= Name.size( ) + 7 )
        {
            unsigned char Rank = data[Name.size( ) + 5];
            unsigned char Status = data[Name.size( ) + 6];

            // in the original VB source the location string is read but discarded, so that's what I do here

            BYTEARRAY Location = UTIL_ExtractCString( data, Name.size( ) + 7 );
            return new CIncomingClanList(	string( Name.begin( ), Name.end( ) ),
                                            Rank,
                                            Status );
        }
    }

    return NULL;
}
开发者ID:Quji,项目名称:OHSystem,代码行数:32,代码来源:bnetprotocol.cpp

示例7: CIncomingJoinPlayer

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;
}
开发者ID:brunobnb,项目名称:ghostcb,代码行数:31,代码来源:gameprotocol.cpp

示例8: Update

bool CPotentialPlayer :: Update( void *fd )
{
	if( m_DeleteMe )
		return true;

	if( !m_Socket )
		return false;

	m_Socket->DoRecv( (fd_set *)fd );
	
	// extract as many packets as possible from the socket's receive buffer and process them

	string *RecvBuffer = m_Socket->GetBytes( );
	BYTEARRAY Bytes = UTIL_CreateByteArray( (unsigned char *)RecvBuffer->c_str( ), RecvBuffer->size( ) );

	// a packet is at least 4 bytes so loop as long as the buffer contains 4 bytes

	while( Bytes.size( ) >= 4 )
	{
		if( Bytes[0] == W3GS_HEADER_CONSTANT || Bytes[0] == GPS_HEADER_CONSTANT )
		{
			// bytes 2 and 3 contain the length of the packet

			uint16_t Length = UTIL_ByteArrayToUInt16( Bytes, false, 2 );

			if( Length >= 4 )
			{
				if( Bytes.size( ) >= Length )
				{
                                        if( Bytes[0] == W3GS_HEADER_CONSTANT && Bytes[1] == CGameProtocol :: W3GS_REQJOIN )
                                        {
                                                delete m_IncomingJoinPlayer;
                                                m_IncomingJoinPlayer = m_Protocol->RECEIVE_W3GS_REQJOIN( BYTEARRAY( Bytes.begin( ), Bytes.begin( ) + Length ) );

                                                if( m_IncomingJoinPlayer )
                                                        m_Game->EventPlayerJoined( this, m_IncomingJoinPlayer );

                                                // this is the packet which interests us for now, the remaining is left for CGamePlayer

                                                *RecvBuffer = RecvBuffer->substr( Length );
                                                Bytes = BYTEARRAY( Bytes.begin( ) + Length, Bytes.end( ) );
                                                break;
                                        }

					*RecvBuffer = RecvBuffer->substr( Length );
					Bytes = BYTEARRAY( Bytes.begin( ) + Length, Bytes.end( ) );
				}
				else
					break;
			}
		}
	}        

	// don't call DoSend here because some other players may not have updated yet and may generate a packet for this player
	// also m_Socket may have been set to NULL during ProcessPackets but we're banking on the fact that m_DeleteMe has been set to true as well so it'll short circuit before dereferencing

	return m_DeleteMe || !m_Socket->GetConnected( ) || m_Socket->HasError( );
}
开发者ID:NoodleBoy,项目名称:aura-bot,代码行数:58,代码来源:gameplayer.cpp

示例9: AddLeaveGame

void CReplay :: AddLeaveGame( uint32_t reason, unsigned char PID, uint32_t result )
{
	BYTEARRAY Block;
	Block.push_back( REPLAY_LEAVEGAME );
	UTIL_AppendByteArray( Block, reason, false );
	Block.push_back( PID );
	UTIL_AppendByteArray( Block, result, false );
	UTIL_AppendByteArray( Block, (uint32_t)1, false );
	m_CompiledBlocks += string( Block.begin( ), Block.end( ) );
}
开发者ID:0x6d48,项目名称:ghostpp,代码行数:10,代码来源:replay.cpp

示例10: string

bool CBNCSUtilInterface :: HELP_SID_AUTH_ACCOUNTLOGONPROOF( BYTEARRAY salt, BYTEARRAY serverKey )
{
	// set m_M1

	char buf[20];
	// nls_get_M1( (nls_t *)m_nls, buf, string( serverKey.begin( ), serverKey.end( ) ).c_str( ), string( salt.begin( ), salt.end( ) ).c_str( ) );
	( (NLS *)m_NLS )->getClientSessionKey( buf, string( salt.begin( ), salt.end( ) ).c_str( ), string( serverKey.begin( ), serverKey.end( ) ).c_str( ) );
	m_M1 = UTIL_CreateByteArray( (unsigned char *)buf, 20 );
	return true;
}
开发者ID:SparkoPro,项目名称:ghostnordicleague,代码行数:10,代码来源:bncsutilinterface.cpp

示例11: SendTo

bool CUDPSocket :: SendTo( struct sockaddr_in sin, BYTEARRAY message )
{
	if( m_Socket == INVALID_SOCKET || m_HasError )
		return false;

	string MessageString = string( message.begin( ), message.end( ) );

	if( sendto( m_Socket, MessageString.c_str( ), MessageString.size( ), 0, (struct sockaddr *)&sin, sizeof( sin ) ) == -1 )
		return false;

	return true;
}
开发者ID:Mofsy,项目名称:ent-ghost,代码行数:12,代码来源:socket.cpp

示例12: BYTEARRAY

BYTEARRAY CBNETProtocol :: RECEIVE_SID_WARDEN( BYTEARRAY data )
{
    // DEBUG_Print( "RECEIVED SID_WARDEN" );
    // DEBUG_PRINT( data );

    // 2 bytes					-> Header
    // 2 bytes					-> Length
    // n bytes					-> Data

    if( ValidateLength( data ) && data.size( ) >= 4 )
        return BYTEARRAY( data.begin( ) + 4, data.end( ) );

    return BYTEARRAY( );
}
开发者ID:Quji,项目名称:OHSystem,代码行数:14,代码来源:bnetprotocol.cpp

示例13: ExtractPackets

void CGamePlayer :: ExtractPackets( )
{
    if( !m_Socket )
        return;

    // extract as many packets as possible from the socket's receive buffer and put them in the m_Packets queue

    string *RecvBuffer = m_Socket->GetBytes( );
    BYTEARRAY Bytes = UTIL_CreateByteArray( (unsigned char *)RecvBuffer->c_str( ), RecvBuffer->size( ) );

    // a packet is at least 4 bytes so loop as long as the buffer contains 4 bytes

    while( Bytes.size( ) >= 4 )
    {
        if( Bytes[0] == W3GS_HEADER_CONSTANT || Bytes[0] == GPS_HEADER_CONSTANT || Bytes[0] == GCBI_HEADER_CONSTANT )
        {
            // bytes 2 and 3 contain the length of the packet

            uint16_t Length = UTIL_ByteArrayToUInt16( Bytes, false, 2 );

            if( Length >= 4 )
            {
                if( Bytes.size( ) >= Length )
                {
                    m_Packets.push( new CCommandPacket( Bytes[0], Bytes[1], BYTEARRAY( Bytes.begin( ), Bytes.begin( ) + Length ) ) );

                    if( Bytes[0] == W3GS_HEADER_CONSTANT )
                        ++m_TotalPacketsReceived;

                    *RecvBuffer = RecvBuffer->substr( Length );
                    Bytes = BYTEARRAY( Bytes.begin( ) + Length, Bytes.end( ) );
                }
                else
                    return;
            }
            else
            {
                m_Error = true;
                m_ErrorString = "received invalid packet from player (bad length)";
                return;
            }
        }
        else
        {
            m_Error = true;
            m_ErrorString = "received invalid packet from player (bad header constant)";
            return;
        }
    }
}
开发者ID:m-unkel,项目名称:OHSystem,代码行数:50,代码来源:gameplayer.cpp

示例14: PrepareForSave

void CSaveGame :: PrepareForSave()
{
	// Custom W3Z file format type header
	// by freed

	BYTEARRAY packet;

	UTIL_AppendByteArray( packet, m_MapPath );
	UTIL_AppendByteArray( packet, customMarkFileType, true );
	UTIL_AppendByteArray( packet, m_GameName );
	UTIL_AppendByteArray( packet, customMarkFileType, true );
	UTIL_AppendByteArray( packet, customMarkFileType, true );

	UTIL_AppendByteArray( packet, (uint32_t)0, false );
	UTIL_AppendByteArray( packet, (uint32_t)0, false );
	UTIL_AppendByteArray( packet, (uint16_t)0, false );

	packet.push_back ( m_Slots.size() );

	for( unsigned char i = 0; i < m_Slots.size(); i++ )
	{
		packet.push_back( m_Slots[i].GetPID() );
		packet.push_back( m_Slots[i].GetDownloadStatus() );
		packet.push_back( m_Slots[i].GetSlotStatus() );
		packet.push_back( m_Slots[i].GetComputer() );
		packet.push_back( m_Slots[i].GetTeam() );
		packet.push_back( m_Slots[i].GetColour() );
		packet.push_back( m_Slots[i].GetRace() );
		packet.push_back( m_Slots[i].GetComputerType() );
		packet.push_back( m_Slots[i].GetHandicap() );
	}
	
	UTIL_AppendByteArray( packet, (uint32_t)m_RandomSeed, false );

	packet.push_back( 0 ); // GameType
	packet.push_back( m_PIDs.size() ); // number of player slots (non observer)

	UTIL_AppendByteArray( packet, m_MagicNumber );

	packet.push_back( m_PIDs.size() );

	for( vector<CGamePlayer*>::iterator i = m_PIDs.begin(); i != m_PIDs.end(); ++i )
	{
		packet.push_back( (*i)->GetPID() );
		UTIL_AppendByteArray( packet, (*i)->GetName(), true );
	}

    m_Decompressed = string( packet.begin( ), packet.end( ) );
}
开发者ID:RiseCakoPlusplus,项目名称:brtGHost,代码行数:49,代码来源:savegame.cpp

示例15: 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


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