Исходник ShiftCmd to supremacy

Участник
Статус
Оффлайн
Регистрация
6 Апр 2021
Сообщения
343
Реакции[?]
216
Поинты[?]
122K
C++:
bool ShiftCmd( int* new_commands, int* backup_commands, const std::uintptr_t ecx, const std::uintptr_t edx, int slot, bf_write* buf, int unk, bool real_cmd ) {
    auto new_from = -1;
    auto shift_amount = TickBaseSys::Get( ).ValueToShift;
    TickBaseSys::Get( ).ValueToShift = 12;

    auto commands = *new_commands;
    auto shift_commands = std::clamp( commands + shift_amount, 1, 62 );
    *new_commands = shift_commands;
    *backup_commands = 0;

    auto next_cmd_nr = g_csgo.m_cl->m_choked_commands + g_csgo.m_cl->m_last_outgoing_command + 1;
    auto new_to = next_cmd_nr - commands + 1;
    if ( new_to <= next_cmd_nr ) {
        while ( nem_hooks::orig_write_user_cmd_delta_to_buffer( ecx, edx, slot, buf, new_from, new_to, true ) ) {
            new_from = new_to++;

            if ( new_to > next_cmd_nr )
                goto next_cmd;
        }
        return false;
    }
next_cmd:
    *( int* )( ( uintptr_t )g_csgo.m_prediction + 0x1C ) = 0;
    *( int* )( ( uintptr_t )g_csgo.m_prediction + 0xC ) = -1;

    auto fake_cmd = g_csgo.m_input->user_cmd( slot, new_from );
    if ( !fake_cmd )
        return true;

    CUserCmd to_cmd;
    CUserCmd from_cmd;

    from_cmd = *fake_cmd;
    to_cmd = from_cmd;

    ++to_cmd.m_command_number;
    if ( real_cmd ) {
        int iterator = 0;
        do {
            g_csgo.m_prediction->Update(
                g_csgo.m_cl->m_delta_tick, g_csgo.m_cl->m_delta_tick > 0,
                g_csgo.m_cl->m_last_command_ack,
                g_csgo.m_cl->m_last_outgoing_command + g_csgo.m_cl->m_choked_commands );
            
            to_cmd.m_buttons &= ~0xFFBEFFF9;

            auto new_cmd = g_csgo.m_input->GetUserCmd( to_cmd.m_command_number );
            auto verified_cmd = g_csgo.m_input->GetVerifiedCmd( to_cmd.m_command_number );

            if ( new_cmd && verified_cmd )
            {
                std::memcpy( new_cmd, &to_cmd, sizeof( CUserCmd ) );
                std::memcpy( &verified_cmd->m_cmd, &to_cmd, sizeof( CUserCmd ) );
                verified_cmd->m_crc = new_cmd->GetChecksum( );
            }

            write_user_cmd( buf, &to_cmd, &from_cmd );

        
            ++iterator;
            if ( iterator >= shift_amount ) { }
            else
            {
                auto net_chan = g_csgo.m_cl->m_net_channel;
                if ( net_chan ) {
                    ++net_chan->m_out_seq;
                    ++net_chan->m_choked_packets;
                }
                ++g_csgo.m_cl->m_choked_commands;
            }
            
            if ( new_cmd ) {
                if ( settings.m_DoubleTapSpeed == 1 ) {
                    new_cmd->m_forward_move = 0.f;
                    new_cmd->m_side_move = 0.f;
                }
                else if ( settings.m_DoubleTapSpeed == 2 ) {
                    static auto cl_forwardspeed = g_csgo.m_cvar->FindVar( HASH( "cl_forwardspeed" ) );
                    static auto cl_sidespeed = g_csgo.m_cvar->FindVar( HASH( "cl_sidespeed" ) );

                    if ( g_cl.m_cmd->m_forward_move >= 5.0f )
                        new_cmd->m_forward_move = cl_forwardspeed->GetFloat( );

                    else if ( g_cl.m_cmd->m_forward_move <= -5.0f )
                        new_cmd->m_forward_move = -cl_forwardspeed->GetFloat( );

                    if ( g_cl.m_cmd->m_side_move >= 5.0f )
                        new_cmd->m_side_move = cl_sidespeed->GetFloat( );

                    else if ( g_cl.m_cmd->m_side_move <= -5.0f )
                        new_cmd->m_side_move = -cl_sidespeed->GetFloat( );
                }
                else if ( settings.m_DoubleTapSpeed == 3 ) {
                    auto v64 = ( g_cl.m_local->m_flDuckAmount( ) * 0.34f ) + 1.0f;
                    auto v47 = 1.0f / ( v64 - g_cl.m_local->m_flDuckAmount( ) );

                    new_cmd->m_forward_move = new_cmd->m_forward_move * v47;
                    new_cmd->m_side_move = v47 * new_cmd->m_side_move;

                    if ( new_cmd->m_side_move > 450.f )
                        new_cmd->m_side_move = 450.f;
                    else if ( new_cmd->m_side_move < -450.f )
                        new_cmd->m_side_move = -450.f;

                    if ( new_cmd->m_forward_move > 450.f )
                        new_cmd->m_forward_move = 450.f;
                    else if ( new_cmd->m_forward_move < -450.f )
                        new_cmd->m_forward_move = -450.f;
                }

                math::NormalizeAngles( new_cmd->m_view_angles );
                MovementFix( new_cmd, g_cl.m_cmd->m_view_angles, new_cmd->m_view_angles );
            }

            //from_cmd.m_tick = INT_MAX;
            from_cmd = to_cmd;
            ++to_cmd.m_command_number;

        } while ( iterator < shift_amount );
    }
    else {
        to_cmd.m_tick = INT_MAX;
        do {
            write_user_cmd( buf, &to_cmd, &from_cmd );

            ++to_cmd.m_command_number;
            shift_amount--;
        } while ( shift_amount > 0 );
    }

}
 
Сверху Снизу