forked from Panguins/OneTap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetvar_compression.cpp
More file actions
29 lines (22 loc) · 909 Bytes
/
netvar_compression.cpp
File metadata and controls
29 lines (22 loc) · 909 Bytes
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
#include "context.h"
#include "netvar_compression.h"
c_netvar_compression g_netvar_compression;
void c_netvar_compression::start()
{
if (!ctx.m_local || !ctx.m_tickrate)
return;
//m_punch.resize( m_tickrate );
m_tickbase = ctx.m_local->tickbase();
m_punch[ctx.m_local->tickbase() % 128] = ctx.m_local->punch();
m_punch_velocity[ctx.m_local->tickbase() % 128] = ctx.m_local->punch_velocity();
}
void c_netvar_compression::finish()
{
// storing viable information for other players is also possible :3
if (!ctx.m_local || m_tickbase != ctx.m_local->tickbase())
return;
if (is_worthy(ctx.m_local->punch(), m_punch[ctx.m_local->tickbase() % 128]))
ctx.m_local->punch() = m_punch[ctx.m_local->tickbase() % 128];
if (is_worthy(ctx.m_local->punch_velocity(), m_punch_velocity[ctx.m_local->tickbase() % 128]))
ctx.m_local->punch_velocity() = m_punch_velocity[ctx.m_local->tickbase() % 128];
}