don't miss the special furniture checks during liquid flow

Closes #405
This commit is contained in:
nhmall
2020-12-11 16:28:59 -05:00
parent abca3d26db
commit 6dc033e5d8
2 changed files with 36 additions and 21 deletions

View File

@@ -13,6 +13,7 @@ static int NDECL(dig);
static void FDECL(dig_up_grave, (coord *));
static int FDECL(adj_pit_checks, (coord *, char *));
static void FDECL(pit_flow, (struct trap *, SCHAR_P));
static boolean FDECL(furniture_handled, (int, int, BOOLEAN_P));
/* Indices returned by dig_typ() */
enum dig_types {
@@ -489,6 +490,33 @@ dig(VOID_ARGS)
return 1;
}
static boolean
furniture_handled(x, y, madeby_u)
int x, y;
boolean madeby_u;
{
struct rm *lev = &levl[x][y];
if (IS_FOUNTAIN(lev->typ)) {
dogushforth(FALSE);
SET_FOUNTAIN_WARNED(x, y); /* force dryup */
dryup(x, y, madeby_u);
} else if (IS_SINK(lev->typ)) {
breaksink(x, y);
} else if (lev->typ == DRAWBRIDGE_DOWN
|| (is_drawbridge_wall(x, y) >= 0)) {
int bx = x, by = y;
/* if under the portcullis, the bridge is adjacent */
(void) find_drawbridge(&bx, &by);
destroy_drawbridge(bx, by);
} else {
return FALSE;
}
return TRUE;
}
/* When will hole be finished? Very rough indication used by shopkeeper. */
int
holetime()
@@ -558,25 +586,8 @@ int ttyp;
reset_utrap(FALSE);
}
/* these furniture checks were in dighole(), but wand
breaking bypasses that routine and calls us directly */
if (IS_FOUNTAIN(lev->typ)) {
dogushforth(FALSE);
SET_FOUNTAIN_WARNED(x, y); /* force dryup */
dryup(x, y, madeby_u);
if (furniture_handled(x, y, madeby_u))
return;
} else if (IS_SINK(lev->typ)) {
breaksink(x, y);
return;
} else if (lev->typ == DRAWBRIDGE_DOWN
|| (is_drawbridge_wall(x, y) >= 0)) {
int bx = x, by = y;
/* if under the portcullis, the bridge is adjacent */
(void) find_drawbridge(&bx, &by);
destroy_drawbridge(bx, by);
return;
}
if (ttyp != PIT && (!Can_dig_down(&u.uz) && !lev->candig)) {
impossible("digactualhole: can't dig %s on this level.",
@@ -876,9 +887,11 @@ coord *cc;
lev->flags = 0;
if (typ != ROOM) {
lev->typ = typ;
liquid_flow(dig_x, dig_y, typ, ttmp,
"As you dig, the hole fills with %s!");
if (!furniture_handled((int) dig_x, (int) dig_y, TRUE)) {
lev->typ = typ;
liquid_flow(dig_x, dig_y, typ, ttmp,
"As you dig, the hole fills with %s!");
}
return TRUE;
}