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

Method OnSetSpectatorModeNetMessage

src/game/server/gamecontext.cpp:2772–2792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2770}
2771
2772void 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
2794void CGameContext::OnChangeInfoNetMessage(const CNetMsg_Cl_ChangeInfo *pMsg, int ClientId)
2795{

Callers

nothing calls this directly

Calls 8

IsGamePausedMethod · 0.80
ReverseTranslateMethod · 0.80
TickSpeedMethod · 0.80
UpdatePlaytimeMethod · 0.80
GetTeamMethod · 0.80
SetSpectatorIdMethod · 0.80
ServerClass · 0.50
TickMethod · 0.45

Tested by

no test coverage detected