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


C++ idBitMsg::ReadData方法代码示例

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


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

示例1: HandleMigrationGameData

/*
========================
idLobby::HandleMigrationGameData
========================
*/
void idLobby::HandleMigrationGameData( idBitMsg& msg )
{
	// Receives game migration data from the server. Just save off the raw data. If we ever become host we'll let the game code read
	// that chunk in (we can't do anything with it now anyways: we don't have entities or any server code to read it in to)
	migrationInfo.persistUntilGameEndsData.hasGameData = true;
	
	// Reset each user's migration game data. If we don't receive new data for them in this msg, we don't want to use the old data
	for( int i = 0; i < GetNumLobbyUsers(); i++ )
	{
		lobbyUser_t* u = GetLobbyUser( i );
		if( u != NULL )
		{
			u->migrationGameData = -1;
		}
	}
	
	msg.ReadData( migrationInfo.persistUntilGameEndsData.gameData, sizeof( migrationInfo.persistUntilGameEndsData.gameData ) );
	int numUsers = msg.ReadByte();
	int dataIndex = 0;
	for( int i = 0; i < numUsers; i++ )
	{
		lobbyUserID_t lobbyUserID;
		lobbyUserID.ReadFromMsg( msg );
		lobbyUser_t* user = GetLobbyUser( GetLobbyUserIndexByID( lobbyUserID ) );
		if( user != NULL )
		{
		
			NET_VERBOSE_PRINT( "NET:    Got migration data[%d] for user %s\n", dataIndex, user->gamertag );
			
			user->migrationGameData = dataIndex;
			msg.ReadData( migrationInfo.persistUntilGameEndsData.gameDataUser[ dataIndex ], sizeof( migrationInfo.persistUntilGameEndsData.gameDataUser[ dataIndex ] ) );
			dataIndex++;
		}
	}
}
开发者ID:BielBdeLuna,项目名称:RBDoom3BFG-mirrored,代码行数:40,代码来源:sys_lobby_migrate.cpp

示例2: ServerProcessReliableMessage

/*
================
idGameLocal::ServerProcessReliableMessage
================
*/
void idGameLocal::ServerProcessReliableMessage( int clientNum, int type, const idBitMsg& msg )
{
	if( clientNum < 0 )
	{
		return;
	}
	switch( type )
	{
		case GAME_RELIABLE_MESSAGE_CHAT:
		case GAME_RELIABLE_MESSAGE_TCHAT:
		{
			char name[128];
			char text[128];
			
			msg.ReadString( name, sizeof( name ) );
			msg.ReadString( text, sizeof( text ) );
			
			mpGame.ProcessChatMessage( clientNum, type == GAME_RELIABLE_MESSAGE_TCHAT, name, text, NULL );
			break;
		}
		case GAME_RELIABLE_MESSAGE_VCHAT:
		{
			int index = msg.ReadLong();
			bool team = msg.ReadBits( 1 ) != 0;
			mpGame.ProcessVoiceChat( clientNum, team, index );
			break;
		}
		case GAME_RELIABLE_MESSAGE_DROPWEAPON:
		{
			mpGame.DropWeapon( clientNum );
			break;
		}
		case GAME_RELIABLE_MESSAGE_EVENT:
		{
			// allocate new event
			entityNetEvent_t* event = eventQueue.Alloc();
			eventQueue.Enqueue( event, idEventQueue::OUTOFORDER_DROP );
			
			event->spawnId = msg.ReadBits( 32 );
			event->event = msg.ReadByte();
			event->time = msg.ReadLong();
			
			event->paramsSize = msg.ReadBits( idMath::BitsForInteger( MAX_EVENT_PARAM_SIZE ) );
			if( event->paramsSize )
			{
				if( event->paramsSize > MAX_EVENT_PARAM_SIZE )
				{
					NetworkEventWarning( event, "invalid param size" );
					return;
				}
				msg.ReadByteAlign();
				msg.ReadData( event->paramsBuf, event->paramsSize );
			}
			break;
		}
		case GAME_RELIABLE_MESSAGE_SPECTATE:
		{
			bool spec = msg.ReadBool();
			idPlayer* player = GetClientByNum( clientNum );
			if( serverInfo.GetBool( "si_spectators" ) )
			{
				// never let spectators go back to game while sudden death is on
				if( mpGame.GetGameState() == idMultiplayerGame::SUDDENDEATH && !spec && player->wantSpectate )
				{
					// Don't allow the change
				}
				else
				{
					if( player->wantSpectate && !spec )
					{
						player->forceRespawn = true;
					}
					player->wantSpectate = spec;
				}
			}
			else
			{
				// If the server turned off si_spectators while a player is spectating, then any spectate message forces the player out of spectate mode
				if( player->wantSpectate )
				{
					player->forceRespawn = true;
				}
				player->wantSpectate = false;
			}
			break;
		}
		case GAME_RELIABLE_MESSAGE_CLIENT_HITSCAN_HIT:
		{
			const int attackerNum = msg.ReadShort();
			const int victimNum = msg.ReadShort();
			idVec3 dir;
			msg.ReadVectorFloat( dir );
			const int damageDefIndex = msg.ReadLong();
			const float damageScale = msg.ReadFloat();
			const int location = msg.ReadLong();
//.........这里部分代码省略.........
开发者ID:Anthony-Gaudino,项目名称:OpenTechBFG,代码行数:101,代码来源:Game_network.cpp


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