MCPcopy Index your code
hub / github.com/NetHack/NetHack / look_at_object

Function look_at_object

src/pager.c:379–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377}
378
379staticfn void
380look_at_object(
381 char *buf, /* output buffer */
382 coordxy x, coordxy y,
383 int glyph)
384{
385 struct obj *otmp = 0;
386 boolean fakeobj = object_from_map(glyph, x, y, &otmp);
387
388 if (otmp) {
389 Strcpy(buf, (otmp->otyp != STRANGE_OBJECT)
390 ? distant_name(otmp, otmp->dknown ? doname_with_price
391 : doname_vague_quan)
392 : obj_descr[STRANGE_OBJECT].oc_name);
393 if (fakeobj) {
394 otmp->where = OBJ_FREE; /* object_from_map set it to OBJ_FLOOR */
395 dealloc_obj(otmp), otmp = NULL; /* has no contents */
396 }
397 } else {
398 Strcpy(buf, something); /* sanity precaution */
399 }
400
401 if (otmp && otmp->where == OBJ_BURIED)
402 Strcat(buf, " (buried)");
403 /* check TREE before STONE due to level.flags.arboreal */
404 else if (IS_TREE(levl[x][y].typ))
405 /* "dangling": "hanging" could imply that it's growing on this tree */
406 Snprintf(eos(buf), BUFSZ - strlen(buf), " %s in a tree",
407 (otmp && is_treefruit(otmp)) ? "dangling" : "stuck");
408 else if (levl[x][y].typ == STONE || levl[x][y].typ == SCORR)
409 Strcat(buf, " embedded in stone");
410 else if (IS_WALL(levl[x][y].typ) || levl[x][y].typ == SDOOR)
411 Strcat(buf, " embedded in a wall");
412 else if (closed_door(x, y))
413 Strcat(buf, " embedded in a door");
414 else if (is_pool(x, y))
415 Strcat(buf, " in water");
416 else if (is_lava(x, y))
417 Strcat(buf, " in molten lava"); /* [can this ever happen?] */
418 return;
419}
420
421staticfn void
422look_at_monster(

Callers 2

lookatFunction · 0.85
look_allFunction · 0.85

Calls 8

object_from_mapFunction · 0.85
distant_nameFunction · 0.85
dealloc_objFunction · 0.85
eosFunction · 0.85
is_treefruitFunction · 0.85
closed_doorFunction · 0.85
is_poolFunction · 0.85
is_lavaFunction · 0.85

Tested by

no test coverage detected