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


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

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


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

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

示例2: Read

bool CPlayerModInfoPacket::Read ( NetBitStreamInterface& BitStream )
{
    // Read type
    if ( !BitStream.ReadString ( m_strInfoType ) )
        return false;

    // Read amount of items
    uint uiCount;
    if ( !BitStream.Read ( uiCount ) )
        return false;

    // Read each item
    for ( uint i = 0 ; i < uiCount ; i++ )
    {
        SModInfoItem item;

        if ( !BitStream.Read ( item.usId ) )
            return false;

        if ( !BitStream.Read ( item.uiHash ) )
            return false;

        if ( !BitStream.ReadString ( item.strName ) )
            return false;

        int iHasSize;
        if ( !BitStream.Read ( iHasSize ) )
            return false;
        item.bHasSize = iHasSize != 0;

        if ( !BitStream.Read ( item.vecSize.fX ) )
            return false;

        if ( !BitStream.Read ( item.vecSize.fY ) )
            return false;

        if ( !BitStream.Read ( item.vecSize.fZ ) )
            return false;

        m_ModInfoItemList.push_back ( item );
    }

    return true;
}
开发者ID:EagleShen,项目名称:MTA,代码行数:44,代码来源:CPlayerModInfoPacket.cpp

示例3: StaticProcessPacket

bool CConnectManager::StaticProcessPacket ( unsigned char ucPacketID, NetBitStreamInterface& BitStream )
{
    // We're working on connecting?
    if ( g_pConnectManager->m_bIsConnecting )
    {
        g_pConnectManager->OnServerExists ();

        // The packet we're expecting?
        if ( ucPacketID == PACKET_ID_MOD_NAME )
        {
            // Read packet data
            unsigned short usServerBitStreamVersion = 0x01;
            BitStream.Read ( usServerBitStreamVersion );

            SString strModName;
            BitStream.ReadString ( strModName );

            // Process packet data
            CCore::GetSingleton ().GetNetwork ()->SetServerBitStreamVersion ( usServerBitStreamVersion );

            if ( strModName != "" )
            {
                // Populate the arguments to pass it (-c host port nick)
                SString strArguments ( "%s %s", g_pConnectManager->m_strNick.c_str(), g_pConnectManager->m_strPassword.c_str() );

                // Hide the messagebox we're currently showing
                CCore::GetSingleton ().RemoveMessageBox ();

                // If we connected from quick-connect, get rid of it
                CQuickConnect * pQuickConnect = CCore::GetSingleton ().GetLocalGUI ()->GetMainMenu ()->GetQuickConnectWindow ();
                if ( pQuickConnect->IsVisible () )
                    pQuickConnect->SetVisible ( false );

                // Save the connection details into the config
                if ( g_pConnectManager->m_bSave )
                {
                    CVARS_SET ( "host",     g_pConnectManager->m_strHost );
                    CVARS_SET ( "port",     g_pConnectManager->m_usPort );
                    CVARS_SET ( "password", g_pConnectManager->m_strPassword );

                }

                //Set the current server info and Add the ASE Offset to the Query port)
                CCore::GetSingleton().SetCurrentServer ( g_pConnectManager->m_Address, g_pConnectManager->m_usPort );

                SetApplicationSettingInt ( "last-server-ip", g_pConnectManager->m_Address.s_addr );
                SetApplicationSettingInt ( "last-server-port", g_pConnectManager->m_usPort );
                SetApplicationSettingInt ( "last-server-time", _time32 ( NULL ) );

                // Kevuwk: Forced the config to save here so that the IP/Port isn't lost on crash
                CCore::GetSingleton ().SaveConfig ();

                // Reset our variables
                g_pConnectManager->m_strNick = "";
                g_pConnectManager->m_strHost = "";
                g_pConnectManager->m_strPassword = "";

                g_pConnectManager->m_Address.s_addr = 0;
                g_pConnectManager->m_usPort = 0;
                g_pConnectManager->m_bIsConnecting = false;
                g_pConnectManager->m_bIsDetectingVersion = false;
                g_pConnectManager->m_tConnectStarted = 0;

                // Load the mod
                if ( !CModManager::GetSingleton ().Load ( strModName, strArguments ) )
                {
                    // Failed loading the mod
                    strArguments.Format ( _("No such mod installed (%s)"), strModName.c_str() );
                    CCore::GetSingleton ().ShowMessageBox ( _("Error")+_E("CC31"), strArguments, MB_BUTTON_OK | MB_ICON_ERROR ); // Mod loading failed
                    g_pConnectManager->Abort ();
                }
            }
            else
            {
                // Show failed message and abort the attempt
                CCore::GetSingleton ().ShowNetErrorMessageBox ( _("Error")+_E("CC32"), _("Bad server response (2)") );
                g_pConnectManager->Abort ();
            }
        }
        else
        {
            // Not the player joined packet?
            if ( ucPacketID != PACKET_ID_SERVER_JOIN && ucPacketID != PACKET_ID_SERVER_JOIN_DATA )
            {
                // Show failed message and abort the attempt
                CCore::GetSingleton ().ShowNetErrorMessageBox ( _("Error")+_E("CC33"), _("Bad server response (1)") );
                g_pConnectManager->Abort ();
            }
        }

        return true;
    }

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

示例4: Read

bool CPlayerScreenShotPacket::Read ( NetBitStreamInterface& BitStream )
{
    m_pResource = NULL;

    CPlayer* pPlayer = GetSourcePlayer ();
    if ( !pPlayer )
        return false;

    bool bHasGrabTime = false;
    uint uiServerGrabTime;

    // Read status
    BitStream.Read ( m_ucStatus );

    if ( m_ucStatus != EPlayerScreenShotResult::SUCCESS )
    {
        // minimized, disabled or error
        bHasGrabTime = true;
        BitStream.Read ( uiServerGrabTime );
        if ( BitStream.Version() >= 0x053 )
        {
            ushort usResourceNetId;
            BitStream.Read ( usResourceNetId );
            m_pResource = g_pGame->GetResourceManager ()->GetResourceFromNetID ( usResourceNetId );
        }
        else
        {
            SString strResourceName;
            BitStream.ReadString ( strResourceName );
            m_pResource = g_pGame->GetResourceManager ()->GetResource ( strResourceName );
        }

        if ( !BitStream.ReadString ( m_strTag ) )
            return false;

        if ( BitStream.Version() >= 0x53 )
            BitStream.ReadString ( m_strError );
    }
    else
    if ( m_ucStatus == EPlayerScreenShotResult::SUCCESS )
    {
        // Read info
        BitStream.Read ( m_usScreenShotId );
        BitStream.Read ( m_usPartNumber );

        // Read data
        ushort usNumBytes = 0;
        if ( !BitStream.Read ( usNumBytes ) )
            return false;

        m_buffer.SetSize ( usNumBytes );
        if ( !BitStream.Read ( m_buffer.GetData (), m_buffer.GetSize () ) )
            return false;

        // Read more info if first part
        if ( m_usPartNumber == 0 )
        {
            bHasGrabTime = true;
            BitStream.Read ( uiServerGrabTime );
            BitStream.Read ( m_uiTotalBytes );
            BitStream.Read ( m_usTotalParts );
            if ( BitStream.Version() >= 0x053 )
            {
                ushort usResourceNetId;
                BitStream.Read ( usResourceNetId );
                m_pResource = g_pGame->GetResourceManager ()->GetResourceFromNetID ( usResourceNetId );
            }
            else
            {
                SString strResourceName;
                BitStream.ReadString ( strResourceName );
                m_pResource = g_pGame->GetResourceManager ()->GetResource ( strResourceName );
            }
            if ( !BitStream.ReadString ( m_strTag ) )
                return false;
        }
    }

    // Fixup grab time
    if ( bHasGrabTime )
    {
        uiServerGrabTime += pPlayer->GetPing () / 2;
        uint uiTimeSinceGrab = GetTickCount32 () - uiServerGrabTime;
        m_llServerGrabTime = GetTickCount64_ () - uiTimeSinceGrab;
    }

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

示例5: SetElementName

void CElementRPCs::SetElementName ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    SString strName;
    if ( bitStream.ReadString ( strName ) )
        pSource->SetName ( strName );
}
开发者ID:Bargas,项目名称:mtasa-blue,代码行数:6,代码来源:CElementRPCs.cpp

示例6: Read

bool CPlayerTransgressionPacket::Read ( NetBitStreamInterface& BitStream )
{
    return BitStream.Read ( m_uiLevel ) &&
            BitStream.ReadString ( m_strMessage );
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:5,代码来源:CPlayerTransgressionPacket.cpp


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