Desync legit crash

Пользователь
Статус
Оффлайн
Регистрация
20 Июл 2017
Сообщения
203
Реакции[?]
116
Поинты[?]
0
Why on the map when I turn on the legit desync gets a crash?
My code:

desynce.cpp
Код:
//#include "Hooks.h"
#include "SDK/Entity.h"
#include "Config.h"
#include <DirectXMath.h>
#include "features.h"
#include "Memory.h"
#include "SDK/GlobalVars.h"
//#include "ani.h"
#define CHECK_VALID( _v) 0

#define RAD2DEG(x) DirectX::XMConvertToDegrees(x)
#define DEG2RAD(x) DirectX::XMConvertToRadians(x)

enum MoveType_t
{
    MOVETYPE_NONE = 0,
    MOVETYPE_ISOMETRIC,
    MOVETYPE_WALK,
    MOVETYPE_STEP,
    MOVETYPE_FLY,
    MOVETYPE_FLYGRAVITY,
    MOVETYPE_VPHYSICS,
    MOVETYPE_PUSH,
    MOVETYPE_NOCLIP,
    MOVETYPE_LADDER,
    MOVETYPE_OBSERVER,
    MOVETYPE_CUSTOM,
    MOVETYPE_LAST = MOVETYPE_CUSTOM,
    MOVETYPE_MAX_BITS = 4
};

enum EEntityFlag
{
    FL_ONGROUND = (1 << 0),
    FL_DUCKING = (1 << 1),
    FL_WATERJUMP = (1 << 2),
    FL_ONTRAIN = (1 << 3),
    FL_INRAIN = (1 << 4),
    FL_FROZEN = (1 << 5),
    FL_ATCONTROLS = (1 << 6),
    FL_CLIENT = (1 << 7),
    FL_FAKECLIENT = (1 << 8),
    MAX_ENTITYFLAGS
};

namespace desync
{
    float yaw_offset;

    bool flip_yaw = false;
    bool flip_packet = false;
    CCSPlayerAnimState* anim_state;
    //const auto localPlayer = interfaces.entityList->getEntity(interfaces.engine->getLocalPlayer());

    bool is_enabled(UserCmd* cmd)
    {
        const auto localPlayer = interfaces.entityList->getEntity(interfaces.engine->getLocalPlayer());
        if (!localPlayer | !localPlayer->isAlive())
            return false;

        if (!config.misc.legitaa || (cmd->buttons & UserCmd::IN_USE))
            return false;

        auto * channel_info = interfaces.engine->GetNetChannelInfo();
        if (channel_info && (channel_info->GetAvgLoss(1) > 0.f || channel_info->GetAvgLoss(0) > 0.f))
            return false;
        if (localPlayer->getProperty<bool>("m_bGunGameImmunity") || localPlayer->getProperty<int32_t>("m_fFlags") & FL_FROZEN)
            return false;

       if (localPlayer->m_nMoveType() == MOVETYPE_LADDER || localPlayer->m_nMoveType() == MOVETYPE_NOCLIP)
        return false;

        return true;
    }

    bool is_firing(UserCmd * cmd)
    {
        const auto localPlayer = interfaces.entityList->getEntity(interfaces.engine->getLocalPlayer());

        auto weapon = localPlayer->getWeapons();
        if (!weapon)

            return false;

        //const auto weapon_type = weapon->get_weapon_data()->WeaponType;

        if (CSWeaponType::WEAPONTYPE_GRENADE)
        {
            return true;

            //if (!weapon->m_bPinPulled() && (cmd->buttons & UserCmd::IN_ATTACK || cmd->buttons & UserCmd::IN_ATTACK2))
            //    return false;
        }
        else if (CSWeaponType::WEAPONTYPE_KNIFE)
        {
            //if (cmd->buttons & UserCmd::IN_ATTACK || cmd->buttons & IN_ATTACK2)
                return true;
        }
        //lse if (weapon->m_iItemDefinitionIndex() == WEAPON_REVOLVER)
        {
            //if (cmd->buttons & UserCmd::IN_ATTACK && weapon->CanFire())
        //        return true;

        //    if (cmd->buttons & UserCmd::IN_ATTACK2)
            //    return true;
    //    }
        //else if (cmd->buttons & UserCmd::IN_ATTACK && weapon->CanFire() && CSWeaponType::WEAPONTYPE_C4)
        //    return true;
        }
        return false;
    }
    float get_max_desync_delta()
    {
        const auto speed_factor = std::max<float>(0.f, std::min<float>(1, anim_state->m_flSpeedFactor));
        const auto speed_fraction = std::max<float>(0.f, std::min<float>(anim_state->m_flSpeedFraction, 1.f));

        const auto unk1 = (anim_state->m_flLandingRatio * -0.30000001 - 0.19999999) * speed_fraction;
        float unk2 = unk1 + 1.f;

        if (anim_state->m_flDuckAmount > 0)
            unk2 += anim_state->m_flDuckAmount * speed_factor * (0.5f - unk2);

        return anim_state->m_flMaxBodyYawDegrees * unk2;
    }



    void correct_movement(UserCmd* cmd, const QAngle& old_angles, const float& old_forward, const float& old_sidemove)
    {
        // side/forward move correction
        float f1, f2, deltaView;
        if (old_angles.yaw < 0.f)
            f1 = 360.0f + old_angles.yaw;
        else
            f1 = old_angles.yaw;

        if (cmd->viewangles.yaw < 0.0f)
            f2 = 360.0f + cmd->viewangles.yaw;
        else
            f2 = cmd->viewangles.yaw;

        if (f2 < f1)
            deltaView = abs(f2 - f1);
        else
            deltaView = 360.0f - abs(f1 - f2);

        deltaView = 360.0f - deltaView;

        cmd->forwardmove = cos(DEG2RAD(deltaView)) * old_forward + cos(DEG2RAD(deltaView + 90.f)) * old_sidemove;
        cmd->sidemove = sin(DEG2RAD(deltaView)) * old_forward + sin(DEG2RAD(deltaView + 90.f)) * old_sidemove;
    }

    void correct_movement(UserCmd* cmd, const QAngle& old_angles)
    {
        correct_movement(cmd, old_angles, cmd->forwardmove, cmd->sidemove);
    }
#    define assert(expression) ((void)0)

    void handle(UserCmd* cmd, bool& send_packet)
    {
        const auto localPlayer = interfaces.entityList->getEntity(interfaces.engine->getLocalPlayer());
        if (!send_packet)
            return;

        if (!is_enabled(cmd))
        {
            yaw_offset = 0.f;

            return;
        }

        anim_state = localPlayer->GetPlayerAnimState();

        assert(anim_state);

        yaw_offset = get_max_desync_delta();

        const auto old_angles = cmd->viewangles;

        flip_packet = !flip_packet;
        send_packet = flip_packet;
        if (!flip_packet)
        {
            if (config.misc.legitaaflip)
                flip_yaw = !flip_yaw;
        }

#ifdef _DEBUG
        //console::print("=== desync ===");
        //console::print("anim state: %p", anim_state);
        //console::print("max desync delta: %.2f", yaw_offset);
#endif

        static float last_lby = 0.f;
        static float last_update = 0.f;

        const auto current_lby = localPlayer->getProperty<float>("m_flLowerBodyYawTarget");
        const float current_time = localPlayer->getProperty<bool>("m_nTickBase") * memory.globalVars->intervalPerTick;

        const float delta = ceilf((current_time - last_update) * 100) / 100;
        const auto next_delta = ceilf((delta + memory.globalVars->intervalPerTick) * 100) / 100;

        if (localPlayer->getProperty<Vector>("m_vecVelocity[0]").Length2D() <= 0.f)
        {
            if (current_lby != 179.f && last_lby != current_lby)
            {
                //console::print("lby updated after %.4f", delta);

                last_lby = current_lby;
                last_update = current_time - memory.globalVars->intervalPerTick;
            }
            else if (next_delta >= 1.1f)
            {
                //console::print("curr: %.4f; next: %.4f", delta, next_delta);

                send_packet = flip_packet = true;

                last_update = current_time;
            }
        }
        else
        {
            last_lby = current_lby;
            last_update = current_time;
        }

        const auto low_fps = memory.globalVars->intervalPerTick * 0.9f < memory.globalVars->frametime;
        if (low_fps || is_firing(cmd))
            send_packet = flip_packet = true;

        if (send_packet)
            anim_state->m_flGoalFeetYaw += flip_yaw ? yaw_offset : -yaw_offset;
        else
        {
            cmd->buttons &= ~(UserCmd::IN_FORWARD | UserCmd::IN_BACK | UserCmd:: IN_MOVERIGHT | UserCmd::IN_MOVELEFT);

            cmd->viewangles.yaw += 179.f;
            cmd->viewangles.NormalizeClamp();
            correct_movement(cmd, old_angles);
        }
    }
}

float flAngleMod(float flAngle)
{
    return((360.0f / 65536.0f) * ((int32_t)(flAngle * (65536.0f / 360.0f)) & 65535));
}

float flApproachAngle(float flTarget, float flValue, float flSpeed)
{
    float flAdjustedSpeed = flSpeed;
    if (flAdjustedSpeed < 0.0f)
    {
        flAdjustedSpeed *= -1.0f;
    }

    float flAngleModTarget = flAngleMod(flTarget);
    float flAngleModValue = flAngleMod(flValue);

    float flDelta = (flAngleModTarget - flAngleModValue);
    if (flDelta >= -180.0f)
    {
        if (flDelta >= 180.0f)
        {
            flDelta -= 360.0f;
        }
    }
    else
    {
        if (flDelta <= -180.0f)
        {
            flDelta += 360.0f;
        }
    }

    float flReturn;

    if (flDelta <= flAdjustedSpeed)
    {
        if ((flAdjustedSpeed * -1.0f) <= flDelta)
        {
            flReturn = flAngleModTarget;
        }
        else
        {
            flReturn = (flAngleModValue - flAdjustedSpeed);
        }
    }
    else
    {
        flReturn = (flAngleModValue + flAdjustedSpeed);
    }

    return flReturn;
}
GetPlayerAnimState:
Код:
    CCSPlayerAnimState* GetPlayerAnimState() noexcept
    {
        //BE A4 3A ? ? ? 74 48 8B 8E ? ? + 0xA
        return reinterpret_cast<CCSPlayerAnimState*>(this + 0x3900);
    }
 
Забаненный
Статус
Оффлайн
Регистрация
9 Янв 2019
Сообщения
701
Реакции[?]
295
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
attach the debugger to csgo and show what line throws an exception
 
ROAD TO THE LEGEND
Забаненный
Статус
Оффлайн
Регистрация
7 Фев 2018
Сообщения
2,194
Реакции[?]
714
Поинты[?]
1K
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
reinterpret_cat
Начинающий
Статус
Оффлайн
Регистрация
24 Янв 2019
Сообщения
53
Реакции[?]
17
Поинты[?]
5K
return reinterpret_cast<CCSPlayerAnimState*>(this + 0x3900);
return *reinterpret_cast<CCSPlayerAnimState**>((DWORD)this + 0x3900);
И желательно проверять всегда nullptr указатель на класс:
Код:
auto AnimState = pLocalPlayer->GetPlayerAnimState();
if (!AnimState)
    return;
 
Последнее редактирование:
Забаненный
Статус
Оффлайн
Регистрация
11 Апр 2017
Сообщения
281
Реакции[?]
37
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
это же сенсум не должно крашить
 
Пользователь
Статус
Оффлайн
Регистрация
20 Июл 2017
Сообщения
203
Реакции[?]
116
Поинты[?]
0
Сверху Снизу