When requesting a non-default range from the leaderboard using e.g. pos=5&before=2&after=2, the positions of the players are incorrect. The reason is pretty simple: before is subtracted from pos to get min (the row number of the first player to return).
|
$after = (isset($_GET['after'])) ? (int)$_GET['after'] : 19; |
|
$before = (isset($_GET['before'])) ? (int)$_GET['before'] : 0; |
|
$pos = (isset($_GET['pos'])) ? (int)$_GET['pos'] : 1; |
|
$min = ($pos - 1) - $before; |
|
$max = $after + 1; |
|
|
|
// Negative correction |
|
if ($min < 0) $min = 0; |
|
if ($max < 0) $max = 0; |
However, the first returned player is not given min+1 (query is zero-indexed, leaderboard is one-indexed) as their position but pos.
|
$query = "SELECT id, name, rank_id, country, time, score FROM player WHERE score > 0 |
|
ORDER BY score DESC, name DESC LIMIT " . $min . ", " . $max; |
|
$result = $connection->query($query); |
|
while ($row = $result->fetch()) |
|
{ |
|
$Response->writeDataLine( |
|
$pos++, |
|
$row['id'], |
|
trim($row['name']), |
|
$row['score'], |
|
$row['time'], |
|
$row['rank_id'], |
|
strtoupper($row['country']) |
|
); |
Thus in the above example, the player that should be on position 3 (pos 5 - before 2) is shows as position 5. Every following player is shifted accordingly.
When requesting a non-default range from the leaderboard using e.g.
pos=5&before=2&after=2, the positions of the players are incorrect. The reason is pretty simple:beforeis subtracted fromposto getmin(the row number of the first player to return).asp/src/ASP/aspx/getleaderboard.php
Lines 82 to 90 in df86f71
However, the first returned player is not given
min+1(query is zero-indexed, leaderboard is one-indexed) as their position butpos.asp/src/ASP/aspx/getleaderboard.php
Lines 121 to 134 in df86f71
Thus in the above example, the player that should be on position 3 (pos 5 - before 2) is shows as position 5. Every following player is shifted accordingly.