Skip to content

Sort the server browser by players, ping or name - #5

Closed
medic-code wants to merge 2 commits into
feat/ping-order-progressfrom
feat/browser-sort-columns
Closed

medic-code wants to merge 2 commits into
feat/ping-order-progressfrom
feat/browser-sort-columns

Conversation

@medic-code

@medic-code medic-code commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Why

Players asked to sort the server browser by ping and by players.

The browser shows one fixed order, most players first. With about 40 public games listed, a player who wants the nearest host has to read every PING number.

Halo PC sorted its list by its column titles. Those titles are in the port's menus, but do nothing.

What it does

  • Click a column title, or press A on it, to sort by PLAYERS (most first), PING (lowest first) or SERVER NAME (A to Z). On a controller, press up from the first game to reach the titles.
  • Pick the same title again to reverse the order. Halo PC's arrow over the title shows which way.
  • Games with no ping yet stay at the bottom.
  • The hosts are pinged in the order shown, so after sorting by PING, REFRESH pings the nearest hosts first.
  • The order lasts until the game quits. Nothing new is sent between computers.

Screenshots

Look at the order of the games: A on PLAYERS puts the fewest players first (it starts most first), A on SERVER NAME puts them A to Z, and A on SERVER NAME again puts them Z to A. The title being used is boxed. Only two public games were on this test build's version.

Sorting the server browser by its column titles

Decisions

Decision Reason Easy to change?
PLAYERS, PING and SERVER NAME sort; MAP, GAME and the icon columns do not The listing carries the scenario path, not the shown map name (beavercreek shows as "Battle Creek"), so a map sort would not match the screen Yes
A second press on the same title reverses the order Halo PC's tags give each sortable title an up and a down arrow (header_sort_arrows); not checked against the PC game itself Yes
Up arrow means lowest or A first, down means most first The Windows list convention; Halo PC's meaning is not known Yes
Games with no ping stay last in either direction A password game, a failed join or one not timed yet has no number to sort Yes
The order lasts for the session, with no setting Nothing shows Halo PC saved it Yes
The controller reaches the titles by pressing up from the first game, then left and right, then A The screen's own focus order; no new button or help line Yes
A new order puts the focus back on the first game Otherwise the outline sits on a different game in the same row Yes
The hosts are timed in the order shown, whatever the sort Builds on OpenCommunityEdition#441: one comparator orders the list and the probes No, by design

Details

  • Flow: a title's A press or click runs gamespy select header, which calls browser_sort (menu_functions.c). browser_sort sets the order with p2p_lobby_set_order (p2p_lobby.c). Each frame p2p_lobby_games returns the games in that order, and update_probes uses the same comparator to choose which host to time next.
  • port/linux/src/p2p_lobby.c: listing_order sorts by the chosen key first and keeps the old order (players, failed, open, name) to break ties. By ping, a game with no ping (not timed yet, a password's, a failed join) is last in both directions. Name order ignores case. The list is sorted under p2p_lock, because the p2p thread reads the order too. Builds on Time server browser hosts in the order shown, with dots OpenCommunityEdition/OpenCE#441, which times the hosts in the order shown.
  • port/linux/src/p2p.h: P2P_LOBBY_ORDER_PLAYERS / PING / NAME, p2p_lobby_set_order, p2p_lobby_order.
  • port/linux/game/menu_functions.c: in the server browser, the header row joins the focus, and only the three sorting titles in it can take the focus. When the screen opens, the focus in the row goes to the sorted title, and only that title shows its arrow: up for lowest or A first, down for most first. A sort goes back to the first game. If a title has the focus when the browser posts a join's A press, the join still goes through. LAN and Direct Link titles do nothing, as before.
  • source/interface/ui_widget.c: a port: comment updated (only some titles are disabled now).
  • tools/ce_menus.py, port/assets/menus/UNWIRED.md: gamespy select header moves to the wired functions.
  • port/linux/README.md: the Server browser section describes sorting.

User experience

  1. Open Join Game > Server Browser. The games show with the most players first, and a down arrow sits over PLAYERS.
  2. Press up from the first game. The focus moves to PLAYERS. Press right to reach PING, then press A (or click PING). The rows now show the lowest ping first, with games that have no ping last, and an up arrow sits over PING.
  3. Press A on PING again. The rows show the highest ping first, and the arrow points down.
  4. Select PLAYERS. The rows show the most players first again.
  5. Press REFRESH. The chosen order stays, and the moving dots run through the rows from the top down.

How to test

  1. python3 configure.py && ninja linux
  2. python3 -m pytest -q tools/test_linux_port.py -k p2p_signatures tools/harness/tests/test_browser_sort.py (Linux, or the halo-toolchain container: the harness needs a 32-bit C runtime).
  3. Run three hosts with HALO_NETWORK_TEST=host:<map> and HALO_NETWORK_TEST_PUBLIC=true on a local broker. Open the Server Browser on a fourth copy (HALO_MENU_OPEN=main_menu/multiplayer_type_select/join_game/join_game_screen), then try steps 2 to 5 above.

Tested

  • tools/p2p_lobby_check.c (via test_linux_port.py): players, ping and name order, each both ways; probes on Refresh in the order shown; the order kept while the browser is off; six mutants of p2p_lobby.c each fail it
  • tools/harness/tests/test_browser_sort.py: 6 cases, 8 negative controls
  • pytest tools/test_linux_port.py tools/test_web_build.py tools/harness in the halo-toolchain container, at each commit
  • Null-renderer run in the container: three local hosts (1, 2 and 3 players) and a browser on a local broker. The rows sorted by ping, reversed, sorted by players, and kept the ping order through REFRESH, with the probes in that order. Pings were spread by instrumentation, because loopback pings are all 0.
  • Mouse clicks on the titles, and how the arrows look (the container cannot render)
  • ninja android, ninja web
  • CI on the fork: Linux, Android, web and Windows.

@medic-code
medic-code force-pushed the feat/ping-order-progress branch from aeac73c to 9624639 Compare October 25, 2026 16:35
Players asked to sort the server browser by ping and by players. The
order lives in p2p_lobby.c, where one comparator gives both the order
p2p_lobby_games returns and the order update_probes times the hosts in,
so a new order also changes which hosts are timed first. By ping, games
with no ping (not yet timed, a password's, one whose join failed) stay
last in either direction; by name, the case is ignored. The order is
kept for the run, also while the browser is closed. The list is now
sorted under p2p_lock, since the p2p thread reads the order too.
Nothing sent between machines changes: the network version stays 38.

Checked: tools/p2p_lobby_check.c shows four games by players, ping and
name, each both ways, and probes them on Refresh in the order shown;
the order survives the browser going off and on; an unknown order falls
back to players. Six mutants of p2p_lobby.c (order ignored, reverse
ignored, probes in their own order, case kept, no-ping first when
reversed, a failed join's ping used) each fail it.
PC's join game screen has column titles that run "gamespy select
header", each with an up and a down arrow, which the port left unwired
and out of the focus. In the server browser, PLAYERS, PING and SERVER
NAME now take the focus (up from the first game, left and right between
them) and sort the games through p2p_lobby_set_order: PLAYERS the most
first, PING the lowest first, SERVER NAME A to Z, and the other way at a
second press on the same title, as PC's pair of arrows shows. The arrow
over the sorted title points up for the lowest or A first and down for
the most first. MAP, GAME and the icon columns stay out of the focus;
LAN's and Direct Link's titles do nothing, as before. A sort goes back
to the first game, and the A press a join posts still joins when a title
has the focus.

Checked: tools/harness/tests/test_browser_sort.py (the titles that sort,
the arrow for each order, the focus, a press and a press again, a join's
press, LAN), with eight negative controls; in a null-renderer run of
three local hosts and a browser on a local broker, pressing up, right
and A sorted the rows by ping lowest first, A again highest first, then
PLAYERS most first, and REFRESH kept the ping order and timed the hosts
in it. Network version stays 38.
@medic-code
medic-code force-pushed the feat/browser-sort-columns branch from 142b622 to 48c5482 Compare October 25, 2026 16:40
@medic-code

Copy link
Copy Markdown
Owner Author

Closing as redundant: OpenCE main (OpenCommunityEdition#490, 815d3a0) now sorts the server browser by its column titles with Halo PC's arrows and remembers the order (network.browser_sort).

@medic-code medic-code closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant