-
Notifications
You must be signed in to change notification settings - Fork 6
Description
It is possible that two players have e.g. the same overall score, meaning they tie for a leaderboard position. For the leaderboard itself, that tie is broken by additionally sorting by name.
asp/src/ASP/aspx/getleaderboard.php
Lines 121 to 122 in df86f71
| $query = "SELECT id, name, rank_id, country, time, score FROM player WHERE score > 0 | |
| ORDER BY score DESC, name DESC LIMIT " . $min . ", " . $max; |
However, the tiebreaker is not applied when determining a player's position on the leaderboard directly.
asp/src/ASP/aspx/getleaderboard.php
Line 147 in df86f71
| $query = "SELECT COUNT(id) FROM player WHERE score > %d"; |
This mismatch results in a potentially incorrect and non-unique leaderboard position being returned for the player, since every player with the same score will be placed at the same position by the 2nd query.
A quick example. The actual leaderboard might be (name is sorted DESC to break ties):
| Pos | Nick | Score |
|---|---|---|
| 1 | alpha | 1000 |
| 2 | charlie | 900 |
| 3 | bravo | 900 |
Requesting the positions of bravo or charlie will return 2, since only alpha has a greater score.