| 163 | } |
| 164 | |
| 165 | void 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 | } |
no test coverage detected