Skip to content

Commit

Permalink
Add Sv_CommandInfo netmsg for autocompletion of chat commands.
Browse files Browse the repository at this point in the history
(cherry picked from DDNet commit 035e7a1068c4cd82174ffdc6e8e0231f6bd131ff)
  • Loading branch information
furo321 authored and Kaffeine committed Dec 15, 2023
1 parent 294916c commit 8ed0c0f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
18 changes: 18 additions & 0 deletions datasrc/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,4 +617,22 @@
NetMessageEx("Sv_YourVote", "[email protected]", [
NetIntRange("m_Voted", -1, 1),
]),

NetMessageEx("Sv_RaceFinish", "[email protected]", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
NetIntAny("m_Time"),
NetIntAny("m_Diff"),
NetBool("m_RecordPersonal"),
NetBool("m_RecordServer", default=False),
]),

NetMessageEx("Sv_CommandInfo", "[email protected]", [
NetStringStrict("m_pName"),
NetStringStrict("m_pArgsFormat"),
NetStringStrict("m_pHelpText")
]),

NetMessageEx("Sv_CommandInfoRemove", "[email protected]", [
NetStringStrict("m_pName")
]),
]
26 changes: 26 additions & 0 deletions src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8ed0c0f

Please sign in to comment.