| 2770 | } |
| 2771 | |
| 2772 | void CGameContext::OnSetSpectatorModeNetMessage(const CNetMsg_Cl_SetSpectatorMode *pMsg, int ClientId) |
| 2773 | { |
| 2774 | if(m_pController->IsGamePaused()) |
| 2775 | return; |
| 2776 | |
| 2777 | int SpectatorId = std::clamp(pMsg->m_SpectatorId, (int)SPEC_FOLLOW, MAX_CLIENTS - 1); |
| 2778 | if(SpectatorId >= 0) |
| 2779 | if(!Server()->ReverseTranslate(SpectatorId, ClientId)) |
| 2780 | return; |
| 2781 | |
| 2782 | CPlayer *pPlayer = m_apPlayers[ClientId]; |
| 2783 | if((g_Config.m_SvSpamprotection && pPlayer->m_LastSetSpectatorMode && pPlayer->m_LastSetSpectatorMode + Server()->TickSpeed() / 4 > Server()->Tick())) |
| 2784 | return; |
| 2785 | |
| 2786 | pPlayer->m_LastSetSpectatorMode = Server()->Tick(); |
| 2787 | pPlayer->UpdatePlaytime(); |
| 2788 | if(SpectatorId >= 0 && (!m_apPlayers[SpectatorId] || m_apPlayers[SpectatorId]->GetTeam() == TEAM_SPECTATORS)) |
| 2789 | SendChatTarget(ClientId, "Invalid spectator id used"); |
| 2790 | else |
| 2791 | pPlayer->SetSpectatorId(SpectatorId); |
| 2792 | } |
| 2793 | |
| 2794 | void CGameContext::OnChangeInfoNetMessage(const CNetMsg_Cl_ChangeInfo *pMsg, int ClientId) |
| 2795 | { |
nothing calls this directly
no test coverage detected