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 /gmod/prediction.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 'gmod/prediction.cpp')
| -rw-r--r-- | gmod/prediction.cpp | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/gmod/prediction.cpp b/gmod/prediction.cpp deleted file mode 100644 index ebfea5b..0000000 --- a/gmod/prediction.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include "prediction.hpp"
-#include "hooks.hpp"
-#include "context.hpp"
-
-NAMESPACE_REGION( features )
-
-void c_prediction::predict_player( c_base_player* player ) {
- static uintptr_t run_command_address = g_gmod.m_prediction->get_old_function< uintptr_t >( 17 );
- static uintptr_t set_prediction_random_seed_address = ( run_command_address + 0x21 + 4 + *( uintptr_t* )( run_command_address + 0x21 ) );
-
-
- CMoveData move_data{ };
- auto ce = player->ce( );
-
- float old_curtime = g_gmod.m_globals->m_curtime;
- float old_frametime = g_gmod.m_globals->m_frametime;
-
- int backup_tickbase = player->m_nTickBase( );
- int backup_simtime = player->m_flSimulationTime( );
-
-
- //random seed is already being calculated and set in createmove
- **( uintptr_t** )( set_prediction_random_seed_address + 0xC ) = g_ctx.get_last_cmd( )->m_random_seed; //prediction seed
- **( uintptr_t** )( run_command_address + 0x2F ) = uintptr_t( g_ctx.m_local ); //prediction player
-
- //start prediction
- g_gmod.m_game_movement( )->StartTrackPredictionErrors( ce );
-
- //run prediction
- g_gmod.m_prediction( )->SetupMove( ce, *player->get< user_cmd_t** >( 0x24B0 ), g_gmod.m_move_helper( ), &move_data );
- g_gmod.m_game_movement( )->ProcessMovement( ce, &move_data );
- g_gmod.m_prediction( )->FinishMove( ce, *player->get< user_cmd_t** >( 0x24B0 ), &move_data );
-
- //finish prediction
- g_gmod.m_game_movement( )->FinishTrackPredictionErrors( ce );
-
- **( uintptr_t** )( set_prediction_random_seed_address + 0xC ) = 0xffffffff;
- **( uintptr_t*** )( run_command_address + 0x2F ) = nullptr;
-
- player->m_nTickBase( ) = backup_tickbase;
- player->m_flSimulationTime( ) = backup_simtime;
-
- g_gmod.m_globals->m_curtime = old_curtime;
- g_gmod.m_globals->m_frametime = old_frametime;
-}
-
-void c_prediction::run( user_cmd_t* ucmd ) {
- if ( !ucmd || !g_ctx.m_local || !g_ctx.m_local->is_alive( ) )
- return;
-
- static uintptr_t run_command_address = g_gmod.m_prediction->get_old_function< uintptr_t >( 17 );
- static uintptr_t relative_call_addr = run_command_address + 0x21;
- static uintptr_t set_prediction_random_seed_address = ( relative_call_addr + 4 + *( uintptr_t* )( relative_call_addr ) );
-
- static auto sv_footsteps = g_gmod.m_cvar( )->FindVar( "sv_footsteps" );
-
- CMoveData move_data{ };
- IClientEntity* local_ent = g_ctx.m_local->ce( );
-
- //backup data
- int old_buttons = ucmd->m_buttons;
- float old_curtime = g_gmod.m_globals->m_curtime;
- float old_frame_time = g_gmod.m_globals->m_frametime;
- int old_tickbase = g_ctx.m_local->m_nTickBase( );
- int old_flags = g_ctx.m_local->m_fFlags( );
- MoveType_t old_move_type = g_ctx.m_local->m_nMoveType( );
- vec3_t old_velocity = g_ctx.m_local->m_vecVelocity( );
- int old_sv_flags = sv_footsteps->m_flags;
-
- sv_footsteps->m_flags = 0;
- sv_footsteps->m_nvalue = 0;
-
- //set globals
- g_gmod.m_globals->m_curtime = g_gmod.m_globals->m_interval_per_tick * old_tickbase;
- g_gmod.m_globals->m_frametime = g_gmod.m_globals->m_interval_per_tick;
-
- //random seed is already being calculated and set in createmove
- **( uintptr_t** )( set_prediction_random_seed_address + 0xC ) = ucmd->m_random_seed; //prediction seed
- **( uintptr_t** )( run_command_address + 0x2F ) = uintptr_t( g_ctx.m_local ); //prediction player
-
- //start prediction
- g_gmod.m_game_movement( )->StartTrackPredictionErrors( local_ent );
-
- //run prediction
- g_gmod.m_prediction( )->SetupMove( local_ent, ucmd, nullptr, &move_data );
- g_gmod.m_game_movement( )->ProcessMovement( local_ent, &move_data );
- g_gmod.m_prediction( )->FinishMove( local_ent, ucmd, &move_data );
-
- //finish prediction
- g_gmod.m_game_movement( )->FinishTrackPredictionErrors( local_ent );
-
- **( uintptr_t** )( set_prediction_random_seed_address + 0xC ) = 0xffffffff;
- **( uintptr_t*** )( run_command_address + 0x2F ) = nullptr;
-
- //good to have, can be used for edge jump and such
- m_predicted_flags = g_ctx.m_local->m_fFlags( );
-
- //restore
- ucmd->m_buttons = old_buttons;
- g_gmod.m_globals->m_curtime = old_curtime;
- g_gmod.m_globals->m_frametime = old_frame_time;
- g_ctx.m_local->m_nTickBase( ) = old_tickbase;
- g_ctx.m_local->m_fFlags( ) = old_flags;
- g_ctx.m_local->m_nMoveType( ) = old_move_type;
- g_ctx.m_local->m_vecVelocity( ) = old_velocity;
-
- sv_footsteps->m_nvalue = 1;
- sv_footsteps->m_flags = old_sv_flags;
-}
-
-END_REGION
\ No newline at end of file |
