| 762 | } |
| 763 | |
| 764 | void 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 | |
| 796 | void CGameContext::SendModeratorAlert(const char *pMessage, int ToClientId) |
| 797 | { |
no test coverage detected