Beispiel #1
0
void
account_exhume_char(struct account *account, struct creature *exhumer, long id)
{
    if (player_idnum_exists(id)) {
        send_to_char(exhumer, "That character has already been exhumed.\r\n");
        return;
    }
    // load char from file
    struct creature *victim;
    
    victim = load_player_from_xml(id);
    if (victim) {
        sql_exec
            ("insert into players (idnum, account, name) values (%ld, %d, '%s')",
            GET_IDNUM(victim), account->id, tmp_sqlescape(GET_NAME(victim)));
        load_players(account);
        send_to_char(exhumer, "%s exhumed.\r\n",
            tmp_capitalize(GET_NAME(victim)));
        slog("%s[%ld] exhumed into account %s[%d]", GET_NAME(victim),
            GET_IDNUM(victim), account->name, account->id);
        free_creature(victim);
    } else {
        send_to_char(exhumer, "Unable to load character %ld.\r\n", id);
    }
}
Beispiel #2
0
int main(int argc, char *argv[])
{
  if(argc < 2 || argc > 4)
  {
    printf("\n Usage: %s port [a|b] [name] \n",argv[0]);
    return 1;
  } 
  sockfd = server_connect(argv[1]);
  if (sockfd < 0) {
    // something happened while trying to connect-- abort mission
    return -1;
  }
  
  parse_settings(argv[2], argv[3]);


  printf("Request name %s and team %d\n", name, team);

  //construct proper sendBuff
  //(name, team)
  snprintf(sendBuff, sizeof sendBuff, "%s %d", name, team);

  // send it
  send_to_server();
  // read reply
  read_from_server();

  //printf("Bytes written: %d. Bytes read: %d.\n%s\n", writtenbytes, readbytes, recvBuff);
  sscanf(recvBuff, "%s", recvName);
  printf("%s\n", recvBuff);
  char *ghs = "Game has already started";
  if(strcmp(ghs, recvBuff) == 0){
    close(sockfd);
    return 0;
  }

  initscr();
  loading_screen();
  display_teams();
  start_color();
  initscr();
  loadMap(mapNameFromServer);
  teamInfoMap();
  initBoard();/* creates play board */
  refresh();/* Print it on to the real screen */
  load_players();
  //place_players();
  control_test();
  final_standings();
  getch();
  endwin();

  close(sockfd);
  return 0;
}
Beispiel #3
0
void		manage_display(t_client *cl, int what)
{
    manage_event(cl);
    if (cl->status == CL_LOAD && what == 0)
    {
        load_background(cl->fx);
        load_map(cl);
        load_ressource(cl);
        load_players(cl);
        /*load_box_info(cl);*/
        SDL_Flip(cl->fx->gui->window);
    }
}
Beispiel #4
0
void
preload_accounts(const char *conditions)
{
    long acct_count, field_count, field_idx;
    const char **fields;
    PGresult *res;

    res =
        sql_query
        ("select idnum, name, password, email, date_part('epoch', creation_time) as creation_time, creation_addr, date_part('epoch', login_time) as login_time, login_addr, date_part('epoch', entry_time) as entry_time, ansi_level, compact_level, term_height, term_width, banned, reputation, quest_points, quest_banned, bank_past, bank_future, metric_units, trust from accounts where %s",
        conditions);
    acct_count = PQntuples(res);

    if (acct_count < 1)
        return;

    // Get field names and put them in an array
    field_count = PQnfields(res);
    fields = (const char **)malloc(sizeof(const char *) * field_count);
    for (field_idx = 0; field_idx < field_count; field_idx++)
        fields[field_idx] = PQfname(res, field_idx);

    int acct_idx;
    for (acct_idx = 0; acct_idx < acct_count; acct_idx++) {
        // Make sure we don't reload one that's already in the cache
        long idnum = atol(PQgetvalue(res, acct_idx, 0));

        if (g_hash_table_lookup(account_cache, GINT_TO_POINTER(idnum)))
            continue;

        // Create a new account and load it up
        struct account *new_acct;
        CREATE(new_acct, struct account, 1);
        for (field_idx = 0; field_idx < field_count; field_idx++)
            account_set(new_acct,
                fields[field_idx], PQgetvalue(res, acct_idx, field_idx));

        load_players(new_acct);
        load_trusted(new_acct);

        g_hash_table_insert(account_cache, GINT_TO_POINTER(idnum), new_acct);
        slog("Account %ld preloaded from database", idnum);
    }
    free(fields);
}
Beispiel #5
0
bool
load_account(struct account *account, long idnum)
{
    long acct_count, field_count, field_idx;
    const char **fields;
    PGresult *res;

    res = sql_query("select idnum, name, password, email, "
                    "date_part('epoch', creation_time) as creation_time, "
                    "date_part('epoch', login_time) as login_time, "
                    "date_part('epoch', entry_time) as entry_time, "
                    "creation_addr, login_addr, "
                    "ansi_level, compact_level, term_height, term_width, "
                    "banned, reputation, quest_points, quest_banned, "
                    "bank_past, bank_future, metric_units, trust "
                    "from accounts where idnum=%ld",
                    idnum);
    acct_count = PQntuples(res);

    if (acct_count > 1) {
        errlog("search for account %ld returned more than one match", idnum);
        return false;
    }

    if (acct_count < 1)
        return false;

    // Get field names and put them in an array
    field_count = PQnfields(res);
    fields = (const char **)malloc(sizeof(const char *) * field_count);
    for (field_idx = 0; field_idx < field_count; field_idx++)
        fields[field_idx] = PQfname(res, field_idx);

    for (field_idx = 0; field_idx < field_count; field_idx++)
        account_set(account, fields[field_idx], PQgetvalue(res, 0, field_idx));
    free(fields);

    load_players(account);
    load_trusted(account);

    slog("Account %d loaded from database", account->id);
    g_hash_table_insert(account_cache, GINT_TO_POINTER(idnum), account);
    return true;
}
Beispiel #6
0
void Graphics::load_all() {
	weapons = load_bmp("gfx/weapons.bmp");
	bombs = load_bmp("gfx/bomb.bmp");
	powerups = load_bmp("gfx/powerups.bmp");

	shield = load_bmp("gfx/shield.bmp");

	player1hp = load_bmp("gfx/player1hp.bmp");
	player2hp = load_bmp("gfx/player2hp.bmp");

	common = load_bmp("gfx/common.bmp");
	pmarker = load_bmp("gfx/pmarkers.bmp");
	
	bg_grey = load_bmp("gfx/bg_grey.bmp");

	bg_menu = Level::get_preview("stage/titlescreen.lvl");

	cups = load_bmp("gfx/cups.bmp");

	tiles = load_bmp("gfx/tiles.bmp");
	
	npc_chick = load_bmp("gfx/chick.bmp");
	npc_cannon = load_bmp("gfx/cannon.bmp");
	npc_gatling = load_bmp("gfx/gatling.bmp");

	statsblock[0] = SDL_CreateRGBSurface(NULL, 16, 18, 32, 0, 0, 0, 0);
	SDL_FillRect(statsblock[0], NULL, 0x880000);

	statsblock[1] = SDL_CreateRGBSurface(NULL, 16, 18, 32, 0, 0, 0, 0);
	SDL_FillRect(statsblock[1], NULL, 0x888800);

	statsblock[2] = SDL_CreateRGBSurface(NULL, 16, 18, 32, 0, 0, 0, 0);
	SDL_FillRect(statsblock[2], NULL, 0x008800);

	text_ready = Main::text->render_text_medium("READY");
	text_random = Main::text->render_text_medium("RANDOM");
	
	text_pressstart = Main::text->render_text_medium("PRESS START");

	load_players();
	set_player_clips();
}
Beispiel #7
0
int				main(int argc, char **argv)
{
	t_arena	*arena;

	arena = create_arena();
	check_param(&argc, &argv, arena);
	save_players(argc, argv, arena);
	load_players(arena);
	if (arena->display != NULL)
		init_display(arena);
	else
		display_champions(arena);
	start_fight(arena);
	if (arena->cycle != arena->dump_cycle)
	{
		if (arena->display != NULL && !arena->display->quitting)
			print_winner_display(arena);
		else
			print_winner(arena);
	}
	destroy_arena(arena);
	return (0);
}
Beispiel #8
0
// The good old main()
int main(int argc, char *argv[]) {
	// Initialize SDL and OpenGL
	init_sdl_and_gl();

	// Initialize FMOD
	init_mixer();

	// Load fonts
	build_font_list();
	font1 = load_png("fonts.png", true, false, true);

	// Show the loading screen
	loading_screen();

	// Find the level files
	find_levels();

	// Load textures
	font_num = load_png("fonts_num.png", true, false, true);
	load_bgrounds();
	load_players();
	load_enemies();
	load_bonus();
	load_maptex();
	load_bombs();
	load_particles();
	load_teleports();
	load_traps();
	load_wisps();
	load_potatoman();
	load_icons();
	load_menus();


	// Add timer to run 60 fps
	start_timer(60);

	// Menu logic
	int ans = show_menu(MENU_ID_MAIN);
	while(ans != MENU_EXIT) {
		// Start the game?
		if(ans == MENU_SINGLEPLAY)			// Single player
			start_game();
		else if(ans == MENU_MULTIPLAY)		// Two players
			start_game(true);

		// Show the menu again
		ans = show_menu(MENU_ID_MAIN);
	}


	// Destroy timer
	kill_timer();

	// Free stuff
	delete_font_list();
	kill_particles();


	// Kill SDL
	SDL_Quit();

	// Close the pakfile
	pakfile.close_mpk();

	// Close the FMOD
	if(music_mod){
		Mix_HaltMusic();
		Mix_FreeMusic(music_mod);
	}
	Mix_CloseAudio();

	// Save the config
	save_config(get_config_location(true), &config);
	return 0;
}