From 7c2b7d4417c3d70e4b3801284eec57fbaf07fdf3 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 14 Sep 2019 17:52:02 -0700 Subject: [PATCH 1/3] github pull request - fake mail Fixes #216 A github pull request changed one of the fake mail messages so that our web site's URL is added at compile time instead of being hard- coded. However, it wouldn't compile with a pre-ANSI compiler since it relied on concatenating adjacent string literals. This is more complex but achieves the same result, and also makes the existing run-time subsitution be a bit clearer. Testing was a hassle but eventually successful. --- src/mail.c | 63 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/src/mail.c b/src/mail.c index 63142ad51..064b69bc5 100644 --- a/src/mail.c +++ b/src/mail.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mail.c $NHDT-Date: 1545597424 2018/12/23 20:37:04 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.39 $ */ +/* NetHack 3.6 mail.c $NHDT-Date: 1568508711 2019/09/15 00:51:51 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.40 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -460,28 +460,65 @@ void readmail(otmp) struct obj *otmp UNUSED; { - static char *junk[] = { - NULL, /* placeholder for "Report bugs to .", */ - "Please disregard previous letter.", "Welcome to NetHack.", + static const char *junk[] = { + "Report bugs to <%s>.", /*** must be first entry ***/ + "Please disregard previous letter.", + "Welcome to NetHack.", #ifdef AMIGA - "Only Amiga makes it possible.", "CATS have all the answers.", + "Only Amiga makes it possible.", + "CATS have all the answers.", #endif "This mail complies with the Yendorian Anti-Spam Act (YASA)", "Please find enclosed a small token to represent your Owlbear", "**FR33 P0T10N 0F FULL H34L1NG**", "Please return to sender (Asmodeus)", + /* when enclosed by "It reads: \"...\"", this is too long + for an ordinary 80-column display so wraps to a second line + (suboptimal but works correctly); + dollar sign and fractional zorkmids are inappropriate within + nethack but are suitable for typical dysfunctional spam mail */ "Buy a potion of gain level for only $19.99! Guaranteed to be blessed!", - "Invitation: Visit the NetHack web site at http://www.nethack.org!" + /* DEVTEAM_URL will be substituted for "%s"; terminating punctuation + (formerly "!") has deliberately been omitted so that it can't be + mistaken for part of the URL (unfortunately that is still followed + by a closing quote--in the pline below, not the data here) */ + "Invitation: Visit the NetHack web site at %s" }; /* XXX replace with more general substitution code and add local - * contact message. Also use DEVTEAM_URL */ - if (junk[0] == NULL) { -#define BUGS_FORMAT "Report bugs to <%s>." - /* +2 from '%s' suffices as substitute for usual +1 for terminator */ - junk[0] = (char *) alloc(strlen(BUGS_FORMAT) + strlen(DEVTEAM_EMAIL)); - Sprintf(junk[0], BUGS_FORMAT, DEVTEAM_EMAIL); -#undef BUGS_FORMAT + * contact message. + * + * FIXME: this allocated memory is never freed. However, if the + * game is restarted, the junk[] update will be a no-op for second + * and subsequent runs and this updated text will still be appropriate. + */ + if (index(junk[0], '%')) { + char *tmp; + int i; + + for (i = 0; i < SIZE(junk); ++i) { + if (index(junk[i], '%')) { + if (i == 0) { + /* +2 from '%s' in junk[0] suffices as substitute + for usual +1 for terminator */ + tmp = (char *) alloc(strlen(junk[0]) + + strlen(DEVTEAM_EMAIL)); + Sprintf(tmp, junk[0], DEVTEAM_EMAIL); + junk[0] = tmp; + } else if (strstri(junk[i], "web site")) { + /* as with junk[0], room for terminator is present */ + tmp = (char *) alloc(strlen(junk[i]) + + strlen(DEVTEAM_URL)); + Sprintf(tmp, junk[i], DEVTEAM_URL); + junk[i] = tmp; + } else { + /* could check for "%%" but unless that becomes needed, + handling it is more complicated than necessary */ + impossible("fake mail #%d has undefined substitution", i); + junk[i] = "Bad fake mail..."; + } + } + } } if (Blind) { pline("Unfortunately you cannot see what it says."); From 5589a16d7426e9477d72871b414b12941fe588d8 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 14 Sep 2019 18:00:39 -0700 Subject: [PATCH 2/3] github pull request - "You are [.]" Fixes #215 A post-3.6.2 change added a message for life-saving which lack its end of sentence punctuation. --- doc/fixes36.3 | 4 +++- src/hack.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index f00cc3e29..6959edf19 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.110 $ $NHDT-Date: 1567805962 2019/09/06 21:39:22 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.112 $ $NHDT-Date: 1568509226 2019/09/15 01:00:26 $ This fixes36.3 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.2 in May 2019. Please note, however, @@ -157,6 +157,8 @@ wizard mode ^I "not carrying anything" still claimed "not carrying anything" if "(all items are already identified)" was given monster throwing from stack of missiles (darts, daggers, spears) would cause crash if it wasn't wielding a weapon (bug in multi-shot shooting fix) +surviving death while polymorphed would yield "You are a " without + terminating period curses: sometimes the message window would show a blank line after a prompt curses: the change to show map in columns 1..79 instead of 2..80 made the highlight for '@' show up in the wrong place if clipped map had been diff --git a/src/hack.c b/src/hack.c index 718eea8bf..7bae18567 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 hack.c $NHDT-Date: 1565288730 2019/08/08 18:25:30 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.215 $ */ +/* NetHack 3.6 hack.c $NHDT-Date: 1568509227 2019/09/15 01:00:27 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.216 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2909,7 +2909,7 @@ const char *msg_override; if life-saved while poly'd and Unchanging (explore or wizard mode declining to die since can't be both Unchanging and Lifesaved) */ if (Upolyd && !strncmpi(nomovemsg, "You survived that ", 18)) - You("are %s", an(mons[u.umonnum].mname)); /* (ignore Hallu) */ + You("are %s.", an(mons[u.umonnum].mname)); /* (ignore Hallu) */ } nomovemsg = 0; u.usleep = 0; From fd03a1b31048f94834f4ee1f80a3878bd34cff55 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 14 Sep 2019 18:04:33 -0700 Subject: [PATCH 3/3] github pull request - man page typo Fixes #205 "at last" should be "at least". doc/nethack.txt is now out of date. --- doc/nethack.6 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/nethack.6 b/doc/nethack.6 index e9f4c72ff..ea704bb2f 100644 --- a/doc/nethack.6 +++ b/doc/nethack.6 @@ -8,9 +8,9 @@ .de NR .ds Nr \\$2 .. -.ND $NHDT-Date: 1524689549 2018/04/25 20:52:29 $ -.NB $NHDT-Branch: NetHack-3.6.0 $ -.NR $NHDT-Revision: 1.14 $ +.ND $NHDT-Date: 1568509458 2019/09/15 01:04:18 $ +.NB $NHDT-Branch: NetHack-3.6 $ +.NR $NHDT-Revision: 1.16 $ .ds Na Robert Patrick Rankin .SH NAME nethack \- Exploring The Mazes of Menace @@ -156,7 +156,7 @@ option). "rrr" are at least the first three letters of the character's race (this can also be specified using a separate .B \-r .I race -option). "aaa" are at last the first three letters of the character's +option). "aaa" are at least the first three letters of the character's alignment, and "ggg" are at least the first three letters of the character's gender. Any of the parts of the suffix may be left out. .PP