void newgame() { fobj = invent = level.buriedobjlist = migrating_objs = (struct obj *)0; fmon = migrating_mons = (struct monst *)0; ftrap = 0; flags.ident = 1; if(wiz1_level.dlevel == 0) init_dungeons(); init_objects(); /* must be before u_init() */ u_init(); init_artifacts(); /* must be after u_init() */ #ifndef NO_SIGNAL (void) signal(SIGINT, (SIG_RET_TYPE) done1); #endif #ifdef NEWS if(flags.news) display_file(NEWS, FALSE); #endif #ifdef MULDGN load_qtlist(); /* load up the quest text info */ quest_init(); if(flags.legacy && moves == 1) com_pager(1); #endif mklev(); u_on_upstairs(); check_special_room(FALSE); vision_reset(); /* set up internals for level (after mklev) */ flags.botlx = 1; /* Move the monster from under you or else * makedog() will fail when it calls makemon(). * - ucsfcgl!kneller */ if(MON_AT(u.ux, u.uy)) mnexto(m_at(u.ux, u.uy)); #ifdef CLIPPING cliparound(u.ux, u.uy); #endif (void) makedog(); docrt(); #ifdef INSURANCE save_currentstate(); #endif return; }
void newgame() { int i; #ifdef MFLOPPY gameDiskPrompt(); #endif flags.ident = 1; for (i = 0; i < NUMMONS; i++) mvitals[i].mvflags = mons[i].geno & G_NOCORPSE; init_objects(); /* must be before u_init() */ flags.pantheon = -1; /* role_init() will reset this */ role_init(); /* must be before init_dungeons(), u_init(), * and init_artifacts() */ init_dungeons(); /* must be before u_init() to avoid rndmonst() * creating odd monsters for any tins and eggs * in hero's initial inventory */ init_artifacts(); /* before u_init() in case $WIZKIT specifies * any artifacts */ u_init(); #ifndef NO_SIGNAL (void) signal(SIGINT, (SIG_RET_TYPE) done1); #endif #ifdef NEWS if(iflags.news) display_file(NEWS, FALSE); #endif load_qtlist(); /* load up the quest text info */ /* quest_init();*/ /* Now part of role_init() */ mklev(); u_on_upstairs(); vision_reset(); /* set up internals for level (after mklev) */ check_special_room(FALSE); flags.botlx = 1; /* Move the monster from under you or else * makedog() will fail when it calls makemon(). * - ucsfcgl!kneller */ if(MON_AT(u.ux, u.uy)) mnexto(m_at(u.ux, u.uy)); (void) makedog(); docrt(); if (flags.legacy) { flush_screen(1); com_pager(1); } #ifdef INSURANCE save_currentstate(); #endif program_state.something_worth_saving++; /* useful data now exists */ #if defined(RECORD_REALTIME) || defined(REALTIME_ON_BOTL) /* Start the timer here */ realtime_data.realtime = (time_t)0L; #if defined(BSD) && !defined(POSIX_TYPES) (void) time((long *)&realtime_data.restoretime); #else (void) time(&realtime_data.restoretime); #endif #endif /* RECORD_REALTIME || REALTIME_ON_BOTL */ /* Success! */ welcome(TRUE); return; }
struct nh_topten_entry * nh_get_topten(int *out_len, char *statusbuf, const char * volatile player, int top, int around, boolean own) { struct toptenentry *ttlist, newtt; struct nh_topten_entry *score_list; boolean game_inited = (wiz1_level.dlevel != 0); boolean game_complete = game_inited && moves && program_state.gameover; int rank = -1; /* index of the completed game in the topten list */ int fd, i, j, sel_count; boolean *selected, off_list = FALSE; statusbuf[0] = '\0'; *out_len = 0; if (!api_entry_checkpoint()) return NULL; if (!game_inited) { /* If nh_get_topten() isn't called after a game, we never went through initialization. */ dlb_init(); init_dungeons(); } if (!player) { if (game_complete) player = plname; else player = ""; } fd = open_datafile(RECORD, O_RDONLY, SCOREPREFIX); ttlist = read_topten(fd, TTLISTLEN); close(fd); if (!ttlist) { strcpy(statusbuf, "Cannot open record file!"); api_exit(); return NULL; } /* find the rank of a completed game in the score list */ if (game_complete && !strcmp(player, plname)) { fill_topten_entry(&newtt, end_how); /* find this entry in the list */ for (i = 0; i < TTLISTLEN && validentry(ttlist[i]); i++) if (!memcmp(&ttlist[i], &newtt, sizeof (struct toptenentry))) rank = i; if (wizard || discover) sprintf(statusbuf, "Since you were in %s mode, your game was not " "added to the score list.", wizard ? "wizard" : "discover"); else if (rank >= 0 && rank < 10) sprintf(statusbuf, "You made the top ten list!"); else if (rank) sprintf(statusbuf, "You reached the %d%s place on the score list.", rank + 1, ordin(rank + 1)); } /* select scores for display */ sel_count = 0; selected = calloc(TTLISTLEN, sizeof (boolean)); for (i = 0; i < TTLISTLEN && validentry(ttlist[i]); i++) { if (top == -1 || i < top) selected[i] = TRUE; if (own && !strcmp(player, ttlist[i].name)) selected[i] = TRUE; if (rank != -1 && rank - around <= i && i <= rank + around) selected[i] = TRUE; if (selected[i]) sel_count++; } if (game_complete && sel_count == 0) { /* didn't make it onto the list and nothing else is selected */ ttlist[0] = newtt; selected[0] = TRUE; sel_count++; off_list = TRUE; } score_list = xmalloc(sel_count * sizeof (struct nh_topten_entry)); memset(score_list, 0, sel_count * sizeof (struct nh_topten_entry)); *out_len = sel_count; j = 0; for (i = 0; i < TTLISTLEN && validentry(ttlist[i]); i++) { if (selected[i]) fill_nh_score_entry(&ttlist[i], &score_list[j++], i + 1, i == rank); } if (off_list) { score_list[0].rank = -1; score_list[0].highlight = TRUE; } if (!game_inited) { free_dungeon(); dlb_cleanup(); } free(selected); free(ttlist); api_exit(); return score_list; }
static void newgame(void) { int i; flags.ident = 1; for (i = 0; i < NUMMONS; i++) mvitals[i].mvflags = mons[i].geno & G_NOCORPSE; init_objects(); /* must be before u_init() */ flags.pantheon = -1;/* role_init() will reset this */ role_init(); /* must be before init_dungeons(), u_init(), * and init_artifacts() */ init_dungeons(); /* must be before u_init() to avoid rndmonst() * creating odd monsters for any tins and eggs * in hero's initial inventory */ init_artifacts(); u_init(); /* struct you must have some basic data for mklev to work right */ load_qtlist(); /* load up the quest text info */ level = mklev(&u.uz); u_init_inv_skills();/* level must be valid to create items */ u_on_upstairs(); vision_reset(); /* set up internals for level (after mklev) */ check_special_room(FALSE); iflags.botl = 1; /* Move the monster from under you or else * makedog() will fail when it calls makemon(). * - ucsfcgl!kneller */ if (MON_AT(level, u.ux, u.uy)) mnexto(m_at(level, u.ux, u.uy)); makedog(); doredraw(); if (Role_if(PM_CONVICT)) { setworn(mkobj(level, CHAIN_CLASS, TRUE), W_CHAIN); setworn(mkobj(level, BALL_CLASS, TRUE), W_BALL); uball->spe = 1; /* attach the ball to the hero */ placebc(); } /* help the window port get it's display charset/tiles sorted out */ notify_levelchange(NULL); if (flags.legacy) { flush_screen(); com_pager(Role_if(PM_CONVICT) ? 199 : 1); } /* Stop autoexplore revisiting the entrance stairs (or position). */ level->locations[u.ux][u.uy].mem_stepped = 1; program_state.something_worth_saving++; /* useful data now exists */ historic_event(FALSE, "entered the Dungeons of Doom to retrieve the Amulet of Yendor!"); /* Success! */ welcome(TRUE); maybe_tutorial(); /* Prepare for the first move. */ flags.move = 0; set_wear(); pickup(1); log_command_result(); program_state.game_running = TRUE; youmonst.movement = NORMAL_SPEED; /* give the hero some movement points */ realtime_tasks(); post_init_tasks(); return; }