MCPcopy Create free account
hub / github.com/ddnet/ddnet / Get

Method Get

src/engine/client/smooth_time.cpp:27–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27int64_t CSmoothTime::Get(int64_t Now) const
28{
29 int64_t c = m_Current + (Now - m_Snap);
30 int64_t t = m_Target + (Now - m_Snap);
31
32 // it's faster to adjust upward instead of downward
33 // we might need to adjust these abit
34
35 float AdjustSpeed = m_aAdjustSpeed[ADJUSTDIRECTION_DOWN];
36 if(t > c)
37 AdjustSpeed = m_aAdjustSpeed[ADJUSTDIRECTION_UP];
38
39 float a = ((Now - m_Snap) / (float)time_freq()) * AdjustSpeed;
40 if(a > 1.0f)
41 a = 1.0f;
42
43 int64_t r = c + (int64_t)((t - c) * a);
44 return r + m_Margin;
45}
46
47void CSmoothTime::UpdateInt(int64_t Target)
48{

Callers 7

SendInputMethod · 0.45
ProcessServerPacketMethod · 0.45
UpdateMethod · 0.45
GetPredictionTimeMethod · 0.45
GetSmoothTickMethod · 0.45
CreateServerBrowserHttpFunction · 0.45
LoadShaderMethod · 0.45

Calls 1

time_freqFunction · 0.85

Tested by

no test coverage detected