71 struct packet_player_info *packet);
75 struct packet_player_diplstate *packet_ds,
76 struct player *receiver,
bool full);
78 struct packet_player_info *packet,
79 struct player *receiver,
bool send_all);
82 struct conn_list *dest);
84 struct conn_list *dest);
86 struct conn_list *dest);
89 bool nationset_change);
106 struct player *barbarians =
nullptr;
126 if (
game.
server.revealmap & REVEAL_MAP_DEAD) {
127 bool someone_alive =
false;
131 if (pteam_member->is_alive) {
132 someone_alive =
true;
138 if (!someone_alive) {
149 _(
"The %s are no more!"),
159 if (pcity->original != pplayer && pcity->original->
is_alive) {
163 if (
transfer_city(pcity->original, pcity, 3,
true,
true,
true,
true)) {
165 pcity->original,
"death-back_to_original");
173 if (
game.
info.gameloss_style & GAMELOSS_STYLE_CWAR) {
174 if (city_list_size(pplayer->
cities)
176 qDebug(
"Civil war strikes the remaining empire of %s", pplayer->
name);
182 qDebug(
"The empire of %s is too small for civil war.", pplayer->
name);
187 if (
game.
info.gameloss_style & GAMELOSS_STYLE_BARB) {
200 qDebug(
"Barbarians take the empire of %s", pplayer->
name);
206 if (
transfer_city(barbarians, pcity, -1,
false,
false,
false,
false)) {
208 barbarians,
"death-barbarians_get");
229 wipe_unit(punit, ULR_PLAYER_DIED,
nullptr);
240 ptile->extras_owner =
nullptr;
265 return CLIP(34, maxrate, 100);
278 qCritical(
"received player_rates packet from %s before start",
281 _(
"Cannot change rates before game start."));
285 if (tax + luxury + science != 100) {
288 if (tax < 0 || tax > 100 || luxury < 0 || luxury > 100 || science < 0
293 if (tax > maxrate || luxury > maxrate || science > maxrate) {
298 }
else if (luxury > maxrate) {
301 rtype =
_(
"Science");
305 _(
"%s rate exceeds the max rate for %s."), rtype,
323 bool revolution_finished)
327 if (revolution_finished) {
339 if (revolution_finished) {
340 log_debug(
"Revolution finished for %s. Government is %s. "
347 _(
"%s now governs the %s as a %s."),
player_name(pplayer),
369 _(
"The national budget for the %s are changed from "
370 "%3d%%/%3d%%/%3d%% (tax/luxury/science) to "
371 "%3d%%/%3d%%/%3d%%."),
399 _(
"You can't revolt without selecting target government."));
414 turns =
MAX(1, turns);
438 log_debug(
"Government changed for %s. Target government is %s; "
439 "old %s. Revofin %d, Turn %d.",
465 if (anarchy && turns <= 0
470 _(
"You can't revolt the same turn you finished previous "
480 log_debug(
"Revolution started for %s. Target government is %s. "
491 }
else if (turns > 0) {
495 PL_(
"The %s have incited a revolt! "
496 "%d turn of anarchy will ensue! "
497 "Target government is %s.",
498 "The %s have incited a revolt! "
499 "%d turns of anarchy will ensue! "
500 "Target government is %s.",
508 _(
"Revolution: returning to anarchy."));
515 log_debug(
"Government change complete for %s. Target government is %s; "
516 "now %s. Turn %d; revofin %d.",
550 log_debug(
"Update revolution for %s. Current government %s, "
551 "target %s, revofin %d, turn %d.",
566 log_debug(
"Update: finishing revolution for %s.",
573 _(
"You should choose a new government from the "
574 "government menu."));
593 struct city *primary_capital =
nullptr;
594 int same_value_count = 0;
600 if (value > max_value) {
602 primary_capital = pcity;
603 same_value_count = 1;
606 pcity->
capital = CAPITAL_SECONDARY;
607 }
else if (value > 0) {
609 pcity->capital = CAPITAL_SECONDARY;
610 if (value == max_value) {
613 if (
fc_rand(same_value_count) == 1) {
614 primary_capital = pcity;
624 if (primary_capital !=
nullptr) {
625 primary_capital->
capital = CAPITAL_PRIMARY;
644 _(
"Tax rate exceeded the max rate; adjusted."));
648 _(
"Science rate exceeded the max rate; adjusted."));
652 _(
"Luxury rate exceeded the max rate; adjusted."));
667 const struct unit_list *pplayer_seen_units,
668 const struct unit_list *pplayer2_seen_units)
718 if (old_owner == pplayer2) {
720 }
else if (old_owner == pplayer) {
747 enum clause_type clause)
763 enum clause_type clause,
764 bool protect_alliances)
766 enum diplstate_type old_type;
767 enum diplstate_type new_type;
772 struct unit_list *pplayer_seen_units, *pplayer2_seen_units;
780 if (clause == CLAUSE_VISION) {
786 _(
"%s no longer gives us shared vision!"),
797 _(
"The senate will not allow you to break treaty "
798 "with the %s. You must either dissolve the senate "
799 "or wait until a more timely moment."),
812 if (protect_alliances && new_type == DS_WAR) {
813 bool blocking_alliances =
false;
817 if (pplayer3 != pplayer && pplayer3 != pplayer2
824 if (
is_ai(pplayer3)) {
829 pplayer,
nullptr, E_TREATY_BROKEN,
ftc_server,
830 _(
"Your advisors discourage you from cancelling your pact "
831 "with the %s, as this would force your team mate %s to "
832 "break their alliance with the %s."),
837 _(
"Your advisors discourage you from cancelling "
838 "your pact with the %s, as this would break your "
839 "alliance with the %s."),
844 blocking_alliances =
true;
849 if (blocking_alliances) {
864 if (old_type == DS_ALLIANCE) {
868 pplayer_seen_units =
nullptr;
869 pplayer2_seen_units =
nullptr;
873 ds_plrplr2->
type = ds_plr2plr->
type = new_type;
876 if (new_type == DS_WAR) {
883 if (old_type == DS_ALLIANCE) {
884 fc_assert(pplayer_seen_units !=
nullptr);
885 fc_assert(pplayer2_seen_units !=
nullptr);
888 pplayer, pplayer2, pplayer_seen_units, pplayer2_seen_units);
889 unit_list_destroy(pplayer_seen_units);
890 unit_list_destroy(pplayer2_seen_units);
900 _(
"The senate passes your bill because of the "
901 "constant provocations of the %s."),
903 }
else if (new_type == DS_WAR) {
905 _(
"The senate refuses to break treaty with the %s, "
906 "but you have no trouble finding a new senate."),
910 if (new_type == DS_WAR) {
929 _(
"The diplomatic state between the %s "
930 "and the %s is now %s."),
933 diplstate_type_translated_name(new_type));
935 _(
" %s canceled the diplomatic agreement! "
936 "The diplomatic state between the %s and the %s "
940 diplstate_type_translated_name(new_type));
947 if (other != pplayer && other != pplayer2 && new_type == DS_WAR
955 _(
"%s has attacked your ally %s! "
956 "You cancel your alliance to the aggressor."),
961 CLAUSE_ALLIANCE,
false);
967 _(
"Your team mate %s declared war on %s. "
968 "You are obligated to cancel alliance with %s."),
973 CLAUSE_ALLIANCE,
false);
984 struct conn_list *dest)
1054 if (src !=
nullptr) {
1068 struct conn_list *dest)
1070 struct packet_player_info info;
1082 if (
nullptr == pconn->playing && pconn->observer) {
1085 }
else if (
nullptr != pconn->playing) {
1092 send_packet_player_info(pconn, &info);
1108 if (src !=
nullptr) {
1122 struct conn_list *dest)
1134 struct packet_player_diplstate packet_ds;
1136 if (
nullptr == pconn->playing && pconn->observer) {
1145 send_packet_player_diplstate(pconn, &packet_ds);
1156 struct packet_player_info *packet)
1166 packet->is_male = plr->
is_male;
1179 if (music !=
nullptr) {
1182 packet->music_style = -1;
1188 packet->flags = plr->
flags;
1211 struct packet_player_info *packet,
1212 struct player *receiver,
bool send_all)
1214 if (
server_state() < S_S_RUNNING || (!send_all && !receiver)) {
1226 for (
int i = 0; i < NI_COUNT; ++i) {
1230 static_cast<national_intelligence
>(i),
1231 EFT_NATION_INTELLIGENCE)
1233 BV_SET(packet->visible, i);
1243 if (
BV_ISSET(packet->visible, NI_MULTIPLIERS)) {
1262 if (
BV_ISSET(packet->visible, NI_WONDERS)) {
1263 for (
int i = 0; i <
B_LAST; ++i) {
1267 || receiver ==
nullptr) {
1268 packet->wonders[i] = plr->
wonders[i];
1275 nullptr,
city_owner(pcity), receiver, pcity, pimprove,
nullptr,
1276 nullptr,
nullptr,
nullptr,
nullptr,
nullptr, EFT_WONDER_VISIBLE);
1278 packet->wonders[i] = plr->
wonders[i];
1284 for (
int i = 0; i <
B_LAST; ++i) {
1290 if (plr->
rgb !=
nullptr) {
1291 packet->color_valid =
true;
1292 packet->color_red = plr->
rgb->
r;
1293 packet->color_green = plr->
rgb->
g;
1294 packet->color_blue = plr->
rgb->
b;
1299 if (preferred !=
nullptr) {
1300 packet->color_valid =
true;
1301 packet->color_red = preferred->
r;
1302 packet->color_green = preferred->
g;
1303 packet->color_blue = preferred->
b;
1306 packet->color_valid =
false;
1308 packet->color_red = 0;
1309 packet->color_green = 0;
1310 packet->color_blue = 0;
1316 if (
BV_ISSET(packet->visible, NI_SCORE)) {
1322 if (
BV_ISSET(packet->visible, NI_GOLD)) {
1330 if (
BV_ISSET(packet->visible, NI_GOVERNMENT)) {
1337 packet->revolution_finishes = -1;
1340 packet->target_government =
1346 if (
BV_ISSET(packet->visible, NI_DIPLOMACY)) {
1347 memset(&packet->real_embassy, 0,
sizeof(packet->real_embassy));
1356 memset(&packet->real_embassy, 0,
sizeof(packet->real_embassy));
1367 if (
BV_ISSET(packet->visible, NI_TECHS)) {
1370 packet->tech_upkeep = 0;
1375 if (
BV_ISSET(packet->visible, NI_TAX_RATES)) {
1381 packet->science = 0;
1385 if (
BV_ISSET(packet->visible, NI_CULTURE)) {
1388 packet->culture = 0;
1391 if (
BV_ISSET(packet->visible, NI_MOOD)) {
1394 packet->mood = MOOD_COUNT;
1397 if (
BV_ISSET(packet->visible, NI_HISTORY)) {
1398 packet->history = plr->
history;
1400 packet->history = 0;
1415 struct packet_player_diplstate *packet_ds,
1416 struct player *receiver,
bool full)
1418 bool send_info =
false;
1420 if (
server_state() < S_S_RUNNING || (!full && !receiver)) {
1431 EFT_NATION_INTELLIGENCE)
1434 EFT_NATION_INTELLIGENCE)
1446 packet_ds->diplstate_id =
1453 packet_ds->type = ds->type;
1454 packet_ds->turns_left = ds->turns_left;
1455 packet_ds->has_reason_to_cancel = ds->has_reason_to_cancel;
1456 packet_ds->contact_turns_left = ds->contact_turns_left;
1458 packet_ds->type = DS_WAR;
1459 packet_ds->turns_left = 0;
1460 packet_ds->has_reason_to_cancel = 0;
1461 packet_ds->contact_turns_left = 0;
1499 pplayer->
server.got_first_city =
false;
1503 pplayer->
server.border_vision =
false;
1506 pplayer->
server.private_map =
nullptr;
1536 pplayer->
server.delegate_to[0] =
'\0';
1537 pplayer->
server.orig_username[0] =
'\0';
1550 return pplayer->
rgb;
1570 qCritical(
"Invalid value for 'game.server.plrcolormode' (%d)!",
1591 const char **reason)
1595 *reason =
_(
"Can only set player color prior to game start if "
1596 "'plrcolormode' is PLR_SET.");
1610 struct rgbcolor_list *spare_colors =
1628 rgbcolor_list_remove(spare_colors, prgbcolor);
1638 rgbcolor_list_destroy(spare_colors);
1645 for (
const auto &pnation :
nations) {
1653 rgbcolor_list_remove(spare_colors, ncol);
1666 if (needed > rgbcolor_list_size(spare_colors)) {
1667 qDebug(
"Not enough unique colors for all players; there will be "
1671 rgbcolor_list_destroy(spare_colors);
1672 spare_colors = rgbcolor_list_copy(
game.
server.plr_colors);
1676 if (needed > rgbcolor_list_size(spare_colors)) {
1677 int i, origsize = rgbcolor_list_size(spare_colors);
1679 rgbcolor_list_shuffle(spare_colors);
1681 for (i = origsize; i < needed; i++) {
1682 rgbcolor_list_append(spare_colors,
1683 rgbcolor_list_get(spare_colors, i - origsize));
1687 rgbcolor_list_shuffle(spare_colors);
1692 if (!pplayer->rgb) {
1694 rgbcolor_list_pop_front(spare_colors);
1699 rgbcolor_list_destroy(spare_colors);
1709 if (prgbcolor !=
nullptr) {
1715 pplayer->
rgb =
nullptr;
1728 static char buf[64];
1736 if (prgbcolor !=
nullptr &&
rgbcolor_to_hex(prgbcolor, hex,
sizeof(hex))) {
1754 int sucount = qstrlen(
game.
server.start_units);
1757 for (i = 0; i < sucount; i++) {
1762 if (utype !=
nullptr) {
1778 bool allow_ai_type_fallbacking)
1787 if (
nullptr == pplayer) {
1791 if (allow_ai_type_fallbacking) {
1798 if (pplayer->
ai ==
nullptr) {
1832 pslot = pplayer->
slot;
1837 _(
"You've been removed from the game!"));
1840 _(
"%s has been removed from the game."),
player_name(pplayer));
1848 while (conn_list_size(pplayer->
connections) > 0) {
1866 if (
game.
info.citizen_nationality) {
1872 if (nationality != 0) {
1944 int maxrate, surplus;
1948 if (
is_ai(pplayer)) {
1949 return pplayer->economic;
1952 economic = pplayer->economic;
1957 if (economic.luxury > maxrate) {
1958 surplus += economic.luxury - maxrate;
1959 economic.luxury = maxrate;
1961 if (economic.tax > maxrate) {
1962 surplus += economic.tax - maxrate;
1963 economic.tax = maxrate;
1965 if (economic.science > maxrate) {
1966 surplus += economic.science - maxrate;
1967 economic.science = maxrate;
1971 while (surplus > 0) {
1972 if (economic.science < maxrate) {
1973 economic.science += 10;
1974 }
else if (economic.tax < maxrate) {
1976 }
else if (economic.luxury < maxrate) {
1977 economic.luxury += 10;
1980 "Failed to distribute the surplus. "
1995 const struct player *pplayer,
1997 const char *
name,
char *error_buf,
1998 size_t error_buf_len)
2001 if (0 == qstrlen(
name)) {
2002 fc_strlcpy(error_buf,
_(
"Please choose a non-blank name."),
2010 if (other_player == pplayer) {
2013 }
else if (
nullptr != pnation && other_player->nation == pnation) {
2016 fc_strlcpy(error_buf,
_(
"That nation is already in use."),
2021 _(
"Another player already has the name '%s'. Please "
2022 "choose another name."),
2029 if (
nullptr == pnation) {
2032 pnation = pplayer->
nation;
2036 if (
nullptr != pnation
2044 if (
nullptr != caller && caller->
access_level < ALLOW_HACK
2047 _(
"Please choose a name containing only ASCII characters."),
2062 const char *
name,
char *error_buf,
2063 size_t error_buf_len)
2070 if (
nullptr == error_buf) {
2072 error_buf_len =
sizeof(buf);
2074 error_buf[0] =
'\0';
2076 if (
nullptr !=
name) {
2080 real_name[0] = QChar::toUpper(real_name[0]);
2083 error_buf, error_buf_len)) {
2084 log_debug(
"Name of player nb %d set to \"%s\".",
2089 qDebug(
"Failed to set the name of the player nb %d to \"%s\": %s",
2095 if (
nullptr != caller) {
2101 if (
nullptr !=
name) {
2106 fc_snprintf(test,
sizeof(test),
"%s%d", real_name, i);
2108 error_buf, error_buf_len)) {
2109 qDebug(
"Name of player nb %d set to \"%s\" instead.",
2114 log_debug(
"Failed to set the name of the player nb %d to \"%s\": %s",
2121 fc_snprintf(real_name,
sizeof(real_name),
_(
"Player no. %d"),
2124 error_buf, error_buf_len)) {
2125 qDebug(
"Name of player nb %d set to \"%s\".",
player_number(pplayer),
2130 log_debug(
"Failed to set the name of the player nb %d to \"%s\": %s",
2136 fc_snprintf(real_name,
sizeof(real_name),
_(
"Player no. %d"), i);
2138 error_buf, error_buf_len)) {
2139 qDebug(
"Name of player nb %d to \"%s\".",
player_number(pplayer),
2144 log_debug(
"Failed to set the name of the player nb %d to \"%s\": %s",
2152 sizeof(pplayer->
name));
2175 static enum diplstate_type
2177 const struct player *pplayer2)
2179 if (
game.
server.initial_diplomatic_state < DS_ALLIANCE) {
2182 if (pplayer3 != pplayer1 && pplayer3 != pplayer2
2214 if (ds_plr1plr2->
type == DS_NO_CONTACT) {
2215 enum diplstate_type new_state =
2217 if (new_state == DS_CEASEFIRE || new_state == DS_ARMISTICE) {
2222 ds_plr1plr2->
type = new_state;
2223 ds_plr2plr1->
type = new_state;
2228 _(
"You have made contact with the %s, ruled by %s."),
2231 _(
"You have made contact with the %s, ruled by %s."),
2233 if (new_state == DS_ARMISTICE) {
2239 PL_(
"You are in armistice with the %s. In %d turn, "
2240 "it will become a peace treaty. Move your "
2241 "military units out of %s territory to avoid them "
2243 "You are in armistice with the %s. In %d turns, "
2244 "it will become a peace treaty. Move any "
2245 "military units out of %s territory to avoid them "
2261 if (
is_ai(pplayer1)) {
2264 if (
is_ai(pplayer2)) {
2308 log_debug(
"shuffle_players: creating shuffled order");
2310 for (i = 0; i < n; i++) {
2317 #ifdef FREECIV_DEBUG
2318 for (i = 0; i < n; i++) {
2331 log_debug(
"set_shuffled_players: loading shuffled array %p",
2378 bool ignore_conflicts,
bool needs_startpos,
2389 int num_avail_nations = 0, num_pref_nations = 0;
2396 for (
auto &pnation :
nations) {
2401 && pnation.server.no_startpos)
2408 nations_used[idx] = UNAVAILABLE;
2413 nations_used[idx] = AVAILABLE;
2424 log_debug(
"Nations '%s' (nb %d) and '%s' (nb %d) are in conflict.",
2428 nations_used[idx] = UNWANTED;
2429 match[idx] -= x * 100;
2432 match[idx] += x * 100;
2438 if (AVAILABLE == nations_used[idx]) {
2439 num_avail_nations += match[idx];
2445 if (
nullptr != choices) {
2449 if (nations_used[idx] == AVAILABLE) {
2450 num_pref_nations += match[idx];
2451 nations_used[idx] = PREFERRED;
2457 if (0 < num_pref_nations || 0 < num_avail_nations) {
2458 if (0 < num_pref_nations) {
2460 pick =
fc_rand(num_pref_nations);
2461 looking_for = PREFERRED;
2462 log_debug(
"Picking a preferred nation.");
2466 pick =
fc_rand(num_avail_nations);
2467 looking_for = AVAILABLE;
2468 log_debug(
"Picking an available nation.");
2471 for (
auto &pnation :
nations) {
2473 if (nations_used[idx] == looking_for) {
2486 log_debug(
"Picking an unwanted nation.");
2487 for (
auto &pnation :
nations) {
2489 if (UNWANTED == nations_used[idx]) {
2491 if (pick > less_worst_score) {
2492 less_worst_nation = &pnation;
2493 less_worst_score = pick;
2499 return less_worst_nation;
2503 qDebug(
"No nation found!");
2531 server.playable_nations = 0;
2532 for (
const auto &pnation :
nations) {
2535 server.playable_nations++;
2551 || !pnation->
server.no_startpos);
2558 bool nationset_change)
2560 struct packet_nation_availability packet;
2563 packet.nationset_change = nationset_change;
2564 for (
const auto &pnation :
nations) {
2568 lsend_packet_nation_availability(dest, &packet);
2614 int i, least_misfits = -1;
2618 if (best ==
nullptr || misfits[i] < least_misfits) {
2620 least_misfits = misfits[i];
2621 if (least_misfits == 0) {
2629 qDebug(
"Current nationset \"%s\" doesn't fit all existing players.",
2646 qDebug(
"Nation %s of player %s not in nationset \"%s\", unsetting.",
2665 if (pplayer->is_ready) {
2666 bool persistent =
false;
2669 switch (
game.
info.persistent_ready) {
2670 case PERSISTENTR_DISABLED:
2673 case PERSISTENTR_CONNECTED:
2674 persistent = pplayer->is_connected;
2680 pplayer->is_ready =
false;
2696 struct research *new_research, *old_research;
2710 false, NOT_A_BARBARIAN);
2726 cplayer->
server.got_first_city =
false;
2736 ds_co->
type = DS_WAR;
2737 ds_oc->
type = DS_WAR;
2739 ds_co->
type = DS_NO_CONTACT;
2740 ds_oc->
type = DS_NO_CONTACT;
2753 if (other_player != pplayer) {
2805 if (pplayer->
team) {
2808 if (pplayer->
team == pdest->team && pplayer != pdest) {
2822 pplayer->
server.border_vision = cplayer->
server.border_vision;
2844 bool honour_server_option)
2848 if (!
game.
info.civil_war_enabled) {
2852 n = city_list_size(pplayer->
cities);
2857 if (honour_server_option) {
2900 prob +=
game.
info.civil_war_bonus_unhappy;
2903 prob +=
game.
info.civil_war_bonus_celebrating;
2908 qDebug(
"Civil war chance for %s: prob %d, dice %d",
player_name(pplayer),
2911 return (dice < prob);
2947 struct city_list *defector_candidates;
2957 qInfo(
_(
"Could not throw %s into civil war - too many players"),
2963 qInfo(
_(
"Could not throw %s into civil war - no available nations"),
2972 defector_candidates = city_list_new();
2975 bool gameloss_present =
false;
2987 gameloss_present =
true;
2992 if (gameloss_present) {
2996 city_list_append(defector_candidates, pcity);
3000 if (city_list_size(defector_candidates) == 0) {
3001 qDebug(
_(
"Could not throw %s into civil war - no available cities"),
3003 city_list_destroy(defector_candidates);
3016 log_debug(
"Increased 'maxplayers' to allow the creation of a new player "
3017 "due to civil war.");
3030 qDebug(
"%s civil war; created AI %s",
3034 _(
"Your nation is thrust into civil war."));
3038 _(
"%s is the rebellious leader of the %s."),
3041 j = city_list_size(defector_candidates);
3048 if (i >= j || (i > 0 &&
fc_rand(2) == 1)) {
3055 if (
transfer_city(cplayer, pcity, -1,
false,
false,
false,
false)) {
3056 qDebug(
"%s declares allegiance to the %s.",
city_name_get(pcity),
3060 _(
"%s declares allegiance to the %s."),
3063 cplayer,
"civil_war");
3071 city_list_destroy(defector_candidates);
3075 i = city_list_size(cplayer->
cities);
3085 PL_(
"Civil war partitions the %s;"
3086 " the %s now hold %d city.",
3087 "Civil war partitions the %s;"
3088 " the %s now hold %d cities.",
3101 const struct packet_player_attribute_chunk *chunk)
3172 if (pplayer ==
nullptr || qstrlen(pplayer->
server.delegate_to) == 0) {
3176 return pplayer->
server.delegate_to;
3187 if (username ==
nullptr || qstrlen(username) == 0) {
3188 pplayer->
server.delegate_to[0] =
'\0';
3201 return (pplayer && qstrlen(pplayer->
server.orig_username) != 0);
3218 _(
"User '%s' is currently allowed to take control of your "
3219 "player while you are away. Use '/delegate cancel' to "
3220 "revoke this access."),
3225 bool any_delegations =
false;
3231 _(
"Control of player '%s' is delegated to you."),
3233 any_delegations =
true;
3237 if (any_delegations) {
3241 _(
"Use '/delegate take <player>' to take control of a "
3242 "delegated player."));
3272 game.
server.plr_colors = rgbcolor_list_new();
3284 if (rgbcolor_list_size(
game.
server.plr_colors) > 0) {
3287 rgbcolor_list_remove(
game.
server.plr_colors, prgbcolor);
3292 rgbcolor_list_destroy(
game.
server.plr_colors);
3303 rgbcolor_list_append(
game.
server.plr_colors, prgbcolor);
3313 return rgbcolor_list_get(
game.
server.plr_colors,
id);
3323 return rgbcolor_list_size(
game.
server.plr_colors);
3336 qCritical(
"Bad number of multipliers %d from client for %s", count,
3341 for (i = 0; i < count; i++) {
3346 qCritical(
"Multiplier value %d for %s out of range for %s",
3353 qCritical(
"Multiplier value %d between valid values for %s for %s",
void adv_data_close(struct player *pplayer)
Free memory for advisor data.
void adv_data_init(struct player *pplayer)
Allocate memory for advisor data.
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
Make and cache lots of calculations needed for other functions.
void adv_data_default(struct player *pplayer)
Initialize with sane values.
const char * ai_name(const struct ai_type *ai)
Return the name of the ai type.
struct ai_type * ai_type_by_name(const char *search)
Find ai type with given name.
const char * ai_type_name_or_fallback(const char *orig_name)
Return usable ai type name, if possible.
#define CALL_FUNC_EACH_AI(_func,...)
#define CALL_PLR_AI_FUNC(_func, _player,...)
void call_incident(enum incident_type type, enum casus_belli_range scope, const struct action *paction, struct player *violator, struct player *victim)
Call incident function of victim.
void ai_traits_close(struct player *pplayer)
Free resources associated with player ai traits.
struct player * create_barbarian_player(enum barbarian_type type)
Creates the land/sea barbarian player and inits some stuff.
bool BV_ISSET(const BV &bv, int bit)
void citizens_nation_move(struct city *pcity, const struct player_slot *pslot_from, const struct player_slot *pslot_to, int move)
Convert a (positive or negative) value to the citizens from one nation to another.
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
Get the number of citizens with the given nationality.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
bool is_capital(const struct city *pcity)
Return TRUE iff this city is its nation's capital.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
bool city_unhappy(const struct city *pcity)
Return TRUE iff the city is unhappy.
bool city_celebrating(const struct city *pcity)
cities celebrate only after consecutive happy turns
#define cities_iterate_end
#define city_list_iterate_safe(citylist, _city)
#define city_list_iterate(citylist, pcity)
#define cities_iterate(pcity)
#define city_list_iterate_end
#define city_list_iterate_safe_end
void city_refresh_queue_add(struct city *pcity)
Queue pending city_refresh() for later.
void city_refresh_queue_processing()
Refresh the listed cities.
void city_refresh_for_player(struct player *pplayer)
Called on government change or wonder completion or stuff like that – Syela.
void connection_detach(struct connection *pconn, bool remove_unused_player)
Remove pconn as a client connected to pplayer: Updates pconn->playing, pconn->playing->connections,...
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
int player_culture(const struct player *plr)
Return current culture score of the player.
void set_ai_level_directer(struct player *pplayer, enum ai_level level)
Set an AI level and related quantities, with no feedback.
void establish_embassy(struct player *pplayer, struct player *aplayer)
Create an embassy.
void reject_all_treaties(struct player *pplayer)
Reject all treaties currently being negotiated.
void cancel_all_meetings(struct player *pplayer)
Cancels all meetings of player.
int get_target_bonus_effects(struct effect_list *plist, const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, enum effect_type effect_type, enum vision_layer vision_layer, enum national_intelligence nintel)
Returns the effect bonus of a given type for any target.
int get_player_intel_bonus(const struct player *pplayer, const struct player *pother, enum national_intelligence nintel, enum effect_type effect_type)
Gets the player effect bonus of a national intelligence.
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Returns the effect bonus for a player.
#define MAX_NUM_PLAYER_SLOTS
#define PL_(String1, String2, n)
size_t featured_text_apply_tag(const char *text_source, char *featured_text, size_t featured_text_len, enum text_tag_type tag_type, ft_offset_t start_offset, ft_offset_t stop_offset,...)
Apply a tag to a text.
const struct ft_color ftc_server
const struct ft_color ftc_any
const char * city_link(const struct city *pcity)
Get a text link to a city.
bool is_player_phase(const struct player *pplayer, int phase)
Return TRUE if it is this player's phase.
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
#define GAME_DEFAULT_REVOLUTION_LENGTH
#define GAME_MIN_CIVILWARSIZE
#define GAME_MAX_CIVILWARSIZE
struct unit_type * crole_to_unit_type(char crole, struct player *pplayer)
Get unit_type for given role character.
struct government * government_of_player(const struct player *pplayer)
Return the government of a player.
struct government * government_by_number(const Government_type_id gov)
Return the government with the given index.
const char * government_name_for_player(const struct player *pplayer)
Return the (translated) name of the given government of a player.
bool untargeted_revolution_allowed()
Is it possible to start a revolution without specifying the target government in the current game?
Government_type_id government_count()
Return the number of governments.
const char * government_rule_name(const struct government *pgovern)
Return the (untranslated) rule name of the government.
bool can_change_to_government(struct player *pplayer, const struct government *gov)
Can change to government if appropriate tech exists, and one of:
Government_type_id government_number(const struct government *pgovern)
Return the government index.
const char * government_name_translation(const struct government *pgovern)
Return the (translated) name of the given government.
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
AI players may have handicaps - allowing them to cheat or preventing them from using certain algorith...
void handicaps_init(struct player *pplayer)
Initialize handicaps for player.
void handicaps_close(struct player *pplayer)
Free resources associated with player handicaps.
Impr_type_id improvement_count()
Return the number of improvements.
struct impr_type * improvement_by_number(const Impr_type_id id)
Returns the improvement type for the given index/ID.
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
bool map_is_empty()
Returns TRUE if we are at a stage of the game where the map has not yet been generated/loaded.
#define square_iterate(nmap, center_tile, radius, tile_itr)
#define square_iterate_end
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
void player_map_init(struct player *pplayer)
Allocate space for map, and initialise the tiles.
void map_calculate_borders()
Update borders for all sources.
void map_claim_ownership(struct tile *ptile, struct player *powner, struct tile *psource, bool claim_bases)
Claim ownership of a single tile.
void map_claim_base(struct tile *ptile, const extra_type *pextra, struct player *powner, struct player *ploser)
Claim base to player's ownership.
void map_know_and_see_all(struct player *pplayer)
Call this function to unfog all tiles.
void give_map_from_player_to_player(struct player *pfrom, struct player *pdest)
Give information about whole map (all tiles) from player to player.
void remove_shared_vision(struct player *pfrom, struct player *pto)
Removes shared vision from between two players.
void player_map_free(struct player *pplayer)
Free a player's private map.
void remove_player_from_maps(struct player *pplayer)
Remove all knowledge of a player from main map and other players' private maps, and send updates to c...
enum mood_type player_mood(struct player *pplayer)
What is the player mood?
struct multiplier * multiplier_by_number(Multiplier_type_id id)
Returns multiplier associated to given number.
const char * multiplier_rule_name(const struct multiplier *pmul)
Return the (untranslated) rule name of the multiplier.
bool multiplier_can_be_changed(struct multiplier *pmul, struct player *pplayer)
Can player change multiplier value.
static struct multiplier multipliers[MAX_NUM_MULTIPLIERS]
Multiplier_type_id multiplier_count()
Return number of loaded multipliers in the ruleset.
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
Returns multiplier index.
#define multipliers_iterate(_mul_)
#define multipliers_iterate_end
struct nation_set * nation_set_by_number(int id)
Return the nation set with the given index.
struct nation_leader * nation_leader_by_name(const struct nation_type *pnation, const char *name)
Returns the nation leader structure which match 'name' or nullptr if not found.
int nations_match(const struct nation_type *pnation1, const struct nation_type *pnation2, bool ignore_conflicts)
Returns how much two nations look good in the same game.
struct government * init_government_of_nation(const struct nation_type *pnation)
Returns initial government type for this nation.
int nation_set_count()
Return the number of nation sets.
int nation_set_index(const struct nation_set *pset)
Return the nation set index.
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
std::vector< nation_type > nations
bool is_nation_playable(const struct nation_type *nation)
Return whether a nation is "playable"; i.e., whether a human player can choose this nation.
struct nation_set * nation_set_by_setting_value(const char *setting)
Returns the nation set that would be selected by the given value of the 'nationset' server setting.
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Check if the given nation is in a given set.
const struct rgbcolor * nation_color(const struct nation_type *pnation)
Returns nation's player color preference, or nullptr if none.
const char * nation_set_rule_name(const struct nation_set *pset)
Return the (untranslated) rule name of a nation set.
const char * nation_adjective_for_player(const struct player *pplayer)
Return the (translated) adjective for the given nation of a player.
Nation_type_id nation_index(const struct nation_type *pnation)
Return the nation index.
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
Returns which kind of barbarians can use this nation.
#define nation_list_iterate(nationlist, pnation)
#define nation_sets_iterate_end
#define nation_sets_iterate(NAME_pset)
#define nation_list_iterate_end
#define NO_NATION_SELECTED
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Similar to notify_conn_packet (see also), but takes player as "destination".
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
See notify_conn_packet - this is just the "non-v" version, with varargs.
void generic_handle_player_attribute_chunk(struct player *pplayer, const struct packet_player_attribute_chunk *chunk)
Updates pplayer->attribute_block according to the given packet.
void send_attribute_block(const struct player *pplayer, struct connection *pconn)
Split the attribute block into chunks and send them over pconn.
struct player_slot * player_slot_by_number(int player_id)
Return the possibly unused and uninitialized player slot.
bool player_slot_is_used(const struct player_slot *pslot)
Returns TRUE is this slot is "used" i.e.
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
Return TRUE if players are in the same team.
enum diplstate_type cancel_pact_result(enum diplstate_type oldstate)
Return the diplomatic state that cancelling a pact will end up in.
struct player * player_by_number(const int player_id)
Return struct player pointer for the given player index.
int player_number(const struct player *pplayer)
Return the player index/number/id.
int player_count()
Return the number of players.
void player_clear(struct player *pplayer, bool full)
Clear all player data.
int player_slot_index(const struct player_slot *pslot)
Returns the index of the player slot.
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
Returns whether pplayer has a real embassy with pplayer2, established from a diplomat,...
void player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Set the player's color.
int player_index(const struct player *pplayer)
Return the player index.
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Set the player's nation to the given nation (may be nullptr).
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
enum dipl_reason pplayer_can_cancel_treaty(const struct player *p1, const struct player *p2)
The senate may not allow you to break the treaty.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
struct player * player_new(struct player_slot *pslot)
Creates a new player for the slot.
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
Check if pplayer has an embassy with pplayer2.
bool gives_shared_vision(const struct player *me, const struct player *them)
Return TRUE iff the player me gives shared vision to player them.
void player_destroy(struct player *pplayer)
Destroys and remove a player from the game.
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
#define players_iterate_end
#define players_iterate(_pplayer)
#define player_list_iterate(playerlist, pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_list_iterate_end
#define set_as_human(plr)
#define players_iterate_alive_end
#define players_iterate_alive(_pplayer)
void handle_player_phase_done(struct player *pplayer, int turn)
(Hmm, how should "turn done" work for multi-connected non-observer players?)
struct conn_list * player_reply_dest(struct player *pplayer)
Convenience function to return "reply" destination connection list for player: pplayer->current_conn ...
void send_nation_availability(struct conn_list *dest, bool nationset_change)
Tell clients which nations can be picked given current server settings.
void handle_player_multiplier(struct player *pplayer, int count, const int *multipliers)
Sets player's multipliers.
void server_player_set_name(struct player *pplayer, const char *name)
Try to set the player name to 'name'.
void send_player_all_c(struct player *src, struct conn_list *dest)
Send all information about a player (player_info and all player_diplstates) to the given connections.
static void send_player_remove_info_c(const struct player_slot *pslot, struct conn_list *dest)
Send information about removed (unused) players.
void player_update_last_war_action(struct player *pplayer)
Update last war action timestamp (affects player mood).
void handle_player_attribute_chunk(struct player *pplayer, const struct packet_player_attribute_chunk *chunk)
The client has send as a chunk of the attribute block.
void player_status_add(struct player *plr, enum player_status pstatus)
Add a status flag to a player.
static struct nation_set * current_nationset()
Return the nationset currently in effect.
struct player * civil_war(struct player *pplayer)
Capturing a nation's primary capital is a devastating blow.
static void send_player_info_c_real(struct player *src, struct conn_list *dest)
Really send information.
void playercolor_init()
Initialise the player colors.
void player_set_under_human_control(struct player *pplayer)
Toggle player under human control.
static void maybe_claim_base(struct tile *ptile, struct player *new_owner, struct player *old_owner)
If there's any units of new_owner on tile, they claim bases.
void count_playable_nations()
Update the server's cached number of playable nations.
void playercolor_free()
Free the memory allocated for the player color.
void give_midgame_initial_units(struct player *pplayer, struct tile *ptile)
Gives units that every player should have.
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Creates a new, uninitialized, used player slot.
static int get_player_maxrate(struct player *pplayer)
Return player maxrate in legal range.
static void call_first_contact(struct player *pplayer, struct player *aplayer)
Call first_contact function if such is defined for player.
static void package_player_common(struct player *plr, struct packet_player_info *packet)
Package player information that is always sent.
static struct player * split_player(struct player *pplayer)
This function creates a new player and copies all of it's science research etc.
bool civil_war_triggered(struct player *pplayer)
civil_war_triggered: The capture of a primary capital is not a sure fire way to throw and empire into...
void server_player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Set the player's color.
void player_set_to_ai_mode(struct player *pplayer, enum ai_level skill_level)
Toggle player to AI mode.
bool server_player_set_name_full(const struct connection *caller, struct player *pplayer, const struct nation_type *pnation, const char *name, char *error_buf, size_t error_buf_len)
Try to set the player name to 'name'.
bool player_delegation_active(const struct player *pplayer)
Returns TRUE if a delegation is active.
struct player * player_by_user_delegated(const char *name)
For a given user, if there is some player that the user originally controlled but is currently delega...
static void package_player_info(struct player *plr, struct packet_player_info *packet, struct player *receiver, bool send_all)
Package player info depending on info_level.
void assign_player_colors()
Permanently assign colors to any players that don't already have them.
void maybe_make_contact(struct tile *ptile, struct player *pplayer)
Check if we make contact with anyone.
void handle_player_attribute_block(struct player *pplayer)
The client request an attribute block.
static void send_nation_availability_real(struct conn_list *dest, bool nationset_change)
Helper doing the actual work for send_nation_availability() (q.v.).
struct rgbcolor * playercolor_get(int id)
Get the player color with the index 'id'.
static enum diplstate_type get_default_diplstate(const struct player *pplayer1, const struct player *pplayer2)
Returns the default diplomatic state between 2 players.
void check_player_max_rates(struct player *pplayer)
The following checks that government rates are acceptable for the present form of government.
void kill_player(struct player *pplayer)
Murder a player in cold blood.
void send_player_info_c(struct player *src, struct conn_list *dest)
Send information about player slot 'src', or all valid (i.e.
void set_shuffled_players(int *shuffled_players)
Initialize the shuffled players list (as from a loaded savegame).
static int shuffled_order[MAX_NUM_PLAYER_SLOTS]
void player_status_reset(struct player *plr)
Reset player status to 'normal'.
void send_delegation_info(const struct connection *pconn)
Send information about delegations to reconnecting users.
void handle_player_change_government(struct player *pplayer, Government_type_id government)
Called by the client or AI to change government.
void update_players_after_alliance_breakup(struct player *pplayer, struct player *pplayer2, const struct unit_list *pplayer_seen_units, const struct unit_list *pplayer2_seen_units)
After the alliance is breaken, we need to do two things:
void handle_diplomacy_cancel_pact_explicit(struct player *pplayer, int other_player_id, enum clause_type clause, bool protect_alliances)
A variant of handle_diplomacy_cancel_pact that allows the caller to explicitely control if war declar...
static void package_player_diplstate(struct player *plr1, struct player *plr2, struct packet_player_diplstate *packet_ds, struct player *receiver, bool full)
Package player diplstate depending on info_level.
bool player_status_check(struct player *plr, enum player_status pstatus)
Check player status flag.
bool civil_war_possible(struct player *pplayer, bool conquering_city, bool honour_server_option)
Check if civil war is possible for a player.
void player_delegation_set(struct player *pplayer, const char *username)
Define a delegation.
static bool server_player_name_is_allowed(const struct connection *caller, const struct player *pplayer, const struct nation_type *pnation, const char *name, char *error_buf, size_t error_buf_len)
Check if this name is allowed for the player.
void fit_nationset_to_players()
Try to select a nation set that fits the current players' nations, or failing that,...
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
This function returns a random-ish nation that is suitable for 'barb_type' and is usable (not already...
void server_remove_player(struct player *pplayer)
This function does not close any connections attached to this player.
void player_info_freeze()
Do not compute and send PACKET_PLAYER_INFO or PACKET_NATION_AVAILABILITY until a call to player_info_...
void government_change(struct player *pplayer, struct government *gov, bool revolution_finished)
Finish the revolution and set the player's government.
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Initialize ANY newly-created player on the server.
int normal_player_count()
Return the number of non-barbarian players.
void handle_diplomacy_cancel_pact(struct player *pplayer, int other_player_id, enum clause_type clause)
Handles a player cancelling a "pact" with another player.
void make_contact(struct player *pplayer1, struct player *pplayer2, struct tile *ptile)
Update contact info.
void playercolor_add(struct rgbcolor *prgbcolor)
Add a color to the list of all available player colors.
void update_capital(struct player *pplayer)
Recalculate what city is the named capital.
struct player_economic player_limit_to_max_rates(struct player *pplayer)
The following limits a player's rates to those that are acceptable for the present form of government...
void player_info_thaw()
If the frozen level is back to 0, send all players' infos, and nation availability,...
static void send_player_diplstate_c_real(struct player *src, struct conn_list *dest)
Really send information.
void handle_player_rates(struct player *pplayer, int tax, int luxury, int science)
Handle a client or AI request to change the tax/luxury/science rates.
bool player_color_changeable(const struct player *pplayer, const char **reason)
Return whether a player's color can currently be set with the '/playercolor' command.
void shuffle_players()
Shuffle or reshuffle the player order, storing in static variables above.
int playercolor_count()
Number of player colors defined.
struct player * shuffled_player(int i)
Returns the i'th shuffled player, or nullptr.
const struct rgbcolor * player_preferred_color(struct player *pplayer)
If a player's color will be predictable when colors are assigned (or assignment has already happened)...
const char * player_delegation_get(const struct player *pplayer)
Returns the username that control of the player is delegated to, if any.
bool client_can_pick_nation(const struct nation_type *pnation)
Return whether a nation is "pickable" – whether players can select it at game start.
void send_player_diplstate_c(struct player *src, struct conn_list *dest)
Identical to send_player_info_c(), but sends the diplstate of the player.
bool nation_is_in_current_set(const struct nation_type *pnation)
Is the nation in the currently selected nationset? If not, it's not allowed to appear in the game.
void enter_war(struct player *pplayer, struct player *pplayer2)
Two players enter war.
static int player_info_frozen_level
int revolution_length(struct government *gov, struct player *plr)
Get length of a revolution.
const char * player_color_ftstr(struct player *pplayer)
Return the player color as featured text string.
void reset_all_start_commands(bool plrchange)
Called when something is changed; this resets everyone's readiness.
void update_revolution(struct player *pplayer)
See if the player has finished their revolution.
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
Set research knowledge about tech to given state.
int player_tech_upkeep(const struct player *pplayer)
Calculate the bulb upkeep needed for all techs of a player.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
void research_update(struct research *presearch)
Mark as TECH_PREREQS_KNOWN each tech which is available, not known and which has all requirements ful...
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Free rgbcolor structure.
bool rgbcolors_are_equal(const struct rgbcolor *c1, const struct rgbcolor *c2)
Test whether two rgbcolor structures represent the exact same color value.
bool rgbcolor_to_hex(const struct rgbcolor *prgbcolor, char *hex, size_t hex_len)
Convert a rgb color to a hex string (like 0xff0000 for red [255, 0, 0]).
#define rgbcolor_list_iterate_end
#define rgbcolor_list_iterate(rgbcolorlist, prgbcolor)
void script_server_signal_emit(const char *signal_name,...)
Invoke all the callback functions attached to a given signal.
void script_server_remove_exported_object(void *object)
Mark any, if exported, full userdata representing 'object' in the current script state as 'Nonexisten...
void array_shuffle(int *array, int n)
Randomize the elements of an array using the Fisher-Yates shuffle.
bool is_ascii_name(const char *name)
This is used in sundry places to make sure that names of cities, players etc.
void remove_leading_trailing_spaces(char *s)
Removes leading and trailing spaces in string pointed to by 's'.
#define CLIP(lower, current, upper)
void send_spaceship_info(struct player *src, struct conn_list *dest)
Send details of src's spaceship (or spaceships of all players if src is nullptr) to specified destina...
void spaceship_init(struct player_spaceship *ship)
Initialize spaceship struct; could also be used to "cancel" a spaceship (eg, if/when capital-capture ...
void check_for_full_turn_done()
Check if turn is really done.
void player_nation_defaults(struct player *pplayer, struct nation_type *pnation, bool set_name)
Set nation for player with nation default values.
bool game_was_started()
Returns iff the game was started once upon a time.
enum server_states server_state()
Return current server state.
void set_ai_level_direct(struct player *pplayer, enum ai_level level)
Set an AI level from the server prompt.
enum capital_type capital
struct civ_game::@28::@32 server
struct packet_ruleset_control control
struct conn_list * est_connections
struct packet_game_info info
struct packet_scenario_info scenario
struct government * government_during_revolution
enum cmdlevel access_level
char username[MAX_LEN_NAME]
government()
Allocate resources associated with the given government.
Functions for handling the nations.
struct nation_type::@48::@50 server
enum barbarian_type barb_type
enum ai_level skill_level
enum barbarian_type barbarian_type
int love[MAX_NUM_PLAYER_SLOTS]
struct city_list * cities
struct player_ai ai_common
struct government * target_government
char username[MAX_LEN_NAME]
struct player::@65::@67 server
struct government * government
struct connection * current_conn
char * savegame_ai_type_name
const struct ai_type * ai
struct conn_list * connections
struct player_economic economic
struct player_spaceship spaceship
bv_player gives_shared_vision
struct player_score score
int multipliers[MAX_NUM_MULTIPLIERS]
struct nation_type * nation
struct nation_style * style
int multipliers_target[MAX_NUM_MULTIPLIERS]
struct player_slot * slot
int bulbs_researched_saved
Tech_type_id researching_saved
struct research::research_invention inventions[A_LAST]
struct player * extras_owner
struct music_style * player_music_style(struct player *plr)
Return music style for player.
int music_style_number(const struct music_style *pms)
Return the music style id.
int style_number(const struct nation_style *pstyle)
Return the style id.
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
size_t fc_strlcpy(char *dest, const char *src, size_t n)
fc_strlcpy() provides utf-8 version of (non-standard) function strlcpy() It is intended as more user-...
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
int cat_snprintf(char *str, size_t n, const char *format,...)
cat_snprintf is like a combination of fc_snprintf and fc_strlcat; it does snprintf to the end of an e...
#define sz_strlcpy(dest, src)
void team_add_player(struct player *pplayer, struct team *pteam)
Set a player to a team.
int team_count()
Return the current number of teams.
int team_number(const struct team *pteam)
Return the team index/number/id.
const struct player_list * team_members(const struct team *pteam)
Returns the member list of the team.
#define advance_index_iterate_end
#define advance_index_iterate(_start, _index)
bool tile_has_claimable_base(const struct tile *ptile, const struct unit_type *punittype)
Check if tile contains base providing effect for unit.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_owner(_tile)
#define trade_routes_iterate_safe_end
#define trade_routes_iterate_safe(c, proute)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.
void send_updated_vote_totals(struct conn_list *dest)
Sends a packet_vote_update to every conn in dest.