本文整理汇总了C++中NetBitStreamInterface类的典型用法代码示例。如果您正苦于以下问题:C++ NetBitStreamInterface类的具体用法?C++ NetBitStreamInterface怎么用?C++ NetBitStreamInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NetBitStreamInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetPedFightingStyle
void CPedRPCs::SetPedFightingStyle ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
unsigned char ucStyle;
if ( bitStream.Read ( ucStyle ) )
{
CClientPed* pPed = m_pPedManager->Get ( pSource->GetID (), true );
if ( pPed )
{
pPed->SetFightingStyle ( ( eFightingStyle ) ucStyle );
}
}
}
示例2: SetPedMoveAnim
void CPedRPCs::SetPedMoveAnim ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
unsigned int uiMoveAnim;
if ( bitStream.ReadCompressed ( uiMoveAnim ) )
{
CClientPed* pPed = m_pPedManager->Get ( pSource->GetID (), true );
if ( pPed )
{
pPed->SetMoveAnim ( (eMoveAnim)uiMoveAnim );
}
}
}
示例3: SetPlayerNametagShowing
void CPlayerRPCs::SetPlayerNametagShowing ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
unsigned char ucShowing;
if ( bitStream.Read ( ucShowing ) )
{
CClientPlayer* pPlayer = m_pPlayerManager->Get ( pSource->GetID () );
if ( pPlayer )
{
pPlayer->SetNametagShowing ( ( ucShowing == 1 ) );
}
}
}
示例4: SetPedChoking
void CPedRPCs::SetPedChoking ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
bool bChoking;
if ( bitStream.ReadBit ( bChoking ) )
{
CClientPed* pPed = m_pPedManager->Get ( pSource->GetID (), true );
if ( pPed )
{
pPed->SetChoking ( bChoking );
}
}
}
示例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: Write
bool CResourceClientScriptsPacket::Write ( NetBitStreamInterface& BitStream ) const
{
if ( m_vecItems.size() == 0 )
return false;
BitStream.Write ( m_pResource->GetNetID() );
unsigned short usItemCount = m_vecItems.size();
BitStream.Write ( usItemCount );
for ( std::vector<CResourceClientScriptItem*>::const_iterator iter = m_vecItems.begin ();
iter != m_vecItems.end();
++iter )
{
if ( BitStream.Version() >= 0x50 )
BitStream.WriteString( (*iter)->GetName() );
const SString& data = (*iter)->GetSourceCode ();
unsigned int len = data.length ();
BitStream.Write ( len );
BitStream.Write ( data.c_str(), len );
}
return true;
}
示例7: SetCameraMatrix
void CCameraRPCs::SetCameraMatrix ( NetBitStreamInterface& bitStream )
{
CVector vecPosition, vecLookAt;
float fRoll = 0.0f;
float fFOV = 70.0f;
if ( bitStream.Read ( vecPosition.fX ) &&
bitStream.Read ( vecPosition.fY ) &&
bitStream.Read ( vecPosition.fZ ) &&
bitStream.Read ( vecLookAt.fX ) &&
bitStream.Read ( vecLookAt.fY ) &&
bitStream.Read ( vecLookAt.fZ ) )
{
bitStream.Read ( fRoll );
bitStream.Read ( fFOV );
if ( !m_pCamera->IsInFixedMode () )
m_pCamera->ToggleCameraFixedMode ( true );
// Put the camera there
m_pCamera->SetPosition ( vecPosition );
m_pCamera->SetTarget ( vecLookAt );
m_pCamera->SetRoll ( fRoll );
m_pCamera->SetFOV ( fFOV );
}
}
示例8: SetWeaponSlot
void CWeaponRPCs::SetWeaponSlot ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
SWeaponSlotSync slot;
if ( bitStream.Read ( &slot ) )
{
CClientPed * pPed = m_pPedManager->Get ( pSource->GetID (), true );
if ( pPed )
{
pPed->SetCurrentWeaponSlot ( (eWeaponSlot) slot.data.uiSlot );
}
}
}
示例9: Read
bool CPlayerModInfoPacket::Read ( NetBitStreamInterface& BitStream )
{
// Read type
if ( !BitStream.ReadString ( m_strInfoType ) )
return false;
// Read amount of items
uint uiCount;
if ( !BitStream.Read ( uiCount ) )
return false;
// Read each item
for ( uint i = 0 ; i < uiCount ; i++ )
{
SModInfoItem item;
if ( !BitStream.Read ( item.usId ) )
return false;
if ( !BitStream.Read ( item.uiHash ) )
return false;
if ( !BitStream.ReadString ( item.strName ) )
return false;
int iHasSize;
if ( !BitStream.Read ( iHasSize ) )
return false;
item.bHasSize = iHasSize != 0;
if ( !BitStream.Read ( item.vecSize.fX ) )
return false;
if ( !BitStream.Read ( item.vecSize.fY ) )
return false;
if ( !BitStream.Read ( item.vecSize.fZ ) )
return false;
m_ModInfoItemList.push_back ( item );
}
return true;
}
示例10: ReadFromBitStream
bool CLuaArguments::ReadFromBitStream(NetBitStreamInterface& bitStream, std::vector<CLuaArguments*>* pKnownTables)
{
bool bKnownTablesCreated = false;
if (!pKnownTables)
{
pKnownTables = new std::vector<CLuaArguments*>();
bKnownTablesCreated = true;
}
unsigned int uiNumArgs;
bool bResult;
#if MTA_DM_VERSION >= 0x150
bResult = bitStream.ReadCompressed(uiNumArgs);
#else
if (bitStream.Version() < 0x05B)
{
unsigned short usNumArgs;
bResult = bitStream.ReadCompressed(usNumArgs);
uiNumArgs = usNumArgs;
}
else
bResult = bitStream.ReadCompressed(uiNumArgs);
#endif
if (bResult)
{
pKnownTables->push_back(this);
for (unsigned int ui = 0; ui < uiNumArgs; ++ui)
{
CLuaArgument* pArgument = new CLuaArgument(bitStream, pKnownTables);
m_Arguments.push_back(pArgument);
}
}
if (bKnownTablesCreated)
delete pKnownTables;
return true;
}
示例11: SetWeather
void CWorldRPCs::SetWeather(NetBitStreamInterface& bitStream)
{
// Read out the weather to apply
unsigned char ucWeather;
if (bitStream.Read(ucWeather))
{
// Check that its within range
if (ucWeather <= MAX_VALID_WEATHER)
{
m_pBlendedWeather->SetWeather(ucWeather);
}
}
}
示例12: SetElementHealth
void CElementRPCs::SetElementHealth ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
float fHealth;
unsigned char ucTimeContext;
if ( bitStream.Read ( fHealth ) &&
bitStream.Read ( ucTimeContext ) )
{
pSource->SetSyncTimeContext ( ucTimeContext );
switch ( pSource->GetType () )
{
case CCLIENTPED:
case CCLIENTPLAYER:
{
CClientPed* pPed = static_cast < CClientPed * > ( pSource );
if ( pPed->IsHealthLocked() )
pPed->LockHealth ( fHealth );
else
pPed->SetHealth ( fHealth );
break;
}
case CCLIENTVEHICLE:
{
CClientVehicle* pVehicle = static_cast < CClientVehicle * > ( pSource );
pVehicle->SetHealth ( fHealth );
break;
}
case CCLIENTOBJECT:
case CCLIENTWEAPON:
{
CClientObject* pObject = static_cast < CClientObject * > ( pSource );
pObject->SetHealth ( fHealth );
break;
}
}
}
}
示例13: SetPedAnimation
void CPedRPCs::SetPedAnimation ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
// Read out the player and vehicle id
char szBlockName [ 64 ], szAnimName [ 64 ];
unsigned char ucBlockSize, ucAnimSize;
int iTime;
bool bLoop, bUpdatePosition, bInterruptable, bFreezeLastFrame;
if ( bitStream.Read ( ucBlockSize ) )
{
// Grab the ped
CClientPed * pPed = m_pPedManager->Get ( pSource->GetID (), true );
if ( pPed )
{
if ( ucBlockSize > 0 )
{
if ( bitStream.Read ( szBlockName, ucBlockSize ) &&
bitStream.Read ( ucAnimSize ) )
{
szBlockName [ ucBlockSize ] = 0;
if ( bitStream.Read ( szAnimName, ucAnimSize ) &&
bitStream.Read ( iTime ) &&
bitStream.ReadBit ( bLoop ) &&
bitStream.ReadBit ( bUpdatePosition ) &&
bitStream.ReadBit ( bInterruptable ) &&
bitStream.ReadBit ( bFreezeLastFrame ) )
{
szAnimName [ ucAnimSize ] = 0;
CAnimBlock * pBlock = g_pGame->GetAnimManager ()->GetAnimationBlock ( szBlockName );
if ( pBlock )
{
pPed->RunNamedAnimation ( pBlock, szAnimName, iTime, bLoop, bUpdatePosition, bInterruptable, bFreezeLastFrame );
}
}
}
}
else
{
pPed->KillAnimation ();
}
}
}
}
示例14: SetSyncIntervals
void CWorldRPCs::SetSyncIntervals(NetBitStreamInterface& bitStream)
{
bitStream.Read(g_TickRateSettings.iPureSync);
bitStream.Read(g_TickRateSettings.iLightSync);
bitStream.Read(g_TickRateSettings.iCamSync);
bitStream.Read(g_TickRateSettings.iPedSync);
bitStream.Read(g_TickRateSettings.iUnoccupiedVehicle);
bitStream.Read(g_TickRateSettings.iObjectSync);
bitStream.Read(g_TickRateSettings.iKeySyncRotation);
bitStream.Read(g_TickRateSettings.iKeySyncAnalogMove);
}
示例15: SetPlayerTeam
void CPlayerRPCs::SetPlayerTeam ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
ElementID TeamID;
if ( bitStream.Read ( TeamID ) )
{
CClientTeam* pTeam = m_pTeamManager->GetTeam ( TeamID );
CClientPlayer* pPlayer = m_pPlayerManager->Get ( pSource->GetID () );
if ( pPlayer )
{
pPlayer->SetTeam ( pTeam, true );
}
}
}