/************************************************************************** Send details of src's spaceship (or spaceships of all players if src is NULL) to specified destinations. If dest is NULL then game.est_connections is used. **************************************************************************/ void send_spaceship_info(struct player *src, struct conn_list *dest) { if (!dest) { dest = game.est_connections; } players_iterate(pplayer) { if (!src || pplayer == src) { struct packet_spaceship_info info; struct player_spaceship *ship = &pplayer->spaceship; info.player_num = player_number(pplayer); info.sship_state = ship->state; info.structurals = ship->structurals; info.components = ship->components; info.modules = ship->modules; info.fuel = ship->fuel; info.propulsion = ship->propulsion; info.habitation = ship->habitation; info.life_support = ship->life_support; info.solar_panels = ship->solar_panels; info.launch_year = ship->launch_year; info.population = ship->population; info.mass = ship->mass; info.support_rate = ship->support_rate; info.energy_rate = ship->energy_rate; info.success_rate = ship->success_rate; info.travel_time = ship->travel_time; info.structure = ship->structure; lsend_packet_spaceship_info(dest, &info); } } players_iterate_end; }
/**************************************************************************** Returns the research structure associated with the player. ****************************************************************************/ struct player_research *player_research_get(const struct player *pplayer) { fc_assert_ret_val(NULL != pplayer, NULL); if (game.info.team_pooled_research) { return &research_array[team_number(pplayer->team)]; } else { return &research_array[player_number(pplayer)]; } }
/****************************************************************** Compares ai's attitude toward the player ******************************************************************/ static int cmp_love(const struct player *player1, const struct player *player2) { int love1, love2; if (NULL == client.conn.playing) { return player_number(player1) - player_number(player2); } if (player1 == client.conn.playing || !player1->ai_controlled) { love1 = MAX_AI_LOVE + 999; } else { love1 = player1->ai_common.love[player_index(client.conn.playing)]; } if (player2 == client.conn.playing || !player2->ai_controlled) { love2 = MAX_AI_LOVE + 999; } else { love2 = player2->ai_common.love[player_index(client.conn.playing)]; } return love1 - love2; }
void set_nation_settings(int nation, char* leader_name, int sex, int city_style) { if(client.conn.playing == NULL) errlog("set_nation_settings: client.conn.playing == NULL\n"); dsend_packet_nation_select_req(&client.conn, player_number(client.conn.playing), nation, sex, leader_name, city_style); }
/************************************************************************** Updates the player list dialog. FIXME: use plrdlg_common.c **************************************************************************/ void real_players_dialog_update(void) { if (players_dialog_shell) { int j = 0; Dimension width; static char *namelist_ptrs[MAX_NUM_PLAYERS]; static char namelist_text[MAX_NUM_PLAYERS][256]; const struct player_diplstate *pds; players_iterate(pplayer) { char idlebuf[32], statebuf[32], namebuf[32], dsbuf[32]; /* skip barbarians */ if(is_barbarian(pplayer)) continue; /* text for state */ sz_strlcpy(statebuf, plrdlg_col_state(pplayer)); /* text for idleness */ if(pplayer->nturns_idle>3) { fc_snprintf(idlebuf, sizeof(idlebuf), PL_("(idle %d turn)", "(idle %d turns)", pplayer->nturns_idle - 1), pplayer->nturns_idle - 1); } else { idlebuf[0]='\0'; } /* text for name, plus AI marker */ if (pplayer->ai_controlled) { fc_snprintf(namebuf, sizeof(namebuf), "*%-15s",player_name(pplayer)); } else { fc_snprintf(namebuf, sizeof(namebuf), "%-16s",player_name(pplayer)); } namebuf[16] = '\0'; /* text for diplstate type and turns -- not applicable if this is me */ if (NULL == client.conn.playing || pplayer == client.conn.playing) { strcpy(dsbuf, "-"); } else { pds = player_diplstate_get(client.conn.playing, pplayer); if (pds->type == DS_CEASEFIRE) { fc_snprintf(dsbuf, sizeof(dsbuf), "%s (%d)", diplstate_text(pds->type), pds->turns_left); } else { fc_snprintf(dsbuf, sizeof(dsbuf), "%s", diplstate_text(pds->type)); } } /* assemble the whole lot */ fc_snprintf(namelist_text[j], sizeof(namelist_text[j]), "%-16s %-12s %-8s %-15s %-8s %-6s %-15s%s", namebuf, nation_adjective_for_player(pplayer), get_embassy_status(client.conn.playing, pplayer), dsbuf, get_vision_status(client.conn.playing, pplayer), statebuf, player_addr_hack(pplayer), /* Fixme for multi-conn */ idlebuf); namelist_ptrs[j]=namelist_text[j]; list_index_to_player_index[j] = player_number(pplayer); j++; } players_iterate_end; XawListChange(players_list, namelist_ptrs, j, 0, True); XtVaGetValues(players_list, XtNwidth, &width, NULL); XtVaSetValues(players_label, XtNwidth, width, NULL); } }