diff --git a/include/extern.h b/include/extern.h index 7b1c7800b..3ddaaa6e2 100644 --- a/include/extern.h +++ b/include/extern.h @@ -162,6 +162,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 ### */ @@ -1486,7 +1487,6 @@ E void NDECL(kill_genocided_monsters); E void FDECL(golemeffects, (struct monst *, int, int)); E boolean FDECL(angry_guards, (BOOLEAN_P)); E void NDECL(pacify_guards); -E struct monst *FDECL(find_ghost_with_name, (char *)); E void FDECL(decide_to_shapeshift, (struct monst *, int)); E boolean FDECL(vamp_stone, (struct monst *)); diff --git a/src/bones.c b/src/bones.c index 93c23b962..d497343f4 100644 --- a/src/bones.c +++ b/src/bones.c @@ -656,4 +656,27 @@ getbones() return ok; } +/* check whether current level contains bones from a particular player */ +boolean +bones_include_name(name) +const char *name; +{ + struct cemetery *bp; + int len; + char buf[BUFSZ]; + + /* prepare buffer by appending terminal hyphen to name, to avoid partial + * matches producing false positives */ + Strcpy(buf, name); + Strcat(buf, "-"); + len = strlen(buf); + + for (bp = g.level.bonesinfo; bp; bp = bp->next) { + if (!strncmp(bp->who, buf, len)) + return TRUE; + } + + return FALSE; +} + /*bones.c*/ diff --git a/src/do.c b/src/do.c index 4d5057595..5807b8675 100644 --- a/src/do.c +++ b/src/do.c @@ -1473,7 +1473,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); diff --git a/src/mon.c b/src/mon.c index 346b21c0f..dd2ea4e3f 100644 --- a/src/mon.c +++ b/src/mon.c @@ -4647,22 +4647,6 @@ pacify_guards() } } -struct monst * -find_ghost_with_name(str) -char *str; -{ - struct monst *mtmp; - - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp) - || mtmp->data != &mons[PM_GHOST] || !has_mgivenname(mtmp)) - continue; - if (!strcmpi(MGIVENNAME(mtmp), str)) - return mtmp; - } - return (struct monst *) 0; -} - void mimic_hit_msg(mtmp, otyp) struct monst *mtmp;