Вопрос Проблема с correction

how to доказать всем что не еблан
Пользователь
Статус
Оффлайн
Регистрация
14 Авг 2019
Сообщения
400
Реакции[?]
114
Поинты[?]
23K
m_iTickBase -= 1 после шифта :DDD у тебя ведь по кд на 1 оверпредиктит
 
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
1 Ноя 2024
Сообщения
30
Реакции[?]
22
Поинты[?]
17K
HvH Legend
Пользователь
Статус
Онлайн
Регистрация
23 Окт 2022
Сообщения
395
Реакции[?]
97
Поинты[?]
27K
wtf you shouldn't do that.. just back what the nemesis had by default, this thing does nothing if u wanna to know
I also watched ur video tickbase diff(1 or -1) it’s normal don’t worry
then the problem is somewhere else
the problem was solved, the problem was lag_comp "calc_time_delta". Thanks a lot for the help :)
 
Участник
Статус
Оффлайн
Регистрация
27 Фев 2019
Сообщения
1,125
Реакции[?]
395
Поинты[?]
50K
нету у меня ево
есть просто valid()

C++:
void c_lag_comp::on_net_update() {
    if (!valve::g_local_player
        || !valve::g_engine->in_game())
        return;


    const auto tick_rate = valve::to_ticks(1.f);
    for (auto i = 1; i <= valve::g_global_vars->m_max_clients; ++i) {
        auto& entry = hacks::g_lag_comp->m_entries.at(i - 1);

        const auto player = static_cast<valve::c_player*>(
            valve::g_entity_list->find_entity(i)
            );

        if (player == valve::g_local_player) {
            entry.reset();

            const auto& net_info = g_context->net_info();

            int activity = 0;
            int difference = valve::to_ticks(player->sim_time() - player->old_sim_time());

            if (difference < 0)
                activity = valve::g_global_vars->m_tick_count + std::abs(difference) - valve::to_ticks(net_info.m_latency.m_out);

            hacks::g_lag_comp->m_local.m_hiden_record = activity > valve::g_global_vars->m_tick_count;

            continue;
        }

        if (entry.m_player != player)
            entry.reset();

        entry.m_player = player;

        if (!player
            || !player->alive()) {
            entry.reset();

            continue;
        }

        if (player->dormant()) {
            entry.m_try_anim_resolver = true;
            entry.m_misses = 0;

            if (entry.m_lag_records.empty()) {
                entry.m_lag_records.emplace_back(
                    std::make_shared< lag_record_t >(player)
                );

                continue;
            }

            if (!entry.m_lag_records.back()->m_dormant) {
                entry.m_lag_records.clear();

                entry.m_lag_records.emplace_back(
                    std::make_shared< lag_record_t >(player)
                );

                continue;
            }

            continue;
        }

        const auto anim_state = player->anim_state();
        if (!anim_state) {
            entry.reset();

            continue;
        }

        if (player->sim_time() == player->old_sim_time())
            g_aim_bot->extrapolate(entry);

        if (entry.m_spawn_time != player->spawn_time()) {
            anim_state->reset();

            entry.m_try_anim_resolver = true;
            entry.m_misses = entry.m_prev_anim_side = 0;

            //entry.m_missed_shots[entry.m_player->index()];

            entry.m_lag_records.clear();

            entry.m_spawn_time = player->spawn_time();
        }

        lag_anim_data_t* previous{};
        if (entry.m_prev_anim_data.has_value())
            previous = &entry.m_prev_anim_data.value();

        const auto current = entry.m_lag_records.emplace_back(
            std::make_shared< lag_record_t >(player)
        ).get();

        const auto& cur_alive_loop_cycle = player->anim_layers().at(11).m_cycle;
        if (cur_alive_loop_cycle == entry.m_alive_loop_cycle)
            current->m_invalid_sim_time = true;
        else
            entry.m_alive_loop_cycle = cur_alive_loop_cycle;

        current->correct(previous);

        g_anim_sync->on_net_update(entry, current, previous);

        while (entry.m_lag_records.size() > tick_rate - 1)
            entry.m_lag_records.pop_front();
    }
}
hpp:
 {

    enum resolver_type : DWORD
    {
        RESOLVER_LAYER_3,
        RESOLVER_LAYER_6,
        RESOLVER_REIS,
        RESOLVER_UNK,
        RESOLVER_FAILED_TO_RESOLVE,
        RESOLVER_979,
        RESOLVER_FREESTAND,
        RESOLVER_NO_NEED,
        RESOLVER_NEVER_STARTED,
        RESOLVER_REACHED_END,
        RESOLVER_FLASHED,
        RESOLVER_FLINCH,
        RESOLVER_RELOAD,
        RESOLVER_SHOT,
        RESOLVER_FEET,
        RESOLVER_FORCE_RIGHT,
        RESOLVER_BRUTEFORCE,
        RESOLVER_MOVE_YAW
    };

    struct lag_backup_t {
        __forceinline constexpr lag_backup_t( ) = default;

        __forceinline lag_backup_t( valve::c_player* const player );

        __forceinline void restore( valve::c_player* const player ) const;

        float            m_foot_yaw{};
        vec3_t            m_origin{}, m_abs_origin{},
                        m_obb_min{}, m_obb_max{};

        valve::bones_t    m_bones{};
        int                m_bones_count{},
                        m_readable_bones{}, m_writable_bones{};

        unsigned long    m_mdl_bone_counter{};
    };

    struct lag_anim_data_t;

    struct lag_record_t {
        struct anim_side_t {
            valve::bones_t            m_bones{};
            std::size_t                m_bones_count{};

            float                    m_foot_yaw{}, m_prev_foot_yaw{},
                                    m_move_yaw_ideal{}, m_move_yaw_cur_to_ideal{},
                                    m_move_yaw{};

            valve::anim_layers_t    m_anim_layers{};
        };

        __forceinline constexpr lag_record_t( ) = default;

        __forceinline lag_record_t(
            valve::c_player* const player
        ) : m_dormant{ player->dormant( ) },
            m_flags{ player->flags( ) },
            m_sim_ticks{ valve::to_ticks( player->sim_time( ) - player->old_sim_time( ) ) },
            m_total_cmds{ m_sim_ticks }, m_receive_tick{ valve::g_client_state->m_server_tick },
            m_sim_time{ player->sim_time( ) },
            m_lby{ player->lby( ) }, m_duck_amount{ player->duck_amount( ) },
            m_weapon{ player->weapon( ) },
            m_last_shot_time{ m_weapon ? m_weapon->last_shot_time( ) : std::numeric_limits< float >::max( ) },
            m_eye_angles{ player->eye_angles( ) },
            m_velocity{ player->velocity( ) }, m_origin{ player->origin( ) },
            m_obb_min{ player->obb_min( ) }, m_obb_max{ player->obb_max( ) },
            m_anim_layers{ player->anim_layers( ) } {}

        __forceinline void restore( valve::c_player* const player, const int anim_index, const bool only_anim = false ) const;

        __forceinline void correct( const lag_anim_data_t* const previous );

        __forceinline bool valid( ) const;

        bool                            m_dormant{}, m_invalid_sim_time{}, m_trying_to_resolve{}, m_extrapolated{},
                                        m_broke_lc{}, m_accelerating{}, m_too_much_diff{}, m_extending{}, m_slow_walking{}, m_use_anims{}, m_shot{};

        valve::e_ent_flags                m_flags{};
        int                                m_sim_ticks{}, m_total_cmds{}, m_anim_side{}, m_priority{}, m_receive_tick{}, m_resolver_type{}, m_extrapolate_ticks{};
        float                            m_sim_time{}, m_lby{}, m_duck_amount{}, m_on_ground_time{};

        std::optional< bool >            m_jumped{};

        valve::c_weapon*                m_weapon{};
        float                            m_last_shot_time{}, m_max_delta{}, m_delta{};

        qangle_t                        m_eye_angles{};
        vec3_t                            m_velocity{}, m_origin{}, m_obb_min{}, m_obb_max{};

        valve::anim_layers_t            m_anim_layers{};

        std::array< anim_side_t, 3u >    m_anim_sides{};
    };

    struct lag_anim_data_t {
        __forceinline constexpr lag_anim_data_t( ) = default;

        __forceinline lag_anim_data_t( const lag_record_t* const lag_record );

        struct anim_side_t {
            float    m_foot_yaw{}, m_prev_foot_yaw{},
                    m_move_yaw_ideal{}, m_move_yaw_cur_to_ideal{},
                    m_move_yaw{};
        };

        valve::c_weapon*                m_weapon{};

        qangle_t                        m_eye_angles{};
        vec3_t                            m_origin{}, m_velocity{};

        valve::e_ent_flags                m_flags{};
        float                            m_lby{}, m_duck_amount{};

        valve::anim_layers_t            m_anim_layers{};

        std::array< anim_side_t, 3u >    m_anim_sides{};
    };

    struct player_entry_t {
        struct interpolated_t {
            __forceinline constexpr interpolated_t( ) = default;

            __forceinline constexpr interpolated_t(
                const float sim_time, const float duck_amount,
                const valve::e_ent_flags flags, const vec3_t& velocity
            ) : m_sim_time{ sim_time }, m_duck_amount{ duck_amount },
                m_flags{ flags }, m_velocity{ velocity } {}

            float                m_sim_time{},
                                m_duck_amount{};

            valve::e_ent_flags    m_flags{};
            vec3_t                m_velocity{};

        };

        __forceinline void reset( );

        __forceinline void interpolate(
            const lag_anim_data_t* const from, const lag_record_t* const to
        );

        valve::c_player*                                m_player{};

        float                                            m_spawn_time{},
                                                        m_receive_time{},
                                                        m_alive_loop_cycle{};

        valve::bones_t                                    m_bones{};

        bool                                            m_unk{}, m_try_anim_resolver{ true }, m_was_first_bruteforce{ false }, m_was_second_bruteforce{ false }, m_was_first_low_bruteforce{ false }, m_was_second_low_bruteforce{ false };
        int                                                m_misses{}, m_storred_anim_side{}, m_last_storred_tick{}, m_brute_side{}, m_prev_anim_side{};

        std::optional< lag_anim_data_t >                m_prev_anim_data{};

        std::deque< std::shared_ptr< lag_record_t > >    m_lag_records{};
        std::vector< interpolated_t >                    m_interpolated{};
    };

    struct local_t {
        bool m_hiden_record{};
    };


    class c_lag_comp {
    private:
        std::array< player_entry_t, 64u > m_entries{};
        local_t m_local{};
    public:
        void on_net_update( );

        std::shared_ptr< lag_record_t > get_last_record(const player_entry_t& entry);

        std::shared_ptr< lag_record_t > get_oldest_record(const player_entry_t& entry);

        __forceinline float calc_time_delta( const float sim_time ) const;

        __forceinline player_entry_t& entry( const std::size_t i );
    };

    inline const auto g_lag_comp = std::make_unique< c_lag_comp >( );
}
inl:
 {
    __forceinline lag_backup_t::lag_backup_t(valve::c_player* const player) {
        if (const auto anim_state = player->anim_state())
            m_foot_yaw = anim_state->m_foot_yaw;

        m_origin = player->origin();
        m_abs_origin = player->get_abs_origin();

        m_obb_min = player->obb_min();
        m_obb_max = player->obb_max();

        const auto& bone_accessor = player->bone_accessor();

        m_readable_bones = bone_accessor.m_readable_bones;
        m_writable_bones = bone_accessor.m_writable_bones;

        const auto& bone_cache = player->bone_cache();

        std::memcpy(
            m_bones.data(),
            bone_cache.m_mem.m_ptr,
            bone_cache.m_size * sizeof(mat3x4_t)
        );

        m_bones_count = bone_cache.m_size;

        m_mdl_bone_counter = player->mdl_bone_counter();
    }

    __forceinline void lag_backup_t::restore(valve::c_player* const player) const {
        player->origin() = m_origin;

        player->set_abs_origin(m_abs_origin);

        player->set_collision_bounds(m_obb_min, m_obb_max);

        player->set_abs_angles({ 0.f, m_foot_yaw, 0.f });

        auto& bone_accessor = player->bone_accessor();

        bone_accessor.m_readable_bones = m_readable_bones;
        bone_accessor.m_writable_bones = m_writable_bones;

        std::memcpy(
            player->bone_cache().m_mem.m_ptr,
            m_bones.data(), m_bones_count * sizeof(mat3x4_t)
        );

        player->mdl_bone_counter() = m_mdl_bone_counter;
    }

    __forceinline void lag_record_t::restore(valve::c_player* const player, const int anim_index, const bool only_anim) const {
        if (!only_anim) {
            player->origin() = m_origin;

            player->set_abs_origin(m_origin);

            player->set_collision_bounds(m_obb_min, m_obb_max);
        }

        const auto& anim_side = m_anim_sides.at(anim_index);

        player->set_abs_angles({ 0.f, anim_side.m_foot_yaw, 0.f });

        std::memcpy(
            player->bone_cache().m_mem.m_ptr,
            anim_side.m_bones.data(), anim_side.m_bones_count * sizeof(mat3x4_t)
        );

        player->mdl_bone_counter() = [B]reinterpret_cast<unsigned long[/B]>(
            g_context->addresses().m_invalidate_bone_cache + 0xau
            );
    }

    __forceinline void lag_record_t::correct(const lag_anim_data_t* const previous) {
        /* tf reisw */
        if (!previous
            || ((m_origin - previous->m_origin).length_sqr() > 4096.f))
            m_broke_lc = true;

        const auto& cur_alive_loop_layer = m_anim_layers.at(11u);

        if (previous) {
            const auto& prev_alive_loop_layer = previous->m_anim_layers.at(11u);

            if (prev_alive_loop_layer.m_playback_rate == cur_alive_loop_layer.m_playback_rate) {
                if (previous->m_weapon == m_weapon
                    && cur_alive_loop_layer.m_playback_rate > 0.f
                    && cur_alive_loop_layer.m_cycle > prev_alive_loop_layer.m_cycle) {
                    const auto v16 = m_sim_ticks + 1;
                    const auto v17 = valve::to_ticks(
                        (cur_alive_loop_layer.m_cycle - prev_alive_loop_layer.m_cycle)
                        / cur_alive_loop_layer.m_playback_rate
                    );

                    if (v17 > v16
                        && v17 <= 19)
                        m_total_cmds = v17;
                }
            }

            const auto total_cmds_time = valve::to_time(m_total_cmds);
            if (total_cmds_time > 0.f
                && total_cmds_time < 1.f)
                m_velocity = (m_origin - previous->m_origin) / total_cmds_time;

            if (m_total_cmds >= 2) {
                const auto anim_time = m_sim_time - total_cmds_time;

                if (m_flags & valve::e_ent_flags::on_ground) {
                    if (!(previous->m_flags & valve::e_ent_flags::on_ground)) {
                        const auto& cycle = m_anim_layers.at(5u).m_cycle;
                        if (cycle < 0.999f) {
                            const auto playback_rate = m_anim_layers.at(5u).m_playback_rate;
                            if (playback_rate > 0.f) {
                                const auto land_time = m_sim_time - (cycle / playback_rate);
                                if (land_time > anim_time
                                    && m_sim_time <= land_time) {
                                    m_on_ground_time = land_time;
                                    m_jumped = false;
                                }
                            }
                        }
                    }
                }
                else {
                    if (!(previous->m_flags & valve::e_ent_flags::on_ground)) {
                        const auto& cycle = m_anim_layers.at(4u).m_cycle;
                        if (cycle < 0.999f) {
                            const auto playback_rate = m_anim_layers.at(4u).m_playback_rate;
                            if (playback_rate > 0.f) {
                                const auto on_ground_time = m_sim_time - (cycle / playback_rate);
                                if (on_ground_time > anim_time
                                    && m_sim_time <= on_ground_time) {
                                    m_on_ground_time = on_ground_time;
                                    m_jumped = true;
                                }
                            }
                        }
                    }
                }
            }
        }

        if (m_weapon
            && m_last_shot_time > (m_sim_time - valve::to_time(m_total_cmds))
            && m_sim_time >= m_last_shot_time)
            if (const auto wpn_data = m_weapon->wpn_data(); wpn_data && (static_cast<std::size_t>(wpn_data->m_unk_type - 2) <= 5 || m_weapon->item_index() == valve::e_item_index::taser))
                m_shot = true;

        if ((m_flags & valve::e_ent_flags::on_ground)
            && (!previous || (previous->m_flags & valve::e_ent_flags::on_ground))) {
            if (m_anim_layers.at(6u).m_playback_rate == 0.f)
                m_velocity = {};

            if (previous
                && m_weapon == previous->m_weapon
                && cur_alive_loop_layer.m_playback_rate == previous->m_anim_layers.at(11u).m_playback_rate) {
                const auto speed =
                    (0.55f - ((cur_alive_loop_layer.m_weight - 1.f) * 0.35f))
                    * (m_weapon ? std::max(0.1f, m_weapon->max_speed()) : 260.f);

                const auto average_speed = m_velocity.length_2d();

                if ((cur_alive_loop_layer.m_weight >= 1.f && average_speed > speed)
                    || (cur_alive_loop_layer.m_weight < 1.f && (speed >= average_speed || cur_alive_loop_layer.m_weight > 0.f))) {
                    if (average_speed) {
                        m_velocity.x /= average_speed;
                        m_velocity.y /= average_speed;
                    }

                    m_velocity.x *= speed;
                    m_velocity.y *= speed;
                }
            }
        }
    }

    __forceinline bool lag_record_t::valid() const {
        if (m_invalid_sim_time
            || m_broke_lc
            || g_lag_comp->calc_time_delta(m_sim_time) > 0.2f)
            return false;

        int delay{};
        if (g_movement->should_fake_duck())
            delay = 15 - valve::g_client_state->m_choked_cmds;

        int server_tickcount = delay + valve::g_global_vars->m_tick_count + valve::to_ticks(g_context->net_info().m_latency.m_out + g_context->net_info().m_latency.m_in);
        int dead_time = (int)(valve::to_time(server_tickcount) - g_context->cvars().m_sv_maxunlag->get_float());

        if (m_sim_time < (float)dead_time)
            return false;

        return true;
    }

    __forceinline lag_anim_data_t::lag_anim_data_t(const lag_record_t* const lag_record) {
        m_weapon = lag_record->m_weapon;

        m_eye_angles = lag_record->m_eye_angles;
        m_origin = lag_record->m_origin;
        m_velocity = lag_record->m_velocity;

        m_flags = lag_record->m_flags;
        m_lby = lag_record->m_lby;
        m_duck_amount = lag_record->m_duck_amount;

        m_anim_layers = lag_record->m_anim_layers;

        for (std::size_t i{}; i < m_anim_sides.size(); ++i) {
            auto& to = m_anim_sides.at(i);
            const auto& from = lag_record->m_anim_sides.at(i);

            to.m_foot_yaw = from.m_foot_yaw;
            to.m_prev_foot_yaw = from.m_prev_foot_yaw;
            to.m_move_yaw_ideal = from.m_move_yaw_ideal;
            to.m_move_yaw_cur_to_ideal = from.m_move_yaw_cur_to_ideal;
            to.m_move_yaw = from.m_move_yaw;
        }
    }

    __forceinline void player_entry_t::reset() {
        m_player = nullptr;

        m_alive_loop_cycle = -1.f;
        m_misses = m_prev_anim_side = 0;
        m_prev_anim_data = std::nullopt;
        m_try_anim_resolver = true;

        m_lag_records.clear();
    }

    __forceinline void player_entry_t::interpolate(
        const lag_anim_data_t* const from, const lag_record_t* const to
    ) {
        if (!from
            || to->m_total_cmds <= 1
            || to->m_total_cmds >= 20) {
            m_interpolated.emplace_back(
                to->m_sim_time, to->m_duck_amount,
                to->m_flags, to->m_velocity
            );

            return;
        }

        m_interpolated.reserve(to->m_total_cmds);

        const auto anim_time = to->m_sim_time - valve::to_time(to->m_total_cmds);

        const auto duck_amount_delta = to->m_duck_amount - from->m_duck_amount;
        const auto velocity_delta = to->m_velocity - from->m_velocity;

        const auto interpolate_velocity =
            to->m_anim_layers.at(6u).m_playback_rate == 0.f || from->m_anim_layers.at(6u).m_playback_rate == 0.f
            || ((to->m_velocity.length_2d() >= 1.1f) && (from->m_velocity.length_2d() >= 1.1f));

        for (auto i = 1; i <= to->m_total_cmds; ++i) {
            if (i == to->m_total_cmds) {
                m_interpolated.emplace_back(
                    to->m_sim_time, to->m_duck_amount,
                    to->m_flags, to->m_velocity
                );

                break;
            }

            const auto lerp = i / static_cast<float>(to->m_total_cmds);

            auto& interpolated = m_interpolated.emplace_back();

            interpolated.m_flags = to->m_flags;

            if (to->m_jumped.has_value()) {
                interpolated.m_flags &= ~valve::e_ent_flags::on_ground;

                if (from->m_flags & valve::e_ent_flags::on_ground)
                    interpolated.m_flags |= valve::e_ent_flags::on_ground;
            }

            interpolated.m_sim_time = anim_time + valve::to_time(i);
            interpolated.m_duck_amount = from->m_duck_amount + duck_amount_delta * lerp;

            if (interpolate_velocity)
                interpolated.m_velocity = from->m_velocity + velocity_delta * lerp;
            else
                interpolated.m_velocity = { 0.f, 0.f, 0.f };

            if (to->m_jumped.has_value()) {
                if (to->m_jumped.value()) {
                    if ((valve::to_ticks(interpolated.m_sim_time) + 1) == valve::to_ticks(to->m_on_ground_time))
                        interpolated.m_flags |= valve::e_ent_flags::on_ground;
                }
                else if (interpolated.m_sim_time >= to->m_on_ground_time)
                    interpolated.m_flags |= valve::e_ent_flags::on_ground;
            }
        }
    }

    __forceinline float c_lag_comp::calc_time_delta(const float sim_time) const {
        const auto& net_info = g_context->net_info();

        const auto correct = std::clamp(
            net_info.m_lerp + net_info.m_latency.m_in + net_info.m_latency.m_out,
            0.f, g_context->cvars().m_sv_maxunlag->get_float()
        );

        auto tick_base = valve::g_local_player->tick_base();

        if (g_exploits->ticks_allowed() > 0)
            tick_base -= 13;

        return std::fabs(correct - (valve::to_time(tick_base) - sim_time));
    }

    __forceinline player_entry_t& c_lag_comp::entry(const std::size_t i) { return m_entries.at(i); }
}
После этого комментария можно далее не читать проблему. Автор не понимает того, что делает абсолютно.
 
Сверху Снизу