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


C++ NetBitStreamInterface::ReadBits方法代码示例

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


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

示例1: 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;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:15,代码来源:CSimPedTaskPacket.cpp

示例2: SetTrafficLightState

void CWorldRPCs::SetTrafficLightState(NetBitStreamInterface& bitStream)
{
    char ucTrafficLightState;

    if (bitStream.ReadBits(&ucTrafficLightState, 4))
    {
        bool bForced = bitStream.ReadBit();
        // We ignore updating the serverside traffic light state if it's blocked, unless script forced it
        if (bForced || !g_pMultiplayer->GetTrafficLightsLocked())
            g_pMultiplayer->SetTrafficLightState((unsigned char)*&ucTrafficLightState);
    }
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:12,代码来源:CWorldRPCs.cpp

示例3: Read

bool CVehicleInOutPacket::Read ( NetBitStreamInterface& BitStream )
{
    // Read out the vehicle id
    m_ID = INVALID_ELEMENT_ID;
    BitStream.Read ( m_ID );
    if ( m_ID == INVALID_ELEMENT_ID )
    {
        return false;
    }

    // Read out the action id
    m_ucAction = 0xFF;
    if ( !BitStream.ReadBits ( &m_ucAction, 4 ) )
        return false;

    // If the action is requesting to get in, read out the "passenger" flag too
    if ( m_ucAction == CGame::VEHICLE_REQUEST_IN )
    {
        return BitStream.ReadBits ( &m_ucSeat, 3 ) &&
               BitStream.ReadBit  ( m_bOnWater ) &&
               BitStream.ReadBits ( &m_ucDoor, 3 );
    }
    else if ( m_ucAction == CGame::VEHICLE_NOTIFY_JACK_ABORT )
    {
        SDoorOpenRatioSync door;
        bool bStartedJacking;
        if ( BitStream.ReadBits ( &m_ucDoor, 3 ) &&
             BitStream.Read ( &door ) &&
             BitStream.ReadBit ( bStartedJacking ) )
        {
            m_ucStartedJacking = bStartedJacking;
            m_fDoorAngle = door.data.fRatio;
        }
        else
            return false;
    }
    else if ( m_ucAction == CGame::VEHICLE_NOTIFY_IN_ABORT )
    {
        SDoorOpenRatioSync door;
        if ( BitStream.ReadBits ( &m_ucDoor, 3 ) &&
             BitStream.Read ( &door ) )
        {
            m_fDoorAngle = door.data.fRatio;
        }
        else
            return false;
    }
    else if ( m_ucAction == CGame::VEHICLE_REQUEST_OUT )
    {
        m_ucDoor = 0;
        if ( !BitStream.ReadBits ( &m_ucDoor, 2 ) )
            m_ucDoor = 0xFF;
    }
    return true;
}
开发者ID:EagleShen,项目名称:MTA,代码行数:55,代码来源:CVehicleInOutPacket.cpp


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