本文整理汇总了C++中idBitMsg::ReadBits方法的典型用法代码示例。如果您正苦于以下问题:C++ idBitMsg::ReadBits方法的具体用法?C++ idBitMsg::ReadBits怎么用?C++ idBitMsg::ReadBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idBitMsg
的用法示例。
在下文中一共展示了idBitMsg::ReadBits方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnpackStats
void rvPlayerStat::UnpackStats( const idBitMsg& msg ) {
for( int i = 0; i < MAX_WEAPONS; i++ ) {
weaponShots[ i ] = msg.ReadShort();
}
for( int i = 0; i < MAX_WEAPONS; i++ ) {
weaponHits[ i ] = msg.ReadShort();
}
for( int i = 0; i < IGA_NUM_AWARDS; i++ ) {
inGameAwards[ i ] = msg.ReadByte();
}
endGameAwards.SetNum( msg.ReadByte() );
for( int i = 0; i < endGameAwards.Num(); i++ ) {
endGameAwards[ i ] = (endGameAward_t)msg.ReadByte();
}
deaths = msg.ReadBits( ASYNC_PLAYER_DEATH_BITS );
kills = msg.ReadBits( ASYNC_PLAYER_KILL_BITS );
}
示例2: ReadFromSnapshot
/*
================
idMoveable::ReadFromSnapshot
================
*/
void idExplodingBarrel::ReadFromSnapshot( const idBitMsg& msg )
{
idMoveable::ReadFromSnapshot( msg );
if( msg.ReadBits( 1 ) )
{
Hide();
}
else
{
Show();
}
}
示例3: ReadFromSnapshot
/*
================
idPhysics_Monster::ReadFromSnapshot
================
*/
void idPhysics_Monster::ReadFromSnapshot( const idBitMsg& msg )
{
current.origin[0] = msg.ReadFloat();
current.origin[1] = msg.ReadFloat();
current.origin[2] = msg.ReadFloat();
current.velocity[0] = msg.ReadFloat( MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
current.velocity[1] = msg.ReadFloat( MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
current.velocity[2] = msg.ReadFloat( MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
current.localOrigin[0] = msg.ReadDeltaFloat( current.origin[0] );
current.localOrigin[1] = msg.ReadDeltaFloat( current.origin[1] );
current.localOrigin[2] = msg.ReadDeltaFloat( current.origin[2] );
current.pushVelocity[0] = msg.ReadDeltaFloat( 0.0f, MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
current.pushVelocity[1] = msg.ReadDeltaFloat( 0.0f, MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
current.pushVelocity[2] = msg.ReadDeltaFloat( 0.0f, MONSTER_VELOCITY_EXPONENT_BITS, MONSTER_VELOCITY_MANTISSA_BITS );
current.atRest = msg.ReadLong();
current.onGround = msg.ReadBits( 1 ) != 0;
}
示例4: ClientReceiveEvent
END_CLASS
bool idPDAItem::ClientReceiveEvent(int event,int time,const idBitMsg &msg)
{
switch (event)
{
case EVENT_GIVEPDA: {
int spawnId = msg.ReadBits( 32 );
idEntityPtr< idPlayer > entPtr;
if( !entPtr.SetSpawnId( spawnId ) ) {
break;
}
Event_GivePDA(entPtr.GetEntity());
return true;
}
}
return idItem::ClientReceiveEvent(event,time,msg);
}
示例5: ReceiveAllStats
void rvStatManager::ReceiveAllStats( const idBitMsg& msg ) {
assert( gameLocal.isClient );
assert( MAX_CLIENTS <= 32 );
unsigned sentClients = msg.ReadBits( MAX_CLIENTS );
for(int i=0; i < MAX_CLIENTS; i++)
{
if ( sentClients & ( 1 << i ) ) {
playerStats[ i ].UnpackStats( msg );
} else {
playerStats[ i ].Clear();
}
playerStats[ i ].lastUpdateTime = gameLocal.time;
}
if ( gameLocal.mpGame.GetGameState()->GetMPGameState() == GAMEREVIEW ) {
gameLocal.mpGame.ShowStatSummary();
}
}
示例6: ReadNetworkState
/*
================
idScriptObject::ReadNetworkState
================
*/
void idScriptObject::ReadNetworkState( networkStateMode_t mode, const sdEntityStateNetworkData& baseState, sdEntityStateNetworkData& newState, const idBitMsg& msg ) const {
NET_GET_STATES( sdScriptObjectNetworkData );
SetupStateData( mode, newData );
baseData.Reset();
newData.Reset();
for ( int i = 0; i < networkFields[ mode ].fields.Num(); i++ ) {
const networkFieldSync_t& value = networkFields[ mode ].fields[ i ];
switch( value.type ) {
case ev_object: {
const int& oldBase = baseData.GetInt();
int& newBase = newData.GetInt();
newBase = msg.ReadDeltaLong( oldBase );
break;
}
case ev_vector: {
const idVec3& oldBase = baseData.GetVector();
idVec3& newBase = newData.GetVector();
newBase = msg.ReadDeltaVector( oldBase );
break;
}
case ev_float: {
const float& oldBase = baseData.GetFloat();
float& newBase = newData.GetFloat();
newBase = msg.ReadDeltaFloat( oldBase );
break;
}
case ev_boolean: {
const int& oldBase = baseData.GetInt();
int& newBase = newData.GetInt();
newBase = msg.ReadBits( 1 );
break;
}
}
}
}
示例7: 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();
//.........这里部分代码省略.........