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


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

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


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

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

示例2: ReadFromBitStream

bool CLuaArguments::ReadFromBitStream ( NetBitStreamInterface& bitStream, std::vector < CLuaArguments* > * pKnownTables )
{
    bool bKnownTablesCreated = false;
    if ( !pKnownTables )
    {
        pKnownTables = new std::vector < CLuaArguments* > ();
        bKnownTablesCreated = true;
    }

    unsigned short usNumArgs;
    if ( bitStream.ReadCompressed ( usNumArgs ) )
    {
        pKnownTables->push_back ( this );
        for ( unsigned short us = 0 ; us < usNumArgs ; us++ )
        {
		    CLuaArgument* pArgument = new CLuaArgument ( bitStream, pKnownTables );
            m_Arguments.push_back ( pArgument );
        }
	}

    if ( bKnownTablesCreated )
        delete pKnownTables;

    return true;
}
开发者ID:MrHankey,项目名称:multitheftauto,代码行数:25,代码来源:CLuaArguments.cpp

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

示例4: Read

bool CCustomDataPacket::Read(NetBitStreamInterface& BitStream)
{
    unsigned short usNameLength;
    if (BitStream.Read(m_ElementID) && BitStream.ReadCompressed(usNameLength) && usNameLength > 0 && usNameLength <= MAX_CUSTOMDATA_NAME_LENGTH)
    {
        m_szName = new char[usNameLength + 1];
        if (BitStream.Read(m_szName, usNameLength))
        {
            m_szName[usNameLength] = 0;
            if (m_Value.ReadFromBitStream(BitStream))
            {
                return true;
            }
        }
    }

    return false;
}
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:18,代码来源:CCustomDataPacket.cpp

示例5: RemoveElementData

void CElementRPCs::RemoveElementData ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    // Read out the name length
    unsigned short usNameLength;
    bool bRecursive;
    if ( bitStream.ReadCompressed ( usNameLength ) )
    {
        SString strName;

        // Read out the name plus whether it's recursive or not
        if ( bitStream.ReadStringCharacters ( strName, usNameLength ) &&
             bitStream.ReadBit ( bRecursive ) )
        {
            // Remove that name
            pSource->DeleteCustomData ( strName, bRecursive );
        }
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:18,代码来源:CElementRPCs.cpp

示例6: SetElementData

void CElementRPCs::SetElementData ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    unsigned short usNameLength;
    if ( bitStream.ReadCompressed ( usNameLength ) )
    {
        // We should never receive an illegal name length from the server
        if ( usNameLength > MAX_CUSTOMDATA_NAME_LENGTH )
        {
            CLogger::ErrorPrintf ( "RPC SetElementData name length > MAX_CUSTOMDATA_NAME_LENGTH" );
            return;
        }
        SString strName;
        CLuaArgument Argument;
        if ( bitStream.ReadStringCharacters ( strName, usNameLength ) && Argument.ReadFromBitStream ( bitStream ) )
        {
            pSource->SetCustomData ( strName, Argument, NULL );
        }
    }
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:19,代码来源:CElementRPCs.cpp

示例7: Read

bool CLuaEventPacket::Read(NetBitStreamInterface& BitStream)
{
    unsigned short usNameLength;
    if (BitStream.ReadCompressed(usNameLength))
    {
        if (usNameLength < (MAX_EVENT_NAME_LENGTH - 1) && BitStream.ReadStringCharacters(m_strName, usNameLength) && BitStream.Read(m_ElementID))
        {
            // Faster than using a constructor
            m_ArgumentsStore.DeleteArguments();
            if(!m_ArgumentsStore.ReadFromBitStream(BitStream))
                return false;
            m_pArguments = &m_ArgumentsStore;

            return true;
        }
    }

    return false;
}
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:19,代码来源:CLuaEventPacket.cpp

示例8: ReadFromBitStream

bool CLuaArgument::ReadFromBitStream ( NetBitStreamInterface& bitStream, std::vector < CLuaArguments* > * pKnownTables )
{
    DeleteTableData ();
    SLuaTypeSync type;

    // Read out the type
    if ( bitStream.Read ( &type ) )
    {
        // Depending on what type...
        switch ( type.data.ucType )
        {
            // Nil type
            case LUA_TNIL:
            {
                m_iType = LUA_TNIL;
                break;
            }

            // Boolean type
            case LUA_TBOOLEAN:
            {
                bool bValue;
                if ( bitStream.ReadBit ( bValue ) )
                    ReadBool ( bValue );
                break;
            }

            // Number type
            case LUA_TNUMBER:
            {
                bool bIsFloatingPoint;
                if ( bitStream.ReadBit ( bIsFloatingPoint ) && bIsFloatingPoint )
                {
                    float fNum;
                    if ( bitStream.Read ( fNum ) )
                        ReadNumber ( fNum );
                }
                else
                {
                    long lNum;
                    if ( bitStream.ReadCompressed ( lNum ) )
                        ReadNumber ( lNum );
                }
                break;
            }

            // Table type
            case LUA_TTABLE:
            {
                m_pTableData = new CLuaArguments ( bitStream, pKnownTables );
                m_bWeakTableRef = false;
                m_iType = LUA_TTABLE;
                m_pTableData->ValidateTableKeys ();
                break;
            }

            // Table reference
            case LUA_TTABLEREF:
            {
                unsigned long ulTableRef;
                if ( bitStream.ReadCompressed ( ulTableRef ) )
                {
                    if ( pKnownTables && ulTableRef < pKnownTables->size () )
                    {
                        m_pTableData = pKnownTables->at ( ulTableRef );
                        m_bWeakTableRef = true;
                        m_iType = LUA_TTABLE;
                    }
                }
                break;
            }

            // String type
            case LUA_TSTRING:
            {
                // Read out the string length
                unsigned short usLength;
                if ( bitStream.ReadCompressed ( usLength ) && usLength )
                {
                    // Allocate a buffer and read the string into it
                    char* szValue = new char [ usLength + 1 ];
                    if ( bitStream.Read ( szValue, usLength ) )
                    {
                        // Put it into us
                        ReadString ( std::string ( szValue, usLength ) );
                    }

                    // Delete the buffer
                    delete [] szValue;
                }
                else
                    ReadString ( "" );

                break;
            }

            // Long string type
            case LUA_TSTRING_LONG:
            {
                // Read out the string length
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:openvice,代码行数:101,代码来源:CLuaArgument.cpp

示例9: ReadFromBitStream

// Can't use bitStream.Version() here as it is sometimes not set
bool CLuaArgument::ReadFromBitStream(NetBitStreamInterface& bitStream, std::vector<CLuaArguments*>* pKnownTables)
{
    DeleteTableData();
    SLuaTypeSync type;

    // Read out the type
    if (bitStream.Read(&type))
    {
        // Depending on what type...
        switch (type.data.ucType)
        {
            // Nil type
            case LUA_TNIL:
            {
                m_iType = LUA_TNIL;
                break;
            }

            // Boolean type
            case LUA_TBOOLEAN:
            {
                bool bValue;
                if (bitStream.ReadBit(bValue))
                    ReadBool(bValue);
                break;
            }

            // Number type
            case LUA_TNUMBER:
            {
                if (bitStream.ReadBit())
                {
                    if (bitStream.ReadBit())
                    {
                        double dNum;
                        if (bitStream.Read(dNum))
                            ReadNumber(dNum);
                    }
                    else
                    {
                        float fNum;
                        if (bitStream.Read(fNum))
                            ReadNumber(RoundFromFloatSource(fNum));
                    }
                }
                else
                {
                    int iNum;
                    if (bitStream.ReadCompressed(iNum))
                        ReadNumber(iNum);
                }
                break;
            }

            // Table type
            case LUA_TTABLE:
            {
                m_pTableData = new CLuaArguments(bitStream, pKnownTables);
                m_bWeakTableRef = false;
                m_iType = LUA_TTABLE;
                m_pTableData->ValidateTableKeys();
                break;
            }

            // Table reference
            case LUA_TTABLEREF:
            {
                unsigned long ulTableRef;
                if (bitStream.ReadCompressed(ulTableRef))
                {
                    if (pKnownTables && ulTableRef < pKnownTables->size())
                    {
                        m_pTableData = pKnownTables->at(ulTableRef);
                        m_bWeakTableRef = true;
                        m_iType = LUA_TTABLE;
                    }
                }
                break;
            }

            // String type
            case LUA_TSTRING:
            {
                // Read out the string length
                unsigned short usLength;
                if (bitStream.ReadCompressed(usLength) && usLength)
                {
                    // Allocate a buffer and read the string into it
                    char* szValue = new char[usLength + 1];
                    if (bitStream.Read(szValue, usLength))
                    {
                        // Put it into us
                        ReadString(std::string(szValue, usLength));
                    }

                    // Delete the buffer
                    delete[] szValue;
                }
                else
//.........这里部分代码省略.........
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:101,代码来源:CLuaArgument.cpp

示例10: ReadFromBitStream

bool CLuaArgument::ReadFromBitStream ( NetBitStreamInterface& bitStream, std::vector < CLuaArguments* > * pKnownTables )
{
    DeleteTableData ();
    SLuaTypeSync type;

    // Read out the type
	if ( bitStream.Read ( &type ) )
	{
        // Depending on what type...
		switch ( type.data.ucType )
		{
            // Nil type
            case LUA_TNIL:
            {
                m_iType = LUA_TNIL;
                break;
            }

            // Boolean type
			case LUA_TBOOLEAN:
			{
				bool bValue;
				if ( bitStream.ReadBit ( bValue ) )
					Read(bValue);
				break;
			}

            // Number type
			case LUA_TNUMBER:
			{
                bool bIsFloatingPoint;
                if ( bitStream.ReadBit ( bIsFloatingPoint ) && bIsFloatingPoint )
                {
                    float fNum;
                    if ( bitStream.Read ( fNum ) )
                        Read ( (double) fNum );
                }
                else
                {
                    long lNum;
                    if ( bitStream.ReadCompressed ( lNum ) )
                        Read ( (double) lNum );
                }
				break;
			}

            // Table type
            case LUA_TTABLE:
            {
                m_pTableData = new CLuaArguments ( bitStream, pKnownTables );
                m_bWeakTableRef = false;
                m_iType = LUA_TTABLE;
                break;
            }

            // Table reference
            case LUA_TTABLEREF:
            {
                unsigned long ulTableRef;
                if ( bitStream.ReadCompressed ( ulTableRef ) )
                {
                    if ( pKnownTables && ulTableRef < pKnownTables->size () )
                    {
                        m_pTableData = pKnownTables->at ( ulTableRef );
                        m_bWeakTableRef = true;
                        m_iType = LUA_TTABLE;
                    }
                }
                break;
            }

            // String type
			case LUA_TSTRING:
			{
                // Read out the string length
				unsigned short usLength;
				if ( bitStream.ReadCompressed ( usLength ) && usLength )
				{
                    // Allocate a buffer and read the string into it
                    char* szValue = new char [ usLength + 1 ];
                    if ( bitStream.Read ( szValue, usLength ) )
                    {
                        // Put it into us
                        szValue [ usLength ] = 0;
						Read ( szValue );
                    }

                    // Delete the buffer
                    delete [] szValue;
				}
				else
					Read ( "" );

				break;
			}

            // Element type?
			case LUA_TLIGHTUSERDATA:
			{
				ElementID ElementID;
//.........这里部分代码省略.........
开发者ID:50p,项目名称:multitheftauto,代码行数:101,代码来源:CLuaArgument.cpp

示例11: Read


//.........这里部分代码省略.........
                // Health
                SVehicleHealthSync health;
                if ( !BitStream.Read ( &health ) )
                    return false;
                float fPreviousHealth = pVehicle->GetHealth ();                
                float fHealth = health.data.fValue;

                // Less than last time?
                if ( fHealth < fPreviousHealth )
                {                 
                    // Grab the delta health
                    float fDeltaHealth = fPreviousHealth - fHealth;

					if ( fDeltaHealth > 0.0f )
					{
						// Call the onVehicleDamage event
						CLuaArguments Arguments;
						Arguments.PushNumber ( fDeltaHealth );
						pVehicle->CallEvent ( "onVehicleDamage", Arguments );
					}
                }
                pVehicle->SetHealth ( fHealth );

                // Trailer chain
                CVehicle* pTowedByVehicle = pVehicle;
                CVehicle* pTrailer = NULL;
                ElementID TrailerID;
                bool bHasTrailer;
                if ( !BitStream.ReadBit ( bHasTrailer ) )
                    return false;

                while ( bHasTrailer )
                {
                    BitStream.ReadCompressed ( TrailerID );
                    CElement* pElement = CElementIDs::GetElement ( TrailerID );
                    if ( pElement )
                        pTrailer = static_cast < CVehicle* > ( pElement );
                    
                    // Read out the trailer position and rotation
                    SPositionSync trailerPosition ( false );
                    if ( !BitStream.Read ( &trailerPosition ) )
                        return false;

                    SRotationDegreesSync trailerRotation;
                    if ( !BitStream.Read ( &trailerRotation ) )
                        return false;

                    // If we found the trailer
                    if ( pTrailer )
                    {
                        // Set its position and rotation
                        pTrailer->SetPosition ( trailerPosition.data.vecPosition );
                        pTrailer->SetRotationDegrees ( trailerRotation.data.vecRotation );
    
                        // Is this a new trailer, attached?
                        CVehicle* pCurrentTrailer = pTowedByVehicle->GetTowedVehicle ();
                        if ( pCurrentTrailer != pTrailer )
                        {
                            // If theres a trailer already attached
                            if ( pCurrentTrailer )
                            {
                                pTowedByVehicle->SetTowedVehicle ( NULL );
                                pCurrentTrailer->SetTowedByVehicle ( NULL );

                                // Tell everyone to detach them
                                CVehicleTrailerPacket AttachPacket ( pTowedByVehicle, pCurrentTrailer, false );
开发者ID:50p,项目名称:multitheftauto,代码行数:67,代码来源:CVehiclePuresyncPacket.cpp


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