fix pull request #227 - running over engravings

Fixes #227

Travel, <ctrl><direction>, <g|G><direction> all stop on engravings,
but <shift><direction> told the player what the engraving said and
kept going.  The message output is buffered until map update or
another message, so player couldn't tell where hero was at the time
the engraving got shown.  Make <shift> running stop on engravings.
This commit is contained in:
PatR
2019-10-05 16:42:13 -07:00
parent a9e8348dfa
commit f7bf56555e
2 changed files with 17 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 engrave.c $NHDT-Date: 1456304550 2016/02/24 09:02:30 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.61 $ */
/* NetHack 3.6 engrave.c $NHDT-Date: 1570318925 2019/10/05 23:42:05 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.75 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -314,7 +314,6 @@ int x, y;
{
register struct engr *ep = engr_at(x, y);
int sensed = 0;
char buf[BUFSZ];
/* Sensing an engraving does not require sight,
* nor does it necessarily imply comprehension (literacy).
@@ -363,17 +362,22 @@ int x, y;
impossible("%s is written in a very strange way.", Something);
sensed = 1;
}
if (sensed) {
char *et;
unsigned maxelen = BUFSZ - sizeof("You feel the words: \"\". ");
if (strlen(ep->engr_txt) > maxelen) {
(void) strncpy(buf, ep->engr_txt, (int) maxelen);
char *et, buf[BUFSZ];
int maxelen = (int) (sizeof buf
/* sizeof "literal" counts terminating \0 */
- sizeof "You feel the words: \"\".");
if ((int) strlen(ep->engr_txt) > maxelen) {
(void) strncpy(buf, ep->engr_txt, maxelen);
buf[maxelen] = '\0';
et = buf;
} else
} else {
et = ep->engr_txt;
}
You("%s: \"%s\".", (Blind) ? "feel the words" : "read", et);
if (context.run > 1)
if (context.run > 0)
nomul(0);
}
}