Skip to content

Commit cc71b79

Browse files
committed
Fix: mdig_tunnel wasn't returning TRUE for digging monster's death
Apparently in the change which excised mb_trapped for doors, so too was any code path which returned true from this function. While I was figuring out where exactly to return true from it, I also decided to restructure this bit of code. Instead of one large if statement for the monster not being dead, it merely returns true early if the monster is dead. It also checks if interacting with a door trap made the door no longer closed, in which case the digging attempt is aborted.
1 parent 11872b6 commit cc71b79

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/dig.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,26 +1464,30 @@ mdig_tunnel(struct monst *mtmp)
14641464
if (here->typ == SDOOR)
14651465
cvt_sdoor_to_door(here); /* ->typ = DOOR */
14661466

1467-
/* Eats away door if present & closed or locked */
1467+
/* Eats away door if present & closed */
14681468
if (closed_door(mtmp->mx, mtmp->my)) {
14691469
if (door_is_iron(here) && (withpick || !metallivorous(mtmp->data)))
14701470
return FALSE;
14711471
(void) predoortrapped(mtmp->mx, mtmp->my, mtmp,
14721472
(withpick ? ARM : FACE), D_BROKEN);
1473-
if (!DEADMONSTER(mtmp)) {
1474-
if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
1475-
add_damage(mtmp->mx, mtmp->my, 0L);
1476-
(void) postdoortrapped(mtmp->mx, mtmp->my, mtmp,
1477-
(withpick ? ARM : FACE), D_BROKEN);
1478-
set_doorstate(here, D_BROKEN);
1479-
recalc_block_point(mtmp->mx, mtmp->my); /* vision */
1480-
newsym(mtmp->mx, mtmp->my);
1481-
if (!Unaware && flags.verbose && !rn2(3)) {
1482-
/* not too often.. */
1483-
draft_message(TRUE); /* "You feel an unexpected draft." */
1484-
}
1473+
if (DEADMONSTER(mtmp))
1474+
/* dead monster won't finish eating the door */
1475+
return TRUE;
1476+
if (!closed_door(mtmp->mx, mtmp->my))
1477+
/* trap made it no longer closed, no reason to eat through it */
1478+
return FALSE;
1479+
set_doorstate(here, D_BROKEN);
1480+
recalc_block_point(mtmp->mx, mtmp->my); /* vision */
1481+
newsym(mtmp->mx, mtmp->my);
1482+
if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
1483+
add_damage(mtmp->mx, mtmp->my, 0L);
1484+
(void) postdoortrapped(mtmp->mx, mtmp->my, mtmp,
1485+
(withpick ? ARM : FACE), D_BROKEN);
1486+
if (!Unaware && flags.verbose && !rn2(3)) {
1487+
/* not too often.. */
1488+
draft_message(TRUE); /* "You feel an unexpected draft." */
14851489
}
1486-
return FALSE;
1490+
return DEADMONSTER(mtmp); /* in case postdoortrapped killed it */
14871491
} else if (here->typ == SCORR) {
14881492
here->typ = CORR, here->flags = 0;
14891493
unblock_point(mtmp->mx, mtmp->my);

0 commit comments

Comments
 (0)