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

Method Tick

src/game/server/player.cpp:165–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165void CPlayer::Tick()
166{
167 if(m_ScoreQueryResult != nullptr && m_ScoreQueryResult->m_Completed && m_SentSnaps >= 3)
168 {
169 ProcessScoreResult(*m_ScoreQueryResult);
170 m_ScoreQueryResult = nullptr;
171 }
172 if(m_ScoreFinishResult != nullptr && m_ScoreFinishResult->m_Completed)
173 {
174 ProcessScoreResult(*m_ScoreFinishResult);
175 m_ScoreFinishResult = nullptr;
176 }
177
178 if(!Server()->ClientIngame(m_ClientId))
179 return;
180
181 if(m_ChatScore > 0)
182 m_ChatScore--;
183
184 if(m_Moderating && m_Afk)
185 {
186 m_Moderating = false;
187 GameServer()->SendChatTarget(m_ClientId, "Active moderator mode disabled because you are afk.");
188
189 if(!GameServer()->PlayerModerating())
190 GameServer()->SendChat(-1, TEAM_ALL, "Server kick/spec votes are no longer actively moderated.");
191 }
192
193 // do latency stuff
194 {
195 IServer::CClientInfo Info;
196 if(Server()->GetClientInfo(m_ClientId, &Info))
197 {
198 m_Latency.m_Accum += Info.m_Latency;
199 m_Latency.m_AccumMax = maximum(m_Latency.m_AccumMax, Info.m_Latency);
200 m_Latency.m_AccumMin = minimum(m_Latency.m_AccumMin, Info.m_Latency);
201 }
202 // each second
203 if(Server()->Tick() % Server()->TickSpeed() == 0)
204 {
205 m_Latency.m_Avg = m_Latency.m_Accum / Server()->TickSpeed();
206 m_Latency.m_Max = m_Latency.m_AccumMax;
207 m_Latency.m_Min = m_Latency.m_AccumMin;
208 m_Latency.m_Accum = 0;
209 m_Latency.m_AccumMin = 1000;
210 m_Latency.m_AccumMax = 0;
211 }
212 }
213
214 if(Server()->GetNetErrorString(m_ClientId)[0])
215 {
216 SetInitialAfk(true);
217
218 char aBuf[512];
219 str_format(aBuf, sizeof(aBuf), "'%s' would have timed out, but can use timeout protection now", Server()->ClientName(m_ClientId));
220 GameServer()->SendChat(-1, TEAM_ALL, aBuf);
221 Server()->ResetNetErrorString(m_ClientId);
222 }

Callers 8

ResetMethod · 0.45
OnDirectInputMethod · 0.45
SetTeamMethod · 0.45
OverrideDefaultEmoteMethod · 0.45
ProcessPauseMethod · 0.45
PauseMethod · 0.45
ForcePauseMethod · 0.45

Calls 15

maximumFunction · 0.85
str_formatFunction · 0.85
ClientIngameMethod · 0.80
SendChatTargetMethod · 0.80
PlayerModeratingMethod · 0.80
GetClientInfoMethod · 0.80
TickSpeedMethod · 0.80
GetNetErrorStringMethod · 0.80
ClientNameMethod · 0.80
ResetNetErrorStringMethod · 0.80
IsGamePausedMethod · 0.80
IsAliveMethod · 0.80

Tested by

no test coverage detected