-/* $NetBSD: scores.c,v 1.7 1999/09/17 20:44:51 jsm Exp $ */
+/* $NetBSD: scores.c,v 1.13 2004/01/27 20:30:30 jsm Exp $ */
/*-
* Copyright (c) 1992, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
static int gotscores;
static struct highscore scores[NUMSPOTS];
-static int checkscores __P((struct highscore *, int));
-static int cmpscores __P((const void *, const void *));
-static void getscores __P((FILE **));
-static void printem __P((int, int, struct highscore *, int, const char *));
-static char *thisuser __P((void));
+static int checkscores(struct highscore *, int);
+static int cmpscores(const void *, const void *);
+static void getscores(FILE **);
+static void printem(int, int, struct highscore *, int, const char *);
+static char *thisuser(void);
/*
* Read the score file. Can be called from savescore (before showscores)
savescore(level)
int level;
{
- register struct highscore *sp;
- register int i;
+ struct highscore *sp;
+ int i;
int change;
FILE *sf;
const char *me;
*/
nscores = checkscores(scores, nscores);
rewind(sf);
- if (fwrite(scores, sizeof(*sp), nscores, sf) != nscores ||
+ if (fwrite(scores, sizeof(*sp), nscores, sf) != (size_t)nscores ||
fflush(sf) == EOF)
- warnx("error writing %s: %s -- %s\n",
+ warnx("error writing %s: %s -- %s",
_PATH_SCOREFILE, strerror(errno),
"high scores may be damaged");
}
static char *
thisuser()
{
- register const char *p;
- register struct passwd *pw;
- register size_t l;
+ const char *p;
+ struct passwd *pw;
+ size_t l;
static char u[sizeof(scores[0].hs_name)];
if (u[0])
cmpscores(x, y)
const void *x, *y;
{
- register const struct highscore *a, *b;
- register long l;
+ const struct highscore *a, *b;
+ long l;
a = x;
b = y;
*/
static int
checkscores(hs, num)
- register struct highscore *hs;
+ struct highscore *hs;
int num;
{
- register struct highscore *sp;
- register int i, j, k, numnames;
+ struct highscore *sp;
+ int i, j, k, numnames;
int levelfound[NLEVELS];
struct peruser {
char *name;
int times;
} count[NUMSPOTS];
- register struct peruser *pu;
+ struct peruser *pu;
/*
* Sort so that highest totals come first.
showscores(level)
int level;
{
- register struct highscore *sp;
- register int i, n, c;
+ struct highscore *sp;
+ int i, n, c;
const char *me;
int levelfound[NLEVELS];
static void
printem(level, offset, hs, n, me)
int level, offset;
- register struct highscore *hs;
- register int n;
+ struct highscore *hs;
+ int n;
const char *me;
{
- register struct highscore *sp;
+ struct highscore *sp;
int nrows, row, col, item, i, highlight;
char buf[100];
#define TITLE "Rank Score Name (points/level)"
(void)putchar('\n');
continue;
}
- (void)printf(item + offset < 10 ? " " : " ");
sp = &hs[item];
(void)sprintf(buf,
- "%d%c %6d %-11s (%d on %d)",
+ "%3d%c %6d %-11s (%6d on %d)",
item + offset, sp->hs_time ? '*' : ' ',
sp->hs_score * sp->hs_level,
sp->hs_name, sp->hs_score, sp->hs_level);