int main(void) { const int max = 3; fori(max) { forj(max) { printf("(%d, %d) ", i, j); } printf("\n"); } printf("\n"); some_func(max); printf("\n"); const int i = 10; const float f = 1.0f; putl(i); putd(f); putl(10); // still works, sort of... putx(i); putx(f); print_vec2(vec(1.0, 2.0)); print_vec3(vec(1.0, 2.0, 3.0)); struct player p1 = player("Mario"); struct player p2 = player("Luigi", .lives = 2); // -Winitializer-overrides warning print_player(p1); print_player(p2); }
//function to print the board void print_board(board_t *board, player_t *player, int player_id, int turn) { //print this if player1 if (player_id == 1) { print_player(player, turn); print_hand(&player->player_hand, &player->player_deck); printf("\n"); } //print the middle of the board printf("# "); if (board->lane1 == 0) { printf(" "); } else{ play_card(&board->lane1_card); } printf(" # "); if (board->lane2 == 0) { printf(" "); } else { play_card(&board->lane2_card); } printf(" # "); if (board->lane3 == 0) { printf(" "); } else { play_card(&board->lane3_card); } printf(" # "); if (board->lane4 == 0) { printf(" "); } else { play_card(&board->lane4_card); } printf(" # "); if (board->lane5 == 0) { printf(" "); } else { play_card(&board->lane5_card); } printf(" #\n\n"); //print this if player2 if (player_id == 2) { print_hand(&player->player_hand, &player->player_deck); print_player(player, turn); } if(board->lane1_card.special_index != 0){board->lane1=0;} if(board->lane2_card.special_index != 0){board->lane2=0;} if(board->lane3_card.special_index != 0){board->lane3=0;} if(board->lane4_card.special_index != 0){board->lane4=0;} if(board->lane5_card.special_index != 0){board->lane5=0;} }
void config_save( ) { FILE *file = 0; char file_name[512]; sprintf( file_name, "%s/%s", config.dir_name, CONFIG_FILE_NAME ); if ( ( file = fopen( file_name, "w" ) ) == 0 ) fprintf( stderr, "Cannot access config file '%s' to save settings\n", file_name ); else { fprintf( file, "@\n" ); fprintf( file, "gametype»%i\n", config.gametype ); fprintf( file, "starting_level»%i\n", config.starting_level ); fprintf( file, "preview»%i\n", config.preview ); fprintf( file, "help»%i\n", config.help ); fprintf( file, "expert»%i\n", config.expert ); fprintf( file, "center_preview»%i\n", config.center_preview ); fprintf( file, "holes»%i\n", config.holes ); fprintf( file, "rand_holes»%i\n", config.rand_holes ); fprintf( file, "send_all»%i\n", config.send_all ); fprintf( file, "send_tetris»%i\n", config.send_tetris ); print_player( file, 1, &config.player1 ); print_player( file, 2, &config.player2 ); print_player( file, 3, &config.player3 ); fprintf( file, "clear_keystate»%i\n", config.clear_keystate ); fprintf( file, "cpu_aggr»%i\n", config.cpu_aggr ); fprintf( file, "cpu_delay»%i\n", config.cpu_delay ); fprintf( file, "cpu_rot_delay»%i\n", config.cpu_rot_delay ); fprintf( file, "sound»%i\n", config.sound ); fprintf( file, "volume»%i\n", config.volume ); fprintf( file, "transparency»%i\n", config.trp ); fprintf( file, "animations»%i\n", config.anim ); fprintf( file, "fullscreen»%i\n", config.fullscreen ); fprintf( file, "fading»%i\n", config.fade ); fprintf( file, "fps»%i\n", config.fps ); fprintf( file, "background»%i\n", config.bkgnd ); fprintf( file, "static_background»%i\n", config.keep_bkgnd ); fprintf( file, "smooth_hori»%i\n", config.smooth_hori ); fprintf( file, "hori_delay»%i\n", config.hori_delay ); fprintf( file, "vert_delay»%i\n", config.vert_delay ); fprintf( file, "pause_key»%i\n", config.pause_key ); fprintf( file, "block_by_block»%i\n", config.block_by_block ); fprintf( file, "motion_mod»%i\n", config.motion_mod ); fprintf( file, "relative_motion»%i\n", config.rel_motion ); fprintf( file, "grab_input»%i\n", config.grab ); fprintf( file, "invert_mouse»%i\n", config.invert ); fprintf( file, "quick_help»%i\n", config.quick_help ); fprintf( file, "async_collision_check»%i\n", config.async_col_check ); } }
void readcb(struct bufferevent* conn, void* arg) { char buffer[BUFSIZ]; bzero(buffer, sizeof(buffer)); size_t len = bufferevent_read(conn, buffer, sizeof(buffer)); char* start_json = NULL; size_t i; for (i = 0; i < len; i++) { if (buffer[i] == '{') { start_json = &buffer[i]; break; } } if (start_json != NULL) { char buf[BUFSIZ]; size_t j; struct server* server = arg; struct server_status status; DEBUG(255, "raw json: %s", start_json); json_t* json = json_loads(start_json, 0, NULL); status.server = server; json_t* json_description = json_object_get(json, "description"); if (json_description) status.motd = (char*) json_string_value(json_description); json_t* json_version = json_object_get(json, "version"); if (json_version) { json_t* version_name = json_object_get(json_version, "name"); if (version_name) status.version = (char*) json_string_value(version_name); } json_t* json_players = json_object_get(json, "players"); if (json_players) { json_t* max = json_object_get(json_players, "max"); if (max) status.maxplayers = json_integer_value(max); json_t* online = json_object_get(json_players, "online"); if (online) status.numplayers = json_integer_value(online); if (server->players) { json_t* json_sample = json_object_get(json_players, "sample"); if (json_sample) { for (i = 0; i < json_array_size(json_sample); i++) { json_t* player = json_array_get(json_sample, i); if (player) { for (j = 0; server->players[j]; j++) { if (print_player(&status, player, server->players[j], buf, sizeof(buf))) printf("%s\n", buf); } } } } } } for (j = 0; server->format[j]; j++) { if (print_status(&status, server->format[j], buf, sizeof(buf))) printf("%s\n", buf); } json_decref(json); } eventcb(conn, BEV_FINISHED, arg); };
void print_board(struct board_t board) { print_player(board.pl[0]); print_border('_'); printf("\n"); print_hand(board.pl[0]); print_border('#'); printf("\n"); print_field(board, 0); printf("\n"); print_field(board, 1); printf("\n"); print_border('#'); print_hand(board.pl[1]); print_border('_'); printf("\n"); print_player(board.pl[1]); }
static void player_added(GDBusProxy *proxy) { players = g_list_append(players, proxy); if (default_player == NULL) default_player = proxy; print_player(proxy, COLORED_NEW); }
static void player_removed(GDBusProxy *proxy) { print_player(proxy, COLORED_DEL); if (default_player == proxy) default_player = NULL; players = g_list_remove(players, proxy); }
static void cmd_list(int argc, char *arg[]) { GList *l; for (l = players; l; l = g_list_next(l)) { GDBusProxy *proxy = l->data; print_player(proxy, NULL); } return bt_shell_noninteractive_quit(EXIT_SUCCESS); }
void parse(){ ESTADO e; char *args=getenv("QUERY_STRING"); if(strlen(args) == 0) e = inicializar(0); else e = str2estado(args); if(e.acao==1){ e = inicializar(++e.nivel); } print_board(); print_enemies(e); print_walls(e); print_goal(e); print_player(e); }
static void cmd_select(int argc, char *argv[]) { GDBusProxy *proxy; proxy = g_dbus_proxy_lookup(players, NULL, argv[1], BLUEZ_MEDIA_PLAYER_INTERFACE); if (proxy == NULL) { bt_shell_printf("Player %s not available\n", argv[1]); return bt_shell_noninteractive_quit(EXIT_FAILURE); } if (default_player == proxy) return bt_shell_noninteractive_quit(EXIT_SUCCESS); default_player = proxy, print_player(proxy, NULL); return bt_shell_noninteractive_quit(EXIT_SUCCESS); }
void print_board(t_game *game, char clean) { int i; int j; if (clean) clear_map(game); i = -1; while (++i < game->height) { j = -1; while (++j < game->width) { if (game->map[i][j] > -1) print_player(game->map[i][j]); else ft_putstr("o "); } ft_putstr("\b\n"); } ft_putstr("\n"); }
int main() { pcd pointer, *dp, fanswm; pcd dipai[3]; pointer = card; dp = dipai; set_card(pointer, 14, 4); set_card_ddz_ji(pointer, 14, 4); print_card(pointer, 14, 4); print_card2(pointer, 14, 4); print_card_ji(pointer); fapai(player, 3, 17, pointer, dp); print_player(player,3,17); print_dipai(dp); all_player_sort(player, 3, 17); print_player_no_hua(player,3,17); }
int main (int argc, char *argv[]) /* plist command provides a quick way to check a given players * * level, class, password and inventory without having to log * * the player in or use the editor */ { int i, adj; char filename[256]; char flags = 0; HFINDFILE hff; lvl=0; adj = 1; if (argc < 1) { usage(); return(1); } for (i=1;i<argc;i++){ if (argv[i][0] == '-'){ switch(argv[i][1]){ case 'i': set_flag(flags,0); continue; break; case 'n': set_flag(flags,1); continue; case 'p': set_flag(flags,2); continue; break; } if(i+1 < argc && isdigit(argv[i+1][0])){ switch(argv[i][1]){ case 'l': lvl = atoi(argv[i+1]); break; case 's': Spellnum = atoi(argv[i+1]); spl=1; break; default: set_flag(flags,3); break; } i++; } else set_flag(flags,3); } else break; if (is_fset(flags,3)){ usage(); return(1); } } adj = i; if (adj > argc) { usage(); return(1); } else if ( adj == argc ) { /* wants all players */ hff = find_first_file(get_player_path(), filename, 256); if ( hff ) { do { if ( filename[0] != '.') { print_player( filename, flags ); } } while( find_next_file( hff, filename, 256 )); close_find_file(hff); } } else { for(i= adj;i < argc; i++) { print_player( argv[i], flags ); } } return(0); }
void update_players() { register struct player *j, *closest = NULL; register Player *p, *ce = NULL, *cf = NULL, *ct = NULL; register int i; int mce = INT_MAX, mcf = INT_MAX, mct = INT_MAX, d; int pldist; int predictx, predicty, rx,ry; Player *nt; if(_state.closest_e && _state.closest_e->p && _state.closest_e->p->p_status == PEXPLODE){ explode_danger = 5/(int)updates + 1; } if(explode_danger) explode_danger --; _state.total_enemies = 0; _state.total_wenemies = 0; _state.closest_e = NULL; _state.total_friends = 0; _state.closest_f = NULL; _state.num_tbombers = 0; _state.num_ttakers = 0; shmem_updmyloc(me->p_x, me->p_y); for(i=0, j= &players[i]; i< MAXPLAYER; i++,j++){ p = &_state.players[j->p_no]; switch(j->p_status){ case PFREE: if(p->last_init){ /* any field not nulled below */ if(j->p_no == _state.controller-1){ _state.controller = 0; locked = 0; } if(_state.last_defend && _state.last_defend->p && _state.last_defend->p->p_no == j->p_no) _state.last_defend = NULL; bzero(p, sizeof(Player)); } continue; case POUTFIT: p->p = NULL; p->dist = GWIDTH; p->p_x = -GWIDTH; p->p_y = -GWIDTH; case PDEAD: case PEXPLODE: if(WAR(j)){ _state.total_enemies ++; } p->alive = 0; p->plcarry = 0.0; if(j->p_team == _state.warteam) _state.total_wenemies ++; continue; } if(j->p_team == _state.warteam) _state.total_wenemies ++; if(j->p_status == PEXPLODE && j->p_explode == 0){ do_expdamage(j); j->p_explode ++; } /* if(j == me) continue; */ if((j!= me) && WAR(j)){ _state.total_enemies ++; p->enemy = 1; } else { _state.total_friends ++; p->enemy = 0; shmem_rloc(j->p_no, &j->p_x, &j->p_y); } if(!p->alive){ /* reset all attributes */ p->p = j; init_sstats(p); } p->alive ++; p->p = j; if(j->p_x < 0 || j->p_y < 0){ /* very little information available */ if ( ! p->invisible ) { p->invisible = 1; /* p->last_init = _udcounter - 1; p->dist = GWIDTH; continue; */ } } else p->invisible = 0; #ifdef NO_PFTRACT /* if server doesn't give tractor info */ /* tractor_check resets or sets this flag */ if(p->pp_flags & PFTRACT){ p->pp_flags = j->p_flags; p->pp_flags |= PFTRACT; } #endif /* NO_PFTRACT */ p->robot = j->p_flags & PFROBOT; if(p->robot) p->fuel = j->p_ship.s_maxfuel; if(j != me){ orbit_check(p, j); army_check1(p, j); army_check2(p, j); if (hm_cr) army_check3(p, j); } if(p->invisible) { p->closest_pl = p->closest_pl; /* keep stale info JKH */ } else { p->closest_pl = closest_planet(j, &pldist, p->closest_pl); p->closest_pl_dist = pldist; } if(j->p_flags & PFBOMB) p->bombing = _udcounter; /* the old information is in p not j */ if(p->invisible) d = GWIDTH; else d = edist_to_me(j); p->lastdist = p->dist; p->dist = d; p->hispr = PHRANGE(p); if(p->invisible){ p->crs = get_wrapcourse(p->p_x, p->p_y); p->icrs = p->crs; /* xxx */ } else{ p->crs = get_wrapcourse(j->p_x, j->p_y); get_intercept_course(p, j, p->dist, &p->icrs); } if(p->enemy && d < mce){ ce = p; mce = d; if(!ignoring_e(p)){ ct = p; mct = d; } } if(p->enemy && d < mct && !ignoring_e(p)){ ct = p; mct = d; } if(!p->enemy && p->p != me && d < mcf){ cf = p; mcf = d; } if(j != me) cloak_check(p, j); if(_udcounter - p->last_init > 450){ /* roughly 45 seconds */ init_sstats(p); } else if(_udcounter - p->last_init == 1){ /* common case for close enemies */ update_sstats(p, 100); } else /* should be actual time in ms, I think */ update_sstats(p, 100 * (_udcounter - p->last_init)); if(p->enemy && !(j->p_flags & PFCLOAK)){ p->thittime = 0; p->phittime = 0; p->thit = p->phit = 0; } if(!p->enemy){ /* what's he doing */ if(_udcounter - p->bombing < 3*60*10) _state.num_tbombers++; } p->last_init = _udcounter; #ifdef nodef if(DEBUG & DEBUG_ENEMY) print_player(p); #endif /* don't update unless it's a value number */ if ( ! p->invisible ) { p->p_x = j->p_x; /* last x */ p->p_y = j->p_y; /* last y */ } } _state.closest_e = ce; _state.closest_f = cf; if(ce) tractor_check(ce, ce->p); nt = get_target(ct); if(nt != _state.current_target){ if(sync_check(&nt)){ _state.current_target = nt; shmem_updmytarg(nt->p->p_no); sendOggVPacket(); } } #ifdef nodef check_server_response(&predictx, &predicty, nint(_serverdelay), NULL, NULL); rx = ABS(me->p_x - predictx); ry = ABS(me->p_y - predicty); /* printf("(sd: %lg) diff: (%d,%d)\n", _serverdelay, rx,ry); */ printf("server (s %d, d %d), local (s %d, d %d), diff (s %d, d %d)\n", _state.sp_subspeed, _state.sp_subdir, _state.p_subspeed, _state.p_subdir, _state.sp_subspeed - _state.p_subspeed, _state.sp_subdir - _state.p_subspeed); #endif /* update my information */ _state.last_x = me->p_x; _state.last_y = me->p_y; _state.last_speed = me->p_speed; _state.last_desspeed = _state.p_desspeed; _state.last_dir = me->p_dir; _state.last_desdir = _state.p_desdir; _state.last_subspeed = _state.p_subspeed; _state.last_subdir = _state.p_subdir; last_udcounter = _udcounter; update_player_density(); check_active_enemies(); }