Esempio n. 1
0
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 );        
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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;
}
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;
}
Esempio n. 5
0
void CElementRPCs::SetElementName ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    SString strName;
    if ( bitStream.ReadString ( strName ) )
        pSource->SetName ( strName );
}
bool CPlayerTransgressionPacket::Read ( NetBitStreamInterface& BitStream )
{
    return BitStream.Read ( m_uiLevel ) &&
            BitStream.ReadString ( m_strMessage );
}