1
0
forked from 0ad/0ad

primeSortPlayers should not return a playerID twice, refs 59ce8b3081.

The other maps had never read this playerID, so it wasn't noticed until
Jebel Barkal read it.

Paste: https://code.wildfiregames.com/P115
Reviewed By: temple
This was SVN commit r21568.
This commit is contained in:
elexis 2018-03-16 18:44:21 +00:00
parent ded01c904d
commit 2d10c4374f

View File

@ -516,16 +516,16 @@ function sortAllPlayers()
*/
function primeSortPlayers(playerIDs)
{
if (!playerIDs.length)
return [];
let prime = [];
for (let i = 0; i < Math.ceil(playerIDs.length / 2); ++i)
for (let i = 0; i < Math.floor(playerIDs.length / 2); ++i)
{
prime.push(playerIDs[i]);
prime.push(playerIDs[playerIDs.length - 1 - i]);
}
if (playerIDs.length % 2)
prime.push(playerIDs[Math.floor(playerIDs.length / 2)]);
return prime;
}