From 80539245c8222ededb34f2593cbe257e44825933 Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Sat, 9 Jan 2021 16:05:54 +0300 Subject: [PATCH] GameContext: Extract SendMotd() and SendSettings() methods Partial cherry-pick from upstream d8d259a1663a6c47bd703b071dd798d6535e45ae --- src/game/server/gamecontext.cpp | 47 ++++++++++++++++++--------------- src/game/server/gamecontext.h | 2 ++ 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 98c66a873..b1046fc9c 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -469,6 +469,28 @@ void CGameContext::SendWeaponPickup(int ClientID, int Weapon) Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID); } +void CGameContext::SendMotd(int ClientID) +{ + CNetMsg_Sv_Motd Msg; + Msg.m_pMessage = g_Config.m_SvMotd; + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID); +} + +void CGameContext::SendSettings(int ClientID) +{ + if(Server()->IsSixup(ClientID)) + { + protocol7::CNetMsg_Sv_ServerSettings Msg; + Msg.m_KickVote = g_Config.m_SvVoteKick; + Msg.m_KickMin = g_Config.m_SvVoteKickMin; + Msg.m_SpecVote = g_Config.m_SvVoteSpectate; + Msg.m_TeamLock = 0; + Msg.m_TeamBalance = 0; + Msg.m_PlayerSlots = g_Config.m_SvMaxClients - g_Config.m_SvSpectatorSlots; + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientID); + } +} + void CGameContext::SendBroadcast(const char *pText, int ClientID, bool IsImportant) { CNetMsg_Sv_Broadcast Msg; @@ -1361,23 +1383,8 @@ void CGameContext::OnClientConnected(int ClientID) } #endif - // send motd - CNetMsg_Sv_Motd Msg; - Msg.m_pMessage = g_Config.m_SvMotd; - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID); - - //send sixup settings - if(Server()->IsSixup(ClientID)) - { - protocol7::CNetMsg_Sv_ServerSettings Msg; - Msg.m_KickVote = g_Config.m_SvVoteKick; - Msg.m_KickMin = g_Config.m_SvVoteKickMin; - Msg.m_SpecVote = g_Config.m_SvVoteSpectate; - Msg.m_TeamLock = 0; - Msg.m_TeamBalance = 0; - Msg.m_PlayerSlots = g_Config.m_SvMaxClients - g_Config.m_SvSpectatorSlots; - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientID); - } + SendMotd(ClientID); + SendSettings(ClientID); Server()->ExpireServerInfo(); } @@ -2989,12 +2996,8 @@ void CGameContext::ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *p pfnCallback(pResult, pCallbackUserData); if(pResult->NumArguments()) { - CNetMsg_Sv_Motd Msg; - Msg.m_pMessage = g_Config.m_SvMotd; CGameContext *pSelf = (CGameContext *)pUserData; - for(int i = 0; i < MAX_CLIENTS; ++i) - if(pSelf->m_apPlayers[i]) - pSelf->Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i); + pSelf->SendMotd(-1); } } diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index e0637dcde..3ae76729c 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -219,6 +219,8 @@ public: void SendChat(int ClientID, int Team, const char *pText, int SpamProtectionClientID = -1, int Flags = CHAT_SIX | CHAT_SIXUP); void SendEmoticon(int ClientID, int Emoticon); void SendWeaponPickup(int ClientID, int Weapon); + void SendMotd(int ClientID); + void SendSettings(int ClientID); void SendBroadcast(const char *pText, int ClientID, bool IsImportant = true); void List(int ClientID, const char *filter);