Ejemplo n.º 1
0
/*
 * This is the start of the client handling code.
 * The server process has accepted a connection and authenticated it. Data from
 * the client will arrive here via infd and data that should be sent back goes
 * through outfd.
 * An instance of NitroHack will run in this process under the control of the
 * remote player. 
 */
void client_main(int userid, int _infd, int _outfd)
{
    char **gamepaths;
    int i;
    
    infd = _infd;
    outfd = _outfd;
    gamefd = -1;
    
    init_database();
    if (!db_get_user_info(userid, &user_info)) {
	log_msg("get_user_info error for uid %d!", userid);
	exit_client("database error");
    }
    
    gamepaths = init_game_paths();
    nh_lib_init(&server_windowprocs, gamepaths);
    for (i = 0; i < PREFIX_COUNT; i++)
	free(gamepaths[i]);
    free(gamepaths);

    db_restore_options(userid);
    
    client_main_loop();
    
    exit_client(NULL);
    /*NOTREACHED*/
    
    return;
}
Ejemplo n.º 2
0
int
main(int argc, char *argv[])
{
    srand(time(NULL));

    char **gamepaths;
    int i;
    nh_bool init_ok;

    umask(0777 & ~FCMASK);

    /* this can change argc and *argv, so must come first */
    initialize_uncursed(&argc, argv);

    process_args(argc, argv);   /* grab -U, -H, -k, --help early */
    init_options();
    gamepaths = init_game_paths(argv[0]);

    nh_lib_init(&curses_windowprocs, (const char * const*)gamepaths);
    init_curses_ui(gamepaths[DATAPREFIX]);
    init_ok = read_nh_config();
    for (i = 0; i < PREFIX_COUNT; i++)
        free(gamepaths[i]);
    free(gamepaths);


    process_args(argc, argv);   /* other command line options */
    init_displaychars();

    if (init_ok)
        mainmenu();
    else
        curses_msgwin("Could not initialize game options!", krc_notification);

    exit_curses_ui();
    nh_lib_exit();
    free_displaychars();

    exit(EXIT_SUCCESS);
     /*NOTREACHED*/ return 0;
}