From: PatR Date: Fri, 18 Dec 2015 15:11:41 +0000 (-0800) Subject: more while-helpless X-Git-Tag: NetHack-3.6.1_RC01~1153 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fcc30bee8846f64223debc96194114102896a64a;p=nethack more while-helpless Guard xlogfile entries against naming killer monst ", while". --- diff --git a/src/topten.c b/src/topten.c index 22ebaae1f..9af1d54df 100644 --- a/src/topten.c +++ b/src/topten.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 topten.c $NHDT-Date: 1450432761 2015/12/18 09:59:21 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.43 $ */ +/* NetHack 3.6 topten.c $NHDT-Date: 1450451497 2015/12/18 15:11:37 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.44 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -65,8 +65,7 @@ STATIC_DCL void FDECL(discardexcess, (FILE *)); STATIC_DCL void FDECL(readentry, (FILE *, struct toptenentry *)); STATIC_DCL void FDECL(writeentry, (FILE *, struct toptenentry *)); #ifdef XLOGFILE -STATIC_DCL void FDECL(writexlentry, (FILE *, struct toptenentry *)); -STATIC_DCL char *FDECL(shortdeath, (char *, char *)); +STATIC_DCL void FDECL(writexlentry, (FILE *, struct toptenentry *, int)); STATIC_DCL long NDECL(encodexlogflags); STATIC_DCL long NDECL(encodeconduct); STATIC_DCL long NDECL(encodeachieve); @@ -316,9 +315,10 @@ struct toptenentry *tt; /* as tab is never used in eg. plname or death, no need to mangle those. */ STATIC_OVL void -writexlentry(rfile, tt) +writexlentry(rfile, tt, how) FILE *rfile; struct toptenentry *tt; +int how; { #define Fprintf (void) fprintf #define XLOG_SEP '\t' /* xlogfile field separator. */ @@ -337,9 +337,11 @@ struct toptenentry *tt; Sprintf(buf, "%crole=%s%crace=%s%cgender=%s%calign=%s", XLOG_SEP, tt->plrole, XLOG_SEP, tt->plrace, XLOG_SEP, tt->plgend, XLOG_SEP, tt->plalign); + /* make a copy of death reason that doesn't include ", while helpless" */ + formatkiller(tmpbuf, sizeof tmpbuf, how, FALSE); Fprintf(rfile, "%s%cname=%s%cdeath=%s", buf, /* (already includes separator) */ - XLOG_SEP, plname, XLOG_SEP, shortdeath(tmpbuf, tt->death)); + XLOG_SEP, plname, XLOG_SEP, tmpbuf); if (multi) Fprintf(rfile, "%cwhile=%s", XLOG_SEP, multi_reason ? multi_reason : "helpless"); @@ -356,20 +358,6 @@ struct toptenentry *tt; #undef XLOG_SEP } -/* used to strip ", while helpless" so xlogfile can show that separately - in case formatkiller() ending up truncating ", while "+multi_reason */ -STATIC_OVL char * -shortdeath(outbuf, deathstring) -char *outbuf, *deathstring; -{ - char *p; - - Strcpy(outbuf, deathstring); - if ((p = strstr(outbuf, ", while")) != 0) - *p = '\0'; - return outbuf; -} - STATIC_OVL long encodexlogflags() { @@ -568,7 +556,7 @@ time_t when; if (!(xlfile = fopen_datafile(XLOGFILE, "a", SCOREPREFIX))) { HUP raw_print("Cannot open extended log file!"); } else { - writexlentry(xlfile, t0); + writexlentry(xlfile, t0, how); (void) fclose(xlfile); } unlock_file(XLOGFILE); @@ -579,6 +567,7 @@ time_t when; if (how != PANICKED) HUP { char pbuf[BUFSZ]; + topten_print(""); Sprintf(pbuf, "Since you were in %s mode, the score list will not be checked.",