Skip to content

Commit

Permalink
Merge pull request ddnet#8280 from Robyt3/Client-Redirect-Password-Fix
Browse files Browse the repository at this point in the history
Fix wrong server address used in password popup when redirected, minor refactoring
  • Loading branch information
def- authored Apr 29, 2024
2 parents d265057 + 938d264 commit 7e857ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/game/client/components/menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7e857ce

Please sign in to comment.