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

Method SendServerAlert

src/game/server/gamecontext.cpp:764–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

762}
763
764void CGameContext::SendServerAlert(const char *pMessage)
765{
766 for(int ClientId = 0; ClientId < Server()->MaxClients(); ClientId++)
767 {
768 if(!m_apPlayers[ClientId])
769 {
770 continue;
771 }
772
773 if(m_apPlayers[ClientId]->GetClientVersion() >= VERSION_DDNET_IMPORTANT_ALERT)
774 {
775 CNetMsg_Sv_ServerAlert Msg;
776 Msg.m_pMessage = pMessage;
777 Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientId);
778 }
779 else
780 {
781 char aBroadcastText[1024 + 32];
782 str_copy(aBroadcastText, "SERVER ALERT\n\n");
783 str_append(aBroadcastText, pMessage);
784 SendBroadcast(aBroadcastText, ClientId, true);
785 }
786 }
787
788 // Record server alert to demos exactly once
789 // TODO: Workaround https://github.com/ddnet/ddnet/issues/11144 by using client ID 0,
790 // otherwise the message is recorded multiple times.
791 CNetMsg_Sv_ServerAlert Msg;
792 Msg.m_pMessage = pMessage;
793 Server()->SendPackMsg(&Msg, MSGFLAG_NOSEND, 0);
794}
795
796void CGameContext::SendModeratorAlert(const char *pMessage, int ToClientId)
797{

Callers 1

ConServerAlertMethod · 0.80

Calls 6

ServerClass · 0.50
str_copyFunction · 0.50
str_appendFunction · 0.50
MaxClientsMethod · 0.45
GetClientVersionMethod · 0.45
SendPackMsgMethod · 0.45

Tested by

no test coverage detected