Fix shopkeeper Kop summons causing segfault
... if it happened on a level with no downstairs, such as the tourist quest.
This commit is contained in:
@@ -3112,6 +3112,7 @@ extern void nethack_enter_windows(void);
|
||||
extern void amulet(void);
|
||||
extern int mon_has_amulet(struct monst *);
|
||||
extern int mon_has_special(struct monst *);
|
||||
extern void choose_stairs(xchar *, xchar *, boolean);
|
||||
extern int tactics(struct monst *);
|
||||
extern boolean has_aggravatables(struct monst *);
|
||||
extern void aggravate(void);
|
||||
|
||||
17
src/shk.c
17
src/shk.c
@@ -344,14 +344,9 @@ call_kops(register struct monst* shkp, register boolean nearshop)
|
||||
|
||||
{
|
||||
coord mm;
|
||||
stairway *stway = g.stairs;
|
||||
xchar sx = 0, sy = 0;
|
||||
|
||||
while (stway) {
|
||||
if (!stway->isladder && !stway->up
|
||||
&& stway->tolev.dnum == u.uz.dnum)
|
||||
break;
|
||||
stway = stway->next;
|
||||
}
|
||||
choose_stairs(&sx, &sy, TRUE);
|
||||
|
||||
if (nearshop) {
|
||||
/* Create swarm around you, if you merely "stepped out" */
|
||||
@@ -365,9 +360,11 @@ call_kops(register struct monst* shkp, register boolean nearshop)
|
||||
if (flags.verbose)
|
||||
pline_The("Keystone Kops are after you!");
|
||||
/* Create swarm near down staircase (hinders return to level) */
|
||||
mm.x = stway->sx;
|
||||
mm.y = stway->sy;
|
||||
makekops(&mm);
|
||||
if (isok(sx, sy)) {
|
||||
mm.x = sx;
|
||||
mm.y = sy;
|
||||
makekops(&mm);
|
||||
}
|
||||
/* Create swarm near shopkeeper (hinders return to shop) */
|
||||
mm.x = shkp->mx;
|
||||
mm.y = shkp->my;
|
||||
|
||||
11
src/wizard.c
11
src/wizard.c
@@ -17,7 +17,6 @@ static struct obj *on_ground(short);
|
||||
static boolean you_have(int);
|
||||
static unsigned long target_on(int, struct monst *);
|
||||
static unsigned long strategy(struct monst *);
|
||||
static void choose_stairs(xchar *, xchar *);
|
||||
|
||||
/* adding more neutral creatures will tend to reduce the number of monsters
|
||||
summoned by nasty(); adding more lawful creatures will reduce the number
|
||||
@@ -311,12 +310,12 @@ strategy(struct monst *mtmp)
|
||||
return dstrat;
|
||||
}
|
||||
|
||||
static void
|
||||
choose_stairs(xchar *sx, xchar *sy)
|
||||
void
|
||||
choose_stairs(xchar *sx, xchar *sy, boolean dir)
|
||||
{
|
||||
xchar x = 0, y = 0;
|
||||
stairway *stway = g.stairs;
|
||||
boolean stdir = !builds_up(&u.uz);
|
||||
boolean stdir = dir && !builds_up(&u.uz);
|
||||
|
||||
if ((stway = stairway_find_type_dir(FALSE, stdir)) != 0) {
|
||||
x = stway->sx;
|
||||
@@ -335,7 +334,7 @@ choose_stairs(xchar *sx, xchar *sy)
|
||||
}
|
||||
}
|
||||
|
||||
if (x && y) {
|
||||
if (isok(x, y)) {
|
||||
*sx = x;
|
||||
*sy = y;
|
||||
}
|
||||
@@ -356,7 +355,7 @@ tactics(struct monst *mtmp)
|
||||
case STRAT_HEAL: /* hide and recover */
|
||||
mx = mtmp->mx, my = mtmp->my;
|
||||
/* if wounded, hole up on or near the stairs (to block them) */
|
||||
choose_stairs(&sx, &sy);
|
||||
choose_stairs(&sx, &sy, FALSE);
|
||||
mtmp->mavenge = 1; /* covetous monsters attack while fleeing */
|
||||
if (In_W_tower(mx, my, &u.uz)
|
||||
|| (mtmp->iswiz && !sx && !mon_has_amulet(mtmp))) {
|
||||
|
||||
Reference in New Issue
Block a user