From 6edfb3ee6d3aa18d14e759cb8a196d81b34c2528 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Sun, 12 Jun 2016 22:01:02 +1000 Subject: [PATCH] bigfix: aigetlastknownpos() fails when one of the adjacent cells is off the edge of the map. --- ai.c | 2 +- god.c | 3 +++ objects.c | 13 +++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ai.c b/ai.c index 97abee0..2b1a56b 100644 --- a/ai.c +++ b/ai.c @@ -679,7 +679,7 @@ cell_t *aigetlastknownpos(lifeform_t *lf, lifeform_t *target, int *lastx, int *l cell_t *c; // follow the trail c = getcellindir(trailcell, locallastdir); - if (getcelldist(c, target->cell) < getcelldist(trailcell, target->cell)) { + if (c && (getcelldist(c, target->cell) < getcelldist(trailcell, target->cell))) { locallastdir = D_NONE; finalcell = c; } diff --git a/god.c b/god.c index 466066b..fbbf15b 100644 --- a/god.c +++ b/god.c @@ -1973,9 +1973,12 @@ void pleasegod(enum RACE rid, int amt) { } */ + lf = findgod(rid); real_getlfname(lf, lfname, NULL, B_NOSHOWALL, B_REALRACE); + dblog("pleasing %s by %d\n", lfname, amt); + oldplev = getpietylev(rid, NULL, NULL); modpiety(rid, amt); newplev = getpietylev(rid, NULL, NULL); diff --git a/objects.c b/objects.c index acaa7b0..287e530 100644 --- a/objects.c +++ b/objects.c @@ -7802,12 +7802,15 @@ object_t *hasequippedobidon(obpile_t *op, enum OBTYPE oid, enum BODYPART bp) { } int hasinteractableflags(flagpile_t *fp) { - if (hasflag(fp, F_IMPASSABLE)) { + if (hasflag(fp, F_IMPASSABLE) && hasflag(fp, F_OPERABLE)) { + return B_TRUE; + } else if (hasflag(fp, F_CONTAINER) && hasflag(fp, F_OPERABLE)) { + return B_TRUE; + } else if (hasflag(fp, F_CLIMBABLE) && hasflag(fp, F_LOCKABLE)) { + // ie. locked stairs return B_TRUE; } else if (hasflag(fp, F_DOOR)) { return B_TRUE; - } else if (hasflag(fp, F_CONTAINER)) { - return B_TRUE; } return B_FALSE; } @@ -8407,9 +8410,7 @@ int isimpassableob(object_t *o, lifeform_t *lf, enum LFSIZE forcesize) { // It's NOT fine to interact with a wand, even though it is operable. // int isinteractable(object_t *o) { - if (isoperable(o) && hasinteractableflags(o->flags)) { - return B_TRUE; - } else if (isdoor(o, NULL)) { + if (hasinteractableflags(o->flags)) { return B_TRUE; } return B_FALSE;