Skip to content
This repository has been archived by the owner on Nov 16, 2017. It is now read-only.

Restricting rcon output to player #233

Open
wants to merge 2 commits into
base: DDRace
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/engine/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class IServer : public IInterface
// DDRace

virtual void GetClientAddr(int ClientID, NETADDR *pAddr) = 0;
virtual void RestrictRconOutput(int ClientID) = 0;
};

class IGameServer : public IInterface
Expand Down
6 changes: 5 additions & 1 deletion src/engine/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ CServer::CServer() : m_DemoRecorder(&m_SnapshotDelta)
m_RconClientID = IServer::RCON_CID_SERV;
m_RconAuthLevel = AUTHED_ADMIN;

m_RconOutputRestrict = -1;

Init();
}

Expand Down Expand Up @@ -788,7 +790,7 @@ void CServer::SendRconLineAuthed(const char *pLine, void *pUser)

for(i = 0; i < MAX_CLIENTS; i++)
{
if(pThis->m_aClients[i].m_State != CClient::STATE_EMPTY && pThis->m_aClients[i].m_Authed >= pThis->m_RconAuthLevel)
if(pThis->m_aClients[i].m_State != CClient::STATE_EMPTY && pThis->m_aClients[i].m_Authed >= pThis->m_RconAuthLevel && (pThis->m_RconOutputRestrict == -1 || pThis->m_RconOutputRestrict == i))
pThis->SendRconLine(i, pLine);
}

Expand Down Expand Up @@ -1016,7 +1018,9 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
m_RconClientID = ClientID;
m_RconAuthLevel = m_aClients[ClientID].m_Authed;
Console()->SetAccessLevel(m_aClients[ClientID].m_Authed == AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : m_aClients[ClientID].m_Authed == AUTHED_MOD ? IConsole::ACCESS_LEVEL_MOD : IConsole::ACCESS_LEVEL_USER);
RestrictRconOutput(ClientID);
Console()->ExecuteLineFlag(pCmd, CFGFLAG_SERVER, ClientID);
RestrictRconOutput(-1);
Console()->SetAccessLevel(IConsole::ACCESS_LEVEL_ADMIN);
m_RconClientID = IServer::RCON_CID_SERV;
m_RconAuthLevel = AUTHED_ADMIN;
Expand Down
3 changes: 3 additions & 0 deletions src/engine/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class CServer : public IServer
CRegister m_Register;
CMapChecker m_MapChecker;

int m_RconOutputRestrict;

CServer();

int TrySetClientName(int ClientID, const char *pName);
Expand Down Expand Up @@ -255,6 +257,7 @@ class CServer : public IServer
int m_aPrevStates[MAX_CLIENTS];
char *GetAnnouncementLine(char const *FileName);
unsigned m_AnnouncementLastLine;
void RestrictRconOutput(int ClientID) { m_RconOutputRestrict = ClientID; }
};

#endif
2 changes: 2 additions & 0 deletions src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
if(pMsg->m_pMessage[0]=='/')
{
m_ChatResponseTargetID = ClientID;
Server()->RestrictRconOutput(ClientID);
Console()->SetFlagMask(CFGFLAG_CHAT);

if (pPlayer->m_Authed)
Expand All @@ -821,6 +822,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
Console()->SetAccessLevel(IConsole::ACCESS_LEVEL_ADMIN);
Console()->SetFlagMask(CFGFLAG_SERVER);
m_ChatResponseTargetID = -1;
Server()->RestrictRconOutput(-1);
}
else
SendChat(ClientID, Team, pMsg->m_pMessage, ClientID);
Expand Down