From b73ce9b42fe5a4c9592bb347523683d211b69ad5 Mon Sep 17 00:00:00 2001 From: GreYFoXGTi Date: Fri, 17 Sep 2010 16:47:31 +0300 Subject: [PATCH] Implemented auth id 0 Signed-off-by: GreYFoXGTi --- src/engine/server/server.cpp | 11 +++++++++++ src/engine/server/server.h | 2 +- src/game/server/gamecontext.cpp | 16 +++++++++------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index f037fa68f..054bfc809 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1770,3 +1770,14 @@ int main(int argc, const char **argv) // ignore_convention return 0; } +void CServer::LogOut(int ClientId) +{ + if(m_aClients[ClientId].m_Authed>0) + { + dbg_msg("server", "%s logged out. ClientId=%x ip=%d.%d.%d.%d",ClientName(ClientId), ClientId,m_aClients[ClientId].m_Addr.ip[0], m_aClients[ClientId].m_Addr.ip[1], m_aClients[ClientId].m_Addr.ip[2], m_aClients[ClientId].m_Addr.ip[3] ); + CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS); + Msg.AddInt(0); + SendMsgEx(&Msg, MSGFLAG_VITAL, ClientId, true); + m_aClients[ClientId].m_Authed = 0; + } +} diff --git a/src/engine/server/server.h b/src/engine/server/server.h index f40baecfe..52e381bec 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -207,7 +207,7 @@ public: void RegisterCommands(); - + void LogOut(int ClientId); virtual int SnapNewID(); virtual void SnapFreeID(int ID); virtual void *SnapNewItem(int Type, int Id, int Size); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index acfdfe6c6..08818256a 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -471,13 +471,13 @@ void CGameContext::OnTick() { Console()->ExecuteLine(m_aVoteCommand, 3,-1); SendChat(-1, CGameContext::CHAT_ALL, "Vote passed (enforced by Admin)"); - dbg_msg("Vote","Due to vote enforcing, vote level has been set to 3"); + dbg_msg("Vote","Due to vote enforcing, vote Level has been set to 3"); EndVote(); } else { Console()->ExecuteLine(m_aVoteCommand, 4,-1); - dbg_msg("Vote","vote level is set to 4"); + dbg_msg("Vote","vote Level is set to 4"); EndVote(); SendChat(-1, CGameContext::CHAT_ALL, "Vote passed"); } @@ -1698,11 +1698,13 @@ void CGameContext::ConSetlvl(IConsole::IResult *pResult, void *pUserData, int C { CGameContext *pSelf = (CGameContext *)pUserData; int Victim = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1); - int level = clamp(pResult->GetInteger(1), 0, 3); - - if (pSelf->m_apPlayers[Victim] && (pSelf->m_apPlayers[Victim]->m_Authed > level) && (compare_players(pSelf->m_apPlayers[ClientId],pSelf->m_apPlayers[Victim]) || ClientId == Victim)) + int Level = clamp(pResult->GetInteger(1), 0, 3); + CServer* pServ = (CServer*)pSelf->Server(); + if (pSelf->m_apPlayers[Victim] && (pSelf->m_apPlayers[Victim]->m_Authed > Level) && (compare_players(pSelf->m_apPlayers[ClientId],pSelf->m_apPlayers[Victim]) || ClientId == Victim)) { - pSelf->m_apPlayers[Victim]->m_Authed = level; + pSelf->m_apPlayers[Victim]->m_Authed = Level; + if(!Level) + pServ->LogOut(Victim); } } @@ -2234,7 +2236,7 @@ void CGameContext::OnConsoleInit() Console()->Register("kill_pl", "i", CFGFLAG_SERVER, ConKillPlayer, this, "Kills player i and announces the kill", 2); - Console()->Register("auth", "ii", CFGFLAG_SERVER, ConSetlvl, this, "Authenticates player i1 to the level of i2 (level 0 = logout)", 3); + Console()->Register("auth", "ii", CFGFLAG_SERVER, ConSetlvl, this, "Authenticates player i1 to the Level of i2 (Level 0 = logout)", 3); Console()->Register("mute", "ii", CFGFLAG_SERVER, ConMute, this, "Mutes player i1 for i2 seconds", 2);