1152: send password to first connected server r=heinrich5991 a=ZombieToad

https://github.com/ddnet/ddnet/pull/1149#issuecomment-397538132

fixes issues with connecting to servers with reserved slots

Co-authored-by: ZombieToad <25847476+zombietoad@users.noreply.github.com>
This commit is contained in:
bors[bot] 2018-06-20 09:05:56 +00:00
commit af1f9d198a
2 changed files with 21 additions and 4 deletions

View file

@ -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<IConsole>();
@ -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);

View file

@ -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,6 +349,7 @@ 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);