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

Function makewish

src/zap.c:6311–6422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6309}
6310
6311RESTORE_WARNING_FORMAT_NONLITERAL
6312
6313void
6314makewish(void)
6315{
6316 char buf[BUFSZ] = DUMMY;
6317 char bufcpy[BUFSZ], wish[BUFSZ], promptbuf[QBUFSZ];
6318 struct obj *otmp, nothing;
6319 long maybe_LL_arti;
6320 int tries = 0;
6321 long oldwisharti = u.uconduct.wisharti;
6322
6323 svc.context.resume_wish = 0;
6324 promptbuf[0] = '\0';
6325 nothing = cg.zeroobj; /* lint suppression; only its address matters */
6326 if (flags.verbose)
6327 You("may wish for an object.");
6328 retry:
6329 Strcpy(promptbuf, "For what do you wish");
6330 if (iflags.cmdassist && tries > 0)
6331 Strcat(promptbuf, " (enter 'help' for assistance)");
6332 Strcat(promptbuf, "?");
6333
6334 if (iflags.menu_requested && wish_history[0] && (tries == 0))
6335 wish_history_menu(buf);
6336 else
6337 getlin(promptbuf, buf);
6338
6339 if (iflags.term_gone) {
6340 if (!iflags.debug_fuzzer)
6341 svc.context.resume_wish = 1;
6342 return;
6343 }
6344
6345 (void) mungspaces(buf);
6346 if (buf[0] == '\033') {
6347 buf[0] = '\0';
6348 } else if (!strcmpi(buf, "help")) {
6349 wishcmdassist(MAXWISHTRY - tries);
6350 buf[0] = '\0'; /* for EDIT_GETLIN */
6351 goto retry;
6352 }
6353 /*
6354 * Note: if they wished for and got a non-object successfully,
6355 * otmp == &hands_obj. That includes an artifact which has been
6356 * denied. Wishing for "nothing" requires a separate value to remain
6357 * distinct.
6358 */
6359 strcpy(bufcpy, buf);
6360 otmp = readobjnam(buf, &nothing);
6361 if (!otmp) {
6362 pline("Nothing fitting that description exists in the game.");
6363 if (++tries < MAXWISHTRY)
6364 goto retry;
6365 pline1(thats_enough_tries);
6366 otmp = readobjnam((char *) 0, (struct obj *) 0);
6367 if (!otmp)
6368 return; /* for safety; should never happen */

Callers 6

allmain.cFile · 0.85
throne_sit_effectFunction · 0.85
special_throne_effectFunction · 0.85
mongrantswishFunction · 0.85
wiz_wishFunction · 0.85
zapnodirFunction · 0.85

Calls 15

YouFunction · 0.85
wish_history_menuFunction · 0.85
getlinFunction · 0.85
mungspacesFunction · 0.85
wishcmdassistFunction · 0.85
readobjnamFunction · 0.85
livelog_printfFunction · 0.85
wish_history_addFunction · 0.85
artifact_originFunction · 0.85
donameFunction · 0.85
u_safe_from_fatal_corpseFunction · 0.85
hold_another_objectFunction · 0.85

Tested by

no test coverage detected