-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathnetdata.cpp
70 lines (54 loc) · 2.11 KB
/
netdata.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "includes.h"
NetData g_netdata{};;
void NetData::store( ) {
int tickbase;
StoredData_t *data;
if( !g_cl.m_processing ) {
reset( );
return;
}
tickbase = g_cl.m_local->m_nTickBase( );
// get current record and store data.
data = &m_data[ tickbase % MULTIPLAYER_BACKUP ];
data->m_tickbase = tickbase;
data->m_punch = g_cl.m_local->m_aimPunchAngle( );
data->m_punch_vel = g_cl.m_local->m_aimPunchAngleVel( );
data->m_view_offset = g_cl.m_local->m_vecViewOffset( );
}
void NetData::apply( ) {
int tickbase;
StoredData_t *data;
ang_t punch_delta, punch_vel_delta;
vec3_t view_delta;
if( !g_cl.m_processing ) {
reset( );
return;
}
tickbase = g_cl.m_local->m_nTickBase( );
// get current record and validate.
data = &m_data[ tickbase % MULTIPLAYER_BACKUP ];
if( g_cl.m_local->m_nTickBase( ) != data->m_tickbase )
return;
// get deltas.
// note - dex; before, when you stop shooting, punch values would sit around 0.03125 and then goto 0 next update.
// with this fix applied, values slowly decay under 0.03125.
punch_delta = g_cl.m_local->m_aimPunchAngle( ) - data->m_punch;
punch_vel_delta = g_cl.m_local->m_aimPunchAngleVel( ) - data->m_punch_vel;
view_delta = g_cl.m_local->m_vecViewOffset( ) - data->m_view_offset;
// set data.
if( std::abs( punch_delta.x ) < 0.03125f &&
std::abs( punch_delta.y ) < 0.03125f &&
std::abs( punch_delta.z ) < 0.03125f )
g_cl.m_local->m_aimPunchAngle( ) = data->m_punch;
if( std::abs( punch_vel_delta.x ) < 0.03125f &&
std::abs( punch_vel_delta.y ) < 0.03125f &&
std::abs( punch_vel_delta.z ) < 0.03125f )
g_cl.m_local->m_aimPunchAngleVel( ) = data->m_punch_vel;
if( std::abs( view_delta.x ) < 0.03125f &&
std::abs( view_delta.y ) < 0.03125f &&
std::abs( view_delta.z ) < 0.03125f )
g_cl.m_local->m_vecViewOffset( ) = data->m_view_offset;
}
void NetData::reset( ) {
m_data.fill( StoredData_t( ) );
}