shopkeeper's name, without any visibility constraint; if hallucinating, will yield some other shopkeeper's name (not necessarily one residing in the current game's dungeon, or who keeps same type of shop) */
| 853 | will yield some other shopkeeper's name (not necessarily one residing |
| 854 | in the current game's dungeon, or who keeps same type of shop) */ |
| 855 | char * |
| 856 | shkname(struct monst *mtmp) |
| 857 | { |
| 858 | char *nam; |
| 859 | unsigned save_isshk = mtmp->isshk; |
| 860 | |
| 861 | mtmp->isshk = 0; /* don't want mon_nam() calling shkname() */ |
| 862 | /* get a modifiable name buffer along with fallback result */ |
| 863 | nam = noit_mon_nam(mtmp); |
| 864 | mtmp->isshk = save_isshk; |
| 865 | |
| 866 | if (!mtmp->isshk) { |
| 867 | impossible("shkname: \"%s\" is not a shopkeeper.", nam); |
| 868 | } else if (!has_eshk(mtmp)) { |
| 869 | panic("shkname: shopkeeper \"%s\" lacks 'eshk' data.", nam); |
| 870 | } else { |
| 871 | const char *shknm = ESHK(mtmp)->shknam; |
| 872 | |
| 873 | if (Hallucination && !program_state.gameover) { |
| 874 | const char *const *nlp; |
| 875 | int num; |
| 876 | |
| 877 | /* count the number of non-unique shop types; |
| 878 | pick one randomly, ignoring shop generation probabilities; |
| 879 | pick a name at random from that shop type's list */ |
| 880 | for (num = 0; num < SIZE(shtypes); num++) |
| 881 | if (shtypes[num].prob == 0) |
| 882 | break; |
| 883 | if (num > 0) { |
| 884 | nlp = shtypes[rn2(num)].shknms; |
| 885 | for (num = 0; nlp[num]; num++) |
| 886 | continue; |
| 887 | if (num > 0) |
| 888 | shknm = nlp[rn2(num)]; |
| 889 | } |
| 890 | } |
| 891 | /* strip prefix if present */ |
| 892 | if (!letter(*shknm)) |
| 893 | ++shknm; |
| 894 | Strcpy(nam, shknm); |
| 895 | } |
| 896 | return nam; |
| 897 | } |
| 898 | |
| 899 | boolean |
| 900 | shkname_is_pname(struct monst *mtmp) |
no test coverage detected