From 24e9e99693f9c9425a41fd1d879ef2827523537c Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 11 Sep 2009 19:11:07 +0000 Subject: [PATCH] (main): Sort scores before trimming them, reported by Jason Feng (bug#4397). --- lib-src/ChangeLog | 5 +++++ lib-src/update-game-score.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 7970ee5aae2..93cd999509e 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,8 @@ +2009-09-11 Stefan Monnier + + * update-game-score.c (main): Sort scores before trimming them, + reported by Jason Feng (bug#4397). + 2009-09-09 Glenn Morris * Makefile.in ($(DESTDIR)${archlibdir}): Set umask to world-readable diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c index d85f426cbf6..e4ddb79247f 100644 --- a/lib-src/update-game-score.c +++ b/lib-src/update-game-score.c @@ -254,15 +254,15 @@ main (argc, argv) lose_syserr ("Failed to read scores file"); } push_score (&scores, &scorecount, newscore, user_id, newdata); + sort_scores (scores, scorecount, reverse); /* Limit the number of scores. If we're using reverse sorting, then we should increment the beginning of the array, to skip over the *smallest* scores. Otherwise, we just decrement the number of scores, since the smallest will be at the end. */ if (scorecount > MAX_SCORES) scorecount -= (scorecount - MAX_SCORES); - if (reverse) - scores += (scorecount - MAX_SCORES); - sort_scores (scores, scorecount, reverse); + if (reverse) + scores += (scorecount - MAX_SCORES); if (write_scores (scorefile, scores, scorecount) < 0) { unlock_file (scorefile, lockstate); -- 2.39.2