+/* $NetBSD: score.c,v 1.8 1999/09/12 09:02:23 jsm Exp $ */
+
/*
- * Copyright (c) 1988 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Timothy C. Stoehr.
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-/*static char sccsid[] = "from: @(#)score.c 5.5 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: score.c,v 1.3 1993/09/23 22:28:42 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: score.c,v 1.8 1999/09/12 09:02:23 jsm Exp $");
+#endif
#endif /* not lint */
/*
#include "rogue.h"
#include "pathnames.h"
-extern char login_name[];
-extern char *m_names[];
-extern short max_level;
-extern boolean score_only, no_skull, msg_cleared;
-extern char *byebye_string, *nick_name;
-
+void
killed_by(monster, other)
-object *monster;
-short other;
+ const object *monster;
+ short other;
{
char buf[128];
put_scores(monster, other);
}
+void
win()
{
unwield(rogue.weapon); /* disarm and relax */
put_scores((object *) 0, WIN);
}
+void
quit(from_intrpt)
-boolean from_intrpt;
+ boolean from_intrpt;
{
char buf[128];
short i, orow, ocol;
boolean mc;
+ orow = ocol = 0;
+ mc = FALSE;
md_ignore_signals();
if (from_intrpt) {
killed_by((object *) 0, QUIT);
}
+void
put_scores(monster, other)
-object *monster;
-short other;
+ const object *monster;
+ short other;
{
short i, n, rank = 10, x, ne = 0, found_player = -1;
char scores[10][82];
md_lock(1);
- if ((fp = fopen(_PATH_SCOREFILE, "r+")) == NULL) {
+ setegid(egid);
+ if ((fp = fopen(_PATH_SCOREFILE, "r+")) == NULL &&
+ (fp = fopen(_PATH_SCOREFILE, "w+")) == NULL) {
+ setegid(gid);
message("cannot read/write/create score file", 0);
sf_error();
}
+ setegid(gid);
rewind(fp);
(void) xxx(1);
rank = ne;
}
if (rank < 10) {
- insert_score(scores, n_names, nick_name, rank, ne, monster,
- other);
+ insert_score(scores, n_names, nick_name, rank, ne,
+ monster, other);
if (ne < 10) {
ne++;
}
clean_up("");
}
+void
insert_score(scores, n_names, n_name, rank, n, monster, other)
-char scores[][82];
-char n_names[][30];
-char *n_name;
-short rank, n;
-object *monster;
+ char scores[][82];
+ char n_names[][30];
+ const char *n_name;
+ short rank, n;
+ const object *monster;
+ int other;
{
short i;
char buf[128];
}
}
}
- sprintf(buf, "%2d %6d %s: ", rank+1, rogue.gold, login_name);
+ sprintf(buf, "%2d %6ld %s: ", rank+1, (long)rogue.gold,
+ login_name);
if (other) {
switch(other) {
(void) strcpy(n_names[rank], n_name);
}
+boolean
is_vowel(ch)
-short ch;
+ short ch;
{
return( (ch == 'a') ||
(ch == 'e') ||
(ch == 'u') );
}
+void
sell_pack()
{
object *obj;
message("", 0);
}
+int
get_value(obj)
-object *obj;
+ const object *obj;
{
short wc;
int val;
+ val = 0;
wc = obj->which_kind;
switch(obj->what_is) {
return(val);
}
+void
id_all()
{
short i;
}
}
+int
name_cmp(s1, s2)
-char *s1, *s2;
+ char *s1;
+ const char *s2;
{
short i = 0;
int r;
return(r);
}
+void
xxxx(buf, n)
-char *buf;
-short n;
+ char *buf;
+ short n;
{
short i;
unsigned char c;
long
xxx(st)
-boolean st;
+ boolean st;
{
static long f, s;
long r;
return(r);
}
+void
nickize(buf, score, n_name)
-char *buf, *score, *n_name;
+ char *buf;
+ const char *score, *n_name;
{
short i = 15, j;
}
}
+void
center(row, buf)
-short row;
-char *buf;
+ short row;
+ const char *buf;
{
short margin;
mvaddstr(row, margin, buf);
}
+void
sf_error()
{
md_lock(0);