ceiling and surface relocations and adjustments

relocate surface(), ceiling(), and avoid_ceiling() to dungeon.c
adjacent to has_ceiling() etc.

astral and fire, like airlevel and waterlevel return FALSE
for has_ceiling()

if a caller does happen to call ceiling() on fire level,
return "flames above"

if a caller does happen to call ceiling() on quest level,
return a more-generic "expanse above", instead of the
word "ceiling"

add "stairs" return to surface()

remove recent update to engrave.c to special-case "stairs"
since surface() will return that now
This commit is contained in:
nhmall
2023-03-27 18:09:13 -04:00
parent f74628b9d1
commit 2855f71764
4 changed files with 92 additions and 89 deletions

View File

@@ -713,6 +713,9 @@ extern boolean Can_fall_thru(d_level *);
extern boolean Can_dig_down(d_level *);
extern boolean Can_rise_up(coordxy, coordxy, d_level *);
extern boolean has_ceiling(d_level *);
extern boolean avoid_ceiling(d_level *);
extern const char *surface(coordxy, coordxy);
extern const char *ceiling(coordxy, coordxy);
extern boolean In_quest(d_level *);
extern boolean In_mines(d_level *);
extern branch *dungeon_branch(const char *);
@@ -815,8 +818,6 @@ extern char *random_engraving(char *);
extern void wipeout_text(char *, int, unsigned);
extern boolean can_reach_floor(boolean);
extern void cant_reach_floor(coordxy, coordxy, boolean, boolean);
extern const char *surface(coordxy, coordxy);
extern const char *ceiling(coordxy, coordxy);
extern struct engr *engr_at(coordxy, coordxy);
extern struct engr *sengr_at(const char *, coordxy, coordxy, boolean);
extern void u_wipe_engr(int);
@@ -2351,7 +2352,6 @@ extern void punish(struct obj *);
extern void unpunish(void);
extern boolean cant_revive(int *, boolean, struct obj *);
extern boolean create_particular(void);
extern boolean avoid_ceiling(d_level *);
/* ### rect.c ### */

View File

@@ -1719,8 +1719,95 @@ Can_rise_up(coordxy x, coordxy y, d_level *lev)
boolean
has_ceiling(d_level *lev)
{
/* [what about level 1 of the quest?] */
return (boolean) (!Is_airlevel(lev) && !Is_waterlevel(lev));
if (!(Is_astralevel(lev) || Is_firelevel(lev)
|| Is_airlevel(lev) || Is_waterlevel(lev)))
return TRUE;
return FALSE;
}
boolean
avoid_ceiling(d_level *lev)
{
/* The quest is challenging since parts of the level
may have ceilings and other parts may not; Avoid
the ambiguity there by testing with avoid_ceiling()
and using alternative messaging that avoids the term
ceiling altogether there */
if (In_quest(lev) || !has_ceiling(lev))
return TRUE;
return FALSE;
}
const char *
ceiling(coordxy x, coordxy y)
{
struct rm *lev = &levl[x][y];
const char *what;
/* other room types will no longer exist when we're interested --
* see check_special_room()
*/
if (*in_rooms(x, y, VAULT))
what = "vault's ceiling";
else if (*in_rooms(x, y, TEMPLE))
what = "temple's ceiling";
else if (*in_rooms(x, y, SHOPBASE))
what = "shop's ceiling";
else if (Is_waterlevel(&u.uz))
/* water plane has no surface; its air bubbles aren't below sky */
what = "water above";
else if (IS_AIR(lev->typ))
what = "sky";
else if (Is_firelevel(&u.uz))
what = "flames above";
else if (In_quest(&u.uz))
/* just in case; try to avoid in caller if you can */
what = "expanse above";
else if (Underwater)
what = "water's surface";
else if ((IS_ROOM(lev->typ) && !Is_earthlevel(&u.uz))
|| IS_WALL(lev->typ) || IS_DOOR(lev->typ) || lev->typ == SDOOR)
what = "ceiling";
else
what = "rock cavern";
return what;
}
const char *
surface(coordxy x, coordxy y)
{
struct rm *lev = &levl[x][y];
if (u_at(x, y) && u.uswallow && is_animal(u.ustuck->data))
/* 'husk' is iffy but maw is wrong for 't' class */
return digests(u.ustuck->data) ? "maw"
: enfolds(u.ustuck->data) ? "husk"
: "nonesuch"; /* can't happen (fingers crossed...) */
else if (IS_AIR(lev->typ) && Is_airlevel(&u.uz))
return "air";
else if (is_pool(x, y))
return (Underwater && !Is_waterlevel(&u.uz))
? "bottom" : hliquid("water");
else if (is_ice(x, y))
return "ice";
else if (is_lava(x, y))
return hliquid("lava");
else if (lev->typ == DRAWBRIDGE_DOWN)
return "bridge";
else if (IS_ALTAR(levl[x][y].typ))
return "altar";
else if (IS_GRAVE(levl[x][y].typ))
return "headstone";
else if (IS_FOUNTAIN(levl[x][y].typ))
return "fountain";
else if (On_stairs(x, y))
return "stairs";
else if ((IS_ROOM(lev->typ) && !Is_earthlevel(&u.uz))
|| IS_WALL(lev->typ) || IS_DOOR(lev->typ) || lev->typ == SDOOR)
return "floor";
else
return "ground";
}
/*

View File

@@ -186,71 +186,6 @@ cant_reach_floor(coordxy x, coordxy y, boolean up, boolean check_pit)
: surface(x, y));
}
const char *
surface(coordxy x, coordxy y)
{
struct rm *lev = &levl[x][y];
if (u_at(x, y) && u.uswallow && is_animal(u.ustuck->data))
/* 'husk' is iffy but maw is wrong for 't' class */
return digests(u.ustuck->data) ? "maw"
: enfolds(u.ustuck->data) ? "husk"
: "nonesuch"; /* can't happen (fingers crossed...) */
else if (IS_AIR(lev->typ) && Is_airlevel(&u.uz))
return "air";
else if (is_pool(x, y))
return (Underwater && !Is_waterlevel(&u.uz))
? "bottom" : hliquid("water");
else if (is_ice(x, y))
return "ice";
else if (is_lava(x, y))
return hliquid("lava");
else if (lev->typ == DRAWBRIDGE_DOWN)
return "bridge";
else if (IS_ALTAR(levl[x][y].typ))
return "altar";
else if (IS_GRAVE(levl[x][y].typ))
return "headstone";
else if (IS_FOUNTAIN(levl[x][y].typ))
return "fountain";
else if ((IS_ROOM(lev->typ) && !Is_earthlevel(&u.uz))
|| IS_WALL(lev->typ) || IS_DOOR(lev->typ) || lev->typ == SDOOR)
return "floor";
else
return "ground";
}
const char *
ceiling(coordxy x, coordxy y)
{
struct rm *lev = &levl[x][y];
const char *what;
/* other room types will no longer exist when we're interested --
* see check_special_room()
*/
if (*in_rooms(x, y, VAULT))
what = "vault's ceiling";
else if (*in_rooms(x, y, TEMPLE))
what = "temple's ceiling";
else if (*in_rooms(x, y, SHOPBASE))
what = "shop's ceiling";
else if (Is_waterlevel(&u.uz))
/* water plane has no surface; its air bubbles aren't below sky */
what = "water above";
else if (IS_AIR(lev->typ))
what = "sky";
else if (Underwater)
what = "water's surface";
else if ((IS_ROOM(lev->typ) && !Is_earthlevel(&u.uz))
|| IS_WALL(lev->typ) || IS_DOOR(lev->typ) || lev->typ == SDOOR)
what = "ceiling";
else
what = "rock cavern";
return what;
}
struct engr *
engr_at(coordxy x, coordxy y)
{
@@ -320,10 +255,6 @@ read_engr_at(coordxy x, coordxy y)
const char *eloc = surface(x, y);
int sensed = 0;
if (!spot_shows_engravings(x, y)) {
if (On_stairs(x, y))
eloc = "stairs";
}
/* Sensing an engraving does not require sight,
* nor does it necessarily imply comprehension (literacy).
*/
@@ -1056,10 +987,6 @@ doengrave(void)
}
eloc = surface(u.ux, u.uy);
if (!spot_shows_engravings(u.ux, u.uy)) {
if (On_stairs(u.ux, u.uy))
eloc = "stairs";
}
adding = (oep && !eow);
switch (type) {
default:

View File

@@ -52,17 +52,6 @@ static boolean create_particular_parse(char *,
struct _create_particular_data *);
static boolean create_particular_creation(struct _create_particular_data *);
boolean
avoid_ceiling(d_level *lev)
{
if (In_quest(lev) || Is_astralevel(lev)
|| Is_firelevel(lev) || !has_ceiling(lev))
return TRUE;
return FALSE;
}
static boolean
learnscrolltyp(short scrolltyp)
{