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

Function curses_choose_character

win/curses/cursinit.c:376–685  ·  view source on GitHub ↗

Allow player to pick character's role, race, gender, and alignment. Borrowed from the Gnome window port. */

Source from the content-addressed store, hash-verified

374/* Allow player to pick character's role, race, gender, and alignment.
375 Borrowed from the Gnome window port. */
376void
377curses_choose_character(void)
378{
379 int n, i, sel, count_off, pick4u;
380 int count = 0;
381 int cur_character = 0;
382 const char **choices;
383 int *pickmap;
384 char *prompt;
385 char pbuf[QBUFSZ];
386 char choice[QBUFSZ];
387 char tmpchoice[QBUFSZ];
388
389 prompt = build_plselection_prompt(pbuf, QBUFSZ, flags.initrole,
390 flags.initrace, flags.initgend,
391 flags.initalign);
392
393 /* This part is irritating: we have to strip the choices off of
394 the string and put them in a separate string in order to use
395 curses_character_input_dialog for this prompt. */
396 while (cur_character != '[') {
397 cur_character = prompt[count];
398 count++;
399 }
400
401 count_off = count;
402
403 while (cur_character != ']') {
404 tmpchoice[count - count_off] = prompt[count];
405 count++;
406 cur_character = prompt[count];
407 }
408
409 tmpchoice[count - count_off] = '\0';
410 lcase(tmpchoice);
411
412 while (!isspace(prompt[count_off])) {
413 count_off--;
414 }
415
416 prompt[count_off] = '\0';
417 Snprintf(choice, sizeof(choice), "%s%c", tmpchoice, '\033');
418 if (strchr(tmpchoice, 't')) { /* Tutorial mode */
419 mvaddstr(0, 1, "New? Press t to enter a tutorial.");
420 }
421
422 /* Add capital letters as choices that aren't displayed */
423 for (count = 0; tmpchoice[count]; count++) {
424 tmpchoice[count] = toupper(tmpchoice[count]);
425 }
426
427 strcat(choice, tmpchoice);
428
429 /* prevent an unnecessary prompt */
430 rigid_role_checks();
431
432 if (!flags.randomall &&
433 (flags.initrole == ROLE_NONE || flags.initrace == ROLE_NONE ||

Callers 1

curses_player_selectionFunction · 0.85

Calls 15

build_plselection_promptFunction · 0.85
lcaseFunction · 0.85
isspaceFunction · 0.85
rigid_role_checksFunction · 0.85
clearlocksFunction · 0.85
curses_bailFunction · 0.85
refreshFunction · 0.85
ok_roleFunction · 0.85
curses_character_dialogFunction · 0.85
pick_roleFunction · 0.85
randroleFunction · 0.85

Tested by

no test coverage detected