mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Show warning when connect address cannot be resolved
Show warning and disconnect instead of falling back to connecting to `localhost` when the connect address cannot be resolved.
This commit is contained in:
parent
00586a0c4a
commit
323ccf5a22
|
@ -456,7 +456,6 @@ void CClient::Connect(const char *pAddress, const char *pPassword)
|
|||
Disconnect();
|
||||
dbg_assert(m_State == IClient::STATE_OFFLINE, "Disconnect must ensure that client is offline");
|
||||
|
||||
m_ConnectionId = RandomUuid();
|
||||
if(pAddress != m_aConnectAddressStr)
|
||||
str_copy(m_aConnectAddressStr, pAddress);
|
||||
|
||||
|
@ -464,8 +463,6 @@ void CClient::Connect(const char *pAddress, const char *pPassword)
|
|||
str_format(aMsg, sizeof(aMsg), "connecting to '%s'", m_aConnectAddressStr);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aMsg, gs_ClientNetworkPrintColor);
|
||||
|
||||
ServerInfoRequest();
|
||||
|
||||
int NumConnectAddrs = 0;
|
||||
NETADDR aConnectAddrs[MAX_SERVER_ADDRESSES];
|
||||
mem_zero(aConnectAddrs, sizeof(aConnectAddrs));
|
||||
|
@ -502,11 +499,18 @@ void CClient::Connect(const char *pAddress, const char *pPassword)
|
|||
|
||||
if(NumConnectAddrs == 0)
|
||||
{
|
||||
log_error("client", "could not find any connect address, defaulting to localhost for whatever reason...");
|
||||
net_host_lookup("localhost", &aConnectAddrs[0], m_aNetClient[CONN_MAIN].NetType());
|
||||
NumConnectAddrs = 1;
|
||||
log_error("client", "could not find any connect address");
|
||||
char aWarning[256];
|
||||
str_format(aWarning, sizeof(aWarning), Localize("Could not resolve connect address '%s'. See local console for details."), m_aConnectAddressStr);
|
||||
SWarning Warning(Localize("Connect address error"), aWarning);
|
||||
Warning.m_AutoHide = false;
|
||||
AddWarning(Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
m_ConnectionId = RandomUuid();
|
||||
ServerInfoRequest();
|
||||
|
||||
if(m_SendPassword)
|
||||
{
|
||||
str_copy(m_aPassword, g_Config.m_Password);
|
||||
|
|
Loading…
Reference in a new issue