From 1801dbd491d30c68bbe81c1d52c2cb9fb3979851 Mon Sep 17 00:00:00 2001 From: KebsCS Date: Fri, 8 Nov 2024 21:29:19 +0100 Subject: [PATCH] Auto rcon auth both main and dummy --- src/engine/client.h | 2 +- src/engine/client/client.cpp | 16 +++++++--------- src/engine/client/client.h | 2 +- src/game/client/components/console.cpp | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/engine/client.h b/src/engine/client.h index 8dcc9839e..54fc73d2d 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -208,7 +208,7 @@ public: virtual int *GetInput(int Tick, int IsDummy = 0) const = 0; // remote console - virtual void RconAuth(const char *pUsername, const char *pPassword) = 0; + virtual void RconAuth(const char *pUsername, const char *pPassword, bool Dummy) = 0; virtual bool RconAuthed() const = 0; virtual bool UseTempRconCommands() const = 0; virtual void Rcon(const char *pLine) = 0; diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 607d652ea..b9242e42b 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -262,9 +262,9 @@ void CClient::SendMapRequest() } } -void CClient::RconAuth(const char *pName, const char *pPassword) +void CClient::RconAuth(const char *pName, const char *pPassword, bool Dummy) { - if(RconAuthed()) + if(m_aRconAuthed[Dummy] != 0) return; if(pName != m_aRconUsername) @@ -276,7 +276,7 @@ void CClient::RconAuth(const char *pName, const char *pPassword) { CMsgPacker Msg7(protocol7::NETMSG_RCON_AUTH, true, true); Msg7.AddString(pPassword); - SendMsgActive(&Msg7, MSGFLAG_VITAL); + SendMsg(Dummy, &Msg7, MSGFLAG_VITAL); return; } @@ -284,7 +284,7 @@ void CClient::RconAuth(const char *pName, const char *pPassword) Msg.AddString(pName); Msg.AddString(pPassword); Msg.AddInt(1); - SendMsgActive(&Msg, MSGFLAG_VITAL); + SendMsg(Dummy, &Msg, MSGFLAG_VITAL); } void CClient::Rcon(const char *pCmd) @@ -760,12 +760,7 @@ void CClient::DummyDisconnect(const char *pReason) m_aNetClient[CONN_DUMMY].Disconnect(pReason); g_Config.m_ClDummy = 0; - if(!m_aRconAuthed[0] && m_aRconAuthed[1]) - { - RconAuth(m_aRconUsername, m_aRconPassword); - } m_aRconAuthed[1] = 0; - m_aapSnapshots[1][SNAP_CURRENT] = 0; m_aapSnapshots[1][SNAP_PREV] = 0; m_aReceivedSnapshots[1] = 0; @@ -1772,6 +1767,9 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy) if(!Unpacker.Error()) { m_aRconAuthed[Conn] = ResultInt; + + if(m_aRconAuthed[Conn]) + RconAuth(m_aRconUsername, m_aRconPassword, g_Config.m_ClDummy ^ 1); } if(Conn == CONN_MAIN) { diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 9b3104727..9ca2699fd 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -293,7 +293,7 @@ public: bool RconAuthed() const override { return m_aRconAuthed[g_Config.m_ClDummy] != 0; } bool UseTempRconCommands() const override { return m_UseTempRconCommands != 0; } - void RconAuth(const char *pName, const char *pPassword) override; + void RconAuth(const char *pName, const char *pPassword, bool Dummy = g_Config.m_ClDummy) override; void Rcon(const char *pCmd) override; bool ReceivingRconCommands() const override { return m_ExpectedRconCommands > 0; } float GotRconCommandsPercentage() const override; diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index d892898f7..803ff5929 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -310,7 +310,7 @@ void CGameConsole::CInstance::ExecuteLine(const char *pLine) } else { - m_pGameConsole->Client()->RconAuth(m_aUser, pLine); + m_pGameConsole->Client()->RconAuth(m_aUser, pLine, g_Config.m_ClDummy); m_UserGot = false; } }