/* * Player race */ static bool get_player_race(void) { int i; birth_menu *races; int race; C_MAKE(races, z_info->p_max, birth_menu); /* Extra info */ //Term_putstr(QUESTION_COL, QUESTION_ROW, -1, TERM_YELLOW, // "Your race affects your ability scores and other factors."); /* Tabulate races */ for (i = 0; i < z_info->p_max; i++) { races[i].name = p_name + p_info[i].name; races[i].ghost = FALSE; races[i].text = p_text + p_info[i].text; } race = get_player_choice(races, z_info->p_max, p_ptr->prace, RACE_COL, 15, race_aux_hook); /* No selection? */ if (race == INVALID_CHOICE) { return (FALSE); } // if different race to last time, then wipe the history, age, height, weight if (race != p_ptr->prace) { p_ptr->psex = SEX_UNDEFINED; p_ptr->history[0] = '\0'; p_ptr->age = 0; p_ptr->ht = 0; p_ptr->wt = 0; for (i = 0; i < A_MAX; i++) { p_ptr->stat_base[i] = 0; } } p_ptr->prace = race; /* Save the race pointer */ rp_ptr = &p_info[p_ptr->prace]; FREE(races); /* Success */ return (TRUE); }
/* * Present a sorted list to the player, and get a selection */ int get_player_sort_choice(cptr *choices, int num, int col, int wid, cptr helpfile, void (*hook) (cptr)) { int i; int choice; cptr *strings; C_MAKE(strings, num, cptr); /* Initialise the sorted string array */ for (i = 0; i < num; i++) { strings[i] = choices[i]; } /* Sort the strings */ ang_sort_comp = ang_sort_comp_hook_string; ang_sort_swap = ang_sort_swap_hook_string; /* Sort the (unique) slopes */ ang_sort((void *)strings, NULL, num); /* Get the choice */ choice = get_player_choice(strings, num, col, wid, helpfile, hook); /* Invert the choice */ for (i = 0; i < num; i++) { /* Does the string match the one we selected? */ if (choices[i] == strings[choice]) { /* Save the choice + exit */ choice = i; break; } } /* Free the strings */ FREE((void *)strings); /* Return the value from the list */ return (choice); }
/* * Player house */ static bool get_player_house(void) { int i; int house = 0; int house_choice; int old_house_choice = 0; birth_menu *houses; // select 'houseless' automatically if there are no available houses if ((rp_ptr->choice & 1)) { p_ptr->phouse = 0; hp_ptr = &c_info[p_ptr->phouse]; return (TRUE); } C_MAKE(houses, z_info->c_max, birth_menu); /* Extra info */ //Term_putstr(QUESTION_COL, QUESTION_ROW, -1, TERM_YELLOW, // "Your house modifies your race bonuses."); /* Tabulate houses */ for (i = 0; i < z_info->c_max; i++) { /* Analyze */ if (rp_ptr->choice & (1L << i)) { houses[house].ghost = FALSE; houses[house].name = c_name + c_info[i].name; houses[house].text = c_text + c_info[i].text; if (p_ptr->phouse == i) old_house_choice = house; house++; } } house_choice = get_player_choice(houses, house, old_house_choice, CLASS_COL, 22, house_aux_hook); /* No selection? */ if (house_choice == INVALID_CHOICE) { return (FALSE); } /* Get house from choice number */ house = 0; for (i = 0; i < z_info->c_max; i++) { if (rp_ptr->choice & (1L << i)) { if (house_choice == house) { // if different house to last time, then wipe the history, age, height, weight if (i != p_ptr->phouse) { int j; p_ptr->psex = SEX_UNDEFINED; p_ptr->history[0] = '\0'; p_ptr->age = 0; p_ptr->ht = 0; p_ptr->wt = 0; for (j = 0; j < A_MAX; j++) { p_ptr->stat_base[j] = 0; } } p_ptr->phouse = i; } house++; } } /* Set house */ hp_ptr = &c_info[p_ptr->phouse]; FREE(houses); return (TRUE); }