]> granicus.if.org Git - nethack/commitdiff
Merge branch 'NetHack-3.6'
authornhmall <nhmall@nethack.org>
Sat, 16 Nov 2019 03:12:12 +0000 (22:12 -0500)
committernhmall <nhmall@nethack.org>
Sat, 16 Nov 2019 03:12:12 +0000 (22:12 -0500)
1  2 
include/decl.h
include/extern.h
src/decl.c
src/end.c
src/files.c
src/potion.c
src/windows.c

diff --cc include/decl.h
Simple merge
Simple merge
diff --cc src/decl.c
Simple merge
diff --cc src/end.c
Simple merge
diff --cc src/files.c
index 2de453dcaac029dee529d24681f7aafee4326464,5a0e1a7b233faf59552d73436d577c70e360d171..e1bcf88aa42989a62f3c7a65ea241e2830885d62
@@@ -4265,18 -4003,16 +4264,18 @@@ boolean wildcards
  void
  reveal_paths(VOID_ARGS)
  {
-     const char *fqn, *filep;
 -    const char *fqn, *gamename = (hname && *hname) ? hname : "NetHack";
++    const char *fqn, *gamename = (g.hname && *g.hname) ? g.hname : "NetHack";
      char buf[BUFSZ];
- #if defined(UNIX) 
-     char *strp;
+ #if defined(SYSCF) || !defined(UNIX)
+     const char *filep;
  #endif
 +#if defined(PREFIXES_IN_USE)
 +    const char *cstrp;
 +#endif
  #ifdef UNIX
-     char *envp, cwdbuf[PATH_MAX];
+     char *endp, *envp, cwdbuf[PATH_MAX];
  #endif
  #ifdef PREFIXES_IN_USE
 -    const char *strp;
      int i, maxlen = 0;
  
      raw_print("Variable playground locations:");
  
  #ifdef SYSCF
  #ifdef PREFIXES_IN_USE
 -    strp = fqn_prefix_names[SYSCONFPREFIX];
 +    cstrp = fqn_prefix_names[SYSCONFPREFIX];
      maxlen = BUFSZ - sizeof " (in )";
-     if (cstrp && strlen(cstrp) < (size_t) maxlen)
 -    if (strp && (int) strlen(strp) < maxlen)
 -        Sprintf(buf, " (in %s)", strp);
++    if (cstrp && (int) strlen(cstrp) < maxlen)
 +        Sprintf(buf, " (in %s)", cstrp);
  #else
      buf[0] = '\0';
  #endif
  #ifndef UNIX
  #ifdef PREFIXES_IN_USE
  #ifdef WIN32
 -    strp = fqn_prefix_names[SYSCONFPREFIX];
 +    cstrp = fqn_prefix_names[SYSCONFPREFIX];
  #else
 -    strp = fqn_prefix_names[HACKPREFIX];
 +    cstrp = fqn_prefix_names[HACKPREFIX];
  #endif /* WIN32 */
      maxlen = BUFSZ - sizeof " (in )";
-     if (cstrp && strlen(cstrp) < (size_t) maxlen)
 -    if (strp && (int) strlen(strp) < maxlen)
 -        Sprintf(buf, " (in %s)", strp);
++    if (cstrp && (int) strlen(cstrp) < maxlen)
 +        Sprintf(buf, " (in %s)", cstrp);
  #endif /* PREFIXES_IN_USE */
-     raw_printf("Your game's loadable symbols file%s:", buf);
+     raw_printf("%s loadable symbols file%s:", s_suffix(gamename), buf);
  #endif /* UNIX */
  
  #ifdef UNIX
  
      buf[0] = '\0';
  #ifdef PREFIXES_IN_USE
 -    strp = fqn_prefix_names[CONFIGPREFIX];
 +    cstrp = fqn_prefix_names[CONFIGPREFIX];
      maxlen = BUFSZ - sizeof " (in )";
-     if (cstrp && strlen(cstrp) < (size_t) maxlen)
 -    if (strp && (int) strlen(strp) < maxlen)
 -        Sprintf(buf, " (in %s)", strp);
++    if (cstrp && (int) strlen(cstrp) < maxlen)
 +        Sprintf(buf, " (in %s)", cstrp);
  #endif /* PREFIXES_IN_USE */
      raw_printf("Your personal configuration file%s:", buf);
  
diff --cc src/potion.c
index cfb4d78ff45e9cc7f0b8065e461f77c4cc985df5,16b2c5ddafedf899a7425731363f409bf45c8e72..3d3c639b051f24236093e1fa0e8b75acf683fac9
@@@ -2027,10 -2030,10 +2027,10 @@@ dodip(
                 around for potionbreathe() [and we can't set obj->in_use
                 to 'amt' because that's not implemented] */
              obj->in_use = 1;
-             pline("BOOM!  They explode!");
+             pline("%sThey explode!", !Deaf ? "BOOM!  " : "");
              wake_nearto(u.ux, u.uy, (BOLT_LIM + 1) * (BOLT_LIM + 1));
              exercise(A_STR, FALSE);
 -            if (!breathless(youmonst.data) || haseyes(youmonst.data))
 +            if (!breathless(g.youmonst.data) || haseyes(g.youmonst.data))
                  potionbreathe(obj);
              useupall(obj);
              losehp(amt + rnd(9), /* not physical damage */
              singlepotion->dknown = FALSE;
          } else {
              singlepotion->dknown = !Hallucination;
+             *newbuf = '\0';
              if (mixture == POT_WATER && singlepotion->dknown)
                  Sprintf(newbuf, "clears");
-             else
+             else if (!Blind)
                  Sprintf(newbuf, "turns %s",
                          hcolor(OBJ_DESCR(objects[mixture])));
-             pline_The("%spotion%s %s.", oldbuf,
-                       more_than_one ? " that you dipped into" : "", newbuf);
-             if (!objects[old_otyp].oc_uname
-                 && !objects[old_otyp].oc_name_known && old_dknown) {
+             if (*newbuf)
+                 pline_The("%spotion%s %s.", oldbuf,
+                           more_than_one ? " that you dipped into" : "",
+                           newbuf);
+             else
+                 pline("Somehing happens.");
+             if (old_dknown
+                 && !objects[old_otyp].oc_name_known
+                 && !objects[old_otyp].oc_uname) {
                  struct obj fakeobj;
 -                fakeobj = zeroobj;
 +                fakeobj = cg.zeroobj;
                  fakeobj.dknown = 1;
                  fakeobj.otyp = old_otyp;
                  fakeobj.oclass = POTION_CLASS;
diff --cc src/windows.c
index dfb3f3629d0bedef7629797d5ae3313a795e7dd6,7dac248a05dc2e157d97d1ede044f642ddf3dc69..475d2d89587ad943a5d6b79816aeb3dc06f868bf
@@@ -1083,18 -1085,19 +1083,19 @@@ unsigned long *colormasks UNUSED
      putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */
  }
  
 -STATIC_VAR struct window_procs dumplog_windowprocs_backup;
 -STATIC_VAR FILE *dumplog_file;
 +static struct window_procs dumplog_windowprocs_backup;
 +static FILE *dumplog_file;
  
  #ifdef DUMPLOG
 -STATIC_VAR time_t dumplog_now;
 +static time_t dumplog_now;
  
- static char *FDECL(dump_fmtstr, (const char *, char *));
- static char *
- dump_fmtstr(fmt, buf)
+ char *
+ dump_fmtstr(fmt, buf, fullsubs)
  const char *fmt;
  char *buf;
+ boolean fullsubs; /* True -> full substitution for file name, False ->
+                    * partial substitution for '--showpaths' feedback
+                    * where there's no game in progress when executed */
  {
      const char *fp = fmt;
      char *bp = buf;
                  Sprintf(tmpbuf, "%ld", uid);
                  break;
              case 'n': /* player name */
-                 Sprintf(tmpbuf, "%s", *g.plname ? g.plname : "unknown");
+                 if (fullsubs)
 -                    Sprintf(tmpbuf, "%s", *plname ? plname : "unknown");
++                    Sprintf(tmpbuf, "%s", *g.plname ? g.plname : "unknown");
+                 else
+                     Strcpy(tmpbuf, "{hero name}");
                  break;
              case 'N': /* first character of player name */
-                 Sprintf(tmpbuf, "%c", *g.plname ? *g.plname : 'u');
+                 if (fullsubs)
 -                    Sprintf(tmpbuf, "%c", *plname ? *plname : 'u');
++                    Sprintf(tmpbuf, "%c", *g.plname ? *g.plname : 'u');
+                 else
+                     Strcpy(tmpbuf, "{hero initial}");
                  break;
              }
+             if (fullsubs) {
+                 /* replace potentially troublesome characters (including
+                    <space> even though it might be an acceptable file name
+                    character); user shouldn't be able to get ' ' or '/'
+                    or '\\' into plname[] but play things safe */
+                 (void) strNsubst(tmpbuf, " ", "_", 0);
+                 (void) strNsubst(tmpbuf, "/", "_", 0);
+                 (void) strNsubst(tmpbuf, "\\", "_", 0);
+                 /* note: replacements are only done on field substitutions,
+                    not on the template (from sysconf or DUMPLOG_FILE) */
+             }
  
-             slen = strlen(tmpbuf);
-             if (len + slen < BUFSZ-1) {
+             slen = (int) strlen(tmpbuf);
+             if (len + slen < BUFSZ - 1) {
                  len += slen;
                  Sprintf(bp, "%s", tmpbuf);
                  bp += slen;