diff options
| author | boris <wzn@moneybot.cc> | 2018-11-28 16:00:02 +1300 |
|---|---|---|
| committer | boris <wzn@moneybot.cc> | 2018-11-28 16:00:02 +1300 |
| commit | 3d412a4b30a9f7c7f51ea6562e694315948bd3da (patch) | |
| tree | 26d67dfd1f3e5fd12903ad13e85d0cb8bcf8f21c /cheat/tf2/ctx.cpp | |
| parent | e4729e4393d90271a3814c7a79950a660c48325a (diff) | |
cleaned up
in short, the cheat and loader are now separate solutions. unused stuff was moved into the legacy solution in case anyone wants to compile it or whatever.
i can change this back if you want to. also, i configured the loader to compile in x64, and have separate build types for linux and win64
Diffstat (limited to 'cheat/tf2/ctx.cpp')
| -rw-r--r-- | cheat/tf2/ctx.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/cheat/tf2/ctx.cpp b/cheat/tf2/ctx.cpp new file mode 100644 index 0000000..37e192f --- /dev/null +++ b/cheat/tf2/ctx.cpp @@ -0,0 +1,97 @@ +#include "ctx.hpp"
+#include "console.hpp"
+#include "hooks.h"
+#include "base_cheat.h"
+
+context::c_context g_ctx;
+
+NAMESPACE_REGION( context )
+
+bool c_context::run_frame( ) {
+ m_local = cl.m_entlist( )->get_client_entity< c_base_player >(
+ cl.m_engine( )->GetLocalPlayer( ) );
+
+ return !!m_local;
+}
+
+
+//predicted servertime of player, use this for breaking lby etc
+float c_context::pred_time( ) {
+ calculate_tickbase( );
+
+ return m_tickbase * cl.m_globals->interval_per_tick;
+}
+
+//calculate tickbase depending on whether last ucmd was predicted
+bool c_context::calculate_tickbase( ) {
+ if( !m_local ) {
+ return false;
+ }
+
+ //get current tickbase
+ auto player_tickbase = m_local->get_tick_base( );
+
+ //disabled due to our engine pred being shit
+ m_tickbase = player_tickbase;
+ return true;
+
+ if( m_snapshot.empty( ) ) {
+ m_tickbase = player_tickbase;
+ return false;
+ }
+
+ //if cmd wasnt predicted increment tickbase
+ auto snap_cmd = &m_snapshot.front( );
+ if( !snap_cmd->m_predicted ) {
+ if( !m_tickbase ) {
+ m_tickbase = player_tickbase;
+ }
+
+ m_tickbase++;
+ snap_cmd->m_predicted = true;
+ }
+ else {
+ m_tickbase = player_tickbase;
+ }
+
+ return true;
+}
+
+bool c_context::precache_model( const char* model ) {
+
+ auto cache_table = cl.m_string_table( )->FindTable( "modelprecache" );
+
+ if( !cache_table )
+ return true;
+
+ cl.m_modelinfo( )->FindOrLoadModel( model );
+
+ int string_index = cache_table->AddString( false, model );
+
+ if( string_index == -1 )
+ return false;
+
+ return true;
+}
+
+//save snapshots of usercommands
+bool c_context::create_snapshot( user_cmd_t* ucmd ) {
+ user_cmd_t ucmd_copy;
+
+ while( m_snapshot.size( ) >= 64 ) {
+ m_snapshot.pop_back( );
+ }
+
+ if( !ucmd ) {
+ return false;
+ }
+
+ memcpy( &ucmd_copy,
+ ucmd,
+ sizeof( ucmd_copy ) );
+
+ m_snapshot.push_front( ucmd_copy );
+ return true;
+}
+
+END_REGION
\ No newline at end of file |
