Compare commits

...

3 Commits

Author SHA1 Message Date
Dennis Felsing 7e857ce37e
Merge pull request #8280 from Robyt3/Client-Redirect-Password-Fix
Fix wrong server address used in password popup when redirected, minor refactoring
2024-04-29 04:23:57 +00:00
Robert Müller 938d264c43 Fix wrong server address used in password popup when redirected
Always use the server address from the network client to reconnect to the correct server after being disconnected due to wrong password. The password popup is only shown after being disconnected, so the server address of the network client should always the address of the server which the client should reconnect to with the password. Using `ui_server_address` was causing the wrong address to be used after being redirected to another server and if the config variable is changed while the password popup is open.

Closes #8260.
2024-04-28 17:05:28 +02:00
Robert Müller d2139e4bec Use `net_addr_str` directly to format address including port 2024-04-28 16:45:56 +02:00
2 changed files with 6 additions and 5 deletions

View File

@ -1585,11 +1585,10 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
{
return;
}
char aAddr[128];
char aIp[64];
char aAddr[NETADDR_MAXSTRSIZE];
NETADDR ServerAddr = ServerAddress();
net_addr_str(&ServerAddr, aIp, sizeof(aIp), 0);
str_format(aAddr, sizeof(aAddr), "%s:%d", aIp, RedirectPort);
ServerAddr.port = RedirectPort;
net_addr_str(&ServerAddr, aAddr, sizeof(aAddr), true);
Connect(aAddr);
}
else if(Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_ADD)

View File

@ -1433,7 +1433,9 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
static CButtonContainer s_ButtonTryAgain;
if(DoButton_Menu(&s_ButtonTryAgain, Localize("Try again"), 0, &TryAgain) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
{
Client()->Connect(g_Config.m_UiServerAddress, g_Config.m_Password);
char aAddr[NETADDR_MAXSTRSIZE];
net_addr_str(&Client()->ServerAddress(), aAddr, sizeof(aAddr), true);
Client()->Connect(aAddr, g_Config.m_Password);
}
Box.HSplitBottom(60.f, &Box, &Part);