- push_score(&scores, &scorecount, newscore, get_user_id(), newdata);
- sort_scores(scores, scorecount, reverse);
- if (write_scores(scorefile, scores, scorecount) < 0)
+ push_score (&scores, &scorecount, newscore, user_id, newdata);
+ /* 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 (write_scores (scorefile, scores, scorecount) < 0)