PlayMan86 / gproxyplusplus

Automatically exported from code.google.com/p/gproxyplusplus
0 stars 0 forks source link

A bug in W3GS_INCOMING_ACTION handler #7

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
take a look at the code blow:

else if( Packet->GetID( ) == CGameProtocol :: W3GS_INCOMING_ACTION )
{
    if( m_GameIsReliable )
    {
        // we received a game update which means we can reset the number of empty actions we have to work with
        // we also must send any remaining empty actions now
        // note: the lag screen can't be up right now otherwise the server made a big mistake, so we don't need to check for it

        BYTEARRAY EmptyAction;
        EmptyAction.push_back( 0xF7 );
        EmptyAction.push_back( 0x0C );
        EmptyAction.push_back( 0x06 );
        EmptyAction.push_back( 0x00 );
        EmptyAction.push_back( 0x00 );
        EmptyAction.push_back( 0x00 );

        for( unsigned char i = m_NumEmptyActionsUsed; i < m_NumEmptyActions; i++ )
            m_LocalSocket->PutBytes( EmptyAction );

        m_NumEmptyActionsUsed = 0;
    }

    m_ActionReceived = true;
    m_LastActionTime = GetTime( );
}

GProxy sends a couple (m_NumEmptyActions) of empty actions on EACH 
W3GS_INCOMING_ACTION packet, and this issue cause non-gproxy players to desync 
with others.

W3GS_INCOMING_ACTION2 handler doesn't have this issue, it does send required 
number of emty actions only once after reconnect happens:

else if( Packet->GetID( ) == CGameProtocol :: W3GS_INCOMING_ACTION2 )
{
    if( m_GameIsReliable )
    {
        // we received a fractured game update which means we cannot use any empty actions until we receive the subsequent game update
        // we also must send any remaining empty actions now
        // note: this means if we get disconnected right now we can't use any of our buffer time, which would be very unlucky
        // it still gives us 60 seconds total to reconnect though
        // note: the lag screen can't be up right now otherwise the server made a big mistake, so we don't need to check for it

        BYTEARRAY EmptyAction;
        EmptyAction.push_back( 0xF7 );
        EmptyAction.push_back( 0x0C );
        EmptyAction.push_back( 0x06 );
        EmptyAction.push_back( 0x00 );
        EmptyAction.push_back( 0x00 );
        EmptyAction.push_back( 0x00 );

        for( unsigned char i = m_NumEmptyActionsUsed; i < m_NumEmptyActions; i++ )
            m_LocalSocket->PutBytes( EmptyAction );

        m_NumEmptyActionsUsed = m_NumEmptyActions;
    }
}

diff:
m_NumEmptyActionsUsed = 0;
m_NumEmptyActionsUsed = m_NumEmptyActions;

Original issue reported on code.google.com by FukOfHea...@gmail.com on 29 Apr 2014 at 6:40