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


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

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


在下文中一共展示了NetBitStreamInterface::Write方法的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: WriteVehicleSpecific

void CVehiclePuresyncPacket::WriteVehicleSpecific ( CVehicle* pVehicle, NetBitStreamInterface& BitStream ) const
{
    // Turret states
    unsigned short usModel = pVehicle->GetModel ();
    if ( CVehicleManager::HasTurret ( usModel ) )
    {
        SVehicleTurretSync vehicle;
        pVehicle->GetTurretPosition ( vehicle.data.fTurretX, vehicle.data.fTurretY );

        BitStream.Write ( &vehicle );
    }

    // Adjustable property value
    if ( CVehicleManager::HasAdjustableProperty ( usModel ) )
    {
        BitStream.Write ( pVehicle->GetAdjustableProperty () );
    }

    // Door angles.
    if ( CVehicleManager::HasDoors ( usModel ) )
    {
        SDoorOpenRatioSync door;
        for ( unsigned int i = 2; i < 6; ++i )
        {
            door.data.fRatio = pVehicle->GetDoorOpenRatio ( i );
            BitStream.Write ( &door );
        }
    }
}
开发者ID:EagleShen,项目名称:MTA,代码行数:29,代码来源:CVehiclePuresyncPacket.cpp

示例3: Write

bool CPlayerStatsPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Write the source player.
    if ( m_pSourceElement )
    {
        ElementID ID = m_pSourceElement->GetID ();
        BitStream.Write ( ID );

        // Write the stats
        unsigned short usNumStats = static_cast < unsigned short  >( m_List.size () );
        BitStream.WriteCompressed ( usNumStats );

        map < unsigned short, sPlayerStat > ::const_iterator iter = m_List.begin ();
        for ( ; iter != m_List.end () ; ++iter )
        {
            const sPlayerStat& playerStat = (*iter).second;
            BitStream.Write ( playerStat.id );
            BitStream.Write ( playerStat.value );
        }

        return true;
    }

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

示例4: Write

bool CUpdateInfoPacket::Write(NetBitStreamInterface& BitStream) const
{
    BitStream.Write((unsigned short)m_strType.length());
    BitStream.Write(m_strType.c_str(), m_strType.length());

    BitStream.Write((unsigned short)m_strData.length());
    BitStream.Write(m_strData.c_str(), m_strData.length());

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

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

示例6: Write

bool CObjectSyncPacket::Write(NetBitStreamInterface& BitStream) const
{
    bool                              bSent = false;
    vector<SyncData*>::const_iterator iter = m_Syncs.begin();
    // Write syncs
    for (; iter != m_Syncs.end(); ++iter)
    {
        SyncData* pData = *iter;
        // If we're not supposed to ignore the packet
        if (pData->bSend)
        {
            // Write the ID
            BitStream.Write(pData->ID);

            // Write the sync time context
            BitStream.Write(pData->ucSyncTimeContext);

            // Write flags
            SIntegerSync<unsigned char, 3> flags(pData->ucFlags);
            BitStream.Write(&flags);

            // Write position if we need
            if (flags & 0x1)
            {
                SPositionSync position;
                position.data.vecPosition = pData->vecPosition;
                BitStream.Write(&position);
            }

            // Write rotation
            if (flags & 0x2)
            {
                SRotationRadiansSync rotation;
                rotation.data.vecRotation = pData->vecRotation;
                BitStream.Write(&rotation);
            }

            // Write health
            if (flags & 0x4)
            {
                SObjectHealthSync health;
                health.data.fValue = pData->fHealth;
            }

            // We've sent atleast one sync
            bSent = true;
        }
    }

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

示例7: Write

bool CPlayerChangeNickPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    if ( m_pSourceElement )
    {
        // Write the source player id
        ElementID ID = m_pSourceElement->GetID ();
        BitStream.Write ( ID );

        // Write the nick
        BitStream.Write ( const_cast < char* > ( m_szNewNick ), strlen ( m_szNewNick ) );
        return true;
    }
    
    return false;
}
开发者ID:EagleShen,项目名称:MTA,代码行数:15,代码来源:CPlayerChangeNickPacket.cpp

示例8: Write

bool CVoiceDataPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    if ( m_usActualDataLength )
    {
            // Write the source player
            ElementID ID = m_pSourceElement->GetID();
            BitStream.Write ( ID );
            // Write the length as an unsigned short and then write the string
            BitStream.Write ( m_usActualDataLength );
            BitStream.Write ( reinterpret_cast < const char * > ( m_pBuffer ), m_usActualDataLength );
            return true;
    }

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

示例9: Write

bool CVehicleDamageSyncPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    BitStream.Write ( m_Vehicle );
    BitStream.Write ( &m_damage );

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

示例10: COMMAND_Executed

bool COMMAND_Executed ( const char* szCommand, const char* szArguments, bool bHandleRemotely, bool bHandled )
{
    // Has the core already handled this command?
    if ( !bHandled )
    {
        //char szBuffer [256];
        const char* szCommandBufferPointer = szCommand;

        if ( !bHandleRemotely )
        {
            // Is the command "say" and the arguments start with '/' ? (command comes from the chatbox)
            if ( stricmp ( szCommand, "chatboxsay" ) == 0 )
                szCommandBufferPointer = "say";
        }

        // Toss them together so we can send it to the server
        SString strClumpedCommand;
        if ( szArguments && szArguments [ 0 ] )
            strClumpedCommand.Format ( "%s %s", szCommandBufferPointer, szArguments );
        else
            strClumpedCommand = szCommandBufferPointer;

        // Convert to Unicode, and clamp it to a maximum command length
        std::wstring strClumpedCommandUTF = MbUTF8ToUTF16(strClumpedCommand.c_str());
        strClumpedCommandUTF = strClumpedCommandUTF.substr(0,MAX_COMMAND_LENGTH);
        strClumpedCommand = UTF16ToMbUTF8(strClumpedCommandUTF);

        luaexecute( szCommandBufferPointer, szArguments );

        // Call the event on the local player's onClientConsole first
        if ( g_pClientGame->GetLocalPlayer() )
        {
            lua_State *L = g_pClientGame->GetLuaManager()->GetVirtualMachine();
            lua_pushlstring( L, strClumpedCommand.c_str(), strClumpedCommand.size() );
            g_pClientGame->GetLocalPlayer()->CallEvent( "onClientConsole", L, 1 );
        }

        // Write the chatlength and the content
        NetBitStreamInterface* pBitStream = g_pNet->AllocateNetBitStream ();
        if ( !pBitStream ) 
            return false;

        // Write it to the bitstream
        pBitStream->Write ( strClumpedCommand.c_str(), static_cast < int > ( strlen ( strClumpedCommand.c_str() ) ) );

        // Send the packet to the server and free it
        g_pNet->SendPacket ( PACKET_ID_COMMAND, pBitStream, PACKET_PRIORITY_MEDIUM, PACKET_RELIABILITY_RELIABLE, PACKET_ORDERING_CHAT );
        g_pNet->DeallocateNetBitStream ( pBitStream );

        return true;
    }
    else
    {
        // Call our comand-handlers for core-executed commands too
        luaexecute( szCommand, szArguments );
    }
    return false;
}
开发者ID:qaisjp,项目名称:green-candy,代码行数:58,代码来源:ClientCommands.cpp

示例11: Write

bool CPlayerClothesPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Write the source player.
    if ( m_pSourceElement )
    {
        ElementID ID = m_pSourceElement->GetID ();
        BitStream.Write ( ID );

        // Write the clothes
        unsigned short usNumClothes = static_cast < unsigned short > ( m_List.size () );
        BitStream.Write ( usNumClothes );

        vector < SPlayerClothes* > ::const_iterator iter = m_List.begin ();
        for ( ; iter != m_List.end () ; ++iter )
        {
            char* szTexture = (*iter)->szTexture;
            char* szModel = (*iter)->szModel;
            unsigned char ucTextureLength = strlen ( szTexture );
            unsigned char ucModelLength = strlen ( szModel );
            BitStream.Write ( ucTextureLength );
            BitStream.Write ( szTexture, ucTextureLength );
            BitStream.Write ( ucModelLength );
            BitStream.Write ( szModel, ucModelLength );
            BitStream.Write ( (*iter)->ucType );
        }

        return true;
    }

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

示例12: Write

//
// Should do the same this as what CPedTaskPacket::Write() does
//
bool CSimPedTaskPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    // Write the source player id
    BitStream.Write ( m_PlayerID );

    // Write packet data
    BitStream.WriteBits( m_Cache.DataBuffer, m_Cache.uiNumBitsInPacketBody );
    return true;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:12,代码来源:CSimPedTaskPacket.cpp

示例13: WriteVehicleSpecific

void CVehiclePuresyncPacket::WriteVehicleSpecific ( CVehicle* pVehicle, NetBitStreamInterface& BitStream ) const
{
    // Turret states
    unsigned short usModel = pVehicle->GetModel ();
    if ( CVehicleManager::HasTurret ( usModel ) )
    {
        SVehicleSpecific vehicle;
        pVehicle->GetTurretPosition ( vehicle.data.fTurretX, vehicle.data.fTurretY );

        BitStream.Write ( &vehicle );
    }

    // Adjustable property value
    if ( CVehicleManager::HasAdjustableProperty ( usModel ) )
    {
        BitStream.Write ( pVehicle->GetAdjustableProperty () );
    }
}
开发者ID:50p,项目名称:multitheftauto,代码行数:18,代码来源:CVehiclePuresyncPacket.cpp

示例14: Write

bool CPlayerSpawnPacket::Write ( NetBitStreamInterface& BitStream ) const
{
    BitStream.Write ( m_PlayerID );

    // No flags atm
    BitStream.Write ( static_cast < unsigned char > ( 0 ) );

    BitStream.Write ( m_vecSpawnPosition.fX );
    BitStream.Write ( m_vecSpawnPosition.fY );
    BitStream.Write ( m_vecSpawnPosition.fZ );
    BitStream.Write ( m_fSpawnRotation );
    BitStream.Write ( m_usPlayerSkin );
    BitStream.Write ( m_ucInterior );
    BitStream.Write ( m_usDimension );
    BitStream.Write ( m_Team );
    BitStream.Write ( m_ucTimeContext );

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

示例15: Write

bool CLuaEventPacket::Write(NetBitStreamInterface& BitStream) const
{
    unsigned short usNameLength = static_cast<unsigned short>(m_strName.length());
    BitStream.WriteCompressed(usNameLength);
    BitStream.WriteStringCharacters(m_strName, usNameLength);
    BitStream.Write(m_ElementID);
    m_pArguments->WriteToBitStream(BitStream);

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


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