X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/629fa8000f93ef02e38680e026feec5a0fd0b6bb..283621ee3b4a30d66d08567b6507c0ba1580dbf1:/rogue/score.c diff --git a/rogue/score.c b/rogue/score.c index 4b4f0691..3ef52dcd 100644 --- a/rogue/score.c +++ b/rogue/score.c @@ -1,6 +1,8 @@ +/* $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. @@ -34,9 +36,13 @@ * SUCH DAMAGE. */ +#include #ifndef lint -/*static char sccsid[] = "from: @(#)score.c 5.5 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$Id: score.c,v 1.4 1993/11/10 10:02:20 cgd 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 */ /* @@ -55,15 +61,10 @@ static char rcsid[] = "$Id: score.c,v 1.4 1993/11/10 10:02:20 cgd Exp $"; #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]; @@ -129,6 +130,7 @@ short other; put_scores(monster, other); } +void win() { unwield(rogue.weapon); /* disarm and relax */ @@ -152,13 +154,16 @@ win() 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) { @@ -193,9 +198,10 @@ boolean 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]; @@ -207,11 +213,14 @@ short other; md_lock(1); + 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); @@ -269,8 +278,8 @@ short other; 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++; } @@ -319,12 +328,14 @@ short other; 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]; @@ -337,7 +348,8 @@ object *monster; } } } - 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) { @@ -381,8 +393,9 @@ object *monster; (void) strcpy(n_names[rank], n_name); } +boolean is_vowel(ch) -short ch; + short ch; { return( (ch == 'a') || (ch == 'e') || @@ -391,6 +404,7 @@ short ch; (ch == 'u') ); } +void sell_pack() { object *obj; @@ -423,12 +437,14 @@ sell_pack() 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) { @@ -470,6 +486,7 @@ object *obj; return(val); } +void id_all() { short i; @@ -491,8 +508,10 @@ id_all() } } +int name_cmp(s1, s2) -char *s1, *s2; + char *s1; + const char *s2; { short i = 0; int r; @@ -506,9 +525,10 @@ char *s1, *s2; return(r); } +void xxxx(buf, n) -char *buf; -short n; + char *buf; + short n; { short i; unsigned char c; @@ -524,7 +544,7 @@ short n; long xxx(st) -boolean st; + boolean st; { static long f, s; long r; @@ -540,8 +560,10 @@ boolean st; return(r); } +void nickize(buf, score, n_name) -char *buf, *score, *n_name; + char *buf; + const char *score, *n_name; { short i = 15, j; @@ -565,9 +587,10 @@ char *buf, *score, *n_name; } } +void center(row, buf) -short row; -char *buf; + short row; + const char *buf; { short margin; @@ -575,6 +598,7 @@ char *buf; mvaddstr(row, margin, buf); } +void sf_error() { md_lock(0);