MCPcopy Create free account
hub / github.com/NetHack/NetHack / dfeature_at

Function dfeature_at

src/invent.c:4036–4099  ·  view source on GitHub ↗

return a string describing the dungeon feature at if there is one worth mentioning at that location; otherwise null */

Source from the content-addressed store, hash-verified

4034/* return a string describing the dungeon feature at <x,y> if there
4035 is one worth mentioning at that location; otherwise null */
4036const char *
4037dfeature_at(coordxy x, coordxy y, char *buf)
4038{
4039 struct rm *lev = &levl[x][y];
4040 int ltyp = lev->typ, cmap = -1;
4041 const char *dfeature = 0;
4042 static char altbuf[BUFSZ];
4043 stairway *stway = stairway_at(x, y);
4044
4045 if (IS_DOOR(ltyp)) {
4046 switch (lev->doormask) {
4047 case D_NODOOR:
4048 cmap = S_ndoor;
4049 break; /* "doorway" */
4050 case D_ISOPEN:
4051 cmap = S_vodoor;
4052 break; /* "open door" */
4053 case D_BROKEN:
4054 dfeature = "broken door";
4055 break;
4056 default:
4057 cmap = S_vcdoor;
4058 break; /* "closed door" */
4059 }
4060 /* override door description for open drawbridge */
4061 if (is_drawbridge_wall(x, y) >= 0)
4062 dfeature = "open drawbridge portcullis", cmap = -1;
4063 } else if (IS_FOUNTAIN(ltyp))
4064 cmap = S_fountain; /* "fountain" */
4065 else if (IS_THRONE(ltyp))
4066 cmap = S_throne; /* "opulent throne" */
4067 else if (is_lava(x, y))
4068 cmap = S_lava; /* "molten lava" */
4069 else if (is_ice(x, y))
4070 dfeature = ice_descr(x, y, altbuf), cmap = -1; /* "ice" */
4071 else if (is_pool(x, y))
4072 dfeature = "pool of water";
4073 else if (IS_SINK(ltyp))
4074 cmap = S_sink; /* "sink" */
4075 else if (IS_ALTAR(ltyp)) {
4076 Sprintf(altbuf, "%saltar to %s (%s)",
4077 (lev->altarmask & AM_SANCTUM) ? "high " : "",
4078 a_gname(),
4079 align_str(Amask2align(lev->altarmask & ~AM_SHRINE)));
4080 dfeature = altbuf;
4081 } else if (stway) {
4082 dfeature = stairs_description(stway, altbuf, TRUE);
4083 } else if (ltyp == DRAWBRIDGE_DOWN)
4084 cmap = S_vodbridge; /* "lowered drawbridge" */
4085 else if (ltyp == DBWALL)
4086 cmap = S_vcdbridge; /* "raised drawbridge" */
4087 else if (IS_GRAVE(ltyp))
4088 cmap = S_grave; /* "grave" */
4089 else if (ltyp == TREE)
4090 cmap = S_tree; /* "tree" */
4091 else if (ltyp == IRONBARS)
4092 dfeature = "set of iron bars";
4093

Callers 2

look_hereFunction · 0.85
describe_decorFunction · 0.85

Calls 9

stairway_atFunction · 0.85
is_drawbridge_wallFunction · 0.85
is_lavaFunction · 0.85
is_iceFunction · 0.85
ice_descrFunction · 0.85
is_poolFunction · 0.85
a_gnameFunction · 0.85
align_strFunction · 0.85
stairs_descriptionFunction · 0.85

Tested by

no test coverage detected