本文整理汇总了C++中NetBitStreamInterface::GetNumberOfUnreadBits方法的典型用法代码示例。如果您正苦于以下问题:C++ NetBitStreamInterface::GetNumberOfUnreadBits方法的具体用法?C++ NetBitStreamInterface::GetNumberOfUnreadBits怎么用?C++ NetBitStreamInterface::GetNumberOfUnreadBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetBitStreamInterface
的用法示例。
在下文中一共展示了NetBitStreamInterface::GetNumberOfUnreadBits方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Read
bool CUnoccupiedVehicleSyncPacket::Read(NetBitStreamInterface& BitStream)
{
uint uiMaxCount = g_pGame->GetVehicleManager()->Count() * 2 + 10;
// While we're not out of bytes
for (uint i = 0; BitStream.GetNumberOfUnreadBits() >= 8; i++)
{
if (i > uiMaxCount)
{
CLogger::LogPrintf("WARN: Received excess unoccupied vehicle sync data (%d bytes)", BitStream.GetNumberOfUnreadBits() / 8);
break;
}
// Read out the sync data
SyncData data;
data.bSend = false;
SUnoccupiedVehicleSync vehicle;
if (BitStream.Read(&vehicle))
{
data.syncStructure = vehicle;
// Add it to our list. We no longer check if it's valid here
// because CUnoccupiedVehicleSync does and it won't write bad ID's
// back to clients.
m_Syncs.push_back(data);
}
}
return m_Syncs.size() > 0;
}
示例2: Packet_UnoccupiedVehicleSync
void CUnoccupiedVehicleSync::Packet_UnoccupiedVehicleSync ( NetBitStreamInterface& BitStream )
{
// While we're not out of vehicles
while ( BitStream.GetNumberOfUnreadBits () >= 8 )
{
SUnoccupiedVehicleSync vehicle;
if ( BitStream.Read ( &vehicle ) )
{
CClientVehicle* pVehicle = m_pVehicleManager->Get ( vehicle.data.vehicleID );
if ( pVehicle && pVehicle->CanUpdateSync ( vehicle.data.ucTimeContext ) )
{
if ( vehicle.data.bSyncPosition ) pVehicle->SetTargetPosition ( vehicle.data.vecPosition, UNOCCUPIED_VEHICLE_SYNC_RATE, vehicle.data.bSyncVelocity, vehicle.data.vecVelocity.fZ );
if ( vehicle.data.bSyncRotation ) pVehicle->SetTargetRotation ( vehicle.data.vecRotation, UNOCCUPIED_VEHICLE_SYNC_RATE );
if ( vehicle.data.bSyncVelocity ) pVehicle->SetMoveSpeed ( vehicle.data.vecVelocity );
if ( vehicle.data.bSyncTurnVelocity ) pVehicle->SetTurnSpeed ( vehicle.data.vecTurnVelocity );
if ( vehicle.data.bSyncHealth ) pVehicle->SetHealth ( vehicle.data.fHealth );
pVehicle->SetEngineOn ( vehicle.data.bEngineOn );
if ( pVehicle->GetVehicleType() == CLIENTVEHICLE_TRAIN )
pVehicle->SetDerailed ( vehicle.data.bDerailed );
#ifdef MTA_DEBUG
pVehicle->m_pLastSyncer = NULL;
pVehicle->m_ulLastSyncTime = GetTickCount32 ();
pVehicle->m_szLastSyncType = "unoccupied";
#endif
}
}
else
break;
}
}
示例3: Read
bool CObjectSyncPacket::Read(NetBitStreamInterface& BitStream)
{
// While we're not out of bytes
while (BitStream.GetNumberOfUnreadBits() > 8)
{
// Read out the sync data
SyncData* pData = new SyncData;
pData->bSend = false;
// Read out the ID
if (!BitStream.Read(pData->ID))
return false;
// Read the sync time context
if (!BitStream.Read(pData->ucSyncTimeContext))
return false;
// Read out flags
SIntegerSync<unsigned char, 3> flags;
if (!BitStream.Read(&flags))
return false;
pData->ucFlags = flags;
// Read out the position if we need
if (flags & 0x1)
{
SPositionSync position;
if (!BitStream.Read(&position))
return false;
pData->vecPosition = position.data.vecPosition;
}
// Read out the rotation
if (flags & 0x2)
{
SRotationRadiansSync rotation;
if (!BitStream.Read(&rotation))
return false;
pData->vecRotation = rotation.data.vecRotation;
}
// Read out the health
if (flags & 0x4)
{
SObjectHealthSync health;
if (!BitStream.Read(&health))
return false;
pData->fHealth = health.data.fValue;
}
// Add it to our list
m_Syncs.push_back(pData);
}
return m_Syncs.size() > 0;
}
示例4: Packet_PedSync
void CPedSync::Packet_PedSync ( NetBitStreamInterface& BitStream )
{
// While we're not out of peds
while ( BitStream.GetNumberOfUnreadBits () > 32 )
{
// Read out the ped id
ElementID ID;
if ( BitStream.Read ( ID ) )
{
// Read out the sync time context. See CClientEntity for documentation on that.
unsigned char ucSyncTimeContext = 0;
BitStream.Read ( ucSyncTimeContext );
unsigned char ucFlags = 0;
BitStream.Read ( ucFlags );
CVector vecPosition, vecMoveSpeed;
float fRotation, fHealth, fArmor;
// Read out the position
if ( ucFlags & 0x01 )
{
BitStream.Read ( vecPosition.fX );
BitStream.Read ( vecPosition.fY );
BitStream.Read ( vecPosition.fZ );
}
// And rotation
if ( ucFlags & 0x02 ) BitStream.Read ( fRotation );
// And the move speed
if ( ucFlags & 0x04 )
{
BitStream.Read ( vecMoveSpeed.fX );
BitStream.Read ( vecMoveSpeed.fY );
BitStream.Read ( vecMoveSpeed.fZ );
}
// And health with armour
if ( ucFlags & 0x08 ) BitStream.Read ( fHealth );
if ( ucFlags & 0x10 ) BitStream.Read ( fArmor );
// Grab the ped. Only update the sync if this packet is from the same context.
CClientPed* pPed = m_pPedManager->Get ( ID );
if ( pPed && pPed->CanUpdateSync ( ucSyncTimeContext ) )
{
if ( ucFlags & 0x01 ) pPed->SetPosition ( vecPosition );
if ( ucFlags & 0x02 ) pPed->SetCurrentRotation ( fRotation );
if ( ucFlags & 0x04 ) pPed->SetMoveSpeed ( vecMoveSpeed );
if ( ucFlags & 0x08 ) pPed->LockHealth ( fHealth );
if ( ucFlags & 0x10 ) pPed->LockArmor ( fArmor );
}
}
}
}
示例5: Packet_ObjectSync
void CObjectSync::Packet_ObjectSync ( NetBitStreamInterface& BitStream )
{
// While we're not out of bytes
while ( BitStream.GetNumberOfUnreadBits () > 8 )
{
// Read out the ID
ElementID ID;
if ( !BitStream.Read ( ID ) )
return;
// Read out the sync time context. See CClientEntity for documentation on that.
unsigned char ucSyncTimeContext;
if ( !BitStream.Read ( ucSyncTimeContext ) )
return;
// Read out flags
SIntegerSync < unsigned char, 3 > flags ( 0 );
if ( !BitStream.Read ( &flags ) )
return;
// Read out the position if we need
SPositionSync position;
if ( flags & 0x1 )
{
if ( !BitStream.Read ( &position ) )
return;
}
// Read out the rotation
SRotationRadiansSync rotation;
if ( flags & 0x2 )
{
if ( !BitStream.Read ( &rotation ) )
return;
}
// Read out the health
SObjectHealthSync health;
if ( flags & 0x4 )
{
if ( !BitStream.Read ( &health ) )
return;
}
// Grab the object
CDeathmatchObject* pObject = static_cast < CDeathmatchObject* > ( m_pObjectManager->Get ( ID ) );
// Only update the sync if this packet is from the same context
if ( pObject && pObject->CanUpdateSync ( ucSyncTimeContext ) )
{
if ( flags & 0x1 ) pObject->SetPosition ( position.data.vecPosition );
if ( flags & 0x2 ) pObject->SetRotationRadians ( rotation.data.vecRotation );
if ( flags & 0x4 ) pObject->SetHealth ( health.data.fValue );
}
}
}
示例6: Read
//
// Should do the same this as what CPedTaskPacket::Read() does
//
bool CSimPedTaskPacket::Read ( NetBitStreamInterface& BitStream )
{
// Read and save packet data
m_Cache.uiNumBitsInPacketBody = BitStream.GetNumberOfUnreadBits();
uint uiNumBytes = ( m_Cache.uiNumBitsInPacketBody + 1 ) / 8;
dassert( uiNumBytes < sizeof( m_Cache.DataBuffer ) );
if( uiNumBytes < sizeof( m_Cache.DataBuffer ) )
if ( BitStream.ReadBits( m_Cache.DataBuffer, m_Cache.uiNumBitsInPacketBody ) )
return true;
return false;
}
示例7: SetPlayerMoney
void CPlayerRPCs::SetPlayerMoney ( NetBitStreamInterface& bitStream )
{
// Read out the new money amount
long lMoney;
bool bInstant = false;
if ( bitStream.Read ( lMoney ) )
{
if (bitStream.GetNumberOfUnreadBits() > 0)
bitStream.ReadBit(bInstant);
// Set it
m_pClientGame->SetMoney ( lMoney, bInstant );
}
}
示例8: SetElementModel
void CElementRPCs::SetElementModel ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
unsigned short usModel;
if ( bitStream.Read ( usModel ) )
{
switch ( pSource->GetType () )
{
case CCLIENTPED:
case CCLIENTPLAYER:
{
CClientPed* pPed = static_cast < CClientPed * > ( pSource );
pPed->SetModel ( usModel );
break;
}
case CCLIENTVEHICLE:
{
uchar ucVariant = 255, ucVariant2 = 255;
if ( bitStream.GetNumberOfUnreadBits () >= sizeof ( ucVariant ) + sizeof ( ucVariant2 ) )
{
bitStream.Read ( ucVariant );
bitStream.Read ( ucVariant2 );
}
CClientVehicle* pVehicle = static_cast < CClientVehicle * > ( pSource );
pVehicle->SetModelBlocking ( usModel, ucVariant, ucVariant2 );
break;
}
case CCLIENTOBJECT:
case CCLIENTWEAPON:
{
CClientObject* pObject = static_cast < CClientObject * > ( pSource );
pObject->SetModel ( usModel );
break;
}
}
}
}
示例9: Read
bool CUnoccupiedVehicleSyncPacket::Read ( NetBitStreamInterface& BitStream )
{
// While we're not out of bytes
while ( BitStream.GetNumberOfUnreadBits () >= 8 )
{
// Read out the sync data
SyncData data;
data.bSend = false;
SUnoccupiedVehicleSync vehicle;
if ( BitStream.Read ( &vehicle ) )
{
data.syncStructure = vehicle;
// Add it to our list. We no longer check if it's valid here
// because CUnoccupiedVehicleSync does and it won't write bad ID's
// back to clients.
m_Syncs.push_back ( data );
}
}
return m_Syncs.size () > 0;
}