From 65ce24409cbb7a4da18751e5043978ded5090fac Mon Sep 17 00:00:00 2001 From: boris Date: Wed, 5 Dec 2018 18:11:08 +1300 Subject: im a retard double events still happen :| --- cheat/internal_rewrite/extra.cpp | 57 ++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 19 deletions(-) (limited to 'cheat/internal_rewrite/extra.cpp') diff --git a/cheat/internal_rewrite/extra.cpp b/cheat/internal_rewrite/extra.cpp index e95a840..07a8aaf 100644 --- a/cheat/internal_rewrite/extra.cpp +++ b/cheat/internal_rewrite/extra.cpp @@ -79,22 +79,51 @@ namespace features } void c_extra::update_netchannel( ) { + // fuck u bithc + auto *netchan = g_csgo.m_global_state->get_client_state()->m_netchannel; + + if (netchan->m_nInSequenceNr != m_last_sequence) { + m_last_sequence = netchan->m_nInSequenceNr; + + // emplace new record + netchan_record_t record{ + g_csgo.m_globals->m_realtime, + netchan->m_nInReliableState, + netchan->m_nInSequenceNr + }; + m_net_records.emplace_back(record); + } + + // clear outdated records + for (auto &it = m_net_records.begin(); it != m_net_records.end(); ++it) { + const float delta = g_csgo.m_globals->m_realtime - it->m_realtime; + // 200ms is the max we can fake anyway.. + // hnn this might be why it's so fucked :/ + if (delta > 0.4f) + m_net_records.erase(it); + } } void c_extra::add_latency( INetChannel* channel ) { - // todo @boris: - // replace this with sharklazer's method + auto nci = g_csgo.m_engine()->GetNetChannelInfo(); + float in_latency = nci->GetLatency(0); + + // amount of latency we want to achieve + float latency = 0.15f - (in_latency + g_csgo.m_globals->m_frametime) - TICK_INTERVAL(); if ( g_ctx.m_local && g_ctx.m_local->is_valid( ) ) { - - auto nci = g_csgo.m_engine( )->GetNetChannelInfo( ); - float in_latency = nci->GetLatency( 0 ); + // god this is autistic + for (auto &it = m_net_records.begin(); it != m_net_records.end(); ++it) { + const float delta = g_csgo.m_globals->m_realtime - it->m_realtime; - float latency = 0.15f - ( in_latency + g_csgo.m_globals->m_frametime ) - TICK_INTERVAL( ); + if (delta >= latency) { + // apply latency + channel->m_nInReliableState = it->m_reliable; + channel->m_nInSequenceNr = it->m_sequence; - if( g_settings.misc.net_fakelag && latency > 0.f ) { - channel->m_nInSequenceNr += 2 * 64 - ( 63 * latency ); + break; + } } } } @@ -122,12 +151,6 @@ namespace features // I am so, so, so, so sorry. void c_extra::money_talk( IGameEvent *evt ) { - static float last_time = 0.0f; - - if( !g_csgo.m_engine( )->IsConnected( ) || !g_csgo.m_engine( )->IsInGame( ) ) { - last_time = 0.0f; - } - if( !g_settings.misc.money_talk( ) ) return; @@ -135,11 +158,7 @@ namespace features const int player = g_csgo.m_engine( )->GetPlayerForUserID( evt->GetInt( xors( "attacker" ) ) ); if( player == g_csgo.m_engine( )->GetLocalPlayer( ) ) { - if( last_time <= g_csgo.m_globals->m_curtime ) { - g_csgo.m_engine( )->ClientCmd( xors( "say god i wish i had moneybot" ) ); - - last_time = g_csgo.m_globals->m_curtime + 0.1f; - } + g_csgo.m_engine( )->ClientCmd( xors( "say god i wish i had moneybot" ) ); } } } -- cgit v1.2.3