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

Function do_supplemental_info

src/pager.c:2252–2316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2250};
2251
2252staticfn void
2253do_supplemental_info(
2254 char *name,
2255 struct permonst *pm,
2256 boolean without_asking)
2257{
2258 const char **textp;
2259 winid datawin = WIN_ERR;
2260 char *entrytext = name, *bp = (char *) 0, *bp2 = (char *) 0;
2261 char question[QBUFSZ];
2262 boolean yes_to_moreinfo = FALSE;
2263 boolean is_marauder = is_orc(pm);
2264
2265 /*
2266 * Provide some info on some specific things
2267 * meant to support in-game mythology, and not
2268 * available from data.base or other sources.
2269 */
2270 if (is_marauder && (strlen(name) < (BUFSZ - 1))) {
2271 char fullname[BUFSZ];
2272
2273 bp = strstri(name, " of ");
2274 bp2 = strstri(name, " the Fence");
2275
2276 if (bp || bp2) {
2277 Strcpy(fullname, name);
2278 if (!without_asking) {
2279 Strcpy(question, "More info about \"");
2280 /* +2 => length of "\"?" */
2281 copynchars(eos(question), entrytext,
2282 (int) (sizeof question - 1 - (strlen(question) + 2)));
2283 Strcat(question, "\"?");
2284 if (y_n(question) == 'y')
2285 yes_to_moreinfo = TRUE;
2286 }
2287 if (yes_to_moreinfo) {
2288 int i, subs = 0;
2289 const char *gang = (char *) 0;
2290
2291 if (bp) {
2292 textp = suptext1;
2293 gang = bp + 4;
2294 *bp = '\0';
2295 } else {
2296 textp = suptext2;
2297 gang = "";
2298 }
2299 datawin = create_nhwindow(NHW_MENU);
2300 for (i = 0; textp[i]; i++) {
2301 char buf[BUFSZ];
2302 const char *txt;
2303
2304 if (strstri(textp[i], "%s") != 0) {
2305 Sprintf(buf, textp[i], subs++ ? gang : fullname);
2306 txt = buf;
2307 } else
2308 txt = textp[i];
2309 putstr(datawin, 0, txt);

Callers 1

do_lookFunction · 0.85

Calls 3

strstriFunction · 0.85
copyncharsFunction · 0.85
eosFunction · 0.85

Tested by

no test coverage detected