Esempio n. 1
0
void startup_common(const char *name, int playmode)
{
    /* (re)init all global data */
    init_data();
    init_tutorial();
    init_timeout();
    init_shop_selection();
    reset_food(); /* zero out victual and tin */
    reset_steal();
    reset_dig_status();
    reset_encumber_msg();
    reset_occupations();

    /* create mutable copies of object and artifact liss */
    init_objlist();
    init_artilist();
    reset_rndmonst(NON_PM);
    free_dungeon(); /* clean up stray dungeon data */

    program_state.game_running = 0;
    initoptions();

    dlb_init();	/* must be before newgame() */

    /*
     * Initialization of the boundaries of the mazes
     * Both boundaries have to be even.
     */
    x_maze_max = COLNO-1;
    if (x_maze_max % 2)
	x_maze_max--;
    y_maze_max = ROWNO-1;
    if (y_maze_max % 2)
	y_maze_max--;

    /*
	*  Initialize the vision system.  This must be before mklev() on a
	*  new game or before a level restore on a saved game.
	*/
    vision_init();
    
    if (playmode == MODE_TUTORIAL)
	flags.tutorial = TRUE;
    if (playmode == MODE_EXPLORE)
	discover = TRUE;
    else if (playmode == MODE_WIZARD)
	wizard = TRUE;
    
    if (name && name[0]) {
	strncpy(plname, name, PL_NSIZ);
	plname[PL_NSIZ-1] = '\0';
    }

    if (wizard)
	strcpy(plname, "巫师");

    cls();

    initrack();
}
Esempio n. 2
0
jboolean nhjni_run() {
  windowprocs = _nhjni_proxy_procs;
  _nhjni_proxy_init();
  int fd = create_levelfile(0, (char *)0);
  if (fd < 0) {
    raw_print("Cannot create lock file");
  } else {
    hackpid = 1;
    write(fd, (genericptr_t) &hackpid, sizeof(hackpid));
    close(fd);
  }
  
  iflags.news = TRUE;
  int argc=1;
  char *argv[]={"nethack",NULL};
  
  initoptions();
  init_nhwindows(&argc,argv);
  dlb_init();
  vision_init();
  display_gamewindows();
  
  if ((fd = restore_saved_game()) >= 0) {
    const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1);

    pline("Restoring save file...");
    mark_synch();	/* flush output */
    if(!dorecover(fd))
      goto not_recovered;

    check_special_room(FALSE);
    //wd_message();

    if (discover || wizard) {
      if(yn("Do you want to keep the save file?") == 'n')
          (void) delete_savefile();
      else {
          (void) chmod(fq_save,FCMASK); /* back to readable */
          compress(fq_save);
      }
    }
    flags.move = 0;
  } else {
not_recovered:
    player_selection();
    newgame();
    flags.move = 0;
    set_wear();
    (void) pickup(1);
  }

  moveloop();
  
  return JNI_TRUE;
}