Revert "Revert "Restrict rcon output (east)""

This reverts commit 35cf8832a9.
This commit is contained in:
def 2013-07-31 01:31:53 +02:00
parent 9ae9b53c7f
commit 8720186c75
4 changed files with 9 additions and 1 deletions

View file

@ -32,6 +32,7 @@ public:
virtual bool ClientIngame(int ClientID) = 0; virtual bool ClientIngame(int ClientID) = 0;
virtual int GetClientInfo(int ClientID, CClientInfo *pInfo) = 0; virtual int GetClientInfo(int ClientID, CClientInfo *pInfo) = 0;
virtual void GetClientAddr(int ClientID, char *pAddrStr, int Size) = 0; virtual void GetClientAddr(int ClientID, char *pAddrStr, int Size) = 0;
virtual void RestrictRconOutput(int ClientID) = 0;
virtual int SendMsg(CMsgPacker *pMsg, int Flags, int ClientID) = 0; virtual int SendMsg(CMsgPacker *pMsg, int Flags, int ClientID) = 0;

View file

@ -313,6 +313,8 @@ CServer::CServer() : m_DemoRecorder(&m_SnapshotDelta)
m_RconClientID = IServer::RCON_CID_SERV; m_RconClientID = IServer::RCON_CID_SERV;
m_RconAuthLevel = AUTHED_ADMIN; m_RconAuthLevel = AUTHED_ADMIN;
m_RconRestrict = -1;
Init(); Init();
} }
@ -789,7 +791,7 @@ void CServer::SendRconLineAuthed(const char *pLine, void *pUser)
for(i = 0; i < MAX_CLIENTS; i++) 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_RconRestrict == -1 || pThis->m_RconRestrict == i))
pThis->SendRconLine(i, pLine); pThis->SendRconLine(i, pLine);
} }

View file

@ -169,6 +169,8 @@ public:
CRegister m_Register; CRegister m_Register;
CMapChecker m_MapChecker; CMapChecker m_MapChecker;
int m_RconRestrict;
CServer(); CServer();
int TrySetClientName(int ClientID, const char *pName); int TrySetClientName(int ClientID, const char *pName);
@ -256,6 +258,7 @@ public:
int m_aPrevStates[MAX_CLIENTS]; int m_aPrevStates[MAX_CLIENTS];
char *GetAnnouncementLine(char const *FileName); char *GetAnnouncementLine(char const *FileName);
unsigned m_AnnouncementLastLine; unsigned m_AnnouncementLastLine;
void RestrictRconOutput(int ClientID) { m_RconRestrict = ClientID; }
}; };
#endif #endif

View file

@ -805,6 +805,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
if(pMsg->m_pMessage[0]=='/') // TODO: Add spam protection if(pMsg->m_pMessage[0]=='/') // TODO: Add spam protection
{ {
m_ChatResponseTargetID = ClientID; m_ChatResponseTargetID = ClientID;
Server()->RestrictRconOutput(ClientID);
Console()->SetFlagMask(CFGFLAG_CHAT); Console()->SetFlagMask(CFGFLAG_CHAT);
if (pPlayer->m_Authed) if (pPlayer->m_Authed)
@ -821,6 +822,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
Console()->SetAccessLevel(IConsole::ACCESS_LEVEL_ADMIN); Console()->SetAccessLevel(IConsole::ACCESS_LEVEL_ADMIN);
Console()->SetFlagMask(CFGFLAG_SERVER); Console()->SetFlagMask(CFGFLAG_SERVER);
m_ChatResponseTargetID = -1; m_ChatResponseTargetID = -1;
Server()->RestrictRconOutput(-1);
} }
else else
SendChat(ClientID, Team, pMsg->m_pMessage, ClientID); SendChat(ClientID, Team, pMsg->m_pMessage, ClientID);