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


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

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


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

示例1: 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

示例2: SetElementCollisionsEnabled

void CElementRPCs::SetElementCollisionsEnabled ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    bool bEnable;

    if ( bitStream.ReadBit ( bEnable ) )
    {
        switch ( pSource->GetType () )
        {
            case CCLIENTPED:
            case CCLIENTPLAYER:
            {
                CClientPed* pPed = static_cast < CClientPed * > ( pSource );
                pPed->SetUsesCollision ( bEnable );
                break;
            }

            case CCLIENTVEHICLE:
            {
                CClientVehicle* pVehicle = static_cast < CClientVehicle * > ( pSource );
                pVehicle->SetCollisionEnabled ( bEnable );
                break;
            }

            case CCLIENTOBJECT:
            {
                CClientObject* pObject = static_cast < CClientObject * > ( pSource );
                pObject->SetCollisionEnabled ( bEnable );
                break;
            }
        }
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:32,代码来源:CElementRPCs.cpp

示例3: SetElementFrozen

void CElementRPCs::SetElementFrozen ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    bool bFrozen;

    if ( bitStream.ReadBit ( bFrozen ) )
    {
        switch ( pSource->GetType () )
        {
            case CCLIENTPED:
            case CCLIENTPLAYER:
            {
                CClientPed* pPed = static_cast < CClientPed * > ( pSource );
                pPed->SetFrozen ( bFrozen );
                break;
            }

            case CCLIENTVEHICLE:
            {
                CClientVehicle* pVehicle = static_cast < CClientVehicle * > ( pSource );
                pVehicle->SetFrozen ( bFrozen );
                break;
            }

            case CCLIENTOBJECT:
            {
                CClientObject* pObject = static_cast < CClientObject * > ( pSource );
                pObject->SetStatic ( bFrozen );
                break;
            }
        }
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:32,代码来源:CElementRPCs.cpp

示例4: Read

bool CVehicleTrailerPacket::Read ( NetBitStreamInterface& BitStream )
{
    SPositionSync position ( false );
    SRotationDegreesSync rotation ( false );
    SVelocitySync turn;

    if ( BitStream.Read ( m_Vehicle ) &&
         BitStream.Read ( m_AttachedVehicle ) &&
         BitStream.ReadBit ( m_bAttached ) &&
         ( !m_bAttached ||
           ( BitStream.Read ( &position ) &&
             BitStream.Read ( &rotation ) &&
             BitStream.Read ( &turn )
           )
         )
       )
    {
        if ( m_bAttached )
        {
            m_vecPosition = position.data.vecPosition;
            m_vecRotationDegrees = rotation.data.vecRotation;
            m_vecTurnSpeed = turn.data.vecVelocity;
        }
        return true;
    }
    return false;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:27,代码来源:CVehicleTrailerPacket.cpp

示例5: SetCustomWeaponTarget

void CElementRPCs::SetCustomWeaponTarget ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    ElementID elementID = INVALID_ELEMENT_ID;
    char cTargetBone = 0;
    bool bVector = false;
    CVector vecTarget;

    if ( bitStream.ReadBit ( bVector ) &&
        pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        if ( bVector )
        {
            if ( bitStream.ReadVector ( vecTarget.fX, vecTarget.fY, vecTarget.fZ ) )
            {
                pWeapon->SetWeaponTarget ( vecTarget );
            }
        }
        else
        {
            if ( bitStream.Read ( elementID ) && 
                bitStream.Read ( cTargetBone ) )
            {
                pWeapon->SetWeaponTarget ( CElementIDs::GetElement( elementID ), cTargetBone );
            }
        }
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:28,代码来源:CElementRPCs.cpp

示例6: SetCallPropagationEnabled

void CElementRPCs::SetCallPropagationEnabled ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    bool bEnabled;
    if ( bitStream.ReadBit ( bEnabled ) )
    {
        pSource->SetCallPropagationEnabled ( bEnabled );
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:8,代码来源:CElementRPCs.cpp

示例7: SetJetpackWeaponEnabled

void CWorldRPCs::SetJetpackWeaponEnabled(NetBitStreamInterface& bitStream)
{
    unsigned char ucWeaponID = 0;
    bool          bEnabled;
    bitStream.Read(ucWeaponID);
    bitStream.ReadBit(bEnabled);
    g_pGame->SetJetpackWeaponEnabled((eWeaponType)ucWeaponID, bEnabled);
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:8,代码来源:CWorldRPCs.cpp

示例8: SetElementDoubleSided

void CElementRPCs::SetElementDoubleSided ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    bool bDoubleSided;
    if ( bitStream.ReadBit ( bDoubleSided ) )
    {
        pSource->SetDoubleSided ( bDoubleSided );
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:8,代码来源:CElementRPCs.cpp

示例9: SetOcclusionsEnabled

void CWorldRPCs::SetOcclusionsEnabled(NetBitStreamInterface& bitStream)
{
    bool bEnabled;

    if (bitStream.ReadBit(bEnabled))
    {
        g_pGame->GetWorld()->SetOcclusionsEnabled(bEnabled);
    }
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:9,代码来源:CWorldRPCs.cpp

示例10: SetInteriorSoundsEnabled

void CWorldRPCs::SetInteriorSoundsEnabled(NetBitStreamInterface& bitStream)
{
    bool bEnable;

    if (bitStream.ReadBit(bEnable))
    {
        g_pMultiplayer->SetInteriorSoundsEnabled(bEnable);
    }
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:9,代码来源:CWorldRPCs.cpp

示例11: 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 ();
            }
        }
    }
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:44,代码来源:CPedRPCs.cpp

示例12: SetWorldWaterLevel

void CWaterRPCs::SetWorldWaterLevel ( NetBitStreamInterface& bitStream )
{
    float fLevel;
    bool bIncludeWorldNonSeaLevel;

    if ( bitStream.Read ( fLevel )
            && bitStream.ReadBit ( bIncludeWorldNonSeaLevel ) )
    {
        m_pWaterManager->SetWorldWaterLevel ( fLevel, NULL, bIncludeWorldNonSeaLevel );
    }
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:11,代码来源:CWaterRPCs.cpp

示例13: 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 );
        }
    }
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:12,代码来源:CPedRPCs.cpp

示例14: 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

示例15: SetPedHeadless

void CPedRPCs::SetPedHeadless ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    bool bIsHeadless;

    if ( bitStream.ReadBit ( bIsHeadless ) )
    {
        // Grab the ped
        CClientPed * pPed = m_pPedManager->Get ( pSource->GetID (), true );
        if ( pPed )
        {
            pPed->SetHeadless ( bIsHeadless );
        }
    }
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:14,代码来源:CPedRPCs.cpp


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