diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 81fa35acd..f2403f5b6 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)); @@ -3378,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(); @@ -3416,9 +3429,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); diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 35ed7782c..7e19083de 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]; @@ -348,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);