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


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

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


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

示例1: ReadFromBitStream


//.........这里部分代码省略.........
                {
                    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
                    ReadString("");

                break;
            }

            // Long string type
            case LUA_TSTRING_LONG:
            {
                // Read out the string length
                uint uiLength;
                if (bitStream.ReadCompressed(uiLength) && uiLength)
                {
                    bitStream.AlignReadToByteBoundary();

                    // Allocate a buffer and read the string into it
                    char* szValue = new char[uiLength + 1];
                    assert(szValue);
                    if (bitStream.Read(szValue, uiLength))
                    {
                        // Put it into us
                        ReadString(std::string(szValue, uiLength));
                    }

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

                break;
            }

            // Element type?
            case LUA_TLIGHTUSERDATA:
            case LUA_TUSERDATA:
            {
                ElementID ElementID;
                if (bitStream.Read(ElementID))
                {
                    ReadElementID(ElementID);
                }
                break;
            }
        }
    }
    return true;
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:101,代码来源:CLuaArgument.cpp

示例2: ReadFromBitStream


//.........这里部分代码省略.........
            // 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
                uint uiLength;
                if ( bitStream.ReadCompressed ( uiLength ) && uiLength )
                {
                    bitStream.AlignReadToByteBoundary ();

                    // Allocate a buffer and read the string into it
                    char* szValue = new char [ uiLength + 1 ];
                    assert ( szValue );
                    if ( bitStream.Read ( szValue, uiLength ) )
                    {
                        // Put it into us
                        ReadString ( std::string ( szValue, uiLength ) );
                    }

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

                // Enforce min_mta_version version rule
                if ( uiLength > 65535 && g_pGame->CalculateMinClientRequirement () < LONG_STRING_MIN_VERSION )
                {
                    LogUnableToPacketize ( "#### Couldn't packetize argument list. Invalid string specified, limit is 65535 characters."
                                           " To use longer strings, set script <min_mta_version> to " LONG_STRING_MIN_VERSION " or higher." );
                    m_iType = LUA_TNIL;
                }

                break;
            }

            // Element type?
            case LUA_TLIGHTUSERDATA:
            {
                ElementID ElementID;
                if ( bitStream.Read ( ElementID ) )
                {
                    CElement * element = CElementIDs::GetElement ( ElementID );
                    ReadElement ( element );
                }
                break;
            }
        }
    }
    return true;
}
开发者ID:pombredanne,项目名称:openvice,代码行数:101,代码来源:CLuaArgument.cpp


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