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

Function gnome_player_selection

outdated/win/gnome/gnbind.c:97–344  ·  view source on GitHub ↗

Do a window-port specific player type selection. If player_selection() offers a Quit option, it is its responsibility to clean up and terminate the process. You need to fill in pl_character[0]. */

Source from the content-addressed store, hash-verified

95 the process. You need to fill in pl_character[0].
96*/
97void
98gnome_player_selection()
99{
100 int n, i, sel;
101 const char **choices;
102 int *pickmap;
103
104 /* prevent an unnecessary prompt */
105 rigid_role_checks();
106
107 if (!flags.randomall && flags.initrole < 0) {
108 /* select a role */
109 for (n = 0; roles[n].name.m; n++)
110 continue;
111 choices = (const char **) alloc(sizeof(char *) * (n + 1));
112 pickmap = (int *) alloc(sizeof(int) * (n + 1));
113 for (;;) {
114 for (n = 0, i = 0; roles[i].name.m; i++) {
115 if (ok_role(i, flags.initrace, flags.initgend,
116 flags.initalign)) {
117 if (flags.initgend >= 0 && flags.female
118 && roles[i].name.f)
119 choices[n] = roles[i].name.f;
120 else
121 choices[n] = roles[i].name.m;
122 pickmap[n++] = i;
123 }
124 }
125 if (n > 0)
126 break;
127 else if (flags.initalign >= 0)
128 flags.initalign = -1; /* reset */
129 else if (flags.initgend >= 0)
130 flags.initgend = -1;
131 else if (flags.initrace >= 0)
132 flags.initrace = -1;
133 else
134 panic("no available ROLE+race+gender+alignment combinations");
135 }
136 choices[n] = (const char *) 0;
137 if (n > 1)
138 sel = ghack_player_sel_dialog(
139 choices, _("Player selection"),
140 _("Choose one of the following roles:"));
141 else
142 sel = 0;
143 if (sel >= 0)
144 sel = pickmap[sel];
145 else if (sel == ROLE_NONE) { /* Quit */
146 clearlocks();
147 gtk_exit(0);
148 }
149 free(choices);
150 free(pickmap);
151 } else if (flags.initrole < 0)
152 sel = ROLE_RANDOM;
153 else
154 sel = flags.initrole;

Callers

nothing calls this directly

Calls 15

rigid_role_checksFunction · 0.85
ok_roleFunction · 0.85
ghack_player_sel_dialogFunction · 0.85
clearlocksFunction · 0.85
pick_roleFunction · 0.85
randroleFunction · 0.85
validraceFunction · 0.85
pick_raceFunction · 0.85
randraceFunction · 0.85
ok_raceFunction · 0.85
validgendFunction · 0.85
pick_gendFunction · 0.85

Tested by

no test coverage detected