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


C++ UTIL_AppendByteArray函数代码示例

本文整理汇总了C++中UTIL_AppendByteArray函数的典型用法代码示例。如果您正苦于以下问题:C++ UTIL_AppendByteArray函数的具体用法?C++ UTIL_AppendByteArray怎么用?C++ UTIL_AppendByteArray使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

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

示例2: SEND_W3GS_CHAT_FROM_HOST

BYTEARRAY CGameProtocol :: SEND_W3GS_CHAT_FROM_HOST( unsigned char fromPID, BYTEARRAY toPIDs, unsigned char flag, BYTEARRAY flagExtra, string message )
{
	BYTEARRAY packet;

	if( !toPIDs.empty( ) && !message.empty( ) && message.size( ) < 255 )
	{
		packet.push_back( W3GS_HEADER_CONSTANT );		// W3GS header constant
		packet.push_back( W3GS_CHAT_FROM_HOST );		// W3GS_CHAT_FROM_HOST
		packet.push_back( 0 );							// packet length will be assigned later
		packet.push_back( 0 );							// packet length will be assigned later
		packet.push_back( toPIDs.size( ) );				// number of receivers
		UTIL_AppendByteArray( packet, toPIDs );		// receivers
		packet.push_back( fromPID );					// sender
		packet.push_back( flag );						// flag
		UTIL_AppendByteArray( packet, flagExtra );	// extra flag
		UTIL_AppendByteArray( packet, message );	// message
		AssignLength( packet );
	}
	else
		CONSOLE_Print( "[GAMEPROTO] invalid parameters passed to SEND_W3GS_CHAT_FROM_HOST" );

	// DEBUG_Print( "SENT W3GS_CHAT_FROM_HOST" );
	// DEBUG_Print( packet );
	return packet;
}
开发者ID:interkill,项目名称:brtghost,代码行数:25,代码来源:gameprotocol.cpp

示例3: SEND_W3GS_SEARCHGAME

BYTEARRAY CGameProtocol :: SEND_W3GS_SEARCHGAME( bool TFT, unsigned char war3Version )
{
	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 Unknown[]			= {           0,  0,  0,  0 };

	BYTEARRAY packet;
	packet.push_back( W3GS_HEADER_CONSTANT );				// W3GS header constant
	packet.push_back( W3GS_SEARCHGAME );					// W3GS_SEARCHGAME
	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, Unknown, 4 );				// ???
	AssignLength( packet );
	// DEBUG_Print( "SENT W3GS_SEARCHGAME" );
	// DEBUG_Print( packet );
	return packet;
}
开发者ID:Demolisher,项目名称:ohsystem,代码行数:25,代码来源:gameprotocol.cpp

示例4: SEND_W3GS_SLOTINFOJOIN

BYTEARRAY CGameProtocol :: SEND_W3GS_SLOTINFOJOIN( unsigned char PID, BYTEARRAY port, BYTEARRAY externalIP, vector<CGameSlot> &slots, uint32_t randomSeed, unsigned char layoutStyle, unsigned char playerSlots )
{
	unsigned char Zeros[] = { 0, 0, 0, 0 };

	BYTEARRAY SlotInfo = EncodeSlotInfo( slots, randomSeed, layoutStyle, playerSlots );
	BYTEARRAY packet;

	if( port.size( ) == 2 && externalIP.size( ) == 4 )
	{
		packet.push_back( W3GS_HEADER_CONSTANT );									// W3GS header constant
		packet.push_back( W3GS_SLOTINFOJOIN );										// W3GS_SLOTINFOJOIN
		packet.push_back( 0 );														// packet length will be assigned later
		packet.push_back( 0 );														// packet length will be assigned later
		UTIL_AppendByteArray( packet, (uint16_t)SlotInfo.size( ), false );			// SlotInfo length
		UTIL_AppendByteArrayFast( packet, SlotInfo );								// SlotInfo
		packet.push_back( PID );													// PID
		packet.push_back( 2 );														// AF_INET
		packet.push_back( 0 );														// AF_INET continued...
		UTIL_AppendByteArray( packet, port );										// port
		UTIL_AppendByteArrayFast( packet, externalIP );								// external IP
		UTIL_AppendByteArray( packet, Zeros, 4 );									// ???
		UTIL_AppendByteArray( packet, Zeros, 4 );									// ???
		AssignLength( packet );
	}
	else
		CONSOLE_Print( "[GAMEPROTO] invalid parameters passed to SEND_W3GS_SLOTINFOJOIN" );

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

示例5: SEND_W3GS_GAMEINFO

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

示例6: 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, (uint32_t)0, false );
				}
			}
			else
			{
				if( (*i)->GetLagging( ) )
				{
					packet.push_back( (*i)->GetPID( ) );
					UTIL_AppendByteArray( packet, GetTicks( ) - (*i)->GetStartedLaggingTicks( ), false );
				}
			}
		}

		AssignLength( packet );
	}
	else
		CONSOLE_Print( "[GAMEPROTO] no laggers passed to SEND_W3GS_START_LAG" );

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

示例7: AddLeaveGameDuringLoading

void CReplay :: AddLeaveGameDuringLoading( 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_LoadingBlocks.push( Block );
}
开发者ID:0x6d48,项目名称:ghostpp,代码行数:10,代码来源:replay.cpp

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

示例9: SendChatToGame

BYTEARRAY CPUBProtocol :: SendChatToGame(const string& login, const string& message)
{
 	BYTEARRAY packet;
	packet.push_back( PUB_HEADER_CONSTANT );
	packet.push_back( this->PUB_CHAT_TO_GAME );
	packet.push_back( 0 );
	packet.push_back( 0 );
	UTIL_AppendByteArray( packet, login, true );
	UTIL_AppendByteArray( packet, message, true );
	AssignLength( packet );
	return packet;
}
开发者ID:brunobnb,项目名称:brtGHost,代码行数:12,代码来源:pubprotocol.cpp

示例10: EncodeSlotInfo

BYTEARRAY CGameProtocol :: EncodeSlotInfo( vector<CGameSlot> &slots, uint32_t randomSeed, unsigned char layoutStyle, unsigned char playerSlots )
{
	BYTEARRAY SlotInfo;
	SlotInfo.push_back( (unsigned char)slots.size( ) );		// number of slots

	for( unsigned int i = 0; i < slots.size( ); i++ )
		UTIL_AppendByteArray( SlotInfo, slots[i].GetByteArray( ) );

	UTIL_AppendByteArray( SlotInfo, randomSeed, false );	// random seed
	SlotInfo.push_back( layoutStyle );						// LayoutStyle (0 = melee, 1 = custom forces, 3 = custom forces + fixed player settings)
	SlotInfo.push_back( playerSlots );						// number of player slots (non observer)
	return SlotInfo;
}
开发者ID:brunobnb,项目名称:ghostcb,代码行数:13,代码来源:gameprotocol.cpp

示例11: EncodeSlotInfo

BYTEARRAY CGameProtocol :: EncodeSlotInfo( vector<CGameSlot> &slots, uint32_t randomSeed, unsigned char gameType, unsigned char playerSlots )
{
	BYTEARRAY SlotInfo;
	SlotInfo.push_back( (unsigned char)slots.size( ) );		// number of slots

	for( unsigned int i = 0; i < slots.size( ); i++ )
		UTIL_AppendByteArray( SlotInfo, slots[i].GetByteArray( ) );

	UTIL_AppendByteArray( SlotInfo, randomSeed, false );	// random seed
	SlotInfo.push_back( gameType );							// GameType (seems to be 0 for regular game, 3 for custom game)
	SlotInfo.push_back( playerSlots );						// number of player slots (non observer)
	return SlotInfo;
}
开发者ID:ThaiCat,项目名称:ghost-one,代码行数:13,代码来源:gameprotocol.cpp

示例12: SEND_BNLS_WARDEN_RAW

BYTEARRAY CBNLSProtocol :: SEND_BNLS_WARDEN_RAW( uint32_t cookie, BYTEARRAY raw )
{
	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( 1 );											// BNLS_WARDEN_RAW
	UTIL_AppendByteArray( packet, cookie, false );					// cookie
	UTIL_AppendByteArray( packet, (uint16_t)raw.size( ), false );	// raw length
	UTIL_AppendByteArray( packet, raw );							// raw
	AssignLength( packet );
	return packet;
}
开发者ID:0x6d48,项目名称:ghostpp,代码行数:13,代码来源:bnlsprotocol.cpp

示例13: SEND_GPSC_RECONNECT

BYTEARRAY CGPSProtocol :: SEND_GPSC_RECONNECT( unsigned char PID, uint32_t reconnectKey, uint32_t lastPacket )
{
	BYTEARRAY packet;
	packet.push_back( GPS_HEADER_CONSTANT );
	packet.push_back( GPS_RECONNECT );
	packet.push_back( 0 );
	packet.push_back( 0 );
	packet.push_back( PID );
	UTIL_AppendByteArray( packet, reconnectKey, false );
	UTIL_AppendByteArray( packet, lastPacket, false );
	AssignLength( packet );
	return packet;
}
开发者ID:PrOGm2,项目名称:ent-ghost,代码行数:13,代码来源:gpsprotocol.cpp

示例14: SEND_SID_CLANINVITATION

BYTEARRAY CBNETProtocol :: SEND_SID_CLANINVITATION( string accountName )
{
	unsigned char Cookie[] = { 0, 0, 0, 0 };

	BYTEARRAY packet;
	packet.push_back( BNET_HEADER_CONSTANT );	// BNET header constant
	packet.push_back( SID_CLANINVITATION );		// SID_CLANINVITATION
	packet.push_back( 0 );						// packet length will be assigned later
	packet.push_back( 0 );						// packet length will be assigned later
	UTIL_AppendByteArray( packet, Cookie, 4);
	UTIL_AppendByteArray( packet, accountName);
	AssignLength( packet );
	return packet;	
}
开发者ID:4RtY,项目名称:ghostpp,代码行数:14,代码来源:bnetprotocol.cpp

示例15: SEND_GAME_KEY

BYTEARRAY CPUBProtocol :: SEND_GAME_KEY( string key, string login )
{
	BYTEARRAY packet;
	packet.push_back( PUB_HEADER_CONSTANT );
	packet.push_back( this->PUB_BOT_GAME_KEY );
	packet.push_back( 0 );
	packet.push_back( 0 );
	packet.push_back( key.size() );
	UTIL_AppendByteArray( packet, key, false );
	packet.push_back( login.size() );
	UTIL_AppendByteArray( packet, login, false );
	AssignLength( packet );
	return packet;
}
开发者ID:brunobnb,项目名称:brtGHost,代码行数:14,代码来源:pubprotocol.cpp


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