From 388b76eca0419a0d1fb691c57e974ad604955dad Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 10 Jul 2022 12:12:55 +0200 Subject: Allow auth with RCON using 3rd argument from CCommand. 'rcon PASS' will use the 'rcon_password' convar as password to auth with the server. 'rcon PASS yourpassword' will use the third argument from CCommand to auth with the server. --- NorthstarDedicatedTest/rcon_shared.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/NorthstarDedicatedTest/rcon_shared.cpp b/NorthstarDedicatedTest/rcon_shared.cpp index 86892ea8..c4dc4c6c 100644 --- a/NorthstarDedicatedTest/rcon_shared.cpp +++ b/NorthstarDedicatedTest/rcon_shared.cpp @@ -32,7 +32,7 @@ void _RCON_CmdQuery_f(const CCommand& args) if (args.ArgC() < 2) { - if (g_pRConClient->IsInitialized() && !g_pRConClient->IsConnected() && strlen(CVar_rcon_password->GetString()) > 0) + if (g_pRConClient->IsInitialized() && !g_pRConClient->IsConnected()) { g_pRConClient->Connect(); } @@ -48,8 +48,15 @@ void _RCON_CmdQuery_f(const CCommand& args) { if (strcmp(args.Arg(1), "PASS") == 0) // Auth with RCON server using rcon_password ConVar value. { - std::string svCmdQuery = - g_pRConClient->Serialize(CVar_rcon_password->GetString(), "", cl_rcon::request_t::SERVERDATA_REQUEST_AUTH); + std::string svCmdQuery; + if (args.ArgC() > 2) + { + svCmdQuery = g_pRConClient->Serialize(args.Arg(2), "", cl_rcon::request_t::SERVERDATA_REQUEST_AUTH); + } + else // Use 'rcon_password' ConVar as password. + { + svCmdQuery = g_pRConClient->Serialize(CVar_rcon_password->GetString(), "", cl_rcon::request_t::SERVERDATA_REQUEST_AUTH); + } g_pRConClient->Send(svCmdQuery); return; } -- cgit v1.2.3