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

Method SendModeratorAlert

src/game/server/gamecontext.cpp:796–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794}
795
796void CGameContext::SendModeratorAlert(const char *pMessage, int ToClientId)
797{
798 dbg_assert(in_range(ToClientId, 0, MAX_CLIENTS - 1), "SendImportantAlert ToClientId invalid: %d", ToClientId);
799 dbg_assert(m_apPlayers[ToClientId] != nullptr, "Client not online: %d", ToClientId);
800
801 if(m_apPlayers[ToClientId]->GetClientVersion() >= VERSION_DDNET_IMPORTANT_ALERT)
802 {
803 CNetMsg_Sv_ModeratorAlert Msg;
804 Msg.m_pMessage = pMessage;
805 Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ToClientId);
806 }
807 else
808 {
809 char aBroadcastText[1024 + 32];
810 str_copy(aBroadcastText, "MODERATOR ALERT\n\n");
811 str_append(aBroadcastText, pMessage);
812 SendBroadcast(aBroadcastText, ToClientId, true);
813 log_info("moderator_alert", "Notice: player uses an old client version and may not see moderator alerts: %s (ID %d)", Server()->ClientName(ToClientId), ToClientId);
814 }
815}
816
817void CGameContext::SendBroadcast(const char *pText, int ClientId, bool IsImportant)
818{

Callers 1

ConModAlertMethod · 0.80

Calls 7

in_rangeFunction · 0.85
ClientNameMethod · 0.80
ServerClass · 0.50
str_copyFunction · 0.50
str_appendFunction · 0.50
GetClientVersionMethod · 0.45
SendPackMsgMethod · 0.45

Tested by

no test coverage detected