summaryrefslogtreecommitdiff
path: root/internal_rewrite/prediction.hpp
diff options
context:
space:
mode:
authorJustSomePwner <crotchyalt@gmail.com>2018-08-30 14:01:54 +0200
committerJustSomePwner <crotchyalt@gmail.com>2018-08-30 14:01:54 +0200
commit7ccb819f867493f8ec202ea3b39c94c198c64584 (patch)
tree94622e61af0ff359e3d6689cf274d74f60b2492a /internal_rewrite/prediction.hpp
parent564d979b79e8a5aaa5014eba0ecd36c61575934f (diff)
first
Diffstat (limited to 'internal_rewrite/prediction.hpp')
-rw-r--r--internal_rewrite/prediction.hpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/internal_rewrite/prediction.hpp b/internal_rewrite/prediction.hpp
new file mode 100644
index 0000000..914b97f
--- /dev/null
+++ b/internal_rewrite/prediction.hpp
@@ -0,0 +1,97 @@
+#pragma once
+#include "vector.hpp"
+#include "util.hpp"
+
+#include <array>
+#include <deque>
+
+class user_cmd_t;
+class c_base_player;
+
+NAMESPACE_REGION( features )
+
+class c_prediction
+{
+ user_cmd_t* m_ucmd{ };
+ int m_predicted_flags{ };
+
+ float m_old_time;
+ float m_old_frametime;
+ int m_old_tickcount;
+
+ int m_prediction_seed;
+ int m_prediction_player;
+
+ struct player_data_t {
+ struct lag_velocity_record_t {
+ vec3_t m_velocity;
+ int m_tick;
+ };
+
+ void update( int ent_index );
+
+ float m_simtime{ };
+ int m_last_choke{ };
+ vec3_t m_angles{ };
+ vec3_t m_velocity{ };
+ vec3_t m_old_velocity{ };
+ vec3_t m_position{ };
+ vec3_t m_movement{ };
+ bool m_valid{ };
+ bool m_breaking_lc{ };
+
+ std::deque< lag_velocity_record_t > m_records{ };
+ };
+
+ std::array< player_data_t, 65 > m_players;
+
+ void run( user_cmd_t* ucmd );
+public:
+ // You should be using the un-predicted velocity for fake-walk.
+ vec3_t m_velocity{ };
+
+ // void local_pred( user_cmd_t* );
+
+ void pre_run_command( );
+ void run_command( user_cmd_t *cmd );
+ void post_run_command( );
+
+ int get_predicted_flags( ) const {
+ return m_predicted_flags;
+ }
+
+ bool is_breaking_lc( int ent ) const {
+ return m_players[ ent ].m_breaking_lc;
+ }
+
+ inline player_data_t get_player_data( int ent_index ) {
+ return m_players[ ent_index ];
+ }
+
+ player_data_t m_player;
+
+ //gamemovement functions
+ vec3_t full_walk_move( c_base_player*, int );
+ void check_jump_button( c_base_player*, vec3_t&, vec3_t& );
+ void start_gravity( c_base_player*, vec3_t&, vec3_t& );
+ void finish_gravity( c_base_player*, vec3_t&, vec3_t& );
+ void friction( c_base_player*, vec3_t&, vec3_t& );
+ void air_move( c_base_player*, vec3_t&, vec3_t&, vec3_t&, vec3_t& );
+ void air_accelerate( c_base_player*, vec3_t&, vec3_t&, vec3_t&, float );
+ // void walk_move( c_base_player*, vec3_t&, vec3_t& );
+ bool categorize_position( c_base_player*, vec3_t&, vec3_t& );
+ void check_velocity( c_base_player*, vec3_t&, vec3_t& );
+ void try_player_move( c_base_player*, vec3_t&, vec3_t& );
+
+ void frame_stage_notify( );
+ vec3_t aimware_extrapolate( c_base_player* ent, vec3_t origin, vec3_t& velocity );
+ void predict_player( c_base_player* player );
+ int get_predicted_choke( int );
+ vec3_t extrapolate_player( c_base_player*, int );
+ void trace_player_bbox( c_base_player*, const vec3_t& start, const vec3_t& end, CGameTrace* pm );
+ void try_touch_ground( c_base_player*, const vec3_t& start, const vec3_t& end, const vec3_t& mins, const vec3_t& maxs, CGameTrace* pm );
+ void try_touch_ground_in_quadrants( c_base_player*, const vec3_t& start, const vec3_t& end, CGameTrace* pm );
+
+};
+
+END_REGION