Factor out a new is_moat function.
The fact that Juiblex's swamp is MOAT but not moat is weird and should probably be looked at at some point.
This commit is contained in:
@@ -219,6 +219,7 @@ E boolean FDECL(is_pool, (int,int));
|
|||||||
E boolean FDECL(is_lava, (int,int));
|
E boolean FDECL(is_lava, (int,int));
|
||||||
E boolean FDECL(is_pool_or_lava, (int,int));
|
E boolean FDECL(is_pool_or_lava, (int,int));
|
||||||
E boolean FDECL(is_ice, (int,int));
|
E boolean FDECL(is_ice, (int,int));
|
||||||
|
E boolean FDECL(is_moat, (int,int));
|
||||||
E int FDECL(is_drawbridge_wall, (int,int));
|
E int FDECL(is_drawbridge_wall, (int,int));
|
||||||
E boolean FDECL(is_db_wall, (int,int));
|
E boolean FDECL(is_db_wall, (int,int));
|
||||||
E boolean FDECL(find_drawbridge, (int *,int*));
|
E boolean FDECL(find_drawbridge, (int *,int*));
|
||||||
|
|||||||
@@ -42,9 +42,11 @@ int x,y;
|
|||||||
|
|
||||||
if (!isok(x,y)) return FALSE;
|
if (!isok(x,y)) return FALSE;
|
||||||
ltyp = levl[x][y].typ;
|
ltyp = levl[x][y].typ;
|
||||||
if (ltyp == POOL || ltyp == MOAT || ltyp == WATER) return TRUE;
|
/* The ltyp == MOAT is not redundant with is_moat, because the
|
||||||
if (ltyp == DRAWBRIDGE_UP &&
|
* Juiblex level does not have moats, although it has MOATs. There
|
||||||
(levl[x][y].drawbridgemask & DB_UNDER) == DB_MOAT) return TRUE;
|
* is probably a better way to express this. */
|
||||||
|
if (ltyp == POOL || ltyp == MOAT || ltyp == WATER || is_moat(x, y))
|
||||||
|
return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +88,21 @@ int x,y;
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean
|
||||||
|
is_moat(x,y)
|
||||||
|
int x, y;
|
||||||
|
{
|
||||||
|
schar ltyp;
|
||||||
|
|
||||||
|
if (!isok(x, y)) return FALSE;
|
||||||
|
ltyp = levl[x][y].typ;
|
||||||
|
if (!Is_juiblex_level(&u.uz) &&
|
||||||
|
(ltyp == MOAT || (ltyp == DRAWBRIDGE_UP &&
|
||||||
|
(levl[x][y].drawbridgemask & DB_UNDER) == DB_MOAT)))
|
||||||
|
return TRUE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We want to know whether a wall (or a door) is the portcullis (passageway)
|
* We want to know whether a wall (or a door) is the portcullis (passageway)
|
||||||
* of an eventual drawbridge.
|
* of an eventual drawbridge.
|
||||||
|
|||||||
19
src/dig.c
19
src/dig.c
@@ -486,16 +486,15 @@ boolean fill_if_any; /* force filling if it exists at all */
|
|||||||
|
|
||||||
for (x1 = lo_x; x1 <= hi_x; x1++)
|
for (x1 = lo_x; x1 <= hi_x; x1++)
|
||||||
for (y1 = lo_y; y1 <= hi_y; y1++)
|
for (y1 = lo_y; y1 <= hi_y; y1++)
|
||||||
if (levl[x1][y1].typ == POOL)
|
if (is_moat(x1, y1))
|
||||||
pool_cnt++;
|
moat_cnt++;
|
||||||
else if (levl[x1][y1].typ == MOAT ||
|
else if (is_pool(x1, y1))
|
||||||
(levl[x1][y1].typ == DRAWBRIDGE_UP &&
|
/* This must come after is_moat since moats are pools
|
||||||
(levl[x1][y1].drawbridgemask & DB_UNDER) == DB_MOAT))
|
* but not vice-versa. */
|
||||||
moat_cnt++;
|
pool_cnt++;
|
||||||
else if (levl[x1][y1].typ == LAVAPOOL ||
|
else if (is_lava(x1, y1))
|
||||||
(levl[x1][y1].typ == DRAWBRIDGE_UP &&
|
lava_cnt++;
|
||||||
(levl[x1][y1].drawbridgemask & DB_UNDER) == DB_LAVA))
|
|
||||||
lava_cnt++;
|
|
||||||
if (!fill_if_any) pool_cnt /= 3; /* not as much liquid as the others */
|
if (!fill_if_any) pool_cnt /= 3; /* not as much liquid as the others */
|
||||||
|
|
||||||
if ((lava_cnt > moat_cnt + pool_cnt && rn2(lava_cnt + 1)) ||
|
if ((lava_cnt > moat_cnt + pool_cnt && rn2(lava_cnt + 1)) ||
|
||||||
|
|||||||
@@ -4017,7 +4017,7 @@ short exploding_wand_typ;
|
|||||||
case ZT_COLD:
|
case ZT_COLD:
|
||||||
if (is_pool(x,y) || is_lava(x,y)) {
|
if (is_pool(x,y) || is_lava(x,y)) {
|
||||||
boolean lava = is_lava(x,y);
|
boolean lava = is_lava(x,y);
|
||||||
const char *moat = waterbody_name(x, y);
|
boolean moat = is_moat(x,y);
|
||||||
|
|
||||||
if (lev->typ == WATER) {
|
if (lev->typ == WATER) {
|
||||||
/* For now, don't let WATER freeze. */
|
/* For now, don't let WATER freeze. */
|
||||||
@@ -4041,8 +4041,9 @@ short exploding_wand_typ;
|
|||||||
if (see_it) {
|
if (see_it) {
|
||||||
if(lava)
|
if(lava)
|
||||||
Norep("The lava cools and solidifies.");
|
Norep("The lava cools and solidifies.");
|
||||||
else if(strcmp(moat, "moat") == 0)
|
else if(moat)
|
||||||
Norep("The %s is bridged with ice!", moat);
|
Norep("The %s is bridged with ice!",
|
||||||
|
waterbody_name(x,y));
|
||||||
else
|
else
|
||||||
Norep("The water freezes.");
|
Norep("The water freezes.");
|
||||||
newsym(x,y);
|
newsym(x,y);
|
||||||
|
|||||||
Reference in New Issue
Block a user