Skip to content

Commit 5b59e22

Browse files
Refactor Quick Connect button (#3843)
1 parent 67beec7 commit 5b59e22

File tree

5 files changed

+11
-57
lines changed

5 files changed

+11
-57
lines changed

Client/core/CClientVariables.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,6 @@ void CClientVariables::LoadDefaults()
273273
DEFAULT("host", _S("127.0.0.1")); // hostname
274274
DEFAULT("port", 22003); // port
275275
DEFAULT("password", _S("")); // password
276-
DEFAULT("qc_host", _S("127.0.0.1")); // quick connect hostname
277-
DEFAULT("qc_port", 22003); // quick connect port
278-
DEFAULT("qc_password", _S("")); // quick connect password
279276
DEFAULT("debugfile", _S("")); // debug filename
280277
DEFAULT("console_pos", CVector2D(0, 0)); // console position
281278
DEFAULT("console_size", CVector2D(200, 200)); // console size
@@ -357,7 +354,6 @@ void CClientVariables::LoadDefaults()
357354
DEFAULT("allow_discord_rpc", true); // Enable Discord Rich Presence
358355
DEFAULT("discord_rpc_share_data", false); // Consistent Rich Presence data sharing
359356
DEFAULT("discord_rpc_share_data_firsttime", false); // Display the user data sharing consent dialog box - for the first time
360-
DEFAULT("_beta_qc_rightclick_command", _S("reconnect")); // Command to run when right clicking quick connect (beta - can be removed at any time)
361357
DEFAULT("browser_enable_gpu", true); // Enable GPU in CEF? (allows stuff like WebGL to function)
362358

363359
if (!Exists("locale"))

Client/core/CCommandFuncs.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ void CCommandFuncs::Reconnect(const char* szParameters)
302302
unsigned int uiPort;
303303

304304
CVARS_GET("host", strHost);
305-
CVARS_GET("nick", strNick);
306305
CVARS_GET("password", strPassword);
307306
CVARS_GET("port", uiPort);
308307

@@ -315,7 +314,7 @@ void CCommandFuncs::Reconnect(const char* szParameters)
315314
// Verify and convert the port number
316315
if (uiPort <= 0 || uiPort > 0xFFFF)
317316
{
318-
CCore::GetSingleton().GetConsole()->Print(_("connect: Bad port number"));
317+
CCore::GetSingleton().GetConsole()->Print(_("reconnect: Bad port number"));
319318
return;
320319
}
321320

@@ -330,16 +329,16 @@ void CCommandFuncs::Reconnect(const char* szParameters)
330329
// Start the connect
331330
if (CCore::GetSingleton().GetConnectManager()->Reconnect(strHost.c_str(), usPort, strPassword.c_str(), false))
332331
{
333-
CCore::GetSingleton().GetConsole()->Printf(_("connect: Connecting to %s:%u..."), strHost.c_str(), usPort);
332+
CCore::GetSingleton().GetConsole()->Printf(_("reconnect: Reconnecting to %s:%u..."), strHost.c_str(), usPort);
334333
}
335334
else
336335
{
337-
CCore::GetSingleton().GetConsole()->Printf(_("connect: could not connect to %s:%u!"), strHost.c_str(), usPort);
336+
CCore::GetSingleton().GetConsole()->Printf(_("reconnect: could not connect to %s:%u!"), strHost.c_str(), usPort);
338337
}
339338
}
340339
else
341340
{
342-
CCore::GetSingleton().GetConsole()->Print("connect: Failed to unload current mod");
341+
CCore::GetSingleton().GetConsole()->Print("reconnect: Failed to unload current mod");
343342
}
344343
}
345344

Client/core/CConnectManager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ bool CConnectManager::Connect(const char* szHost, unsigned short usPort, const c
145145

146146
// Display the status box
147147
SString strBuffer(_("Connecting to %s:%u ..."), m_strHost.c_str(), m_usPort);
148+
if (m_bReconnect)
149+
strBuffer = SString(_("Reconnecting to %s:%u ..."), m_strHost.c_str(), m_usPort);
148150
CCore::GetSingleton().ShowMessageBox(_("CONNECTING"), strBuffer, MB_BUTTON_CANCEL | MB_ICON_INFO, m_pOnCancelClick);
149151
WriteDebugEvent(SString("Connecting to %s:%u ...", m_strHost.c_str(), m_usPort));
150152

Client/core/CMainMenu.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -912,17 +912,13 @@ bool CMainMenu::OnQuickConnectButtonClick(CGUIElement* pElement, bool left)
912912
if (m_ucFade != FADE_VISIBLE)
913913
return false;
914914

915-
// If we're right clicking, execute special command
916-
if (!left)
915+
if (left)
916+
g_pCore->GetCommands()->Execute("reconnect", "");
917+
else
917918
{
918-
std::string command;
919-
CVARS_GET("_beta_qc_rightclick_command", command);
920-
g_pCore->GetCommands()->Execute(command.data());
921-
return true;
919+
m_ServerBrowser.SetVisible(true);
920+
m_ServerBrowser.OnQuickConnectButtonClick();
922921
}
923-
924-
m_ServerBrowser.SetVisible(true);
925-
m_ServerBrowser.OnQuickConnectButtonClick();
926922
return true;
927923
}
928924

Client/core/ServerBrowser/CServerBrowser.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -924,30 +924,6 @@ void CServerBrowser::CreateHistoryList()
924924
}
925925
}
926926

927-
// If we had no history, import it from our old quick connect
928-
if (bEmpty)
929-
{
930-
std::string strAddress;
931-
CVARS_GET("qc_host", strAddress);
932-
933-
if (!strAddress.empty())
934-
{
935-
std::string strPort;
936-
CVARS_GET("qc_port", strPort);
937-
938-
if (!strPort.empty())
939-
{
940-
in_addr Address;
941-
if (CServerListItem::Parse(strAddress.c_str(), Address))
942-
{
943-
m_ServersHistory.AddUnique(Address, atoi(strPort.c_str()));
944-
CreateHistoryList(); // Restart with our new list.
945-
return;
946-
}
947-
}
948-
}
949-
}
950-
951927
m_ServersHistory.Refresh();
952928
}
953929

@@ -2030,21 +2006,6 @@ std::string CServerBrowser::GetServerPassword(const std::string& strHost)
20302006
}
20312007
}
20322008
}
2033-
2034-
// If the server is the one from old quick connect, try importing the password from that
2035-
std::string strQCEndpoint;
2036-
CVARS_GET("qc_host", strQCEndpoint);
2037-
2038-
std::string strTemp;
2039-
CVARS_GET("qc_port", strTemp);
2040-
2041-
strQCEndpoint = strQCEndpoint + ":" + strTemp;
2042-
if (strQCEndpoint == strHost)
2043-
{
2044-
CVARS_GET("qc_password", strTemp);
2045-
return strTemp;
2046-
}
2047-
20482009
return "";
20492010
}
20502011

0 commit comments

Comments
 (0)