bigfix: aigetlastknownpos() fails when one of the adjacent cells is off the edge of the map.

This commit is contained in:
Rob Pearce 2016-06-12 22:01:02 +10:00
parent 60e28b6c03
commit 6edfb3ee6d
3 changed files with 11 additions and 7 deletions

2
ai.c
View File

@ -679,7 +679,7 @@ cell_t *aigetlastknownpos(lifeform_t *lf, lifeform_t *target, int *lastx, int *l
cell_t *c; cell_t *c;
// follow the trail // follow the trail
c = getcellindir(trailcell, locallastdir); 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; locallastdir = D_NONE;
finalcell = c; finalcell = c;
} }

3
god.c
View File

@ -1973,9 +1973,12 @@ void pleasegod(enum RACE rid, int amt) {
} }
*/ */
lf = findgod(rid); lf = findgod(rid);
real_getlfname(lf, lfname, NULL, B_NOSHOWALL, B_REALRACE); real_getlfname(lf, lfname, NULL, B_NOSHOWALL, B_REALRACE);
dblog("pleasing %s by %d\n", lfname, amt);
oldplev = getpietylev(rid, NULL, NULL); oldplev = getpietylev(rid, NULL, NULL);
modpiety(rid, amt); modpiety(rid, amt);
newplev = getpietylev(rid, NULL, NULL); newplev = getpietylev(rid, NULL, NULL);

View File

@ -7802,12 +7802,15 @@ object_t *hasequippedobidon(obpile_t *op, enum OBTYPE oid, enum BODYPART bp) {
} }
int hasinteractableflags(flagpile_t *fp) { 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; return B_TRUE;
} else if (hasflag(fp, F_DOOR)) { } else if (hasflag(fp, F_DOOR)) {
return B_TRUE; return B_TRUE;
} else if (hasflag(fp, F_CONTAINER)) {
return B_TRUE;
} }
return B_FALSE; 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. // It's NOT fine to interact with a wand, even though it is operable.
// //
int isinteractable(object_t *o) { int isinteractable(object_t *o) {
if (isoperable(o) && hasinteractableflags(o->flags)) { if (hasinteractableflags(o->flags)) {
return B_TRUE;
} else if (isdoor(o, NULL)) {
return B_TRUE; return B_TRUE;
} }
return B_FALSE; return B_FALSE;