120 pcity->
server.workers_frozen++;
130 pcity->
server.workers_frozen--;
132 if (pcity->
server.workers_frozen == 0 && pcity->
server.needs_arrange) {
151 pcity->
server.needs_arrange =
true;
197 int default_priority)
200 float priority =
static_cast<float>(default_priority);
207 const float mult_factor = 1.4;
218 return default_priority;
321 const struct nation_city_list *default_cities,
324 int choice = 0,
priority, best_priority = -1;
325 const char *
name, *best_name =
nullptr;
333 if (-1 == best_priority ||
priority < best_priority) {
357 char *error_buf,
size_t bufsz)
362 if (QString(cityname).simplified() != cityname) {
365 _(
"City names may not contain leading, trailing, or "
366 "consecutive spaces."));
375 fc_snprintf(error_buf, bufsz,
_(
"You already have a city called %s."),
386 fc_snprintf(error_buf, bufsz,
_(
"A city called %s already exists."),
403 struct player *pother =
nullptr;
414 if (pother !=
nullptr) {
417 _(
"Can't use %s as a city name. It is reserved for %s."),
435 _(
"%s is not a valid name. Only ASCII or "
436 "ruleset names are allowed for cities."),
456 qDebug(
"Suggesting city name for %s at (%d,%d)",
player_name(pplayer),
461 if (
nullptr !=
name) {
485 int queue_size = 1, i = 0, idx;
487 memset(nations_selected, 0,
sizeof(nations_selected));
488 nation_list[0] = pnation;
492 for (; i < queue_size; i++) {
495 const int which = i +
fc_rand(queue_size - i);
498 nation_list[i] = nation_list[which];
499 nation_list[which] = tmp;
501 pnation = nation_list[i];
506 if (
nullptr !=
name) {
515 if (!nations_selected[idx]) {
516 nation_list[queue_size] = n;
517 nations_selected[idx] =
true;
528 if (!nations_selected[idx]) {
529 nation_list[queue_size] = n;
530 nations_selected[idx] =
true;
542 if (!nations_selected[idx]) {
543 nation_list[queue_size] = &n;
558 log_debug(
"City name not found in rulesets.");
590 bool rehome,
bool verbose)
598 "Tried to transfer the dying unit %d.", punit->
id);
600 if (from_player == to_player) {
602 qDebug(
"Changed homecity of %s %s to %s",
620 log_debug(
"%s already have a %s. Can't transfer from %s",
635 _(
"The %s already have a %s. Can't transfer yours."),
639 wipe_unit(punit, ULR_CITY_LOST,
nullptr);
646 qDebug(
"Transferred %s in %s from %s to %s",
unit_rule_name(punit),
652 ftc_server,
_(
"Transferred %s in %s from %s to %s."),
669 qDebug(
"Could not transfer %s from %s to %s",
unit_rule_name(punit),
676 _(
"%s %s lost in transfer to %s %s"),
680 wipe_unit(punit, ULR_CITY_LOST,
nullptr);
709 struct unit_list *units,
struct city *pcity,
710 struct city *exclude_city,
int kill_outside,
714 int saved_id = pcity->
id;
719 if (pplayer != pvictim) {
722 if (vunit->server.dying) {
746 (vunit->homecity == 0) && !unit_list_search(
units, vunit);
755 unit_list_remove(
units, vunit);
774 if (vunit->server.dying) {
783 if (new_home_city && new_home_city != exclude_city
789 }
else if ((kill_outside == -1
802 qDebug(
"Lost %s %s at (%d,%d) when %s was lost.",
807 ftc_server,
_(
"%s lost along with control of %s."),
810 wipe_unit(vunit, ULR_CITY_LOST,
nullptr);
818 if (punit->server.dying) {
850 const struct city *pexclcity,
851 const struct player *pplayer,
bool only_ocean,
852 bool only_continent,
bool only_known,
853 bool only_player,
bool only_enemy,
857 struct city *best_city =
nullptr;
861 if (only_known || only_player || only_enemy) {
865 if (pplayer !=
nullptr && only_player && only_enemy) {
866 qCritical(
"Non of my own cities will be at war with me!");
874 if (pplayer !=
nullptr && only_player && pplayer != aplayer) {
879 if (pplayer !=
nullptr && only_enemy
889 if (pexclcity && pexclcity == pcity) {
902 if ((best_dist == -1 || city_dist < best_dist)
910 && (pclass ==
nullptr
913 best_dist = city_dist;
932 bool city_remains =
true;
993 trade_route_list_append(pcity->
routes, proute);
994 trade_route_list_append(partner->
routes, back);
1025 bv_imprs *had_small_wonders)
1062 _(
"A replacement %s was built in %s."),
1085 int kill_outside,
bool transfer_unit_verbose,
1086 bool resolve_stack,
bool raze,
bool build_free)
1089 bv_imprs had_small_wonders;
1090 struct vision *old_vision, *new_vision;
1091 struct unit_list *old_city_units;
1094 int saved_id = pcity->
id;
1095 bool city_remains =
true;
1096 bool had_great_wonders =
false;
1097 const citizens old_taker_content_citizens =
1099 const citizens old_giver_content_citizens =
1103 bool taker_had_no_cities = (city_list_size(ptaker->
cities) == 0);
1105 const int units_num = unit_list_size(pcenter->
units);
1110 bv_player *could_see_unit =
1111 (units_num > 0 ?
new bv_player[units_num] :
nullptr);
1112 old_city_units = unit_list_new();
1144 unit_list_prepend(old_city_units, punit);
1150 punit->homecity = 0;
1169 had_great_wonders =
true;
1179 old_vision = pcity->
server.vision;
1181 pcity->
server.vision = new_vision;
1192 _(
"You already had a city called %s."
1193 " The city was renamed to %s."),
1198 city_list_remove(pgiver->
cities, pcity);
1202 pcity->
owner = ptaker;
1205 city_list_prepend(ptaker->
cities, pcity);
1216 && !aunit->server.dying) {
1232 delete[] could_see_unit;
1233 could_see_unit =
nullptr;
1236 kill_outside, transfer_unit_verbose);
1238 unit_list_destroy(old_city_units);
1240 if (resolve_stack) {
1245 city_remains =
false;
1274 if (taker_had_no_cities) {
1280 ptaker->
server.got_first_city =
true;
1310 _(
"The people in %s are stunned by your "
1311 "technological insight!"),
1314 if (upgradet !=
nullptr) {
1316 _(
"Workers spontaneously gather and upgrade "
1321 _(
"Workers spontaneously gather and upgrade "
1322 "%s infrastructure."),
1363 if (had_great_wonders) {
1381 if (
BV_ISSET_ANY(had_small_wonders) || had_great_wonders) {
1423 return city_remains;
1438 bool has_small_wonders, has_great_wonders;
1450 first_city = !pplayer->
server.got_first_city;
1452 has_small_wonders =
false;
1453 has_great_wonders =
false;
1471 has_small_wonders =
true;
1491 has_small_wonders =
true;
1493 has_great_wonders =
true;
1499 if (has_great_wonders) {
1503 }
else if (has_small_wonders) {
1513 const char *
name,
struct player *nationality)
1554 if (city_list_size(pplayer->
cities) == 0) {
1558 pplayer->
server.got_first_city =
true;
1569 if (
nullptr != pwork) {
1575 pwork->
server.synced =
false;
1606 city_list_prepend(pplayer->
cities, pcity);
1636 pcity->
server.synced =
false;
1641 _(
"You have founded %s."),
city_link(pcity));
1680 bv_imprs had_small_wonders;
1681 struct vision *old_vision;
1683 bool had_great_wonders =
false;
1686 QBitArray tile_processed;
1687 struct tile_list *process_queue;
1701 had_great_wonders =
true;
1711 if (new_home_city && new_home_city != pcity
1732 struct unit *ptrans;
1743 ACTION_TRANSPORT_EMBARK, ACT_REQ_RULES);
1750 _(
"Moved %s out of disbanded city %s "
1751 "since it cannot stay on %s."),
1763 _(
"When %s was disbanded your %s could not "
1764 "get out, and it was therefore lost."),
1766 wipe_unit(punit, ULR_CITY_LOST,
nullptr);
1771 process_queue = tile_list_new();
1773 for (tile_list_append(process_queue, pcenter);
1774 tile_list_size(process_queue) > 0;) {
1775 struct tile *ptile = tile_list_front(process_queue);
1776 tile_list_pop_front(process_queue);
1780 struct city *other_city;
1785 if (other_city !=
nullptr) {
1789 tile_list_append(process_queue, piter);
1800 _(
"When %s was disbanded your %s in %s was trapped, "
1801 "and it was therefore lost."),
1803 wipe_unit(punit, ULR_CITY_LOST,
nullptr);
1814 tile_list_destroy(process_queue);
1824 wipe_unit(punit, ULR_CITY_LOST,
nullptr);
1857 old_vision = pcity->
server.vision;
1858 pcity->
server.vision =
nullptr;
1906 if (
nullptr == pconn->playing && pconn->observer) {
1910 dsend_packet_city_remove(pconn,
id);
1926 if (had_great_wonders) {
1963 bool try_civil_war =
false;
1970 "Can't conquer city during peace.");
1977 false,
"Bad unit for city occupation.");
1982 "Can't conquer city while transported.");
2000 try_civil_war =
true;
2008 int saved_id = pcity->
id;
2022 if (try_civil_war) {
2029 coins =
MIN(coins,
int(
fc_rand((coins / 20) + 1))
2038 PL_(
"You conquer %s; your lootings accumulate"
2040 "You conquer %s; your lootings accumulate"
2045 PL_(
"%s conquered %s and looted %d gold"
2047 "%s conquered %s and looted %d gold"
2061 PL_(
"You have liberated %s!"
2062 " Lootings accumulate to %d gold.",
2063 "You have liberated %s!"
2064 " Lootings accumulate to %d gold.",
2068 PL_(
"%s liberated %s and looted %d gold"
2070 "%s liberated %s and looted %d gold"
2076 _(
"You have liberated %s!"),
city_link(pcity));
2092 city_remains =
transfer_city(pplayer, pcity, 0,
true,
true,
true,
2101 if (try_civil_war) {
2121 return walls > 0 ? walls : 0;
2139 struct packet_city_short_info *packet)
2149 packet->occupied = pdcity->
occupied;
2150 packet->walls = pdcity->
walls;
2151 packet->style = pdcity->
style;
2153 packet->capital = pdcity->
capital;
2154 packet->happy = pdcity->
happy;
2155 packet->unhappy = pdcity->
unhappy;
2169 struct packet_city_short_info packet;
2175 lsend_packet_city_short_info(pplayer->connections, &packet);
2196 struct packet_city_info packet;
2197 struct packet_city_short_info sc_pack;
2199 struct traderoute_packet_list *routes = traderoute_packet_list_new();
2208 lsend_packet_city_info(powner->
connections, &packet,
false);
2211 lsend_packet_traderoute_info(powner->
connections, route_packet);
2220 lsend_packet_city_short_info(pplayer->connections, &sc_pack);
2230 send_packet_city_info(pconn, &packet,
false);
2237 delete route_packet;
2238 route_packet =
nullptr;
2241 traderoute_packet_list_destroy(routes);
2253 struct player *pplayer = pconn->playing;
2255 if (!pplayer && !pconn->observer) {
2279 qCritical(
"%s radius changed while sending to player.",
2307 if (!dest || dest == powner) {
2308 pcity->
server.synced =
true;
2345 struct city *pcity,
struct tile *ptile)
2347 struct packet_city_info packet;
2348 struct packet_city_short_info sc_pack;
2349 struct player *powner =
nullptr;
2350 struct traderoute_packet_list *routes =
nullptr;
2358 if (powner && powner == pviewer) {
2362 routes = traderoute_packet_list_new();
2367 lsend_packet_city_info(dest, &packet,
false);
2370 lsend_packet_traderoute_info(dest, route_packet);
2378 send_packet_city_info(pconn, &packet,
false);
2381 send_packet_traderoute_info(pconn, route_packet);
2393 routes = traderoute_packet_list_new();
2397 lsend_packet_city_info(dest, &packet,
false);
2400 lsend_packet_traderoute_info(dest, route_packet);
2413 lsend_packet_city_short_info(dest, &sc_pack);
2418 lsend_packet_city_short_info(dest, &sc_pack);
2424 if (routes !=
nullptr) {
2427 delete route_packet;
2428 route_packet =
nullptr;
2431 traderoute_packet_list_destroy(routes);
2439 struct traderoute_packet_list *routes,
bool dipl_invest)
2444 packet->id = pcity->
id;
2456 ppl += packet->ppl_happy[i];
2457 ppl += packet->ppl_content[i];
2458 ppl += packet->ppl_unhappy[i];
2459 ppl += packet->ppl_angry[i];
2467 ppl += packet->specialists[sp];
2472 packet->nationalities_count = 0;
2473 if (
game.
info.citizen_nationality) {
2479 if (nationality != 0) {
2483 packet->nation_id[packet->nationalities_count] =
2485 packet->nation_citizens[packet->nationalities_count] = nationality;
2486 packet->nationalities_count++;
2496 packet->history = pcity->
history;
2500 if (packet->size != ppl) {
2506 qCritical(
"Failed to fix inconsistent city size.");
2516 qCritical(
"City size %d, citizen count %d for %s", packet->size, ppl,
2537 auto *tri_packet =
new packet_traderoute_info;
2539 tri_packet->city = pcity->
id;
2540 tri_packet->index = i;
2541 tri_packet->partner = proute->partner;
2542 tri_packet->value = proute->value;
2543 tri_packet->direction = proute->dir;
2546 traderoute_packet_list_append(routes, tri_packet);
2552 packet->traderoute_count = i;
2556 packet->surplus[o] = pcity->
surplus[o];
2557 packet->waste[o] = pcity->
waste[o];
2559 packet->prod[o] = pcity->
prod[o];
2561 packet->usage[o] = pcity->
usage[o];
2587 packet->diplomat_investigate = dipl_invest;
2589 packet->airlift = pcity->
airlift;
2590 packet->did_buy = pcity->
did_buy;
2592 packet->did_sell = pcity->
did_sell;
2596 packet->style = pcity->
style;
2598 packet->capital = pcity->
capital;
2599 packet->steal = pcity->
steal;
2610 packet->cma_enabled =
true;
2613 packet->cma_enabled =
false;
2614 memset(&packet->cm_parameter, 0,
sizeof(packet->cm_parameter));
2639 bv_imprs improvements;
2662 if (
nullptr == pdcity) {
2665 }
else if (pdcity->
location != pcenter) {
2666 qCritical(
"Trying to update bad city (wrong location) "
2667 "at %i,%i for player %s",
2672 qCritical(
"Trying to update old city (wrong identity) "
2673 "at %i,%i for player %s",
2708 if (playtile->site && playtile->site->location == ptile) {
2711 if (!pcity || pcity->
id != playtile->site->identity) {
2713 playtile->site->identity);
2714 playtile->site =
nullptr;
2726 if (playtile->site && playtile->site->location == ptile) {
2728 playtile->site->identity);
2729 playtile->site =
nullptr;
2751 _(
"Trade between %s and %s lost along with city."),
2752 city1_link, city2_link);
2755 _(
"Trade route between %s and %s canceled."), city1_link,
2762 _(
"Trade between %s city %s and %s lost along with "
2770 _(
"Sorry, the %s canceled the trade route "
2771 "from %s to your city %s."),
2775 _(
"We canceled the trade route "
2776 "from %s to %s city %s."),
2800 trade_route_list_remove(pc1->
routes, proute);
2802 if (pc2 !=
nullptr) {
2805 if (pc1->
id == pback->partner) {
2811 if (back_route !=
nullptr) {
2812 trade_route_list_remove(pc2->
routes, back_route);
2833 _(
"%s has been struck by a plague! Population lost!"),
2850 struct impr_type *pimprove,
const char *reason)
2862 const char *reason,
struct unit *destroyer)
2864 int backup = pcity->
id;
2879 const char *reason,
struct unit *destroyer)
2887 if ((was_capital && (!city_remains || !
is_capital(pcity)))
2940 memset(free_uk, 0,
O_LAST *
sizeof(*free_uk));
2944 EFT_UNIT_UPKEEP_FREE_PER_CITY);
2959 if (free_uk[o] > cost) {
2968 if (cost != punit->upkeep[o]) {
2970 punit->upkeep[o] = cost;
3000 &&
event != E_IMP_AUTO &&
event != E_WORKLIST) {
3006 _(
"The %s have stopped building The %s in %s."),
3030 source =
_(
" from the worklist");
3035 source =
_(
" as suggested by the advisor");
3059 _(
"The %s have started building The %s in %s."),
3070 pcity->
server.prod_change_timestamp = time(
nullptr);
3083 pcity->
server.synced =
false;
3095 pcity->
server.synced =
false;
3113 pwork->
server.synced =
false;
3160 if (!pcity->server.synced) {
3178 ptile, _index, _x, _y)
3229 if ((VUT_TERRAIN == preq->source.kind
3230 || VUT_TERRAINCLASS == preq->source.kind)
3232 nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
3238 PL_(
"You sell %s in %s (now landlocked)"
3240 "You sell %s in %s (now landlocked)"
3264 (
short)
get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ, V_MAIN),
3265 (
short)
get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ, V_INVIS),
3290 int city_tiles_old, city_tiles_new;
3292 int city_radius_sq_new =
game.
info.init_city_radius_sq
3299 if (city_radius_sq_new == city_radius_sq_old) {
3308 if (city_tiles_old == city_tiles_new) {
3316 pcity->
id, city_radius_sq_old, city_radius_sq_new);
3319 log_debug(
"[%s (%d)] city size: %d; specialists: %d (before change)",
3326 if (city_tiles_old < city_tiles_new) {
3338 city_tile(pcity), city_radius_sq_old, city_x, city_y);
3352 struct tile *ptile =
3382 _(
"The size of the city map of %s is %s."),
city_name_get(pcity),
3383 city_tiles_old < city_tiles_new ?
_(
"increased") :
_(
"reduced"));
3386 log_debug(
"[%s (%d)] city size: %d; specialists: %d (after change)",
3399 struct packet_worker_task packet;
3401 if (ptask ==
nullptr) {
3405 worker_task_list_remove(pcity->
task_reqs, ptask);
3407 packet.city_id = pcity->
id;
3409 packet.activity = ACTIVITY_LAST;
3425 while (worker_task_list_size(pcity->
task_reqs) > 0) {
3435 struct packet_worker_task packet;
3437 packet.city_id = pcity->
id;
3442 packet.activity = ptask->act;
3443 if (ptask->tgt ==
nullptr) {
3448 packet.want = ptask->want;
3464 case VUT_IMPROVEMENT:
bool is_action_enabled_unit_on_unit(const action_id wanted_action, const struct unit *actor_unit, const struct unit *target_unit)
Returns TRUE if actor_unit can do wanted_action to target_unit as far as action enablers are concerne...
void advisor_choose_build(struct player *pplayer, struct city *pcity)
Setup improvement building.
int adv_could_unit_move_to_tile(struct unit *punit, struct tile *dest_tile)
returns: 0 if can't move 1 if zoc_ok -1 if zoc could be ok?
#define CALL_FUNC_EACH_AI(_func,...)
#define CALL_PLR_AI_FUNC(_func, _player,...)
bool is_land_barbarian(struct player *pplayer)
Is player a land barbarian?
bool BV_ISSET(const BV &bv, int bit)
#define BV_ARE_EQUAL(vec1, vec2)
#define BV_ISSET_ANY(vec)
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
Get the number of citizens with the given nationality.
void citizens_init(struct city *pcity)
Initialise citizens data.
void citizens_convert_conquest(struct city *pcity)
Convert citizens to the nationality of the one conquering the city.
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.
void city_map_radius_sq_set(struct city *pcity, int radius_sq)
Returns the current squared radius of the city.
int city_production_build_shield_cost(const struct city *pcity)
Return the number of shields it takes to build current city production.
citizens player_angry_citizens(const struct player *pplayer)
Give base number of angry citizens in any city owned by pplayer.
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 citylog_map_workers(QtMsgType level, struct city *pcity)
Display the location of the workers within the city map of pcity.
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
Removes an improvement (and its effects) from a city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
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.
citizens player_content_citizens(const struct player *pplayer)
Give base number of content citizens in any city owned by pplayer.
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.
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:
int city_change_production_penalty(const struct city *pcity, const struct universal *target)
Compute and optionally apply the change-production penalty for the given production change (to target...
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.
citizens city_specialists(const struct city *pcity)
Give the number of specialists in a city.
struct city * city_list_find_name(struct city_list *This, const char *name)
Find city with given name from list.
void city_choose_build_default(struct city *pcity)
Always tile_set_owner(ptile, pplayer) sometime before this!
int city_map_tiles(int city_radius_sq)
Return the number of tiles for the given city radius.
bool city_exist(int id)
Check if city with given id still exist.
bool is_city_center(const struct city *pcity, const struct tile *ptile)
Return TRUE if the city is centered at the given tile.
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 ...
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
Create virtual skeleton for a city.
citizens city_size_get(const struct city *pcity)
Get the city size.
const char * city_production_name_translation(const struct city *pcity)
Return the extended name of the current production.
#define cities_iterate_end
#define city_list_iterate(citylist, pcity)
#define cities_iterate(pcity)
#define CITY_MAP_MAX_RADIUS_SQ
#define CITY_MAP_MIN_RADIUS_SQ
#define city_map_iterate_radius_sq(_radius_sq_min, _radius_sq_max, _x, _y)
#define output_type_iterate(output)
#define city_list_iterate_end
#define city_map_iterate_radius_sq_end
#define city_tile_iterate_skip_center_end
#define city_tile_iterate_skip_center(_radius_sq, _city_tile, _tile, _index, _x, _y)
#define city_built_iterate(_pcity, _p)
#define city_map_iterate_without_index_end
#define city_built_iterate_end
#define city_map_iterate_without_index(_radius_sq, _x, _y)
#define output_type_iterate_end
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.
void nullify_prechange_production(struct city *pcity)
Initialize all variables containing information about production before it was changed.
void city_refresh_queue_processing()
Refresh the listed cities.
bool city_reduce_size(struct city *pcity, citizens pop_loss, struct player *destroyer, const char *reason)
Reduce the city size.
bool city_refresh(struct city *pcity)
Updates unit upkeeps and city internal cached data.
void city_refresh_for_player(struct player *pplayer)
Called on government change or wonder completion or stuff like that – Syela.
void remove_obsolete_buildings_city(struct city *pcity, bool refresh)
Automatically sells obsolete buildings from city.
enum announce_type announce
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 conn_list_do_unbuffer(struct conn_list *dest)
Convenience functions to unbuffer a list of connections.
void conn_list_do_buffer(struct conn_list *dest)
Convenience functions to buffer a list of connections.
bool conn_is_global_observer(const struct connection *pconn)
Returns TRUE if the given connection is a global observer.
struct connection * conn_by_user(const char *user_name)
Find connection by exact user name, from game.all_connections, case-insensitve.
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
int city_culture(const struct city *pcity)
Return current culture score of the city.
int get_unit_bonus(const struct unit *punit, enum effect_type effect_type)
Returns the effect bonus at a unit.
int get_city_output_bonus(const struct city *pcity, const struct output_type *poutput, enum effect_type effect_type)
Returns the player effect bonus of an output.
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
#define MAX_NUM_BUILDING_LIST
signed short Continent_id
#define IDENTITY_NUMBER_ZERO
#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_name(const char *name)
Find city with given name from any player.
void game_remove_city(struct world *gworld, struct city *pcity)
Remove city from game.
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
void send_game_info(struct conn_list *dest)
Send game_info packet; some server options and various stuff...
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 idex_register_city(struct world *iworld, struct city *pcity)
Register a city into idex, with current pcity->id.
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.
struct city * city_from_small_wonder(const struct player *pplayer, const struct impr_type *pimprove)
Get the player city with this small wonder.
bool is_improvement(const struct impr_type *pimprove)
Is this building a regular improvement?
struct impr_type * improvement_by_number(const Impr_type_id id)
Returns the improvement type for the given index/ID.
bool is_improvement_visible(const struct impr_type *pimprove)
Return TRUE if the improvement should be visible to others without spying.
Impr_type_id improvement_index(const struct impr_type *pimprove)
Return the improvement index.
int impr_buy_gold_cost(const struct city *pcity, const struct impr_type *pimprove, int shields_in_stock)
Returns the amount of gold it takes to rush this improvement.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
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 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 improvement_iterate_end
#define improvement_iterate(_p)
void adv_city_free(struct city *pcity)
Free advisors related city data.
void adv_city_update(struct city *pcity)
Update the memory allocated for AI city handling.
void adv_city_alloc(struct city *pcity)
Allocate advisors related city data.
#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 map_num_tiles()
Returns the total number of (real) positions (or tiles) on the map.
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Return real distance between two tiles.
#define adjc_iterate(nmap, center_tile, itr_tile)
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
void vision_clear_sight(struct vision *vision)
Clear all sight points from this vision source.
void map_claim_ownership(struct tile *ptile, struct player *powner, struct tile *psource, bool claim_bases)
Claim ownership of a single tile.
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Return whether the player knows the tile.
void destroy_extra(struct tile *ptile, struct extra_type *pextra)
Remove extra from tile.
void send_tile_info(struct conn_list *dest, struct tile *ptile, bool send_unknown)
Send tile information to all the clients in dest which know and see the tile.
void map_show_tile(struct player *src_player, struct tile *ptile)
Shows the area to the player.
void give_citymap_from_player_to_player(struct city *pcity, struct player *pfrom, struct player *pdest)
Give information about tiles within city radius from player to player.
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Returns whether the layer 'vlayer' of the tile 'ptile' is known and seen by the player 'pplayer'.
void change_playertile_site(struct player_tile *ptile, struct vision_site *new_site)
Changes site information for player tile.
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 player_tile * map_get_player_tile(const struct tile *ptile, const struct player *pplayer)
Players' information of tiles is tracked so that fogged area can be kept consistent even when the cli...
struct vision_site * map_get_player_site(const struct tile *ptile, const struct player *pplayer)
Returns site located at given tile from player map.
struct vision_site * map_get_player_city(const struct tile *ptile, const struct player *pplayer)
Returns city located at given tile from player map.
bool upgrade_city_extras(struct city *pcity, struct extra_type **gained)
Check city for extra upgrade.
void map_clear_border(struct tile *ptile)
Remove border for this source.
void vision_change_sight(struct vision *vision, const v_radius_t radius_sq)
Change the sight points for the vision source, fogging or unfogging tiles as needed.
bool is_city_channel_tile(const struct unit_class *punitclass, const struct tile *ptile, const struct tile *pexclude)
Check for a city channel.
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Return TRUE iff the unit can "exist" at this location.
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
This tile is native to unit.
bool can_unit_survive_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Return TRUE iff the unit can "survive" at this location.
bool is_native_near_tile(const struct civ_map *nmap, const struct unit_class *uclass, const struct tile *ptile)
Is there native tile adjacent to given tile.
enum nation_city_preference nation_city_preference_revert(enum nation_city_preference prefer)
Reverts the nation city preference.
enum nation_city_preference nation_city_terrain_preference(const struct nation_city *pncity, const struct terrain *pterrain)
Return the default nation city preference for the terrain.
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
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
struct nation_type * nation_of_unit(const struct unit *punit)
Return the nation of the player who owns the unit.
enum nation_city_preference nation_city_river_preference(const struct nation_city *pncity)
Return the default nation city preference for rivers.
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.
const char * nation_city_name(const struct nation_city *pncity)
Return the name of the default nation city.
const struct nation_city_list * nation_cities(const struct nation_type *pnation)
Return the default cities of the nation (server only function).
#define nation_list_iterate(nationlist, pnation)
#define nation_city_list_iterate(citylist, pncity)
#define nation_list_iterate_end
#define nation_city_list_iterate_end
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".
int player_number(const struct player *pplayer)
Return the player index/number/id.
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Checks if a unit can be seen by pplayer at its current location.
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players can attack each other.
int player_slot_index(const struct player_slot *pslot)
Returns the index of the player slot.
int player_index(const struct player *pplayer)
Return the player index.
struct player * player_slot_get_player(const struct player_slot *pslot)
Returns the team corresponding to the slot.
bool player_can_see_city_externals(const struct player *pow_player, const struct city *target_city)
Returns TRUE iff pow_player can see externally visible features of target_city.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
Return TRUE iff the player can see units in the city.
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Return TRUE iff the player can see the city's internals.
#define players_iterate_end
#define players_iterate(_pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_slots_iterate(_pslot)
#define player_slots_iterate_end
struct player * civil_war(struct player *pplayer)
Capturing a nation's primary capital is a devastating blow.
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 maybe_make_contact(struct tile *ptile, struct player *pplayer)
Check if we make contact with anyone.
void send_player_info_c(struct player *src, struct conn_list *dest)
Send information about player slot 'src', or all valid (i.e.
bool civil_war_possible(struct player *pplayer, bool conquering_city, bool honour_server_option)
Check if civil war is possible for a player.
int normal_player_count()
Return the number of non-barbarian players.
void update_capital(struct player *pplayer)
Recalculate what city is the named capital.
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.
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.
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Return TRUE iff the two sources are equivalent.
int universal_number(const struct universal *source)
Return the universal number of the constituent.
#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.
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
Check if road provides effect.
#define sanity_check_city(x)
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...
static struct connection connections[MAX_NUM_CONNECTIONS]
void flush_packets()
Attempt to flush all information in the send buffers for upto 'netwait' seconds.
static struct setting settings[]
bool is_ascii_name(const char *name)
This is used in sundry places to make sure that names of cities, players etc.
#define CLIP(lower, current, upper)
void spaceship_lost(struct player *pplayer)
Handle spaceship loss.
Specialist_type_id specialist_count()
Return the number of specialist_types.
#define specialist_type_iterate_end
#define specialist_type_iterate(sp)
#define DEFAULT_SPECIALIST
SPECPQ_PRIORITY_TYPE priority
static int recursion[AIT_LAST]
enum server_states server_state()
Return current server state.
int identity_number()
Identity ids wrap at IDENTITY_NUMBER_SIZE, skipping IDENTITY_NUMBER_ZERO Setup in server_game_init()
struct worker_task_list * task_reqs
struct city::@14 rally_point
struct built_status built[B_LAST]
int last_turns_shield_surplus
enum capital_type capital
bv_city_options city_options
struct trade_route_list * routes
struct universal production
struct unit_order * orders
int unhappy_penalty[O_LAST]
char name[MAX_LEN_CITYNAME]
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 civ_game::@28::@32 server
struct conn_list * glob_observers
struct packet_ruleset_control control
struct conn_list * est_connections
struct packet_game_info info
int global_init_buildings[MAX_NUM_BUILDING_LIST]
struct civ_game::@27 rgame
enum cmdlevel access_level
int init_buildings[MAX_NUM_BUILDING_LIST]
struct nation_type::@48::@50 server
enum spaceship_state state
struct city_list * cities
char username[MAX_LEN_NAME]
struct player::@65::@67 server
struct conn_list * connections
struct player_economic economic
struct player_spaceship spaceship
struct unit::@76::@79 server
struct unit * transporter
enum capital_type capital
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
#define sz_strlcpy(dest, src)
const struct player_list * team_members(const struct team *pteam)
Returns the member list of the team.
bool is_terrain_near_tile(const struct tile *ptile, const struct terrain *pterrain, bool check_self)
Returns TRUE iff any adjacent tile contains the given terrain.
bool is_terrain_class_near_tile(const struct tile *ptile, enum terrain_class tclass)
Is there terrain of the given class near tile? (Does not check ptile itself.)
const char * terrain_name_translation(const struct terrain *pterrain)
Return the (translated) name of the terrain.
#define terrain_type_iterate(_p)
#define terrain_type_iterate_end
void tile_set_owner(struct tile *ptile, struct player *pplayer, struct tile *claimer)
Set the owner of a tile (may be nullptr).
bool tile_extra_rm_apply(struct tile *ptile, struct extra_type *tgt)
Remove extra and adjust other extras accordingly.
void tile_set_worked(struct tile *ptile, struct city *pcity)
Set the city/worker on the tile (may be nullptr).
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_claimer(_tile)
#define tile_worked(_tile)
#define tile_terrain(_tile)
#define tile_continent(_tile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
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.
Goods_type_id goods_number(const struct goods_type *pgood)
Return the goods id.
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
Get trade route settings related to type.
bool can_establish_trade_route(const struct city *pc1, const struct city *pc2)
Returns TRUE iff the two cities can establish a trade route.
#define trade_routes_iterate_safe_end
#define trade_routes_iterate_end
#define trade_routes_iterate_safe(c, proute)
#define trade_routes_iterate(c, proute)
const struct unit_type * utype
const struct impr_type * building
bool can_unit_continue_current_activity(struct unit *punit)
Check if the unit's current activity is actually legal.
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Find the best transporter at the given location for the unit.
bool unit_move_handling(struct unit *punit, struct tile *pdesttile, bool igzoc, bool move_do_not_act)
Will try to move to/attack the tile dest_x,dest_y.
bool unit_activity_handling(struct unit *punit, enum unit_activity new_activity)
Handle request for changing activity.
bool unit_perform_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id_incoming, const char *name, const action_id action_type, const enum action_requester requester)
Execute a request to perform an action and let the caller know if it was performed or not.
void unit_change_homecity_handling(struct unit *punit, struct city *new_pcity, bool rehome)
Transfer a unit from one city (and possibly player) to another.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_safe(unitlist, _unit)
#define unit_list_iterate_end
#define unit_list_iterate_safe_end
int utype_buy_gold_cost(const struct city *pcity, const struct unit_type *punittype, int shields_in_stock)
Returns the amount of gold it takes to rush this unit.
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_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.
bool utype_player_already_has_this_unique(const struct player *pplayer, const struct unit_type *putype)
Returns TRUE iff the unit type is unique and the player already has one.
bool unit_can_take_over(const struct unit *punit)
Return whether the unit can take over enemy cities.
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Return TRUE iff units of the given type can do the specified generalized (ruleset defined) action ena...
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
void vision_site_update_from_city(struct vision_site *psite, const struct city *pcity)
Returns the basic structure filled with current elements.
struct vision * vision_new(struct player *pplayer, struct tile *ptile)
Create a new vision source.
citizens vision_site_size_get(const struct vision_site *psite)
Get the city size.
bool vision_reveal_tiles(struct vision *vision, bool reveal_tiles)
Sets the can_reveal_tiles flag.
struct vision_site * vision_site_new_from_city(const struct city *pcity)
Returns the basic structure filled with initial elements.
void vision_free(struct vision *vision)
Free the vision source.
#define V_RADIUS(main_sq, invis_sq, subs_sq)
#define vision_site_owner(v)
short int v_radius_t[V_COUNT]
#define worker_task_list_iterate(tasklist, ptask)
#define worker_task_list_iterate_end
void worklist_copy(struct worklist *dst, const struct worklist *src)
Copy contents from worklist src to worklist dst.