108 #define SPECLIST_TAG cityimpr
109 #define SPECLIST_TYPE struct cityimpr
112 #define cityimpr_list_iterate(cityimprlist, pcityimpr) \
113 TYPED_LIST_ITERATE(struct cityimpr, cityimprlist, pcityimpr)
114 #define cityimpr_list_iterate_end LIST_ITERATE_END
117 struct cityimpr_list *imprs);
119 struct unit_list *punitlist);
139 struct city *pcity_to);
151 pcity->
server.needs_refresh =
false;
197 pcity->
server.needs_refresh =
true;
212 if (pcity->server.needs_refresh) {
242 PL_(
"%s is selling %s (obsolete) for %d.",
243 "%s is selling %s (obsolete) for %d.", sgold),
251 if (sold && refresh) {
277 const std::unique_ptr<cm_result> &cmr)
287 if (cmr->worker_positions[idx]) {
288 if (
nullptr == pwork) {
294 if (pwork == pcity) {
314 cmp->require_happy =
false;
315 cmp->allow_disorder =
false;
316 cmp->allow_specialists =
true;
342 cmp->happy_factor = 0;
365 if (pcity->
server.workers_frozen > 0) {
366 pcity->
server.needs_arrange =
true;
375 pcity->
server.needs_arrange =
false;
379 pcity->
server.needs_arrange =
false;
400 if (!cmr->found_a_valid) {
408 _(
"The citizen governor can't fulfill the requirements "
409 "for %s. Passing back control."),
418 if (!cmr->found_a_valid) {
424 cmp.minimal_surplus[o] =
428 cmp.require_happy =
false;
432 if (!cmr->found_a_valid) {
441 if (pcity->
server.debug) {
448 qCritical(
"%s radius changed when already arranged workers.",
465 const struct impr_type *pimprove = pcity->production.value.building;
467 if (VUT_IMPROVEMENT == pcity->production.kind
472 _(
"Notice: Wonder %s in %s will be finished next turn."),
484 struct conn_list *dest,
485 const struct player *cache_for_player)
488 struct packet_chat_msg packet;
489 int turns_growth, turns_granary;
506 if (5 > turns_growth && 5 > turns_granary
507 && turns_growth < turns_granary) {
510 _(
"Suggest throttling growth in %s to use %s "
511 "(being built) more effectively."),
513 lsend_packet_chat_msg(dest, &packet);
514 if (
nullptr != cache_for_player) {
525 lsend_packet_chat_msg(dest, &packet);
526 if (
nullptr != cache_for_player) {
536 lsend_packet_chat_msg(dest, &packet);
537 if (
nullptr != cache_for_player) {
550 if (
nullptr != pconn) {
553 if (
nullptr != pplayer) {
597 n = city_list_size(pplayer->
cities);
599 pplayer->
server.bulbs_last_turn = 0;
604 int nation_unit_upkeep = 0;
605 int nation_impr_upkeep = 0;
616 if (tcity !=
nullptr) {
619 if (proute->dir != RDIR_FROM
688 switch (
game.
info.gold_upkeep_style) {
689 case GOLD_UPKEEP_CITY:
692 case GOLD_UPKEEP_MIXED:
699 case GOLD_UPKEEP_NATION:
718 _(
"WARNING, we're LOW on FUNDS %s."),
738 enum unit_loss_reason wipe_reason,
739 bool wipe_in_the_end)
750 punit_id = punit->
id;
784 return change - want;
799 ptile, _index, _x, _y)
808 return change - want;
816 struct player *destroyer,
const char *reason)
844 if (loss_remain > 0) {
862 "city_reduce_size() has remaining"
863 "%d of %d for \"%s\"[%d]",
880 if (reason !=
nullptr) {
899 }
else if (change < 0) {
907 "city_repair_size() has remaining %d of %d for \"%s\"[%d]",
925 return CLIP(0, savings, 100);
937 return CLIP(0, savings, 100);
950 const int surplus_food = std::max(
952 const int saved_surplus = (surplus_food *
surplus_savings(pcity)) / 100;
954 const int saved_by_granary =
957 std::min(saved_by_granary + saved_surplus, new_granary_size);
966 struct player *nationality)
970 bool have_square =
false;
974 int saved_id = pcity->
id;
984 _(
"%s needs %s (being built) to grow beyond size %d."),
989 _(
"%s needs an improvement to grow beyond size %d."),
995 * (100 * 100 -
game.
server.aqueductloss * (100 - savings_pct))
1009 ptile, _index, _x, _y)
1068 struct player *nationality,
const char *reason)
1084 if (real_change != 0 && reason !=
nullptr) {
1094 }
else if (change < 0) {
1112 int saved_id = pcity->
id;
1124 _(
"A recent plague outbreak prevents growth in %s."),
1148 if (punit->upkeep[
O_FOOD] > 0) {
1155 _(
"Famine feared in %s, %s lost!"),
city_link(pcity),
1168 ftc_server,
_(
"Famine causes population loss in %s."),
1191 const void *ptarget;
1192 const char *tgt_name;
1193 const struct requirement_vector *build_reqs;
1194 const char *signal_name;
1199 switch (target->
kind) {
1205 signal_name =
"unit_cant_be_built";
1207 case VUT_IMPROVEMENT:
1211 pcity,
static_cast<const impr_type *
>(ptarget));
1212 signal_name =
"building_cant_be_built";
1216 (target->
kind == VUT_IMPROVEMENT || target->
kind == VUT_UTYPE),
1224 if (!
is_req_active(pplayer,
nullptr, pcity,
nullptr,
nullptr,
nullptr,
1225 nullptr,
nullptr,
nullptr,
nullptr, preq,
1228 switch (preq->source.kind) {
1230 if (preq->present) {
1233 _(
"%s can't build %s from the worklist; "
1234 "tech %s not yet available. Postponing..."),
1245 if (preq->present) {
1248 _(
"%s can't build %s from the worklist; "
1249 "no tech with flag \"%s\" yet available. "
1252 tech_flag_id_name(tech_flag_id(preq->source.value.techflag)));
1260 case VUT_IMPROVEMENT:
1261 if (preq->present) {
1264 _(
"%s can't build %s from the worklist; "
1265 "need to have %s first. Postponing..."),
1268 pcity, preq->source.value.building));
1274 _(
"%s can't build %s from the worklist; "
1275 "need to not have %s. Postponing..."),
1278 pcity, preq->source.value.building));
1283 case VUT_IMPR_GENUS:
1284 if (preq->present) {
1287 _(
"%s can't build %s from the worklist; "
1288 "need to have %s first. Postponing..."),
1290 impr_genus_id_translated_name(preq->source.value.impr_genus));
1292 "need_building_genus");
1296 _(
"%s can't build %s from the worklist; "
1297 "need to not have %s. Postponing..."),
1299 impr_genus_id_translated_name(preq->source.value.impr_genus));
1301 "have_building_genus");
1304 case VUT_GOVERNMENT:
1305 if (preq->present) {
1308 _(
"%s can't build %s from the worklist; "
1309 "it needs %s government. Postponing..."),
1317 _(
"%s can't build %s from the worklist; "
1318 "it cannot have %s government. Postponing..."),
1325 case VUT_ACHIEVEMENT:
1326 if (preq->present) {
1329 _(
"%s can't build %s from the worklist; "
1330 "it needs \"%s\" achievement. Postponing..."),
1334 "need_achievement");
1341 if (preq->present) {
1344 Q_(
"?extra:%s can't build %s from the worklist; "
1345 "%s is required. Postponing..."),
1353 Q_(
"?extra:%s can't build %s from the worklist; "
1354 "%s is prohibited. Postponing..."),
1362 if (preq->present) {
1365 Q_(
"?extra:%s can't build %s from the worklist; "
1366 "%s is required. Postponing..."),
1374 Q_(
"?extra:%s can't build %s from the worklist; "
1375 "%s is prohibited. Postponing..."),
1383 if (preq->present) {
1386 Q_(
"?terrain:%s can't build %s from the worklist; "
1387 "%s terrain is required. Postponing..."),
1395 Q_(
"?terrain:%s can't build %s from the worklist; "
1396 "%s terrain is prohibited. Postponing..."),
1405 if (preq->present) {
1409 Q_(
"?nation:%s can't build %s from the worklist; "
1410 "%s nation is required. Postponing..."),
1418 Q_(
"?nation:%s can't build %s from the worklist; "
1419 "%s nation is prohibited. Postponing..."),
1426 case VUT_NATIONGROUP:
1429 if (preq->present) {
1433 Q_(
"?ngroup:%s can't build %s from the worklist; "
1434 "%s nation is required. Postponing..."),
1438 "need_nationgroup");
1442 Q_(
"?ngroup:%s can't build %s from the worklist; "
1443 "%s nation is prohibited. Postponing..."),
1447 "have_nationgroup");
1454 if (preq->present) {
1457 _(
"%s can't build %s from the worklist; "
1458 "only %s style cities may build this. Postponing..."),
1466 _(
"%s can't build %s from the worklist; "
1467 "%s style cities may not build this. Postponing..."),
1474 case VUT_NATIONALITY:
1477 if (preq->present) {
1481 _(
"%s can't build %s from the worklist; "
1482 "only city with %s may build this. Postponing..."),
1486 "need_nationality");
1491 _(
"%s can't build %s from the worklist; "
1492 "only city without %s may build this. Postponing..."),
1496 "have_nationality");
1500 if (preq->present) {
1506 _(
"%s can't build %s from the worklist; "
1507 "the relationship '%s' is required."
1516 _(
"%s can't build %s from the worklist; "
1517 "the relationship '%s' is prohibited."
1526 if (preq->present) {
1529 _(
"%s can't build %s from the worklist; "
1530 "city must be of size %d or larger. "
1532 city_link(pcity), tgt_name, preq->source.value.minsize);
1538 _(
"%s can't build %s from the worklist; "
1539 "city must be of size %d or smaller."
1541 city_link(pcity), tgt_name, (preq->source.value.minsize - 1));
1546 case VUT_MINCULTURE:
1547 if (preq->present) {
1550 _(
"%s can't build %s from the worklist; "
1551 "city must have culture of %d. Postponing..."),
1552 city_link(pcity), tgt_name, preq->source.value.minculture);
1560 case VUT_MINFOREIGNPCT:
1561 if (preq->present) {
1564 _(
"%s can't build %s from the worklist; "
1565 "city must have %d%% foreign population. Postponing..."),
1566 city_link(pcity), tgt_name, preq->source.value.minforeignpct);
1568 "need_minforeignpct");
1572 _(
"%s can't build %s from the worklist; "
1573 "city must have %d%% native population. Postponing..."),
1575 100 - preq->source.value.minforeignpct);
1577 "need_minforeignpct");
1581 if (preq->present) {
1584 _(
"%s can't build %s from the worklist; "
1585 "%d techs must be known. Postponing..."),
1586 city_link(pcity), tgt_name, preq->source.value.min_techs);
1593 case VUT_MAXTILEUNITS:
1594 if (preq->present) {
1597 PL_(
"%s can't build %s from the worklist; "
1598 "more than %d unit on tile."
1600 "%s can't build %s from the worklist; "
1601 "more than %d units on tile."
1603 preq->source.value.max_tile_units),
1604 city_link(pcity), tgt_name, preq->source.value.max_tile_units);
1610 PL_(
"%s can't build %s from the worklist; "
1611 "fewer than %d unit on tile."
1613 "%s can't build %s from the worklist; "
1614 "fewer than %d units on tile."
1616 preq->source.value.max_tile_units + 1),
1618 preq->source.value.max_tile_units + 1);
1627 case VUT_TERRAINCLASS:
1628 if (preq->present) {
1631 Q_(
"?terrainclass:%s can't build %s from the "
1632 "worklist; %s terrain is required."
1636 terrain_class(preq->source.value.terrainclass)));
1638 "need_terrainclass");
1642 Q_(
"?terrainclass:%s can't build %s from the "
1643 "worklist; %s terrain is prohibited."
1647 terrain_class(preq->source.value.terrainclass)));
1649 "have_terrainclass");
1653 if (preq->present) {
1656 _(
"%s can't build %s from the worklist; "
1657 "terrain with \"%s\" flag is required. "
1660 terrain_flag_id_name(terrain_flag_id(
1661 preq->source.value.terrainflag)));
1663 "need_terrainflag");
1667 _(
"%s can't build %s from the worklist; "
1668 "terrain with \"%s\" flag is prohibited. "
1671 terrain_flag_id_name(terrain_flag_id(
1672 preq->source.value.terrainflag)));
1674 "have_terrainflag");
1678 if (preq->present) {
1681 _(
"%s can't build %s from the worklist; "
1682 "base with \"%s\" flag is required. "
1685 base_flag_id_name(base_flag_id(preq->source.value.baseflag)));
1691 _(
"%s can't build %s from the worklist; "
1692 "base with \"%s\" flag is prohibited. "
1695 base_flag_id_name(base_flag_id(preq->source.value.baseflag)));
1701 if (preq->present) {
1704 _(
"%s can't build %s from the worklist; "
1705 "road with \"%s\" flag is required. "
1708 road_flag_id_name(road_flag_id(preq->source.value.roadflag)));
1714 _(
"%s can't build %s from the worklist; "
1715 "road with \"%s\" flag is prohibited. "
1718 road_flag_id_name(road_flag_id(preq->source.value.roadflag)));
1724 if (preq->present) {
1727 _(
"%s can't build %s from the worklist; "
1728 "extra with \"%s\" flag is required. "
1731 extra_flag_id_translated_name(
1732 extra_flag_id(preq->source.value.extraflag)));
1738 _(
"%s can't build %s from the worklist; "
1739 "extra with \"%s\" flag is prohibited. "
1742 extra_flag_id_translated_name(
1743 extra_flag_id(preq->source.value.extraflag)));
1752 case VUT_MINVETERAN:
1759 case VUT_SPECIALIST:
1760 case VUT_TERRAINALTER:
1762 case VUT_CITYSTATUS:
1763 case VUT_VISIONLAYER:
1766 qCritical(
"worklist_change_build_target() has bogus preq");
1769 if (preq->present) {
1773 _(
"%s can't build %s from the worklist; "
1774 "only available from %s. Postponing..."),
1776 textyear(preq->source.value.minyear));
1784 case VUT_MINCALFRAG:
1787 if (preq->present) {
1792 _(
"%s can't build %s from the worklist; "
1793 "only available from %s. Postponing..."),
1804 _(
"%s can't build %s from the worklist; "
1805 "not available after %s. Postponing..."),
1813 if (preq->present) {
1818 _(
"%s can't build %s from the worklist; "
1819 "only available in worlds with %s map."),
1821 _(topo_flag_name(preq->source.value.topo_property)));
1827 case VUT_SERVERSETTING:
1835 _(
"%s can't build %s from the worklist; "
1836 "only available when the server setting "
1840 preq->source.value.ssetval, preq->present)));
1847 if (preq->present) {
1850 _(
"%s can't build %s from the worklist; "
1851 "only available once %d turns old. Postponing..."),
1852 city_link(pcity), tgt_name, preq->source.value.age);
1862 "worklist_change_build_target() "
1863 "called with invalid preq");
1884 _(
"%s can't build %s from the worklist; "
1885 "reason unknown! Postponing..."),
1902 bool success =
false;
1904 int saved_id = pcity->
id;
1916 if (!city_checked) {
1922 city_checked =
true;
1936 switch (target.
kind) {
1952 _(
"%s can't build %s from the worklist; "
1953 "tech %s not yet available. Postponing..."),
1963 city_checked =
false;
1974 _(
"%s can't build %s from the worklist. Purging..."),
1983 city_checked =
true;
1988 city_checked =
false;
1993 _(
"Production of %s is upgraded to %s in %s."),
2000 case VUT_IMPROVEMENT: {
2023 city_checked =
true;
2025 }
else if (success) {
2028 _(
"Production of %s is upgraded to %s in %s."),
2039 _(
"%s can't build %s from the worklist. Purging..."),
2045 city_checked =
true;
2050 city_checked =
false;
2057 qCritical(
"worklist_change_build_target() has unrecognized "
2078 _(
"The %s worklist is now empty."),
city_link(pcity));
2110 case VUT_IMPROVEMENT:
2126 log_debug(
"Trying advisor_choose_build.");
2128 log_debug(
"Advisor_choose_build didn't kill us.");
2139 const struct impr_type *check = pimprove;
2140 const struct impr_type *best_upgrade =
nullptr;
2147 best_upgrade = check;
2151 return best_upgrade;
2164 ftc_server,
_(
"Production of %s is upgraded to %s in %s."),
2183 const struct unit_type *check = punittype;
2191 best_upgrade = check;
2195 return best_upgrade;
2208 ftc_server,
_(
"Production of %s is upgraded to %s in %s."),
2240 if (
upkeep > 0 && surplus < 0) {
2241 const char *punit_link =
unit_link(punit);
2249 ftc_server,
_(
"%s can't upkeep %s, unit disbanded."),
2269 if (
upkeep > 0 && surplus < 0) {
2272 _(
"Citizens in %s perish for their failure to "
2321 int saved_id = pcity->
id;
2337 _(
"%s is building %s, which is no longer available."),
2384 _(
"The %s have finished building %s in %s."),
2391 _(
"%s has finished building %s."),
city_link(pcity),
2412 PL_(
"%s boosts research; you gain %d immediate "
2414 "%s boosts research; you gain %d immediate "
2420 for (i = 0; i < mod; i++) {
2428 Q_(
"?frombldg:Acquired %s from %s."),
2429 qUtf8Printable(adv_name), provider);
2432 presearch,
nullptr, E_TECH_EMBASSY,
ftc_server,
2435 Q_(
"?frombldg:The %s have acquired %s "
2437 research_name, qUtf8Printable(adv_name), provider);
2442 _(
"The %s have started building a spaceship!"),
2481 saved_unit_id = punit->
id;
2519 int unit_shield_cost, num_units, i;
2520 int saved_city_id = pcity->
id;
2541 _(
"%s is building %s, which is no longer available."),
2545 qDebug(
"%s %s tried to build %s, which is not available.",
2566 _(
"%s can't build %s yet. "
2567 "(city size: %d, unit population cost: %d)"),
2585 for (i = 0; i < num_units; i++) {
2599 _(
"%s is finished building %s."),
city_link(pcity),
2625 PL_(
"%s cost %d population. %s shrinks to size %d.",
2626 "%s cost %d population. %s shrinks to size %d.", pop_cost),
2669 case VUT_IMPROVEMENT:
2692 struct cityimpr_list *imprs)
2699 if (!imprs || cityimpr_list_size(imprs) == 0) {
2703 r =
fc_rand(cityimpr_list_size(imprs));
2704 pcityimpr = cityimpr_list_get(imprs, r);
2708 _(
"Can't afford to maintain %s in %s, building sold!"),
2717 cityimpr_list_remove(imprs, pcityimpr);
2726 pcityimpr =
nullptr;
2753 unit_owner(punit)->economic.gold += gold_upkeep;
2783 unit_list_destroy(punitlist);
2797 struct unit_list *punitlist)
2801 struct unit_list *cargo;
2805 if (!punitlist || unit_list_size(punitlist) == 0) {
2809 r =
fc_rand(unit_list_size(punitlist));
2810 punit = unit_list_get(punitlist, r);
2812 cargo = unit_list_new();
2823 if (pcargo->server.upkeep_payed[
O_GOLD] > 0) {
2827 unit_list_append(cargo, pcargo);
2835 if (unit_list_size(cargo) > 0) {
2841 unit_list_destroy(cargo);
2846 unit_list_destroy(cargo);
2850 #ifdef FREECIV_DEBUG
2857 unit_list_remove(punitlist, punit);
2863 _(
"Not enough gold. %s disbanded."), punit_link);
2880 struct cityimpr_list *pimprlist;
2881 bool sell_unit =
true;
2887 pimprlist = cityimpr_list_new();
2898 ci->pimprove = pimprove;
2899 cityimpr_list_append(pimprlist, ci);
2906 if (punit->server.upkeep_payed[
O_GOLD] > 0) {
2915 && (cityimpr_list_size(pimprlist) > 0
2917 if ((!sell_unit && cityimpr_list_size(pimprlist) > 0)
2923 sell_unit = !sell_unit;
2937 fc_assert_msg(
false,
"Player %s (nb %d) cannot have negative gold!",
2941 cityimpr_list_destroy(pimprlist);
2962 if (punit->server.upkeep_payed[
O_GOLD] > 0) {
2978 fc_assert_msg(
false,
"Player %s (nb %d) cannot have negative gold!",
2993 struct cityimpr_list *pimprlist;
3000 pimprlist = cityimpr_list_new();
3009 ci->pimprove = pimprove;
3010 cityimpr_list_append(pimprlist, ci);
3029 cityimpr_list_destroy(pimprlist);
3056 if (punit->server.upkeep_payed[
O_GOLD] > 0) {
3167 if (!
game.
info.citizen_nationality) {
3172 cost = cost * 2 / 3;
3199 cost = cost / (dist + 3);
3201 if (
game.
info.citizen_nationality) {
3202 int cost_per_citizen = cost / pcity->
size;
3205 int third_party = pcity->
size - natives - tgt_cit;
3207 cost = cost_per_citizen * (natives + 0.7 * third_party + 0.5 * tgt_cit);
3210 cost += (cost *
get_city_bonus(pcity, EFT_INCITE_COST_PCT)) / 100;
3236 log_debug(
"In %s, building %s. Beg of Turn shields = %d",
3285 int revolution_turns =
get_city_bonus(pcity, EFT_REVOLUTION_UNHAPPINESS);
3288 const char *revomsg;
3291 if (pcity->
anarchy == revolution_turns) {
3295 revomsg =
_(
" Unrest threatens to spread beyond the city.");
3302 _(
"Civil disorder in %s.%s"),
city_link(pcity), revomsg);
3307 _(
"CIVIL DISORDER CONTINUES in %s.%s"),
city_link(pcity),
3314 _(
"Order restored in %s."),
city_link(pcity));
3319 if (revolution_turns > 0 && pcity->
anarchy > revolution_turns) {
3322 _(
"The people have overthrown your %s, "
3323 "your country is in turmoil."),
3364 _(
"Celebrations in your honor in %s."),
3370 _(
"Celebrations canceled in %s."),
city_link(pcity));
3405 punit->server.upkeep_payed[
O_GOLD] = punit->upkeep[
O_GOLD];
3417 switch (
game.
info.gold_upkeep_style) {
3418 case GOLD_UPKEEP_CITY:
3424 case GOLD_UPKEEP_MIXED:
3429 case GOLD_UPKEEP_NATION:
3459 saved_id = pcity->
id;
3497 struct city *rcity =
nullptr;
3500 int saved_id = pcity->
id;
3509 _(
"%s can't build %s yet, "
3510 "as we can't disband our only city."),
3605 int build_shield_cost = 0;
3606 bool has_wonder =
false;
3614 return pcity->
server.migration_score;
3637 + (1 - exp(-
static_cast<float> MAX(0, build_shield_cost) / 1000))
3683 score *= (1.0 +
get_city_bonus(pcity, EFT_MIGRATION_PCT) / 100.0);
3688 pcity->
server.migration_score = score;
3703 struct player *pplayer_from, *pplayer_to, *pplayer_citizen;
3704 struct tile *ptile_from, *ptile_to;
3706 const char *nation_from, *nation_to;
3707 struct city *rcity =
nullptr;
3711 if (!pcity_from || !pcity_to) {
3714 to_id = pcity_to->
id;
3716 pplayer_citizen = pplayer_from;
3728 bool migration =
false;
3736 int max_food_tile = -1;
3750 if (max_food_tile >= 0
3759 if (pplayer_from == pplayer_to) {
3763 _(
"Migrants from %s can't go to %s because there is "
3764 "not enough food available!"),
3765 name_from, name_to);
3769 pplayer_from, ptile_to, E_CITY_TRANSFER,
ftc_server,
3771 _(
"Migrants from %s can't go to %s (%s) because there "
3772 "is not enough food available!"),
3773 name_from, name_to, nation_to);
3775 pplayer_to, ptile_to, E_CITY_TRANSFER,
ftc_server,
3777 _(
"Migrants from %s (%s) can't go to %s because there "
3778 "is not enough food available!"),
3779 name_from, nation_from, name_to);
3788 if (pplayer_from == pplayer_to) {
3792 _(
"Migrants from %s can't go to %s because it needs "
3793 "an improvement to grow!"),
3794 name_from, name_to);
3798 pplayer_from, ptile_to, E_CITY_TRANSFER,
ftc_server,
3800 _(
"Migrants from %s can't go to %s (%s) because it "
3801 "needs an improvement to grow!"),
3802 name_from, name_to, nation_to);
3804 pplayer_to, ptile_to, E_CITY_TRANSFER,
ftc_server,
3806 _(
"Migrants from %s (%s) can't go to %s because it "
3807 "needs an improvement to grow!"),
3808 name_from, nation_from, name_to);
3816 if (
game.
info.citizen_nationality) {
3832 false,
false,
true,
false,
nullptr);
3835 int id = pcity_from->
id;
3848 pcity_from->
owner,
nullptr);
3856 _(
"%s was disbanded by its citizens."), name_from);
3866 if (
game.
info.citizen_nationality) {
3870 pplayer_citizen = pplayer_to;
3889 if (pplayer_from == pplayer_to) {
3893 _(
"Migrants from %s moved to %s in search of a better "
3895 name_from, name_to);
3899 pplayer_from, ptile_to, E_CITY_TRANSFER,
ftc_server,
3901 _(
"Migrants from %s moved to %s (%s) in search of a "
3903 name_from, name_to, nation_to);
3905 pplayer_to, ptile_to, E_CITY_TRANSFER,
ftc_server,
3907 _(
"Migrants from %s (%s) moved to %s in search of a "
3909 name_from, nation_from, name_to);
3928 name_from, name_to);
3956 bool internat =
false;
3971 if (!pplayer->cities) {
4000 _(
"All stored food destroyed in %s."),
city_link(pcity));
4015 bool had_internal_effect =
false;
4028 had_internal_effect =
true;
4036 had_internal_effect =
true;
4045 _(
"%s destroys %s entirely."),
4051 _(
"%s causes population loss in %s."),
4055 had_internal_effect =
true;
4066 imprs[total++] = pimprove;
4082 had_internal_effect =
true;
4088 had_internal_effect =
true;
4102 _(
"Production of %s in %s destroyed."), prod,
4105 had_internal_effect =
true;
4110 had_internal_effect);
4135 int probability =
game.
info.disasters * pdis->frequency;
4138 if (result < probability) {
4163 float best_city_player_score, best_city_world_score;
4164 struct city *best_city_player, *best_city_world, *acity;
4165 float score_from, score_tmp, weight;
4167 bool internat =
false;
4182 if (
game.
info.turn == pcity->turn_founded
4183 || ((
game.
info.turn - pcity->turn_founded)
4189 best_city_player_score = 0.0;
4190 best_city_world_score = 0.0;
4191 best_city_player =
nullptr;
4192 best_city_world =
nullptr;
4208 if (!acity || acity == pcity) {
4217 mgr_dist =
static_cast<int>(sqrt(
static_cast<double> MAX(
4224 if (dist > mgr_dist) {
4230 weight = (
static_cast<float>(mgr_dist + 1 - dist)
4231 /
static_cast<float>(mgr_dist + 1));
4234 log_debug(
"[M] T%d - compare city: %s (%s) dist: %d mgr_dist: %d "
4241 if (score_tmp > score_from && score_tmp > best_city_player_score) {
4243 best_city_player_score = score_tmp;
4244 best_city_player = acity;
4246 log_debug(
"[M] T%d - best city (player): %s (%s) score: "
4255 if (
game.
info.citizen_nationality) {
4263 if (score_tmp > score_from && score_tmp > best_city_world_score) {
4265 best_city_world_score = score_tmp;
4266 best_city_world = acity;
4268 log_debug(
"[M] T%d - best city (world): %s (%s) score: "
4272 best_city_world_score, score_from);
4278 if (best_city_player_score > 0) {
4285 _(
"Citizens of %s are thinking about migrating to %s "
4286 "for a better life."),
4287 city_link_text,
city_link(best_city_player));
4296 if (best_city_world_score > 0) {
4308 _(
"Citizens of %s are thinking about migrating to %s "
4309 "(%s) for a better life."),
4310 city_link_text,
city_link(best_city_world), nname);
const char * achievement_name_translation(struct achievement *pach)
Return translated name of this achievement type.
void advisor_choose_build(struct player *pplayer, struct city *pcity)
Setup improvement building.
int tile_border_source_radius_sq(struct tile *ptile)
Border radius sq from given border source tile.
const char * textcalfrag(int frag)
Produce a statically allocated textual representation of the given calendar fragment.
const char * textyear(int year)
Produce a statically allocated textual representation of the given year.
void citizens_nation_add(struct city *pcity, const struct player_slot *pslot, int add)
Add a (positive or negative) value to the citizens of the given nationality.
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
Get the number of citizens with the given nationality.
struct player_slot * citizens_random(const struct city *pcity)
Return random citizen from city.
void citizens_convert(struct city *pcity)
Convert one (random) foreign citizen to the nationality of the owner.
void citizens_update(struct city *pcity, struct player *plr)
struct output_type * get_output_type(Output_type_id output)
Return the output type for this index.
bool can_city_build_unit_later(const struct city *pcity, const struct unit_type *punittype)
Returns whether player can eventually build given unit in the city; returns FALSE if unit can never p...
int city_granary_size(int city_size)
Generalized formula used to calculate granary size.
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Returns whether city can immediately build given target, unit or improvement.
struct city * city_list_find_number(struct city_list *This, int id)
Find city with given id from list.
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Return TRUE iff the city has this building in it.
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.
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Removes an improvement (and its effects) from a city.
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Return the upkeep (gold) needed each turn to upkeep the given improvement in the given city.
int city_airlift_max(const struct city *pcity)
A city's maximum airlift capacity.
bool is_city_option_set(const struct city *pcity, enum city_options option)
Returns TRUE iff the city has set the given option.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
void city_size_add(struct city *pcity, int add)
Add a (positive or negative) value to the city size.
bool city_production_has_flag(const struct city *pcity, enum impr_flag_id flag)
Return TRUE when the current production has this flag.
struct tile * city_map_to_tile(const struct tile *city_center, int city_radius_sq, int city_map_x, int city_map_y)
Finds the map position for a given city map coordinate of a certain city.
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
How many veteran levels will created unit of this type get?
bool can_city_build_improvement_now(const struct city *pcity, const struct impr_type *pimprove)
Return whether given city can build given building; returns FALSE if the building is obsolete.
bool city_tile_index_to_xy(int *city_map_x, int *city_map_y, int city_tile_index, int city_radius_sq)
Returns the coordinates for the given city tile index taking into account the squared city radius.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
bool city_rapture_grow(const struct city *pcity)
Returns whether city is growing by rapture.
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
Calculates the turns which are needed to build the requested production in the city.
bool city_unhappy(const struct city *pcity)
Return TRUE iff the city is unhappy.
Specialist_type_id best_specialist(Output_type_id otype, const struct city *pcity)
Return the "best" specialist available in the game.
bool city_celebrating(const struct city *pcity)
cities celebrate only after consecutive happy turns
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Return the extended name of the building.
bool can_city_build_improvement_direct(const struct city *pcity, const struct impr_type *pimprove)
Return whether given city can build given building, ignoring whether it is obsolete.
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Calculate city's illness in tenth of percent:
bool city_can_grow_to(const struct city *pcity, int pop_size)
Return TRUE iff the city can grow to the given size.
bool city_happy(const struct city *pcity)
Return TRUE iff the city is happy.
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
Adds an improvement (and its effects) to a city.
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
static int cmp(int v1, int v2)
Compare two integer values, as required by qsort.
int city_tile_output(const struct city *pcity, const struct tile *ptile, bool is_celebrating, Output_type_id otype)
Calculate the output for the tile.
void city_refresh_from_main_map(struct city *pcity, bool *workers_map, const std::vector< city * > &gov_centers, const std::array< cached_waste, O_LAST > *pcwaste, const std::vector< std::array< int, O_LAST >> *pcsoutputs)
Refreshes the internal cached data in the city structure.
int city_map_tiles(int city_radius_sq)
Return the number of tiles for the given city radius.
bool can_city_build_unit_direct(const struct city *pcity, const struct unit_type *punittype)
Return whether given city can build given unit, ignoring whether unit is obsolete.
bool city_exist(int id)
Check if city with given id still exist.
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
Returns TRUE when a tile is available to be worked, or the city itself is currently working the tile ...
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Return TRUE if the city could use the additional build slots provided by the effect City_Build_Slots.
citizens city_size_get(const struct city *pcity)
Get the city size.
bool can_city_build_improvement_later(const struct city *pcity, const struct impr_type *pimprove)
Return whether player can eventually build given building in the city; returns FALSE if improvement c...
bool city_had_recent_plague(const struct city *pcity)
Returns whether city had a plague outbreak this turn.
bool city_can_change_build(const struct city *pcity)
Returns TRUE iff the given city can change what it is building.
int city_total_unit_gold_upkeep(const struct city *pcity)
Get the total amount of gold needed to pay upkeep costs for all supported units of the city.
int city_total_impr_gold_upkeep(const struct city *pcity)
Returns the total amount of gold needed to pay for all buildings in the city.
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Return whether given city can build given unit; returns FALSE if unit is obsolete.
#define cities_iterate_end
#define city_list_iterate_safe(citylist, _city)
#define city_list_iterate(citylist, pcity)
#define cities_iterate(pcity)
#define city_tile_iterate(_radius_sq, _city_tile, _tile)
#define output_type_iterate(output)
#define INCITE_IMPOSSIBLE_COST
#define city_list_iterate_end
#define city_list_iterate_safe_end
#define city_tile_iterate_skip_center_end
#define city_tile_iterate_skip_center(_radius_sq, _city_tile, _tile, _index, _x, _y)
#define city_tile_iterate_end
#define CITY_MAP_MAX_RADIUS
#define city_built_iterate(_pcity, _p)
#define city_built_iterate_end
#define output_type_iterate_end
static bool city_illness_check(const struct city *pcity)
Check if city suffers from a plague.
static void uk_rem_gold_append(struct unit *punit)
Add a unit to uk_rem_gold and make the unit remove it self from it if it dies before it is processed.
static bool city_handle_disorder(struct city *pcity)
static bool worklist_change_build_target(struct player *pplayer, struct city *pcity)
Examine the worklist and change the build target.
void remove_obsolete_buildings(struct player *pplayer)
Sell obsolete buildings from all cities of the player.
static bool city_build_stuff(struct player *pplayer, struct city *pcity)
Returns FALSE when the city is removed, TRUE otherwise.
static void city_reset_foodbox(struct city *pcity, int new_size)
Reset the foodbox, usually when a city grows or shrinks.
static const struct unit_type * unit_upgrades_to(struct city *pcity, const struct unit_type *id)
Follow the list of obsoleted_by units until we hit something that we can build.
static void apply_disaster(struct city *pcity, struct disaster_type *pdis)
Disaster has hit a city.
static bool city_distribute_surplus_shields(struct player *pplayer, struct city *pcity)
Disband units if we don't have enough shields to support them.
static int surplus_savings(const struct city *pcity)
Return the percentage of the food surplus that is saved in this city.
static void unit_list_referred_destroy(struct unit_list *punitlist)
Destroy a unit list and make the units it contains aware that it no longer refers to them.
static bool place_pollution(struct city *pcity, enum extra_cause cause)
Add some Pollution if we have waste.
static bool city_handle_plague_risk(struct city *pcity)
void choose_build_target(struct player *pplayer, struct city *pcity)
Assuming we just finished building something, find something new to build.
static void uk_rem_gold_callback(struct unit *punit)
Call back for when a unit in uk_rem_gold dies.
void auto_arrange_workers(struct city *pcity)
Call sync_cities() to send the affected cities to the clients.
void city_refresh_queue_add(struct city *pcity)
Queue pending city_refresh() for later.
static struct unit_list * uk_rem_gold
static bool city_balance_treasury_buildings(struct city *pcity)
Balance the gold of one city by randomly selling some buildings.
static void update_city_activity(struct city *pcity)
Called every turn, at end of turn, for every city.
static void upgrade_unit_prod(struct city *pcity)
Try to upgrade production in pcity.
static float city_migration_score(struct city *pcity)
Helper function to calculate a "score" of a city.
void nullify_prechange_production(struct city *pcity)
Initialize all variables containing information about production before it was changed.
bool city_empty_food_stock(struct city *pcity)
Returns TRUE iff the city's food stock was emptied.
bool check_city_migrations()
Check for citizens who want to migrate between the cities that overlap.
static void upgrade_building_prod(struct city *pcity)
Try to upgrade production in pcity.
void apply_cmresult_to_city(struct city *pcity, const std::unique_ptr< cm_result > &cmr)
Rearrange workers according to a cm_result struct.
bool city_change_size(struct city *pcity, citizens size, struct player *nationality, const char *reason)
Change the city size.
static citizens city_reduce_specialists(struct city *pcity, citizens change)
Reduce the city specialists by some (positive) value.
static void city_global_turn_notify(struct conn_list *dest)
Notices about cities that should be sent to all players.
void city_refresh_queue_processing()
Refresh the listed cities.
static void city_populate(struct city *pcity, struct player *nationality)
Check whether the population can be increased or if the city is unable to support a 'settler'....
static void define_orig_production_values(struct city *pcity)
Called every turn, at beginning of turn, for every city.
void city_repair_size(struct city *pcity, int change)
Repair the city population without affecting city size.
#define cityimpr_list_iterate(cityimprlist, pcityimpr)
static bool upkeep_kill_unit(struct unit *punit, Output_type_id outp, enum unit_loss_reason wipe_reason, bool wipe_in_the_end)
Try to get rid of a unit because of missing upkeep.
static bool city_build_building(struct player *pplayer, struct city *pcity)
Returns FALSE when the city is removed, TRUE otherwise.
static const struct impr_type * building_upgrades_to(struct city *pcity, const struct impr_type *pimprove)
Follow the list of replacement buildings until we hit something that we can build.
void send_city_turn_notifications(struct connection *pconn)
Send global and player specific city turn notifications.
static struct unit * sell_random_unit(struct player *pplayer, struct unit_list *punitlist)
Randomly "sell" a unit from the given list.
int city_incite_cost(struct player *pplayer, struct city *pcity)
Returns the cost to incite a city.
static struct unit * city_create_unit(struct city *pcity, const struct unit_type *utype)
Helper function to create one unit in a city.
static bool city_increase_size(struct city *pcity, struct player *nationality)
Increase city size by one.
static void nullify_caravan_and_disband_plus(struct city *pcity)
Let the advisor set up city building target.
static bool sell_random_building(struct player *pplayer, struct cityimpr_list *imprs)
Randomly sell a building from the given list.
static bool disband_city(struct city *pcity)
Disband a city into the built unit, supported by the closest city.
void update_city_activities(struct player *pplayer)
Update all cities of one nation (costs for buildings, unit upkeep, ...).
bool city_reduce_size(struct city *pcity, citizens pop_loss, struct player *destroyer, const char *reason)
Reduce the city size.
#define cityimpr_list_iterate_end
bool city_refresh(struct city *pcity)
Updates unit upkeeps and city internal cached data.
static void city_turn_notify(const struct city *pcity, struct conn_list *dest, const struct player *cache_for_player)
Send turn notifications for specified city to specified connections.
static void wonder_set_build_turn(struct player *pplayer, const struct impr_type *pimprove)
Record the build turn of a wonder.
void check_disasters()
Check for any disasters hitting any city, and apply those disasters.
void city_style_refresh(struct city *pcity)
Recheck and store style of the city.
static bool city_balance_treasury_units(struct city *pcity)
Balance the gold of one city by randomly selling some units which need gold upkeep.
static bool do_city_migration(struct city *pcity_from, struct city *pcity_to)
Do the migrations between the cities that overlap, if the growth of the target city is not blocked du...
void city_save_surpluses(struct city *pcity)
Save city surplus values for use during city processing.
static struct city_list * city_refresh_queue
void city_refresh_for_player(struct player *pplayer)
Called on government change or wonder completion or stuff like that – Syela.
static int granary_savings(const struct city *pcity)
Return the percentage of food that is lost in this city.
static void check_pollution(struct city *pcity)
Add some Pollution if we have waste.
static void set_default_city_manager(struct cm_parameter *cmp, struct city *pcity)
Set default city manager parameter for the city.
static citizens city_reduce_workers(struct city *pcity, citizens change)
Reduce the city workers by some (positive) value.
static bool worklist_item_postpone_req_vec(struct universal *target, struct city *pcity, struct player *pplayer, int saved_id)
Examine an unbuildable build target from a city's worklist to see if it can be postponed.
static bool player_balance_treasury_units_and_buildings(struct player *pplayer)
Balance the gold of a nation by selling some random units and buildings.
void remove_obsolete_buildings_city(struct city *pcity, bool refresh)
Automatically sells obsolete buildings from city.
static bool check_city_migrations_player(const struct player *pplayer)
Check for migration for each city of one player.
static bool city_build_unit(struct player *pplayer, struct city *pcity)
Build city units.
static bool player_balance_treasury_units(struct player *pplayer)
Balance the gold of a nation by selling some units which need gold upkeep.
void cm_copy_parameter(struct cm_parameter *dest, const struct cm_parameter *const src)
Copy the parameter from the source to the destination field.
void cm_init_parameter(struct cm_parameter *dest)
Initialize the parameter to sane default values.
void cm_query_result(struct city *pcity, const struct cm_parameter *param, std::unique_ptr< cm_result > &result, bool negative_ok)
Wrapper that actually runs the branch & bound, and returns the best solution.
std::unique_ptr< cm_result > cm_result_new(struct city *pcity)
Create a new cm_result.
void cm_init_emergency_parameter(struct cm_parameter *dest)
Initialize the parameter to sane default values that will always produce a result.
void cm_print_result(const std::unique_ptr< cm_result > &result)
Print debugging information about a full CM result.
void cm_print_city(const struct city *pcity)
Debugging routines.
void conn_list_do_unbuffer(struct conn_list *dest)
Convenience functions to unbuffer a list of connections.
struct player * conn_get_player(const struct connection *pconn)
Returns the player that this connection is attached to, or nullptr.
void conn_list_do_buffer(struct conn_list *dest)
Convenience functions to buffer a list of connections.
int city_culture(const struct city *pcity)
Return current culture score of the city.
int city_history_gain(const struct city *pcity)
How much history city gains this turn.
bool can_disaster_happen(const struct disaster_type *pdis, const struct city *pcity)
Whether disaster can happen in given city.
const char * disaster_rule_name(struct disaster_type *pdis)
Return untranslated name of this disaster type.
bool disaster_has_effect(const struct disaster_type *pdis, enum disaster_effect_id effect)
Check if disaster provides effect.
const char * disaster_name_translation(struct disaster_type *pdis)
Return translated name of this disaster type.
#define disaster_type_iterate(_p)
#define DISASTER_BASE_RARITY
#define disaster_type_iterate_end
int get_current_construction_bonus(const struct city *pcity, enum effect_type effect_type, const enum req_problem_type prob_type)
Returns the effect bonus the currently-in-construction-item will provide.
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
enum output_type_id Output_type_id
#define PL_(String1, String2, n)
const char * city_tile_link(const struct city *pcity)
Get a text link to a city tile (make a clickable link to a tile with the city name as text).
const char * unit_tile_link(const struct unit *punit)
Get a text link to a unit tile (make a clickable link to a tile with the unit type name as text).
const struct ft_color ftc_server
const char * city_link(const struct city *pcity)
Get a text link to a city.
const char * unit_link(const struct unit *punit)
Get a text link to an unit.
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
#define GAME_MAX_MGR_DISTANCE
struct government * government_of_city(const struct city *pcity)
Return the government of the player who owns the city.
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Return the ruler title of the player (translated).
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.
int impr_sell_gold(const struct impr_type *pimprove)
Returns the amount of gold received when this improvement is sold.
bool can_city_sell_building(const struct city *pcity, const struct impr_type *pimprove)
Return TRUE iff the city can sell the given improvement.
const char * improvement_rule_name(const struct impr_type *pimprove)
Return the (untranslated) rule name of the improvement.
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
Returns pointer when the improvement_type "exists" in this game, returns nullptr otherwise.
bool is_improvement(const struct impr_type *pimprove)
Is this building a regular improvement?
Impr_type_id improvement_number(const struct impr_type *pimprove)
Return the improvement index.
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
Returns the number of shields it takes to build this improvement.
bool is_wonder(const struct impr_type *pimprove)
Returns whether improvement is some kind of wonder.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
bool improvement_obsolete(const struct player *pplayer, const struct impr_type *pimprove, const struct city *pcity)
Returns TRUE if the improvement or wonder is obsolete.
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
Return TRUE if the impr has this flag otherwise FALSE.
const struct impr_type * improvement_replacement(const struct impr_type *pimprove)
Try to find a sensible replacement building, based on other buildings that may have caused this one t...
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
bool is_small_wonder(const struct impr_type *pimprove)
Is this building a small wonder?
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_msg(condition, message,...)
#define fc_assert_ret_val(condition, val)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
#define log_base(level, message,...)
#define fc_assert_ret_val_msg(condition, val, message,...)
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Return real distance between two tiles.
int map_distance(const struct tile *tile0, const struct tile *tile1)
Return Manhattan distance between two tiles.
#define iterate_outward(nmap, start_tile, max_dist, itr_tile)
#define iterate_outward_end
void map_update_border(struct tile *ptile, struct player *owner, int old_radius_sq, int new_radius_sq)
Update borders for this source.
void map_claim_border(struct tile *ptile, struct player *owner, int radius_sq)
Update borders for this source.
void update_tile_knowledge(struct tile *ptile)
Update playermap knowledge for everybody who sees the tile, and send a packet to everyone whose info ...
struct nation_type * nation_of_city(const struct city *pcity)
Return the nation of the player who owns the city.
const char * nation_group_name_translation(const struct nation_group *pgroup)
Return the translated name of a nation group.
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
const char * nation_adjective_translation(const struct nation_type *pnation)
Return the (translated) adjective for the given nation.
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
const char * nation_adjective_for_player(const struct player *pplayer)
Return the (translated) adjective for the given nation of a player.
const char * nation_plural_translation(const struct nation_type *pnation)
Return the (translated) plural noun of the given nation.
void notify_research(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
Sends a message to all players that share research.
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_research_embassies(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
Sends a message to all players that have embassies with someone who shares research.
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 package_event(struct packet_chat_msg *packet, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Fill a packet_chat_msg structure for common server event.
void event_cache_add_for_player(const struct packet_chat_msg *packet, const struct player *pplayer)
Add an event to the cache for one player.
struct city_list * cities
const char * diplrel_name_translation(int value)
Return the translated name of the given diplomatic relation.
int player_number(const struct player *pplayer)
Return the player index/number/id.
std::vector< city * > player_gov_centers(const struct player *pplayer)
Locate the player's government centers.
struct city * player_city_by_number(const struct player *pplayer, int city_id)
If the specified player owns the city with the specified id, return pointer to the city struct.
struct player * player_slot_get_player(const struct player_slot *pslot)
Returns the team corresponding to the slot.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
#define players_iterate_end
#define players_iterate(_pplayer)
static bool is_barbarian(const struct player *pplayer)
void send_player_info_c(struct player *src, struct conn_list *dest)
Send information about player slot 'src', or all valid (i.e.
void handle_player_change_government(struct player *pplayer, Government_type_id government)
Called by the client or AI to change government.
bool is_req_active(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, const struct requirement *req, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement to see if it is active on the given target.
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
Make user-friendly text for the source.
const char * universal_rule_name(const struct universal *psource)
Return the (untranslated) rule name of the universal.
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
QString research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Store the translated name of the given tech (including A_FUTURE) in 'buf'.
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
int research_pretty_name(const struct research *presearch, char *buf, size_t buf_len)
Set in 'buf' the name of the research owner.
#define sanity_check_city(x)
void script_server_signal_emit(const char *signal_name,...)
Invoke all the callback functions attached to a given signal.
QString ssetv_human_readable(ssetv val, bool present)
Returns the server setting - value pair formated in a user readable way.
static struct setting settings[]
#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...
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
#define DEFAULT_SPECIALIST
#define CITY_LOG(_, pcity, msg,...)
#define TIMING_LOG(timer, activity)
struct city::@14 rally_point
int saved_surplus[O_LAST]
int last_turns_shield_surplus
struct universal production
struct unit_order * orders
int before_change_shields
struct city::@15::@17 server
citizens feel[CITIZEN_LAST][FEELING_LAST]
citizens specialists[SP_MAX]
struct cm_parameter * cm_parameter
struct universal changed_from
struct unit_list * units_supported
struct impr_type * pimprove
struct civ_game::@28::@32 server
struct conn_list * est_connections
struct packet_game_info info
struct requirement_vector reqs
enum spaceship_state state
struct city_list * cities
struct player::@65::@67 server
int wonder_build_turn[B_LAST]
struct conn_list * connections
struct player_economic economic
struct player_spaceship spaceship
struct player_score score
struct player_slot * slot
struct requirement_vector build_reqs
const struct unit_type * obsoleted_by
struct advance * require_advance
struct unit::@76::@79 server
const struct unit_type * utype
int city_style(struct city *pcity)
Return citystyle of the city.
const char * style_name_translation(const struct nation_style *pstyle)
Return the (translated) name of the style.
#define sz_strlcpy(dest, src)
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
const char * advance_name_translation(const struct advance *padvance)
Return the (translated) name of the given advance/technology.
const char * terrain_class_name_translation(enum terrain_class tclass)
Return the (translated) name of the given terrain class.
const char * terrain_name_translation(const struct terrain *pterrain)
Return the (translated) name of the terrain.
void tile_add_extra(struct tile *ptile, const struct extra_type *pextra)
Adds extra to tile.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_worked(_tile)
#define tile_has_extra(ptile, pextra)
bool can_cities_trade(const struct city *pc1, const struct city *pc2)
Return TRUE iff the two cities are capable of trade; i.e., if a caravan from one city can enter the o...
enum trade_route_type cities_trade_route_type(const struct city *pcity1, const struct city *pcity2)
What is type of the traderoute between two cities.
const char * goods_name_translation(struct goods_type *pgood)
Return translated name of this goods type.
bool goods_has_flag(const struct goods_type *pgood, enum goods_flag_id flag)
Check if goods has given flag.
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
Get trade route settings related to type.
bool goods_can_be_provided(struct city *pcity, struct goods_type *pgood, struct unit *punit)
Can the city provide goods.
#define trade_routes_iterate_safe_end
#define trade_routes_iterate_safe(c, proute)
#define trade_partners_iterate_end
#define trade_partners_iterate(c, p)
const struct unit_type * utype
const struct impr_type * building
bool unit_is_alive(int id)
Check if unit with given id is still alive.
#define unit_cargo_iterate_end
#define unit_cargo_iterate(_ptrans, _pcargo)
#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 char * unit_rule_name(const struct unit *punit)
Return the (untranslated) rule name of the unit.
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
int utype_pop_value(const struct unit_type *punittype)
How much city shrinks when it builds unit of this type.
int unit_build_shield_cost(const struct city *pcity, const struct unit *punit)
Returns the number of shields it takes to build this unit.
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
Returns the upkeep of a unit of this type under the given government.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
int utype_build_shield_cost(const struct city *pcity, const struct unit_type *punittype)
Returns the number of shields it takes to build this unit type.
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
const char * unit_name_translation(const struct unit *punit)
Return the (translated) name of the unit.
static bool utype_has_flag(const struct unit_type *punittype, int flag)
bool worklist_peek_ith(const struct worklist *pwl, struct universal *prod, int idx)
Fill in the id and is_unit values for the ith element in the worklist.
bool worklist_is_empty(const struct worklist *pwl)
Returns whether worklist has no elements.
void worklist_remove(struct worklist *pwl, int idx)
Remove element from position idx.
int worklist_length(const struct worklist *pwl)
Returns the number of entries in the worklist.