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

Method Update

src/engine/client/smooth_time.cpp:55–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void CSmoothTime::Update(CGraph *pGraph, int64_t Target, int TimeLeft, EAdjustDirection AdjustDirection)
56{
57 bool UpdateTimer = true;
58
59 if(TimeLeft < 0)
60 {
61 bool IsSpike = false;
62 if(TimeLeft < -50)
63 {
64 IsSpike = true;
65
66 m_SpikeCounter += 5;
67 if(m_SpikeCounter > 50)
68 m_SpikeCounter = 50;
69 }
70
71 if(IsSpike && m_SpikeCounter < 15)
72 {
73 // ignore this ping spike
74 UpdateTimer = false;
75 pGraph->Add(TimeLeft, ColorRGBA(1.0f, 1.0f, 0.0f, 0.75f));
76 }
77 else
78 {
79 pGraph->Add(TimeLeft, ColorRGBA(1.0f, 0.0f, 0.0f, 0.75f));
80 if(m_aAdjustSpeed[AdjustDirection] < 30.0f)
81 m_aAdjustSpeed[AdjustDirection] *= 2.0f;
82 }
83 }
84 else
85 {
86 if(m_SpikeCounter)
87 m_SpikeCounter--;
88
89 pGraph->Add(TimeLeft, ColorRGBA(0.0f, 1.0f, 0.0f, 0.75f));
90
91 m_aAdjustSpeed[AdjustDirection] *= 0.95f;
92 if(m_aAdjustSpeed[AdjustDirection] < 2.0f)
93 m_aAdjustSpeed[AdjustDirection] = 2.0f;
94 }
95
96 if(UpdateTimer)
97 UpdateInt(Target);
98}
99
100void CSmoothTime::UpdateMargin(int64_t Margin)
101{

Callers

nothing calls this directly

Calls 2

ColorRGBAClass · 0.50
AddMethod · 0.45

Tested by

no test coverage detected