fix: deterministic status ordering, connecting-player ping, header alignment - #37
Merged
Merged
Conversation
… align header - Add a stable userid tie-breaker to the sort comparator so rows with equal keys (same ping/time/state/name) keep a deterministic order instead of whatever the unstable SortCustom1D pass produces. - Skip GetClientLatency/GetClientAvgLoss for players that are connected but not yet in-game: those calls return -1 and printed "-1000" ping / "-100" loss. Such players now also sort to the bottom of a ping-ordered list (PING_UNAVAILABLE) rather than jumping to the top. - Collapse GetPlayerStateSortRank/GetPlayerStateLabel into a single GetPlayerState() source of truth (new PlayerState enum) so the displayed label and the sort rank can never diverge. - Align the header labels to a common width (tags/map/edicts/tickrate) so the colons line up like vanilla "status". - Widen the state column to %8s so "spawning" is not clipped against the next column; drop the duplicate title/row format string; read the AuthIdType convar once. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Per-row string buffers (time/ping/loss/addr) are not initialized, so bots and connecting players can print garbage values in the status table output.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the SourceMod Status Fixer plugin to make status output more predictable and polished, primarily by improving sort determinism, handling connecting-player ping/loss safely, and tightening table/header formatting.
Changes:
- Make player row ordering deterministic on sort-key ties by adding an ascending-userid tie-breaker in the comparator.
- Avoid querying latency/loss for clients not yet in-game, and ensure those players sort to the bottom in ping-ordered lists.
- Unify state labeling/sort ranking via a
PlayerStateenum +GetPlayerState(), and adjust header/row formatting alignment.
File summaries
| File | Description |
|---|---|
| addons/sourcemod/scripting/Status.sp | Adds deterministic tie-break sorting, consolidates player state logic, adjusts ping/loss handling for connecting players, and refines output formatting. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
sPlayerTime/sPlayerPing/sPlayerLoss/sPlayerAddr were left uninitialized for bots (which skip the !bFakeClient block) and for still-connecting players (bInGame == false), so stack garbage could end up printed in the status row. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bug fixes and small polish for the
statusoutput, found while reading throughStatus.sp. No new cvars, no new dependencies. Verified withspcomp1.12.0.7253 (0 warnings) with and without the optionalPlayerManager/serverfpsincludes.Bugs fixed
1. Non-deterministic row order on ties
SortCustom1Dis not a stable sort. When two players compared equal on the active key (same ping, same connection time, same state, or a duplicate name) their relative order was whatever the quicksort happened to leave behind, so repeatedstatuscalls could shuffle rows around.The comparator now falls back to an ascending-userid tie-breaker, so equal keys always produce the same, predictable order.
2.
-1000ping /-100loss for players who are still connectingThe player loop called
GetClientLatency()/GetClientAvgLoss()for every non-bot client, including ones that are connected but not yet in-game. Those natives return-1in that window, which was rounded and printed as-1000/-100.Ping/loss are now only queried once the client is actually in-game (matching how bots are already handled — the column is simply left blank). The same players are also given
PING_UNAVAILABLEas their sort key so they land at the bottom of a ping-ordered list instead of at the very top.3. State label and state sort rank could drift apart
GetPlayerStateSortRank()andGetPlayerStateLabel()each re-implemented the sameIsClientInGame/PM_IsPlayerSteamlogic with hard-coded0/1/2. If one was ever updated without the other, a row could be shown asnosteamwhile sorting asactive.Both now derive from a single
GetPlayerState()function returning aPlayerStateenum.Polish
tags,map,edictsandtickratelabels used inconsistent padding, so the colons didn't line up. They're now aligned to a common width like vanillastatus.%7sto%8ssospawning(8 chars) isn't clipped against the next column.sTitleFmtandsRowFmtwere byte-for-byte identical; collapsed to one. Thesm_status_authid_typeconvar is now read once instead of twice.IsFakeClient()/IsClientInGame()are cached per row instead of being called 3× each.Version bumped to
2.2.2.Test plan
spcompclean (0 warnings) withgeoip+PlayerManager+serverfps(CI-equivalent)spcompclean withgeoiponly (noPlayerManager, noserverfps)spcompclean withgeoip+serverfps, noPlayerManagerstatusfrom client console and server console, with a player mid-connection, across eachsm_status_order_byvalue🤖 Generated with Claude Code