From 8ed0c0f408c0e0e04f69347dfdce697cb98b5e39 Mon Sep 17 00:00:00 2001 From: furo Date: Thu, 14 Dec 2023 00:04:23 +0100 Subject: [PATCH] Add `Sv_CommandInfo` netmsg for autocompletion of chat commands. (cherry picked from DDNet commit 035e7a1068c4cd82174ffdc6e8e0231f6bd131ff) --- datasrc/network.py | 18 ++++++++++++++++++ src/game/server/gamecontext.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/datasrc/network.py b/datasrc/network.py index b5135ed6..6457ad56 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -617,4 +617,22 @@ NetMessageEx("Sv_YourVote", "yourvote@netmsg.ddnet.org", [ NetIntRange("m_Voted", -1, 1), ]), + + NetMessageEx("Sv_RaceFinish", "racefinish@netmsg.ddnet.org", [ + NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), + NetIntAny("m_Time"), + NetIntAny("m_Diff"), + NetBool("m_RecordPersonal"), + NetBool("m_RecordServer", default=False), + ]), + + NetMessageEx("Sv_CommandInfo", "commandinfo@netmsg.ddnet.org", [ + NetStringStrict("m_pName"), + NetStringStrict("m_pArgsFormat"), + NetStringStrict("m_pHelpText") + ]), + + NetMessageEx("Sv_CommandInfoRemove", "commandinfo-remove@netmsg.ddnet.org", [ + NetStringStrict("m_pName") + ]), ] diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 074f53c8..e9890a2b 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1672,6 +1672,32 @@ void CGameContext::OnClientEnter(int ClientID) m_apPlayers[ClientID]->m_IsInGame = true; m_apPlayers[ClientID]->Respawn(); + for(const IConsole::CCommandInfo *pCmd = Console()->FirstCommandInfo(IConsole::ACCESS_LEVEL_USER, CFGFLAG_CHAT); + pCmd; pCmd = pCmd->NextCommandInfo(IConsole::ACCESS_LEVEL_USER, CFGFLAG_CHAT)) + { + const char *pName = pCmd->m_pName; + + if(Server()->IsSixup(ClientID)) + { + if(!str_comp_nocase(pName, "w") || !str_comp_nocase(pName, "whisper")) + continue; + + protocol7::CNetMsg_Sv_CommandInfo Msg; + Msg.m_pName = pName; + Msg.m_pArgsFormat = pCmd->m_pParams; + Msg.m_pHelpText = pCmd->m_pHelp; + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientID); + } + else + { + CNetMsg_Sv_CommandInfo Msg; + Msg.m_pName = pName; + Msg.m_pArgsFormat = pCmd->m_pParams; + Msg.m_pHelpText = pCmd->m_pHelp; + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientID); + } + } + m_VoteUpdate = true; // send active vote