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


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

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


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

示例1: 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;
}
开发者ID:pombredanne,项目名称:openvice,代码行数:25,代码来源:CResourceClientScriptsPacket.cpp

示例2: TakePlayerScreenShot

void CPlayerRPCs::TakePlayerScreenShot ( NetBitStreamInterface& bitStream )
{
    ushort usSizeX;
    ushort usSizeY;
    SString strTag;
    uchar ucQuality;
    uint uiMaxBandwidth;
    ushort usMaxPacketSize;
    CResource* pResource;
    uint uiServerSentTime;

    bitStream.Read ( usSizeX );
    bitStream.Read ( usSizeY );
    bitStream.ReadString ( strTag );
    bitStream.Read ( ucQuality );
    bitStream.Read ( uiMaxBandwidth );
    bitStream.Read ( usMaxPacketSize );
    if ( bitStream.Version() >= 0x53 )
    {
        ushort usResourceNetId;
        bitStream.Read ( usResourceNetId );
        pResource = g_pClientGame->GetResourceManager ()->GetResourceFromNetID ( usResourceNetId );
    }
    else
    {
        SString strResourceName;
        bitStream.ReadString ( strResourceName );
        pResource = g_pClientGame->GetResourceManager ()->GetResource ( strResourceName );
    }

    if ( !bitStream.Read ( uiServerSentTime ) )
        return;

    m_pClientGame->TakePlayerScreenShot ( usSizeX, usSizeY, strTag, ucQuality, uiMaxBandwidth, usMaxPacketSize, pResource, uiServerSentTime );        
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:35,代码来源:CPlayerRPCs.cpp

示例3: Write

bool CPlayerJoinCompletePacket::Write ( NetBitStreamInterface& BitStream ) const
{
    BitStream.Write ( m_PlayerID );
    BitStream.Write ( m_ucNumberOfPlayers );
    BitStream.Write ( m_RootElementID );

    // Transmit server requirement for the client to check settings
    BitStream.Write ( m_iEnableClientChecks );

    // Transmit whether or not the Voice is enabled
    BitStream.WriteBit ( m_bVoiceEnabled );

    // Transmit the sample rate for voice
    SIntegerSync < unsigned char, 2 > sampleRate ( m_ucSampleRate );
    BitStream.Write ( &sampleRate );

    // Transmit the quality for voice
    SIntegerSync < unsigned char, 4 > voiceQuality ( m_ucQuality );
    BitStream.Write ( &voiceQuality );

    // Transmit the max bitrate for voice
    BitStream.WriteCompressed ( m_uiBitrate );

    // Tellclient about maybe throttling back http client requests
    BitStream.Write ( m_iHTTPMaxConnectionsPerClient );

    BitStream.Write ( static_cast < unsigned char > ( m_ucHTTPDownloadType ) );

    switch ( m_ucHTTPDownloadType )
    {
    case HTTP_DOWNLOAD_ENABLED_PORT:
        {
            BitStream.Write ( m_usHTTPDownloadPort );
        }

        break;
    case HTTP_DOWNLOAD_ENABLED_URL:
        {
            // Internal http server port
            if ( BitStream.Version() >= 0x48 )
                BitStream.Write( m_usHTTPDownloadPort );

            // External http server URL
            BitStream.WriteString ( m_strHTTPDownloadURL );
        }

        break;
    default:
        break;
    }

    return true;
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:53,代码来源:CPlayerJoinCompletePacket.cpp

示例4: SetAircraftMaxVelocity

void CWorldRPCs::SetAircraftMaxVelocity(NetBitStreamInterface& bitStream)
{
    float fVelocity;

    if (bitStream.Version() >= 0x3E)
    {
        if (bitStream.Read(fVelocity))
        {
            g_pGame->GetWorld()->SetAircraftMaxVelocity(fVelocity);
        }
    }
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:12,代码来源:CWorldRPCs.cpp

示例5: Write

bool CPlayerConnectCompletePacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Send the connection string
    SString strConnText ( "%s %s [%s]", MTA_DM_FULL_STRING, MTA_DM_VERSIONSTRING, MTA_OS_STRING );
    BitStream.WriteString ( strConnText.Left ( MAX_CONN_TEXT_LEN ) );

    // Send the full server version
    if ( BitStream.Version () >= 0x29 )
        BitStream.WriteString ( CStaticFunctionDefinitions::GetVersionSortable () );

    return true;
}
开发者ID:pombredanne,项目名称:openvice,代码行数:12,代码来源:CPlayerConnectCompletePacket.cpp

示例6: 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
    unsigned short usNumArgs;
    if (bitStream.Version() < 0x05B)
    {
        // We got the old version
        bResult = bitStream.ReadCompressed(usNumArgs);
        uiNumArgs = usNumArgs;
    }
    else
    {
        // Check if we got the new version
        if ((bResult = bitStream.ReadCompressed(usNumArgs)))
        {
            if (usNumArgs == 0xFFFF)
                // We got the new version
                bResult = bitStream.ReadCompressed(uiNumArgs);
            else
                // We got the old version
                uiNumArgs = usNumArgs;
        }
    }
#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;
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:51,代码来源:CLuaArguments.cpp

示例7: RestoreWorldModel

void CWorldRPCs::RestoreWorldModel(NetBitStreamInterface& bitStream)
{
    unsigned short usModel = 0;
    float          fRadius = 0.0f, fX = 0.0f, fY = 0.0f, fZ = 0.0f;
    char           cInterior = -1;
    if (bitStream.Read(usModel) && bitStream.Read(fRadius) && bitStream.Read(fX) && bitStream.Read(fY) && bitStream.Read(fZ))
    {
        if (bitStream.Version() >= 0x039)
        {
            bitStream.Read(cInterior);
        }
        g_pGame->GetWorld()->RestoreBuilding(usModel, fRadius, fX, fY, fZ, cInterior);
    }
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:14,代码来源:CWorldRPCs.cpp

示例8: Write

bool CVehicleResyncPacket::Write ( NetBitStreamInterface& BitStream ) const 
{
    if ( !m_pVehicle )
        return false;

    BitStream.Write ( m_pVehicle->GetID() );

    // Write vehicle position and rotation
    SPositionSync position ( false );
    position.data.vecPosition = m_pVehicle->GetPosition();
    BitStream.Write ( &position );

    SRotationDegreesSync rotation;
    m_pVehicle->GetRotationDegrees ( rotation.data.vecRotation );
    BitStream.Write ( &rotation );

    // Write the movespeed
    SVelocitySync velocity;
    velocity.data.vecVelocity = m_pVehicle->GetVelocity ();
    BitStream.Write ( &velocity );

    // Write the turnspeed
    SVelocitySync turnSpeed;
    turnSpeed.data.vecVelocity = m_pVehicle->GetTurnSpeed ();
    BitStream.Write ( &turnSpeed );

    // Write the vehicle health
    SVehicleHealthSync health;
    health.data.fValue = m_pVehicle->GetHealth ();
    BitStream.Write ( &health );

    // Write parts state
    if ( BitStream.Version() >= 0x5D )
    {
        SVehicleDamageSyncMethodeB damage;
        damage.data.bSyncDoors = true;
        damage.data.bSyncWheels = true;
        damage.data.bSyncPanels = true;
        damage.data.bSyncLights = true;
        damage.data.doors.data.ucStates = m_pVehicle->m_ucDoorStates;
        damage.data.wheels.data.ucStates = m_pVehicle->m_ucWheelStates;
        damage.data.panels.data.ucStates = m_pVehicle->m_ucPanelStates;
        damage.data.lights.data.ucStates = m_pVehicle->m_ucLightStates;
        BitStream.Write ( &damage );
    }

    return true;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:48,代码来源:CVehicleResyncPacket.cpp

示例9: SetObjectScale

void CObjectRPCs::SetObjectScale ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    CDeathmatchObject* pObject = static_cast < CDeathmatchObject* > ( m_pObjectManager->Get ( pSource->GetID () ) );
    if ( pObject )
    {
        CVector vecScale;
        
        bitStream.Read ( vecScale.fX );
        vecScale.fY = vecScale.fX;
        vecScale.fZ = vecScale.fX;
        if( bitStream.Version () >= 0x40 )
        {
             bitStream.Read ( vecScale.fY );
             bitStream.Read ( vecScale.fZ );
        }
        pObject->SetScale ( vecScale );
    }
}
开发者ID:ntauthority,项目名称:openvice,代码行数:18,代码来源:CObjectRPCs.cpp

示例10: WriteToBitStream

bool CLuaArguments::WriteToBitStream(NetBitStreamInterface& bitStream, CFastHashMap<CLuaArguments*, unsigned long>* pKnownTables) const
{
    bool bKnownTablesCreated = false;
    if (!pKnownTables)
    {
        pKnownTables = new CFastHashMap<CLuaArguments*, unsigned long>();
        bKnownTablesCreated = true;
    }

    bool bSuccess = true;
    pKnownTables->insert(make_pair((CLuaArguments*)this, pKnownTables->size()));

#if MTA_DM_VERSION >= 0x150
    bitStream.WriteCompressed(static_cast<unsigned int>(m_Arguments.size()));
#else
    if (bitStream.Version() < 0x05B)
        bitStream.WriteCompressed(static_cast<unsigned short>(m_Arguments.size()));
    else
        bitStream.WriteCompressed(static_cast<unsigned int>(m_Arguments.size()));
#endif

    vector<CLuaArgument*>::const_iterator iter = m_Arguments.begin();
    for (; iter != m_Arguments.end(); iter++)
    {
        CLuaArgument* pArgument = *iter;
        if (!pArgument->WriteToBitStream(bitStream, pKnownTables))
        {
            bSuccess = false;
        }
    }

    if (bKnownTablesCreated)
        delete pKnownTables;

    return bSuccess;
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:36,代码来源:CLuaArguments.cpp

示例11: WriteToBitStream

bool CLuaArgument::WriteToBitStream ( NetBitStreamInterface& bitStream, CFastHashMap < CLuaArguments*, unsigned long > * pKnownTables ) const
{
    SLuaTypeSync type;

    switch ( GetType () )
    {
        // Nil type
        case LUA_TNIL:
        {
            type.data.ucType = LUA_TNIL;
            bitStream.Write ( &type );
            break;
        }

        // Boolean type
        case LUA_TBOOLEAN:
        {
            type.data.ucType = LUA_TBOOLEAN;
            bitStream.Write ( &type );

            // Write the boolean to it
            bitStream.WriteBit ( GetBoolean () );
            break;
        }

        // Table argument
        case LUA_TTABLE:
        {
            ulong* pThingy;
            if ( pKnownTables && ( pThingy = MapFind ( *pKnownTables, m_pTableData ) ) )
            {
                // Self-referencing table
                type.data.ucType = LUA_TTABLEREF;
                bitStream.Write ( &type );
                bitStream.WriteCompressed ( *pThingy );
            }
            else
            {
                type.data.ucType = LUA_TTABLE;
                bitStream.Write ( &type );

                // Write the subtable to the bitstream
                m_pTableData->WriteToBitStream ( bitStream, pKnownTables );
            }
            break;
        }

        // Number argument?
        case LUA_TNUMBER:
        {
            type.data.ucType = LUA_TNUMBER;
            bitStream.Write ( &type );
            float fNumber = static_cast < float > ( GetNumber () );
            long lNumber = static_cast < long > ( fNumber );
            float fNumberInteger = static_cast < float > ( lNumber );

            // Check if the number is an integer and can fit a long datatype
            if ( fabs ( fNumber ) > fabs ( fNumberInteger + 1 ) ||
                 fabs ( fNumber - fNumberInteger ) >= FLOAT_EPSILON )
            {
                bitStream.WriteBit ( true );
                bitStream.Write ( fNumber );
            }
            else
            {
                bitStream.WriteBit ( false );
                bitStream.WriteCompressed ( lNumber );
            }
            break;
        }

        // String argument
        case LUA_TSTRING:
        {           
            // Grab the string and its length. Is it short enough to be sendable?
            const char* szTemp = m_strString.c_str ();
            size_t sizeTemp = m_strString.length ();
            unsigned short usLength = static_cast < unsigned short > ( sizeTemp );
            if ( sizeTemp == usLength )
            {
                // This is a string argument
                type.data.ucType = LUA_TSTRING;
                bitStream.Write ( &type );

                // Write its length
                bitStream.WriteCompressed ( usLength );

                // Write the content too if it's not empty
                if ( usLength > 0 )
                {
                    bitStream.Write ( szTemp, usLength );
                }
            }
            else
            if ( sizeTemp > 65535 && bitStream.Version () >= 0x027 && g_pGame->CalculateMinClientRequirement () >= LONG_STRING_MIN_VERSION )
            {
                // This is a long string argument
                type.data.ucType = LUA_TSTRING_LONG;
                bitStream.Write ( &type );

//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:openvice,代码行数:101,代码来源:CLuaArgument.cpp

示例12: SetWeaponProperty


//.........这里部分代码省略.........
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnimLoopStop(fData);
                break;
            }
            case WEAPON_ANIM_LOOP_RELEASE_BULLET_TIME:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnimLoopFireTime(fData);
                break;
            }

            case WEAPON_ANIM2_LOOP_START:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnim2LoopStart(fData);
                break;
            }
            case WEAPON_ANIM2_LOOP_STOP:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnim2LoopStop(fData);
                break;
            }
            case WEAPON_ANIM2_LOOP_RELEASE_BULLET_TIME:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnim2LoopFireTime(fData);
                break;
            }

            case WEAPON_ANIM_BREAKOUT_TIME:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnimBreakoutTime(fData);
                break;
            }
            case WEAPON_DAMAGE:
            {
                bitStream.Read(sData);
                pWeaponInfo->SetDamagePerHit(sData);
                break;
            }
            case WEAPON_MAX_CLIP_AMMO:
            {
                bitStream.Read(sData);
                pWeaponInfo->SetMaximumClipAmmo(sData);
                break;
            }
            case WEAPON_FLAGS:
            {
                int iData = 0;
                if (bitStream.Version() < 0x57)
                {
                    bitStream.Read(sData);
                    iData = sData;
                }
                else
                    bitStream.Read(iData);

                pWeaponInfo->ToggleFlagBits(iData);
                break;
            }
            case WEAPON_ANIM_GROUP:
            {
                bitStream.Read(sData);
                pWeaponInfo->SetAnimGroup(sData);
                break;
            }
            case WEAPON_FLAG_AIM_NO_AUTO:
            case WEAPON_FLAG_AIM_ARM:
            case WEAPON_FLAG_AIM_1ST_PERSON:
            case WEAPON_FLAG_AIM_FREE:
            case WEAPON_FLAG_MOVE_AND_AIM:
            case WEAPON_FLAG_MOVE_AND_SHOOT:
            case WEAPON_FLAG_TYPE_THROW:
            case WEAPON_FLAG_TYPE_HEAVY:
            case WEAPON_FLAG_TYPE_CONSTANT:
            case WEAPON_FLAG_TYPE_DUAL:
            case WEAPON_FLAG_ANIM_RELOAD:
            case WEAPON_FLAG_ANIM_CROUCH:
            case WEAPON_FLAG_ANIM_RELOAD_LOOP:
            case WEAPON_FLAG_ANIM_RELOAD_LONG:
            case WEAPON_FLAG_SHOT_SLOWS:
            case WEAPON_FLAG_SHOT_RAND_SPEED:
            case WEAPON_FLAG_SHOT_ANIM_ABRUPT:
            case WEAPON_FLAG_SHOT_EXPANDS:
            {
                bool bEnable;
                bitStream.ReadBit(bEnable);
                uint uiFlagBit = GetWeaponPropertyFlagBit((eWeaponProperty)ucProperty);
                if (bEnable)
                    pWeaponInfo->SetFlagBits(uiFlagBit);
                else
                    pWeaponInfo->ClearFlagBits(uiFlagBit);
                break;
            }
        }
    }
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:101,代码来源:CWorldRPCs.cpp

示例13: DoPulse

///////////////////////////////////////////////////////////////
//
// CLatentSendQueue::DoPulse
//
// Send next part of the active transfer
//
///////////////////////////////////////////////////////////////
void CLatentSendQueue::DoPulse ( int iTimeMsBetweenCalls )
{
    if ( m_TxQueue.empty () )
    {
        m_iBytesOwing = 0;
        return;
    }

    // Check if previous tx has completed
    if ( m_TxQueue.front ().uiReadPosition == m_TxQueue.front ().bufferRef->GetSize () && m_TxQueue.front ().bSendFinishing )
    {
        m_TxQueue.pop_front ();
        PostQueueRemove ();
        if ( m_TxQueue.empty () )
        {
            m_iBytesOwing = 0;
            return;
        }
    }

    m_uiCurrentRate = Max < uint > ( MIN_SEND_RATE, m_uiCurrentRate );

    // How many bytes to send this pulse
    int iBytesToSendThisPulse = iTimeMsBetweenCalls * m_uiCurrentRate / 1000;

    // Add bytes owing from last pulse
    iBytesToSendThisPulse += m_iBytesOwing;

    // Calc packet size depending on rate
    uint uiMaxPacketSize = Lerp ( MIN_PACKET_SIZE, UnlerpClamped ( MIN_PACKET_SIZE * 10, m_uiCurrentRate, MAX_PACKET_SIZE * 15 ), MAX_PACKET_SIZE );

    // Calc how many packets to do this pulse
    uint uiNumPackets = iBytesToSendThisPulse / uiMaxPacketSize;

    // Update carry over
    m_iBytesOwing = iBytesToSendThisPulse % uiMaxPacketSize;

    // Process item at front of queue
    SSendItem& activeTx = m_TxQueue.front ();
    for ( uint i = 0 ; i < uiNumPackets && !activeTx.bSendFinishing ; i++ )
    {
        // Send next part of data    
        NetBitStreamInterface* pBitStream = DoAllocateNetBitStream ( m_RemoteId, m_usBitStreamVersion );
        pBitStream->WriteBits ( &activeTx.uiId, 15 );

        // Next bit indicates if it has a special flag
        if ( activeTx.uiReadPosition == 0 )
        {
            // Head
            pBitStream->WriteBit ( 1 );
            pBitStream->Write ( (uchar)FLAG_HEAD );
            pBitStream->Write ( activeTx.usCategory );
            pBitStream->Write ( activeTx.bufferRef->GetSize () );
            pBitStream->Write ( activeTx.uiRate );
            if ( pBitStream->Version () >= 0x31 )
                pBitStream->Write ( activeTx.usResourceNetId );
            activeTx.bSendStarted = true;
        }
        else
        if ( activeTx.bufferRef->GetSize () == activeTx.uiReadPosition )
        {
            // Tail
            pBitStream->WriteBit ( 1 );
            pBitStream->Write ( (uchar)FLAG_TAIL );
            activeTx.bSendFinishing = true;
        }
        else
        {
            // Body
            pBitStream->WriteBit ( 0 );
        }

        // Align to next boundary
        pBitStream->AlignWriteToByteBoundary ();
        uint uiMaxDataSize = Max < int > ( 10, uiMaxPacketSize - pBitStream->GetNumberOfBytesUsed () );

        // Calc how much data to send
        uint uiDataOffset = activeTx.uiReadPosition;
        uint uiSizeToSend = Min ( uiMaxDataSize, activeTx.bufferRef->GetSize () - activeTx.uiReadPosition );
        activeTx.uiReadPosition += uiSizeToSend;

        pBitStream->Write ( (ushort)uiSizeToSend );
        pBitStream->Write ( activeTx.bufferRef->GetData () + uiDataOffset, uiSizeToSend );

        // Send
        DoSendPacket ( PACKET_ID_LATENT_TRANSFER, m_RemoteId, pBitStream, PACKET_PRIORITY_LOW, PACKET_RELIABILITY_RELIABLE_ORDERED, PACKET_ORDERING_DATA_TRANSFER );
        DoDeallocateNetBitStream ( pBitStream );
    }
}
开发者ID:0x688,项目名称:gtasa_crashfix,代码行数:96,代码来源:CLatentSendQueue.cpp

示例14: Write

bool CMapInfoPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Write the map weather
    BitStream.Write ( m_ucWeather );
    BitStream.Write ( m_ucWeatherBlendingTo );
    BitStream.Write ( m_ucBlendedWeatherHour );

    BitStream.WriteBit ( m_bHasSkyGradient );
    if ( m_bHasSkyGradient )
    {
        BitStream.Write ( m_ucSkyGradientTR );
        BitStream.Write ( m_ucSkyGradientTG );
        BitStream.Write ( m_ucSkyGradientTB );
        BitStream.Write ( m_ucSkyGradientBR );
        BitStream.Write ( m_ucSkyGradientBG );
        BitStream.Write ( m_ucSkyGradientBB );
    }

    // Write heat haze
    BitStream.WriteBit ( m_bHasHeatHaze );
    if ( m_bHasHeatHaze )
    {
        SHeatHazeSync heatHaze ( m_HeatHazeSettings );
        BitStream.Write ( &heatHaze );
    }

    // Write the map hour
    BitStream.Write ( m_ucClockHour );
    BitStream.Write ( m_ucClockMin );

    BitStream.WriteCompressed ( m_ulMinuteDuration );

    // Write the map flags
    SMapInfoFlagsSync flags;
    flags.data.bShowNametags  = m_bShowNametags;
    flags.data.bShowRadar     = m_bShowRadar;
    flags.data.bCloudsEnabled = m_bCloudsEnabled;
    BitStream.Write ( &flags );

    // Write any other world conditions
    BitStream.Write ( m_fGravity );
    if ( m_fGameSpeed == 1.0f )
        BitStream.WriteBit ( true );
    else
    {
        BitStream.WriteBit ( false );
        BitStream.Write ( m_fGameSpeed );
    }
    BitStream.Write ( m_fWaveHeight );
    // Write world water level
    BitStream.Write ( m_WorldWaterLevelInfo.fSeaLevel );
    BitStream.WriteBit ( m_WorldWaterLevelInfo.bNonSeaLevelSet );
    if ( m_WorldWaterLevelInfo.bNonSeaLevelSet )
        BitStream.Write ( m_WorldWaterLevelInfo.fNonSeaLevel );

    BitStream.WriteCompressed ( m_usFPSLimit );

    // Write the garage states
    for ( unsigned char i = 0 ; i < MAX_GARAGES ; i++ )
    {
        const SGarageStates& garageStates = *m_pGarageStates;
        BitStream.WriteBit( garageStates[i] );
    }

    // Write the fun bugs state
    SFunBugsStateSync funBugs;
    funBugs.data.bQuickReload = g_pGame->IsGlitchEnabled ( CGame::GLITCH_QUICKRELOAD );
    funBugs.data.bFastFire    = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTFIRE );
    funBugs.data.bFastMove    = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTMOVE );
    funBugs.data.bCrouchBug   = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CROUCHBUG );
    funBugs.data.bCloseRangeDamage = g_pGame->IsGlitchEnabled ( CGame::GLITCH_CLOSEDAMAGE );
    funBugs.data2.bHitAnim    = g_pGame->IsGlitchEnabled ( CGame::GLITCH_HITANIM );
    funBugs.data3.bFastSprint = g_pGame->IsGlitchEnabled ( CGame::GLITCH_FASTSPRINT );
    BitStream.Write ( &funBugs );

    BitStream.Write ( m_fJetpackMaxHeight );

    BitStream.WriteBit ( m_bOverrideWaterColor );
    if ( m_bOverrideWaterColor )
    {
        BitStream.Write ( m_ucWaterRed );
        BitStream.Write ( m_ucWaterGreen );
        BitStream.Write ( m_ucWaterBlue );
        BitStream.Write ( m_ucWaterAlpha );
    }

    // Interior sounds
    BitStream.WriteBit ( m_bInteriorSoundsEnabled );

    // Rain level
    BitStream.WriteBit ( m_bOverrideRainLevel );
    if ( m_bOverrideRainLevel )
    {
        BitStream.Write ( m_fRainLevel );
    }

    // Moon size
    if ( BitStream.Version () >= 0x40 )
    {
        BitStream.WriteBit ( m_bOverrideMoonSize );
//.........这里部分代码省略.........
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:101,代码来源:CMapInfoPacket.cpp

示例15: Write

bool CPlayerListPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // bool                  - show the "X has joined the game" messages?
    // [ following repeats <number of players joined> times ]
    // unsigned char  (1)    - assigned player id
    // unsigned char  (1)    - player nick length
    // unsigned char  (X)    - player nick (X = player nick length)
    // bool                  - is he dead?
    // bool                  - spawned? (following data only if this is TRUE)
    // unsigned char  (1)    - model id
    // unsigned char  (1)    - team id
    // bool                  - in a vehicle?
    // unsigned short (2)    - vehicle id (if vehicle)
    // unsigned char  (1)    - vehicle seat (if vehicle)
    // CVector        (12)   - position (if player)
    // float          (4)    - rotation (if player)
    // bool                  - has a jetpack?
    // unsigned short (2)    - dimension

    // Write the global flags
    BitStream.WriteBit ( m_bShowInChat );

    CPlayer* pPlayer = NULL;
    // Put each player in our list into the packet
    list < CPlayer* > ::const_iterator iter = m_List.begin ();
    for ( ; iter != m_List.end (); ++iter )
    {
        // Grab the real pointer
        pPlayer = *iter;

        // Write the player ID
        ElementID PlayerID = pPlayer->GetID ();
        BitStream.Write ( PlayerID );

        // Time sync context
        BitStream.Write ( pPlayer->GetSyncTimeContext () );

        // Write the nick length
        const char* szNickPointer = pPlayer->GetNick ();
        unsigned char ucNickLength = static_cast < unsigned char > ( strlen ( szNickPointer ) );
        if ( ucNickLength < MIN_NICK_LENGTH || ucNickLength > MAX_NICK_LENGTH )
        {
            BitStream.Write ( static_cast < unsigned char > ( 3 ) );
            BitStream.Write ( "???", 3 );
        }
        else
        {
            BitStream.Write ( ucNickLength );
            BitStream.Write ( szNickPointer, ucNickLength );
        }

        // Version info
        if ( BitStream.Version () >= 0x34 )
        {
            BitStream.Write ( pPlayer->GetBitStreamVersion () );
            SString strBuild = pPlayer->GetPlayerVersion ().SubStr ( 8 );
            uint uiBuildNumber = atoi ( strBuild );
            BitStream.Write ( uiBuildNumber );
        }

        // Flags
        bool bInVehicle = ( pPlayer->GetOccupiedVehicle () != NULL );
        BitStream.WriteBit ( pPlayer->IsDead () );  // Currently unused by the client
        BitStream.WriteBit ( true );                // (Was IsSpawned) Used by the client to determine if extra info was sent (in this packet)
        BitStream.WriteBit ( bInVehicle );
        BitStream.WriteBit ( pPlayer->HasJetPack () );
        BitStream.WriteBit ( pPlayer->IsNametagShowing () );
        BitStream.WriteBit ( pPlayer->IsNametagColorOverridden () );
        BitStream.WriteBit ( pPlayer->IsHeadless() );
        BitStream.WriteBit ( pPlayer->IsFrozen() );

        // Nametag stuff
        unsigned char ucNametagTextLength = 0;
        char* szNametagText = pPlayer->GetNametagText ();
        if ( szNametagText )
            ucNametagTextLength = static_cast < unsigned char > ( strlen ( szNametagText ) );

        BitStream.Write ( ucNametagTextLength );
        if ( ucNametagTextLength > 0 )
            BitStream.Write ( szNametagText, ucNametagTextLength );

        // Write nametag color if it's overridden
        if ( pPlayer->IsNametagColorOverridden () )
        {
            unsigned char ucR, ucG, ucB;
            pPlayer->GetNametagColor ( ucR, ucG, ucB );
            BitStream.Write ( ucR );
            BitStream.Write ( ucG );
            BitStream.Write ( ucB );
        }

        // Move anim
        if ( BitStream.Version() > 0x4B )
        {
            uchar ucMoveAnim = pPlayer->GetMoveAnim();
            BitStream.Write ( ucMoveAnim );
        }

        // Always send extra info (Was: "Write spawn info if he's spawned")
        if ( true )
//.........这里部分代码省略.........
开发者ID:Anubhav652,项目名称:mtasa-blue,代码行数:101,代码来源:CPlayerListPacket.cpp


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