Skip to content

Commit

Permalink
MENU: Strip /udp/ from server address
Browse files Browse the repository at this point in the history
  • Loading branch information
MotoLegacy committed Dec 26, 2024
1 parent 3c79565 commit 9e5546b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion source/menu/m_menu.qc
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,21 @@ static string(string s) str2ascii =
return s;
};

//
// Menu_CleanUpServerAddress(server_address)
// Strips stuff from the CNAME like /udp/ etc.
// if it causes conflicts when trying to connect.
//
string Menu_CleanUpServerAddress(string server_address) =
{
// Strip /udp/
if (substring(server_address, 0, 5) == "/udp/") {
return substring(server_address, 5, strlen(server_address) - 5);
}

return server_address;
};

//
// Menu_ServerList(id, pos, size, scrollofs, num_servers)
// Draw the master server list
Expand Down Expand Up @@ -663,7 +678,9 @@ void(string id, vector pos, vector size, __inout vector scrollofs, float num_ser
Menu_PlaySound(MENU_SND_ENTER);
m_toggle(false);
map_name_override = gethostcachestring(gethostcacheindexforkey("map"), index);
localcmd("connect ", gethostcachestring(gethostcacheindexforkey("cname"), index), "\n");

string server_address = Menu_CleanUpServerAddress(gethostcachestring(gethostcacheindexforkey("cname"), index));
localcmd("connect ", server_address, "\n");
}
#endif // MENU

Expand Down

0 comments on commit 9e5546b

Please sign in to comment.