C++ Calculate right delta time for backtrack

Начинающий
Статус
Оффлайн
Регистрация
1 Ноя 2024
Сообщения
27
Реакции[?]
21
Поинты[?]
16K
hello, YG community today its quality post for ur favorite game
C++:
struct lag_compensation_data_t {
    std::uint64_t m_tick{};
    float         m_time{};
    PAD( 0x24 );
}; // size: 0x40

// @xrefs:
// server.dll - "E8 ?? ?? ?? ?? FF C6 48 FF C5"
// server.dll - "40 57 41 54 41 56 48 83 EC 50"
// server.dll - "E8 ?? ?? ?? ?? 66 0F 6E 0B"
// server.dll - "4C 8B DC 49 89 53 10 49 89 4B 08 55 56 57"

/* IsDeadTime:
if ( *(_DWORD *)(v11 + 52) >= (int)(float)((float)((float)(v9 - *(float *)&v10) * 64.0) + 0.5) )
      break;
*/

/* IsBreakLagCompensation:
if ( origin_delta.LengthSqr( ) > 4096 )
     break;

if ( sim_time <= target_time )
     break;
*/

float c_lag_comp::calc_delta_time( int newest_tick ) {
    int tick_count = global_vars_tick_count;
    float max_unlag = sv_maxunlag->get( float );

    // if ( sub_1806DD5B0(&v193) < 0.015625 )
    float unk_modifier std::fmod( max_unlag, 0.015625 );
    float unlag_diff = max_unlag - unk_modifier;
    float time_modifier = unk_modifier * 64.0;
    int unlag_ticks = ( int )( float )( ( float )( unlag_diff * 64.0 ) + 0.5 );

    lag_compensation_data_t v28{};
    v28.m_tick = newest_tick;
    v28.m_time = newest_tick * 0.015625;

    int v20{};
    float v19{}, v21{};

    if ( time_modifier <= ( float )( 1.0 - 0.0099999998 ) )
    {
        v20 = tick_count - unlag_ticks;
        if ( time_modifier > 0.0099999998 )
        {
            v19 = -time_modifier;
            v21 = v19;

            if ( v19 <= 0.0 )
                v19 = v19 + 1.0;
        }
        else
        {
            v19 = 0.0;
            v21 = 0.0;
        }
    }

    int v22 = v20 - 1;

    lag_compensation_data_t v40{};
    v40.m_time = v19;

    if ( v21 >= 0.0 )
        v22 = v20;

    v40.m_tick = v22;

    if ( v19 <= ( float )( 1.0 - 0.0099999998 ) )
    {
        if ( v19 <= 0.0099999998 )
            v40.m_time = 0.0;
    }
    else
    {
        v40.m_tick = v22 + 1;
        v40.m_time = 0.0;
    }

    int tick = v40.m_tick;
    float v24 = ( float )v28.m_tick;
    lag_compensation_data_t v38 = v40;
    int v37{};

    lag_compensation_data_t v39{};

    if ( ( float )( ( float )( v24 + v28.m_time ) * 0.015625 ) <= 0.0 )
    {
        v40.m_tick = newest_tick;
        v40.m_time = 0.0;
        v37 = v40.m_tick;
        tick = v38.m_tick;
        v39 = v40;
    }
    else
    {
        v37 = v28.m_tick;
        v39 = v28;
    }

    int v32{};
    float v30{};

    if ( tick <= v37 && ( tick < v37 || v39.m_time > v38.m_time ) )
    {
        auto v33 = v37 - tick;
        v30 = v39.m_time - v38.m_time;
        if ( ( float )( v39.m_time - v38.m_time ) <= 0.0 )
            v30 = v30 + 1.0;
        v32 = v33 - 1;
        if ( ( float )( v39.m_time - v38.m_time ) >= 0.0 )
            v32 = v33;
        if ( v30 >= ( float )( 1.0 - 0.0099999998 ) )
        {
            ++v32;
            goto LABEL_48;
        }
    LABEL_47:
        if ( v30 > 0.0099999998 )
            goto LABEL_49;
        goto LABEL_48;
    }

    v30 = v38.m_time - v39.m_time;
    int v31 = tick - v37;
    if ( ( float )( v38.m_time - v39.m_time ) <= 0.0 )
        v30 = v30 + 1.0;
    v32 = v31 - 1;
    if ( ( float )( v38.m_time - v39.m_time ) >= 0.0 )
        v32 = v31;
    if ( v30 <= ( float )( 1.0 - 0.0099999998 ) )
        goto LABEL_47;
    ++v32;
LABEL_48:
    v30 = 0.0;
LABEL_49:
    float delta_time = ( float )( ( float )v32 + v30 ) * 0.015625;

    return delta_time;
}

bool c_lag_comp::is_valid_time( )
{
    float max_unlag = sv_maxunlag->get( float );
    float server_time = ( sim_time * 64.0 ) + ( network_game_client_latency * 0.5 ) + ( network_game_client_engine_latency );
    float delta_time = calc_delta_time( server_time );

    if ( std::abs( delta_time ) > max_unlag )
        return false;

    // here need a dead time check..

    return true;
}
 
ЧВК EB_LAN
Эксперт
Статус
Оффлайн
Регистрация
26 Янв 2021
Сообщения
1,567
Реакции[?]
522
Поинты[?]
185K
hello, YG community today its quality post for ur favorite game
C++:
struct lag_compensation_data_t {
    std::uint64_t m_tick{};
    float         m_time{};
    PAD( 0x24 );
}; // size: 0x40

// @xrefs:
// server.dll - "E8 ?? ?? ?? ?? FF C6 48 FF C5"
// server.dll - "40 57 41 54 41 56 48 83 EC 50"
// server.dll - "E8 ?? ?? ?? ?? 66 0F 6E 0B"
// server.dll - "4C 8B DC 49 89 53 10 49 89 4B 08 55 56 57"

/* IsDeadTime:
if ( *(_DWORD *)(v11 + 52) >= (int)(float)((float)((float)(v9 - *(float *)&v10) * 64.0) + 0.5) )
      break;
*/

/* IsBreakLagCompensation:
if ( origin_delta.LengthSqr( ) > 4096 )
     break;

if ( sim_time <= target_time )
     break;
*/

float c_lag_comp::calc_delta_time( int newest_tick ) {
    int tick_count = global_vars_tick_count;
    float max_unlag = sv_maxunlag->get( float );

    // if ( sub_1806DD5B0(&v193) < 0.015625 )
    float unk_modifier std::fmod( max_unlag, 0.015625 );
    float unlag_diff = max_unlag - unk_modifier;
    float time_modifier = unk_modifier * 64.0;
    int unlag_ticks = ( int )( float )( ( float )( unlag_diff * 64.0 ) + 0.5 );

    lag_compensation_data_t v28{};
    v28.m_tick = newest_tick;
    v28.m_time = newest_tick * 0.015625;

    int v20{};
    float v19{}, v21{};

    if ( time_modifier <= ( float )( 1.0 - 0.0099999998 ) )
    {
        v20 = tick_count - unlag_ticks;
        if ( time_modifier > 0.0099999998 )
        {
            v19 = -time_modifier;
            v21 = v19;

            if ( v19 <= 0.0 )
                v19 = v19 + 1.0;
        }
        else
        {
            v19 = 0.0;
            v21 = 0.0;
        }
    }

    int v22 = v20 - 1;

    lag_compensation_data_t v40{};
    v40.m_time = v19;

    if ( v21 >= 0.0 )
        v22 = v20;

    v40.m_tick = v22;

    if ( v19 <= ( float )( 1.0 - 0.0099999998 ) )
    {
        if ( v19 <= 0.0099999998 )
            v40.m_time = 0.0;
    }
    else
    {
        v40.m_tick = v22 + 1;
        v40.m_time = 0.0;
    }

    int tick = v40.m_tick;
    float v24 = ( float )v28.m_tick;
    lag_compensation_data_t v38 = v40;
    int v37{};

    lag_compensation_data_t v39{};

    if ( ( float )( ( float )( v24 + v28.m_time ) * 0.015625 ) <= 0.0 )
    {
        v40.m_tick = newest_tick;
        v40.m_time = 0.0;
        v37 = v40.m_tick;
        tick = v38.m_tick;
        v39 = v40;
    }
    else
    {
        v37 = v28.m_tick;
        v39 = v28;
    }

    int v32{};
    float v30{};

    if ( tick <= v37 && ( tick < v37 || v39.m_time > v38.m_time ) )
    {
        auto v33 = v37 - tick;
        v30 = v39.m_time - v38.m_time;
        if ( ( float )( v39.m_time - v38.m_time ) <= 0.0 )
            v30 = v30 + 1.0;
        v32 = v33 - 1;
        if ( ( float )( v39.m_time - v38.m_time ) >= 0.0 )
            v32 = v33;
        if ( v30 >= ( float )( 1.0 - 0.0099999998 ) )
        {
            ++v32;
            goto LABEL_48;
        }
    LABEL_47:
        if ( v30 > 0.0099999998 )
            goto LABEL_49;
        goto LABEL_48;
    }

    v30 = v38.m_time - v39.m_time;
    int v31 = tick - v37;
    if ( ( float )( v38.m_time - v39.m_time ) <= 0.0 )
        v30 = v30 + 1.0;
    v32 = v31 - 1;
    if ( ( float )( v38.m_time - v39.m_time ) >= 0.0 )
        v32 = v31;
    if ( v30 <= ( float )( 1.0 - 0.0099999998 ) )
        goto LABEL_47;
    ++v32;
LABEL_48:
    v30 = 0.0;
LABEL_49:
    float delta_time = ( float )( ( float )v32 + v30 ) * 0.015625;

    return delta_time;
}

bool c_lag_comp::is_valid_time( )
{
    float max_unlag = sv_maxunlag->get( float );
    float server_time = ( sim_time * 64.0 ) + ( network_game_client_latency * 0.5 ) + ( network_game_client_engine_latency );
    float delta_time = calc_delta_time( server_time );

    if ( std::abs( delta_time ) > max_unlag )
        return false;

    // here need a dead time check..

    return true;
}
lol looks like c+p from leaked weave xdd
 
Начинающий
Статус
Оффлайн
Регистрация
1 Ноя 2024
Сообщения
27
Реакции[?]
21
Поинты[?]
16K
Сверху Снизу