X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/84e7d0704483ce39bbdeacd5e676168db6fa664f..d3f6eb61d18b753c62d64ee95a1c63b9842de3d8:/hack/hack.end.c diff --git a/hack/hack.end.c b/hack/hack.end.c index 0d99ef58..30a4fd85 100644 --- a/hack/hack.end.c +++ b/hack/hack.end.c @@ -1,12 +1,69 @@ -/* $NetBSD: hack.end.c,v 1.4 1997/10/19 16:57:55 christos Exp $ */ +/* $NetBSD: hack.end.c,v 1.9 2008/01/28 06:55:41 dholland Exp $ */ /* - * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. + * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, + * Amsterdam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - 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. + * + * - Neither the name of the Stichting Centrum voor Wiskunde en + * Informatica, nor the names of its contributors may be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 1982 Jay Fenlason + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint -__RCSID("$NetBSD: hack.end.c,v 1.4 1997/10/19 16:57:55 christos Exp $"); +__RCSID("$NetBSD: hack.end.c,v 1.9 2008/01/28 06:55:41 dholland Exp $"); #endif /* not lint */ #include @@ -29,7 +86,7 @@ dodone() /*ARGSUSED*/ void done1(n) - int n; + int n __unused; { (void) signal(SIGINT, SIG_IGN); pline("Really quit?"); @@ -51,7 +108,7 @@ int done_hup; /*ARGSUSED*/ void done_intr(n) - int n; + int n __unused; { done_stopprint++; (void) signal(SIGINT, SIG_IGN); @@ -95,7 +152,7 @@ done_in_by(mtmp) /* Be careful not to call panic from here! */ void done(st1) - char *st1; + const char *st1; { #ifdef WIZARD @@ -265,8 +322,8 @@ topten() int rank, rank0 = -1, rank1 = 0; int occ_cnt = PERSMAX; struct toptenentry *t0, *t1, *tprev; - char *recfile = RECORD; - char *reclock = "record_lock"; + const char *recfile = RECORD; + const char *reclock = "record_lock"; int sleepct = 300; FILE *rfile; int flg = 0; @@ -391,8 +448,8 @@ topten() t1->plchar, t1->sex, t1->name, t1->death); if (done_stopprint) continue; - if (rank > flags.end_top && - (rank < rank0 - flags.end_around || rank > rank0 + flags.end_around) + if (rank > (int)flags.end_top && + (rank < rank0 - (int)flags.end_around || rank > rank0 + (int)flags.end_around) && (!flags.end_own || #ifdef PERS_IS_UID t1->uid != t0->uid)) @@ -400,8 +457,8 @@ topten() strncmp(t1->name, t0->name, NAMSZ))) #endif /* PERS_IS_UID */ continue; - if (rank == rank0 - flags.end_around && - rank0 > flags.end_top + flags.end_around + 1 && + if (rank == rank0 - (int)flags.end_around && + rank0 > (int)flags.end_top + (int)flags.end_around + 1 && !flags.end_own) (void) putchar('\n'); if (rank != rank0) @@ -420,6 +477,7 @@ topten() if (!done_stopprint) (void) outentry(0, t0, 1); (void) fclose(rfile); + free(t0); unlock: (void) unlink(reclock); } @@ -439,11 +497,11 @@ outheader() /* so>0: standout line; so=0: ordinary line; so<0: no output, return lth */ int -outentry(rank, t1, so) - struct toptenentry *t1; +outentry(int rank, struct toptenentry *t1, int so) { - boolean quit = FALSE, killed = FALSE, starv = FALSE; + boolean quit = FALSE, gotkilled = FALSE, starv = FALSE; char linebuf[BUFSZ]; + linebuf[0] = 0; if (rank) Sprintf(eos(linebuf), "%3d", rank); @@ -473,15 +531,15 @@ outentry(rank, t1, so) else if (!strncmp(t1->death, "starv", 5)) Sprintf(eos(linebuf), "starved to death"), starv = TRUE; else - Sprintf(eos(linebuf), "was killed"), killed = TRUE; + Sprintf(eos(linebuf), "was killed"), gotkilled = TRUE; Sprintf(eos(linebuf), " on%s level %d", - (killed || starv) ? "" : " dungeon", t1->level); + (gotkilled || starv) ? "" : " dungeon", t1->level); if (t1->maxlvl != t1->level) Sprintf(eos(linebuf), " [max %d]", t1->maxlvl); if (quit && t1->death[4]) Sprintf(eos(linebuf), t1->death + 4); } - if (killed) + if (gotkilled) Sprintf(eos(linebuf), " by %s%s", (!strncmp(t1->death, "trick", 5) || !strncmp(t1->death, "the ", 4)) ? "" : @@ -527,13 +585,14 @@ itoa(a) return (buf); } -char * +const char * ordin(n) int n; { - int d = n % 10; - return ((d == 0 || d > 3 || n / 10 == 1) ? "th" : (d == 1) ? "st" : - (d == 2) ? "nd" : "rd"); + int dg = n % 10; + + return ((dg == 0 || dg > 3 || n / 10 == 1) ? "th" : (dg == 1) ? "st" : + (dg == 2) ? "nd" : "rd"); } void @@ -593,7 +652,7 @@ prscore(argc, argv) int playerct; int rank; struct toptenentry *t1, *t2; - char *recfile = RECORD; + const char *recfile = RECORD; FILE *rfile; int flg = 0; int i;