Check bones data directly for deja vu messages

After modifications to amnesia, `deja vu' messages are now displayed
upon entering a level containing bones of a previous character of the
current player. This test is done simply by checking for a ghost on the
level that shares a name with the current character.

However, since ghosts generated in other circumstances (such as in the
Valley of the Dead and other special levels) can have names pulled
randomly from the high score list, etc, this message can be displayed on
non-bones levels where a ghost has been generated with the character's
name. Additionally, when a bones pile doesn't include a ghost (such as
when the character in question was slimed, killed by a wraith, etc), the
`deja vu' message will not be displayed when it should be. This is all
described in in NetHack/NetHack#322.

This commit changes the method of testing for `familiarity' by adding a
function to iterate through any bones data for the current level,
searching for a match to the hero's name.

Should fix NetHack/NetHack#322.
This commit is contained in:
Michael Meyer
2020-07-12 20:58:35 -04:00
parent 8820306071
commit 742216540c
3 changed files with 26 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1594168620 2020/07/08 00:37:00 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.851 $ */
/* NetHack 3.6 extern.h $NHDT-Date: 1594601903 2020/07/13 00:58:23 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.852 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
@@ -161,6 +161,7 @@ E void FDECL(drop_upon_death, (struct monst *, struct obj *, int, int));
E boolean NDECL(can_make_bones);
E void FDECL(savebones, (int, time_t, struct obj *));
E int NDECL(getbones);
E boolean FDECL(bones_include_name, (const char *));
/* ### botl.c ### */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 bones.c $NHDT-Date: 1593953344 2020/07/05 12:49:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.100 $ */
/* NetHack 3.6 bones.c $NHDT-Date: 1594601903 2020/07/13 00:58:23 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.102 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985,1993. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -658,4 +658,25 @@ getbones()
return ok;
}
/* check whether current level contains bones from a particular player */
boolean
bones_include_name(name)
const char *name;
{
struct cemetery *bp;
char buf[BUFSZ];
Strcpy(buf, name);
Strcat(buf, "-");
int l = strlen(buf);
if ((bp = g.level.bonesinfo)) {
do {
if (!strncmp(bp->who, buf, l))
return TRUE;
} while ((bp = bp->next) != (struct cemetery *) 0);
}
return FALSE;
}
/*bones.c*/

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do.c $NHDT-Date: 1593953347 2020/07/05 12:49:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.246 $ */
/* NetHack 3.6 do.c $NHDT-Date: 1594601903 2020/07/13 00:58:23 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.247 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1470,7 +1470,7 @@ boolean at_stairs, falling, portal;
mklev();
new = TRUE; /* made the level */
familiar = (find_ghost_with_name(g.plname) != (struct monst *) 0);
familiar = bones_include_name(g.plname);
} else {
/* returning to previously visited level; reload it */
nhfp = open_levelfile(new_ledger, whynot);