From a250b3977ac1a3731eeb73f5060472745f17d9ed Mon Sep 17 00:00:00 2001 From: Cryptkeeper Date: Sat, 27 May 2017 08:05:25 +0800 Subject: [PATCH] Properly sort ping listing to ensure we don't wrongly smooth --- lib/util.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/util.js b/lib/util.js index d186e55..86cb589 100644 --- a/lib/util.js +++ b/lib/util.js @@ -54,6 +54,12 @@ function trimUselessPings(data) { for (var x = 0; x < listing.length; x++) { var entry = listing[x]; + // Make sure we're sorted, otherwise the smoothing code below can + // select wrongly get an older (and worse) ping before one with players online. + listing.sort(function(a, b) { + return a[0] - b[0]; + }); + // 0 is the index of the timestamp. // See the convertPingsToGraph method. if (entry[0] - lastTimestamp >= 60 * 1000) {