From 45a9d96a761352adf1555df03e1d9133c7b26568 Mon Sep 17 00:00:00 2001 From: ZombieToad <25847476+ZombieToad@users.noreply.github.com> Date: Sat, 16 Jun 2018 00:41:55 +0100 Subject: [PATCH 1/5] send password to first connected server --- src/engine/client/client.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index e94ff6198..442ce8a26 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -690,7 +690,12 @@ void CClient::Connect(const char *pAddress, const char *pPassword) net_host_lookup("localhost", &m_ServerAddress, m_NetClient[0].NetType()); } - if(!pPassword) + if(m_SendPassword) + { + str_copy(m_Password, g_Config.m_Password, sizeof(m_Password)); + m_SendPassword = false; + } + else if(!pPassword) m_Password[0] = 0; else str_copy(m_Password, pPassword, sizeof(m_Password)); @@ -3054,6 +3059,22 @@ void CClient::Con_Screenshot(IConsole::IResult *pResult, void *pUserData) pSelf->Graphics()->TakeScreenshot(0); } +void CClient::Con_Password(IConsole::IResult *pResult, void *pUserData) +{ + CClient *pSelf = (CClient *)pUserData; + if(pResult->NumArguments() > 0) + { + str_copy(g_Config.m_Password, pResult->GetString(0), sizeof(g_Config.m_Password)); + pSelf->m_SendPassword = true; + } + else + { + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "Value: %s", g_Config.m_Password); + pSelf->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Console", aBuf); + } +} + void CClient::Con_Rcon(IConsole::IResult *pResult, void *pUserData) { CClient *pSelf = (CClient *)pUserData; @@ -3402,6 +3423,7 @@ void CClient::RegisterCommands() m_pConsole->Register("disconnect", "", CFGFLAG_CLIENT, Con_Disconnect, this, "Disconnect from the server"); m_pConsole->Register("ping", "", CFGFLAG_CLIENT, Con_Ping, this, "Ping the current server"); m_pConsole->Register("screenshot", "", CFGFLAG_CLIENT, Con_Screenshot, this, "Take a screenshot"); + m_pConsole->Register("password", "?r[password]", CFGFLAG_CLIENT, Con_Password, this, "Password to the server"); m_pConsole->Register("rcon", "r[rcon-command]", CFGFLAG_CLIENT, Con_Rcon, this, "Send specified command to rcon"); m_pConsole->Register("rcon_auth", "s[password]", CFGFLAG_CLIENT, Con_RconAuth, this, "Authenticate to rcon"); m_pConsole->Register("rcon_login", "s[username] r[password]", CFGFLAG_CLIENT, Con_RconLogin, this, "Authenticate to rcon with a username"); From 57d1c37fb4d1446e37e85cbbe9e27baeb1b13812 Mon Sep 17 00:00:00 2001 From: ZombieToad <25847476+ZombieToad@users.noreply.github.com> Date: Sat, 16 Jun 2018 00:44:24 +0100 Subject: [PATCH 2/5] send password to first connected server --- src/engine/client/client.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 35ed7782c..d747fca49 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -112,6 +112,7 @@ class CClient : public IClient, public CDemoPlayer::IListener char m_RconPassword[32]; int m_UseTempRconCommands; char m_Password[32]; + bool m_SendPassword; // version-checking char m_aVersionStr[10]; @@ -333,6 +334,7 @@ public: static void Con_Minimize(IConsole::IResult *pResult, void *pUserData); static void Con_Ping(IConsole::IResult *pResult, void *pUserData); static void Con_Screenshot(IConsole::IResult *pResult, void *pUserData); + static void Con_Password(IConsole::IResult *pResult, void *pUserData); static void Con_Rcon(IConsole::IResult *pResult, void *pUserData); static void Con_RconAuth(IConsole::IResult *pResult, void *pUserData); static void Con_RconLogin(IConsole::IResult *pResult, void *pUserData); From 1c88ffd6634bf6df347c470f31ac3dfd2f08d05f Mon Sep 17 00:00:00 2001 From: ZombieToad <25847476+ZombieToad@users.noreply.github.com> Date: Wed, 20 Jun 2018 07:36:10 +0100 Subject: [PATCH 3/5] Update client.h --- src/engine/client/client.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/client/client.h b/src/engine/client/client.h index d747fca49..7e19083de 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -334,7 +334,6 @@ public: static void Con_Minimize(IConsole::IResult *pResult, void *pUserData); static void Con_Ping(IConsole::IResult *pResult, void *pUserData); static void Con_Screenshot(IConsole::IResult *pResult, void *pUserData); - static void Con_Password(IConsole::IResult *pResult, void *pUserData); static void Con_Rcon(IConsole::IResult *pResult, void *pUserData); static void Con_RconAuth(IConsole::IResult *pResult, void *pUserData); static void Con_RconLogin(IConsole::IResult *pResult, void *pUserData); @@ -350,7 +349,8 @@ public: static void ConchainWindowScreen(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainWindowVSync(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainTimeoutSeed(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); - + static void ConchainPassword(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); + static void Con_DemoSlice(IConsole::IResult *pResult, void *pUserData); static void Con_DemoSliceBegin(IConsole::IResult *pResult, void *pUserData); static void Con_DemoSliceEnd(IConsole::IResult *pResult, void *pUserData); From dfaa8d1f46af2618aca0f4353194954913e3e517 Mon Sep 17 00:00:00 2001 From: ZombieToad <25847476+ZombieToad@users.noreply.github.com> Date: Wed, 20 Jun 2018 07:43:55 +0100 Subject: [PATCH 4/5] Update client.cpp --- src/engine/client/client.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 442ce8a26..2af75257d 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3059,22 +3059,6 @@ void CClient::Con_Screenshot(IConsole::IResult *pResult, void *pUserData) pSelf->Graphics()->TakeScreenshot(0); } -void CClient::Con_Password(IConsole::IResult *pResult, void *pUserData) -{ - CClient *pSelf = (CClient *)pUserData; - if(pResult->NumArguments() > 0) - { - str_copy(g_Config.m_Password, pResult->GetString(0), sizeof(g_Config.m_Password)); - pSelf->m_SendPassword = true; - } - else - { - char aBuf[128]; - str_format(aBuf, sizeof(aBuf), "Value: %s", g_Config.m_Password); - pSelf->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Console", aBuf); - } -} - void CClient::Con_Rcon(IConsole::IResult *pResult, void *pUserData) { CClient *pSelf = (CClient *)pUserData; @@ -3399,6 +3383,14 @@ void CClient::ConchainTimeoutSeed(IConsole::IResult *pResult, void *pUserData, I pSelf->m_GenerateTimeoutSeed = false; } +void CClient::ConchainPassword(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) +{ + CClient *pSelf = (CClient *)pUserData; + pfnCallback(pResult, pCallbackUserData); + if(pResult->NumArguments() && pSelf->m_LocalStartTime) //won't set m_SendPassword before game has started + pSelf->m_SendPassword = true; +} + void CClient::RegisterCommands() { m_pConsole = Kernel()->RequestInterface(); @@ -3438,9 +3430,11 @@ void CClient::RegisterCommands() m_pConsole->Register("demo_play", "", CFGFLAG_CLIENT, Con_DemoPlay, this, "Play demo"); m_pConsole->Register("demo_speed", "i[speed]", CFGFLAG_CLIENT, Con_DemoSpeed, this, "Set demo speed"); - // used for server browser update m_pConsole->Chain("cl_timeout_seed", ConchainTimeoutSeed, this); - + + m_pConsole->Chain("password", ConchainPassword, this); + + // used for server browser update m_pConsole->Chain("br_filter_string", ConchainServerBrowserUpdate, this); m_pConsole->Chain("br_filter_gametype", ConchainServerBrowserUpdate, this); m_pConsole->Chain("br_filter_serveraddress", ConchainServerBrowserUpdate, this); From f6d107b264217c47392554de5b7b2d719266dd88 Mon Sep 17 00:00:00 2001 From: ZombieToad <25847476+ZombieToad@users.noreply.github.com> Date: Wed, 20 Jun 2018 07:44:44 +0100 Subject: [PATCH 5/5] Update client.cpp --- src/engine/client/client.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 2af75257d..3e1c61286 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3415,7 +3415,6 @@ void CClient::RegisterCommands() m_pConsole->Register("disconnect", "", CFGFLAG_CLIENT, Con_Disconnect, this, "Disconnect from the server"); m_pConsole->Register("ping", "", CFGFLAG_CLIENT, Con_Ping, this, "Ping the current server"); m_pConsole->Register("screenshot", "", CFGFLAG_CLIENT, Con_Screenshot, this, "Take a screenshot"); - m_pConsole->Register("password", "?r[password]", CFGFLAG_CLIENT, Con_Password, this, "Password to the server"); m_pConsole->Register("rcon", "r[rcon-command]", CFGFLAG_CLIENT, Con_Rcon, this, "Send specified command to rcon"); m_pConsole->Register("rcon_auth", "s[password]", CFGFLAG_CLIENT, Con_RconAuth, this, "Authenticate to rcon"); m_pConsole->Register("rcon_login", "s[username] r[password]", CFGFLAG_CLIENT, Con_RconLogin, this, "Authenticate to rcon with a username");