| 676 | } |
| 677 | |
| 678 | staticfn void |
| 679 | namefloorobj(void) |
| 680 | { |
| 681 | coord cc; |
| 682 | int glyph; |
| 683 | char buf[BUFSZ]; |
| 684 | struct obj *obj = 0; |
| 685 | boolean fakeobj = FALSE, use_plural; |
| 686 | |
| 687 | cc.x = u.ux, cc.y = u.uy; |
| 688 | /* "dot for under/over you" only makes sense when the cursor hasn't |
| 689 | been moved off the hero's '@' yet, but there's no way to adjust |
| 690 | the help text once getpos() has started */ |
| 691 | Sprintf(buf, "object on map (or '.' for one %s you)", |
| 692 | (u.uundetected && hides_under(gy.youmonst.data)) |
| 693 | ? "over" : "under"); |
| 694 | if (getpos(&cc, FALSE, buf) < 0 || cc.x <= 0) |
| 695 | return; |
| 696 | if (u_at(cc.x, cc.y)) { |
| 697 | obj = vobj_at(u.ux, u.uy); |
| 698 | } else { |
| 699 | glyph = glyph_at(cc.x, cc.y); |
| 700 | if (glyph_is_object(glyph)) |
| 701 | fakeobj = object_from_map(glyph, cc.x, cc.y, &obj); |
| 702 | /* else 'obj' stays null */ |
| 703 | } |
| 704 | if (!obj) { |
| 705 | /* "under you" is safe here since there's no object to hide under */ |
| 706 | There("doesn't seem to be any object %s.", |
| 707 | u_at(cc.x, cc.y) ? "under you" : "there"); |
| 708 | return; |
| 709 | } |
| 710 | /* note well: 'obj' might be an instance of STRANGE_OBJECT if target |
| 711 | is a mimic; passing that to xname (directly or via simpleonames) |
| 712 | would yield "glorkum" so we need to handle it explicitly; it will |
| 713 | always fail the Hallucination test and pass the !callable test, |
| 714 | resulting in the "can't be assigned a type name" message */ |
| 715 | Strcpy(buf, (obj->otyp != STRANGE_OBJECT) |
| 716 | ? simpleonames(obj) |
| 717 | : obj_descr[STRANGE_OBJECT].oc_name); |
| 718 | use_plural = (obj->quan > 1L); |
| 719 | if (Hallucination) { |
| 720 | const char *unames[6]; |
| 721 | char tmpbuf[BUFSZ]; |
| 722 | |
| 723 | /* straight role name */ |
| 724 | unames[0] = ((Upolyd ? u.mfemale : flags.female) && gu.urole.name.f) |
| 725 | ? gu.urole.name.f |
| 726 | : gu.urole.name.m; |
| 727 | /* random rank title for hero's role |
| 728 | |
| 729 | note: the 30 is hardcoded in xlev_to_rank, so should be |
| 730 | hardcoded here too */ |
| 731 | unames[1] = rank_of(rn2_on_display_rng(30) + 1, |
| 732 | Role_switch, flags.female); |
| 733 | /* random fake monster */ |
| 734 | unames[2] = bogusmon(tmpbuf, (char *) 0); |
| 735 | /* increased chance for fake monster */ |
no test coverage detected