fix github issue #427 - unreadable mail

The change to make mail objects and monsters separate from mail
delivery (so that toggling the latter wouldn't invalidate save
and bones files) made it possible to wish for scrolls of mail,
find such in bones left by someone who did, or write such via
magic marker.  That was probably unintentional but I've left it
as-is.  The problem was that reading such scrolls issued a
warning:  "What weird effect is this?" because reading scrolls
of mail was only allowed when interacting with MAIL was enabled.

The issue suggested replacing #if MAIL with #if MAIL_STRUCTURES
in seffects(), and then insert #if MAIL in the part of reading
that deals with 'real' (or randomly faked for micros) mail.  I've
done both of those, and also added a couple of message variations
for the unreal cases.

Closes #427
This commit is contained in:
PatR
2020-12-24 13:41:17 -08:00
parent a4184c8684
commit 5552f141ba
3 changed files with 43 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.400 $ $NHDT-Date: 1608749030 2020/12/23 18:43:50 $
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.401 $ $NHDT-Date: 1608846067 2020/12/24 21:41:07 $
General Fixes and Modified Features
-----------------------------------
@@ -445,6 +445,9 @@ a long worm with no visible segments (but one internal segment) might trigger
warning: tail 'segement' at <0,some_y>, worm at <mx,my> if teleported
adding displacer beast inadvertently introduced a regression in swapping with
pets, allowing them to be pulled into water by hero on/over water
splitting #if MAIL into #if MAIL_STRUCTURES and #if MAIL made it possible to
wish for and write scrolls of mail with MAIL disabled, but attempting
to read such a scroll issued impossible "What weird effect is this?"
curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 invent.c $NHDT-Date: 1606765212 2020/11/30 19:40:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.308 $ */
/* NetHack 3.7 invent.c $NHDT-Date: 1608846067 2020/12/24 21:41:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.310 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3784,6 +3784,15 @@ register struct obj *otmp, *obj;
: (!has_omailcmd(otmp) || strcmp(OMAILCMD(obj), OMAILCMD(otmp)) != 0))
return FALSE;
#ifdef MAIL_STRUCTURES
if (obj->otyp == SCR_MAIL
/* wished or bones mail and hand written stamped scrolls
each have two flavors; spe keeps them separate from each
other but we want to keep their flavors separate too */
&& obj->spe > 0 && (obj->o_id % 2) != (otmp->o_id % 2))
return FALSE;
#endif
/* should be moot since matching artifacts wouldn't be unique */
if (obj->oartifact != otmp->oartifact)
return FALSE;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 read.c $NHDT-Date: 1607945439 2020/12/14 11:30:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.205 $ */
/* NetHack 3.7 read.c $NHDT-Date: 1608846072 2020/12/24 21:41:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.207 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -436,7 +436,7 @@ doread()
}
confused = (Confusion != 0);
#ifdef MAIL
#ifdef MAIL_STRUCTURES
if (otyp == SCR_MAIL) {
confused = FALSE; /* override */
/* reading mail is a convenience for the player and takes
@@ -953,22 +953,38 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
|| objects[otyp].oc_name_known);
switch (otyp) {
#ifdef MAIL
case SCR_MAIL:
#ifdef MAIL_STRUCTURES
case SCR_MAIL: {
boolean odd = (sobj->o_id % 2) == 1;
g.known = TRUE;
if (sobj->spe == 2)
switch (sobj->spe) {
case 2:
/* "stamped scroll" created via magic marker--without a stamp */
pline("This scroll is marked \"postage due\".");
else if (sobj->spe)
pline("This scroll is marked \"%s\".",
odd ? "Postage Due" : "Return to Sender");
break;
case 1:
/* scroll of mail obtained from bones file or from wishing;
* note to the puzzled: the game Larn actually sends you junk
* mail if you win!
*/
pline(
"This seems to be junk mail addressed to the finder of the Eye of Larn.");
else
note to the puzzled: the game Larn actually sends you junk
mail if you win! */
pline("This seems to be %s.",
odd ? "a chain letter threatening your luck"
: "junk mail addressed to the finder of the Eye of Larn");
break;
default:
#ifdef MAIL
readmail(sobj);
#else
/* unreachable since with MAIL undefined, sobj->spe won't be 0;
as a precaution, be prepared to give arbitrary feedback;
caller has already reported that it disappears upon reading */
pline("That was a scroll of mail?");
#endif
break;
}
break;
}
#endif
case SCR_ENCHANT_ARMOR: {
register schar s;