| 635 | } |
| 636 | |
| 637 | void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText, int SpamProtectionClientId, int VersionFlags) |
| 638 | { |
| 639 | dbg_assert(ChatterClientId >= -1 && ChatterClientId < MAX_CLIENTS, "ChatterClientId invalid: %d", ChatterClientId); |
| 640 | |
| 641 | if(SpamProtectionClientId >= 0 && SpamProtectionClientId < MAX_CLIENTS) |
| 642 | if(ProcessSpamProtection(SpamProtectionClientId)) |
| 643 | return; |
| 644 | |
| 645 | char aText[256]; |
| 646 | str_copy(aText, pText, sizeof(aText)); |
| 647 | const char *pTeamString = Team == TEAM_ALL ? "chat" : "teamchat"; |
| 648 | if(ChatterClientId == -1) |
| 649 | { |
| 650 | log_info(pTeamString, "*** %s", aText); |
| 651 | } |
| 652 | else |
| 653 | { |
| 654 | log_info(pTeamString, "%d:%d:%s: %s", ChatterClientId, Team, Server()->ClientName(ChatterClientId), aText); |
| 655 | } |
| 656 | |
| 657 | if(Team == TEAM_ALL) |
| 658 | { |
| 659 | CNetMsg_Sv_Chat Msg; |
| 660 | Msg.m_Team = 0; |
| 661 | Msg.m_ClientId = ChatterClientId; |
| 662 | Msg.m_pMessage = aText; |
| 663 | |
| 664 | // pack one for the recording only |
| 665 | if(g_Config.m_SvDemoChat) |
| 666 | Server()->SendPackMsg(&Msg, MSGFLAG_NOSEND, SERVER_DEMO_CLIENT); |
| 667 | |
| 668 | // send to the clients |
| 669 | for(int i = 0; i < Server()->MaxClients(); i++) |
| 670 | { |
| 671 | if(!m_apPlayers[i]) |
| 672 | continue; |
| 673 | bool Send = (Server()->IsSixup(i) && (VersionFlags & FLAG_SIXUP)) || |
| 674 | (!Server()->IsSixup(i) && (VersionFlags & FLAG_SIX)); |
| 675 | |
| 676 | if(!m_apPlayers[i]->m_DND && Send) |
| 677 | Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, i); |
| 678 | } |
| 679 | |
| 680 | char aBuf[sizeof(aText) + 8]; |
| 681 | str_format(aBuf, sizeof(aBuf), "Chat: %s", aText); |
| 682 | LogEvent(aBuf, ChatterClientId); |
| 683 | } |
| 684 | else |
| 685 | { |
| 686 | CTeamsCore *pTeams = &m_pController->Teams().m_Core; |
| 687 | CNetMsg_Sv_Chat Msg; |
| 688 | Msg.m_Team = 1; |
| 689 | Msg.m_ClientId = ChatterClientId; |
| 690 | Msg.m_pMessage = aText; |
| 691 | |
| 692 | // pack one for the recording only |
| 693 | if(g_Config.m_SvDemoChat) |
| 694 | Server()->SendPackMsg(&Msg, MSGFLAG_NOSEND, SERVER_DEMO_CLIENT); |
no test coverage detected