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

Method qt_askname

win/Qt/qt_bind.cpp:244–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242}
243
244void NetHackQtBind::qt_askname()
245{
246 char default_plname[PL_NSIZ];
247 int ch = -1; // -1 => new game
248
249 have_asked = true;
250 str_copy(default_plname, svp.plname, PL_NSIZ);
251
252 // We do it all here (plus qt_plsel.cpp and qt_svsel.cpp),
253 // nothing in player_selection().
254
255#ifdef SELECTSAVED
256 char **saved = 0;
257 if (::iflags.wc2_selectsaved)
258 saved = get_saved_games();
259 if (saved && *saved) {
260 if (splash)
261 splash->hide();
262 NetHackQtSavedGameSelector sgsel((const char **) saved);
263 ch = sgsel.choose();
264 if (ch >= 0)
265 str_copy(svp.plname, saved[ch], SIZE(svp.plname));
266 // caller needs new lock name even if plname[] hasn't changed
267 // because successful get_saved_games() clobbers gs.SAVEF[]
268 ::iflags.renameinprogress = TRUE;
269 }
270 free_saved_games(saved);
271#endif
272
273 switch (ch) {
274 case -1:
275 // New Game
276 if (splash)
277 splash->hide();
278 if (NetHackQtPlayerSelector(keybuffer).Choose()) {
279 // success; handle plname[] verification below prior to returning
280 break;
281 }
282 FALLTHROUGH;
283 /*FALLTHRU*/
284 case -2:
285 // Quit
286 clearlocks();
287 qt_exit_nhwindows(0);
288 nh_terminate(0);
289 /*NOTREACHED*/
290 break;
291 default:
292 // picked a character from the saved games list
293 break;
294 }
295
296 if (!*svp.plname)
297 // in case Choose() returns with plname[] empty
298 Strcpy(svp.plname, default_plname);
299 else if (strcmp(svp.plname, default_plname) != 0)
300 // caller needs to set new lock file name
301 ::iflags.renameinprogress = TRUE;

Callers

nothing calls this directly

Calls 8

str_copyFunction · 0.85
get_saved_gamesFunction · 0.85
free_saved_gamesFunction · 0.85
clearlocksFunction · 0.85
nh_terminateFunction · 0.50
chooseMethod · 0.45
ChooseMethod · 0.45

Tested by

no test coverage detected