Freeciv-3.3: /fast/freeciv/nightly/main/server/cityturn.c File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
cityturn.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <math.h>`
`#include "lua.h"`
`#include "fcintl.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "rand.h"`
`#include "shared.h"`
`#include "support.h"`
`#include "cm.h"`
`#include "achievements.h"`
`#include "actiontools.h"`
`#include "borders.h"`
`#include "calendar.h"`
`#include "citizens.h"`
`#include "city.h"`
`#include "counters.h"`
`#include "culture.h"`
`#include "events.h"`
`#include "disaster.h"`
`#include "game.h"`
`#include "government.h"`
`#include "map.h"`
`#include "player.h"`
`#include "research.h"`
`#include "road.h"`
`#include "server_settings.h"`
`#include "specialist.h"`
`#include "tech.h"`
`#include "traderoutes.h"`
`#include "unit.h"`
`#include "unitlist.h"`
`#include "luascript_types.h"`
`#include "citizenshand.h"`
`#include "citytools.h"`
`#include "cityturn.h"`
`#include "maphand.h"`
`#include "notify.h"`
`#include "plrhand.h"`
`#include "sanitycheck.h"`
`#include "spacerace.h"`
`#include "srv_log.h"`
`#include "srv_main.h"`
`#include "techtools.h"`
`#include "unittools.h"`
`#include "unithand.h"`
`#include "advbuilding.h"`
`#include "advdata.h"`
`#include "script_server.h"`
`#include "speclist.h"`

Go to the source code of this file.

## Data Structures

struct | cityimpr

## Macros

#define | SPECLIST_TAG cityimpr
#define | SPECLIST_TYPE struct cityimpr
#define | cityimpr_list_iterate(cityimprlist, pcityimpr) TYPED_LIST_ITERATE(struct cityimpr, cityimprlist, pcityimpr)
#define | cityimpr_list_iterate_end LIST_ITERATE_END

## Functions

static void | check_pollution (struct city *pcity)
static void | city_populate (struct city *pcity, struct player *nationality)
static bool | worklist_change_build_target (struct player *pplayer, struct city *pcity)
static bool | city_distribute_surplus_shields (struct player *pplayer, struct city *pcity)
static bool | city_build_building (struct player *pplayer, struct city *pcity)
static bool | city_build_unit (struct player *pplayer, struct city *pcity)
static bool | city_build_stuff (struct player *pplayer, struct city *pcity)
static struct unit * | city_create_unit (struct city *pcity, const struct unit_type *utype, struct citizens_reduction *red) fc__attribute((nonnull(1
static struct unit static const struct impr_type * | building_upgrades_to (struct city *pcity, const struct impr_type *pimprove)
static void | upgrade_building_prod (struct city *pcity)
static const struct unit_type * | unit_upgrades_to (struct city *pcity, const struct unit_type *id)
static void | upgrade_unit_prod (struct city *pcity)
static bool | sell_random_building (struct player *pplayer, struct cityimpr_list *imprs)
static struct unit * | sell_random_unit (struct player *pplayer, struct unit_list *punitlist)
static citizens | city_reduce_specialists (struct city *pcity, citizens change)
static citizens | city_reduce_workers (struct city *pcity, citizens change)
static bool | city_balance_treasury_buildings (struct city *pcity)
static bool | city_balance_treasury_units (struct city *pcity)
static bool | disband_city (struct city *pcity)
static void | define_orig_production_values (struct city *pcity)
static void | update_city_activity (struct city *pcity)
static void | nullify_caravan_and_disband_plus (struct city *pcity)
static bool | city_illness_check (const struct city *pcity)
static float | city_migration_score (struct city *pcity)
static bool | do_city_migration (struct city *pcity_from, struct city *pcity_to)
static bool | check_city_migrations_player (const struct player *pplayer)
bool | city_refresh (struct city *pcity)
void | city_refresh_for_player (struct player *pplayer)
void | city_refresh_queue_add (struct city *pcity)
void | city_refresh_queue_processing (void)
void | remove_obsolete_buildings_city (struct city *pcity, bool refresh)
void | remove_obsolete_buildings (struct player *pplayer)
void | apply_cmresult_to_city (struct city *pcity, const struct cm_result *cmr)
static void | set_default_city_manager (struct cm_parameter *cmp, struct city *pcity)
void | auto_arrange_workers (struct city *pcity)
static void | city_global_turn_notify (struct conn_list *dest)
static void | city_turn_notify (const struct city *pcity, struct conn_list *dest, const struct player *cache_for_player)
void | send_city_turn_notifications (struct connection *pconn)
void | update_city_activities (struct player *pplayer)
static bool | upkeep_kill_unit (struct unit *punit, Output_type_id outp, enum unit_loss_reason wipe_reason, bool wipe_in_the_end)
bool | city_reduce_size (struct city *pcity, citizens pop_loss, struct player *destroyer, const char *reason)
void | city_repair_size (struct city *pcity, int change)
int | city_growth_granary_savings (const struct city *pcity)
int | city_shrink_granary_savings (const struct city *pcity)
static void | city_reset_foodbox (struct city *pcity, int new_size, bool shrink)
static bool | city_increase_size (struct city *pcity)
static void | city_refresh_after_city_size_increase (struct city *pcity, struct player *nationality)
bool | city_change_size (struct city *pcity, citizens size, struct player *nationality, const char *reason)
static bool | worklist_item_postpone_req_vec (struct universal *target, struct city *pcity, struct player *pplayer, int saved_id)
void | choose_build_target (struct player *pplayer, struct city *pcity)
static void | uk_rem_gold_callback (struct unit *punit)
static void | uk_rem_gold_append (struct unit *punit)
static void | unit_list_referred_destroy (struct unit_list *punitlist)
bool | player_balance_treasury_units_and_buildings (struct player *pplayer)
bool | player_balance_treasury_units (struct player *pplayer)
static bool | place_pollution (struct city *pcity, enum extra_cause cause)
int | city_incite_cost (struct player *pplayer, struct city *pcity)
void | nullify_prechange_production (struct city *pcity)
bool | check_city_migrations (void)
bool | city_empty_food_stock (struct city *pcity)
static void | apply_disaster (struct city *pcity, struct disaster_type *pdis)
void | check_disasters (void)
void | city_style_refresh (struct city *pcity)
void | city_counters_refresh (struct city *pcity)
void | city_tc_effect_refresh (struct player *pplayer)

## Variables

static struct city_list * | city_refresh_queue = NULL
static struct unit_list * | uk_rem_gold = NULL

## Macro Definition Documentation

## ◆ cityimpr_list_iterate

#define cityimpr_list_iterate | ( |  | cityimprlist,
|  |  | pcityimpr
| ) |  | TYPED_LIST_ITERATE(struct cityimpr, cityimprlist, pcityimpr)

Definition at line 127 of file cityturn.c.

## ◆ cityimpr_list_iterate_end

#define cityimpr_list_iterate_end LIST_ITERATE_END

Definition at line 129 of file cityturn.c.

## ◆ SPECLIST_TAG

#define SPECLIST_TAG cityimpr

Definition at line 123 of file cityturn.c.

## ◆ SPECLIST_TYPE

#define SPECLIST_TYPE struct cityimpr

Definition at line 124 of file cityturn.c.

## Function Documentation

## ◆ apply_cmresult_to_city()

void apply_cmresult_to_city | ( | struct city * | pcity,
|  | const struct cm_result * | cmr
| ) |  |

Rearrange workers according to a cm_result struct. The caller must make sure that the result is valid.

Definition at line 280 of file cityturn.c.

Referenced by auto_arrange_workers(), and dai_manage_taxes().

## ◆ apply_disaster()

static void apply_disaster | ( | struct city * | pcity,
|  | struct disaster_type * | pdis
| ) |  |

static

Disaster has hit a city. Apply its effects.

Definition at line 4277 of file cityturn.c.

Referenced by check_disasters().

## ◆ auto_arrange_workers()

void auto_arrange_workers | ( | struct city * | pcity | ) |

Call sync_cities() to send the affected cities to the clients.

Definition at line 365 of file cityturn.c.

Referenced by adv_best_government(), api_edit_create_building(), building_lost(), city_build_building(), city_map_update_tile_direct(), city_reduce_size(), city_refresh_after_city_size_increase(), city_refresh_for_player(), city_refresh_queue_processing(), city_tc_effect_refresh(), city_thaw_workers(), create_city(), dai_adjust_policies(), dai_gov_value(), dai_government_change(), dai_manage_cities(), do_city_migration(), handle_city_make_specialist(), handle_city_make_worker(), handle_web_cma_set(), package_city(), remove_obsolete_buildings_city(), resolve_city_emergency(), send_player_cities(), sg_load_player_city(), sg_load_player_city(), tile_change_side_effects(), transfer_city(), and update_city_activity().

## ◆ building_upgrades_to()

static const struct impr_type * building_upgrades_to | ( | struct city * | pcity,
|  | const struct impr_type * | pimprove
| ) |  |

static

Follow the list of replacement buildings until we hit something that we can build. Returns NULL if we can't upgrade at all (including if the original building is unbuildable).

Definition at line 2441 of file cityturn.c.

Referenced by upgrade_building_prod(), and worklist_change_build_target().

## ◆ check_city_migrations()

bool check_city_migrations | ( | void |  | ) |

Check for citizens who want to migrate between the cities that overlap. Migrants go to the city with higher score, if the growth of the target city is not blocked due to a missing improvement.

The following setting are used:

'game.server.mgr_turninterval' controls the number of turns between migration checks for one city (counted from the founding). If this setting is zero, or it is the first turn (T1), migration does no occur.

'game.server.mgr_distance' is the maximal distance for migration.

'game.server.mgr_nationchance' gives the chance for migration within one nation.

'game.server.mgr_worldchance' gives the chance for migration between all nations.

Returns TRUE iff there has been INTERNATIONAL migration.

Definition at line 4223 of file cityturn.c.

Referenced by end_turn().

## ◆ check_city_migrations_player()

static bool check_city_migrations_player | ( | const struct player * | pplayer | ) |

static

Check for migration for each city of one player.

For each city of the player do: check each tile within GAME_MAX_MGR_DISTANCE for a city if a city is found check the distance compare the migration score

Definition at line 4435 of file cityturn.c.

Referenced by check_city_migrations().

## ◆ check_disasters()

void check_disasters | ( | void |  | ) |

Check for any disasters hitting any city, and apply those disasters.

Definition at line 4398 of file cityturn.c.

Referenced by end_turn().

## ◆ check_pollution()

static void check_pollution | ( | struct city * | pcity | ) |

static

Add some Pollution if we have waste

Definition at line 3421 of file cityturn.c.

Referenced by update_city_activity().

## ◆ choose_build_target()

void choose_build_target | ( | struct player * | pplayer,
|  | struct city * | pcity
| ) |  |

Assuming we just finished building something, find something new to build. The policy is: use the worklist if we can; if not, try not changing; if we must change, get desparate and use the AI advisor.

Definition at line 2398 of file cityturn.c.

Referenced by city_build_building(), city_build_unit(), and research_tech_lost().

## ◆ city_balance_treasury_buildings()

static bool city_balance_treasury_buildings | ( | struct city * | pcity | ) |

static

Balance the gold of one city by randomly selling some buildings.

Definition at line 3300 of file cityturn.c.

Referenced by update_city_activity().

## ◆ city_balance_treasury_units()

static bool city_balance_treasury_units | ( | struct city * | pcity | ) |

static

Balance the gold of one city by randomly selling some units which need gold upkeep.

NB: This function adds the gold upkeep of disbanded units back to the player's gold. Hence it assumes that this gold was previously taken from the player (i.e. in update_city_activity()).

Definition at line 3347 of file cityturn.c.

Referenced by update_city_activity().

## ◆ city_build_building()

static bool city_build_building | ( | struct player * | pplayer,
|  | struct city * | pcity
| ) |  |

static

Returns FALSE when the city is removed, TRUE otherwise.

Definition at line 2612 of file cityturn.c.

Referenced by city_build_stuff().

## ◆ city_build_stuff()

static bool city_build_stuff | ( | struct player * | pplayer,
|  | struct city * | pcity
| ) |  |

static

Returns FALSE when the city is removed, TRUE otherwise.

Definition at line 2985 of file cityturn.c.

Referenced by update_city_activity().

## ◆ city_build_unit()

static bool city_build_unit | ( | struct player * | pplayer,
|  | struct city * | pcity
| ) |  |

static

Build city units. Several units can be built in one turn if the effect City_Build_Slots is used (on certain conditions). If the unit consumes population, builds it with a dominant nationality of the citizens (that is always foreign if a foreign nation equals in number of consumed citizens to city owner). Otherwise, the unit will be native. Returns FALSE when the city is removed, TRUE otherwise.

Definition at line 2830 of file cityturn.c.

Referenced by city_build_stuff().

## ◆ city_change_size()

bool city_change_size | ( | struct city * | pcity,
|  | citizens | size,
|  | struct player * | nationality,
|  | const char * | reason
| ) |  |

Change the city size. Return TRUE iff the city is still alive afterwards.

Definition at line 1030 of file cityturn.c.

Referenced by city_build(), handle_edit_city(), and handle_edit_city_create().

## ◆ city_counters_refresh()

void city_counters_refresh | ( | struct city * | pcity | ) |

Send updated (by server) counter information of a given city.

Definition at line 4603 of file cityturn.c.

Referenced by api_counter_increase(), api_counter_zero(), end_turn(), send_all_info(), and send_city_info().

## ◆ city_create_unit()

static struct unit * city_create_unit | ( | struct city * | pcity,
|  | const struct unit_type * | utype,
|  | struct citizens_reduction * | red
| ) |  |

static

Helper function to create one unit in a city. Doesn't make any announcements. This might destroy the city due to scripts (but not otherwise; in particular, pop_cost is the caller's problem). If the unit has positive pop_cost and red is not NULL, sets up an array of nationalities to be spent on the unit (must have enough size) Returns the new unit (if it survived scripts).

Definition at line 2769 of file cityturn.c.

Referenced by city_build_unit(), and disband_city().

## ◆ city_distribute_surplus_shields()

static bool city_distribute_surplus_shields | ( | struct player * | pplayer,
|  | struct city * | pcity
| ) |  |

static

Disband units if we don't have enough shields to support them.

Parameters

  pplayer | city owner
  pcity | city to check

Returns
  whether the city is disbanded as a result.

Definition at line 2531 of file cityturn.c.

Referenced by city_build_stuff().

## ◆ city_empty_food_stock()

bool city_empty_food_stock | ( | struct city * | pcity | ) |

Returns TRUE iff the city's food stock was emptied. Should empty the food stock unless it already is empty.

Definition at line 4255 of file cityturn.c.

Referenced by apply_disaster(), and spy_poison().

## ◆ city_global_turn_notify()

static void city_global_turn_notify | ( | struct conn_list * | dest | ) |

static

Notices about cities that should be sent to all players.

Definition at line 489 of file cityturn.c.

Referenced by send_city_turn_notifications().

## ◆ city_growth_granary_savings()

int city_growth_granary_savings | ( | const struct city * | pcity | ) |

Return the percentage of food that is kept in this city after city grows.

Normally this value is 0% but this can be increased by EFT_GROWTH_FOOD effects.

Definition at line 877 of file cityturn.c.

Referenced by city_increase_size(), and city_reset_foodbox().

## ◆ city_illness_check()

static bool city_illness_check | ( | const struct city * | pcity | ) |

static

Check if city suffers from a plague. Return TRUE if it does, FALSE if not.

Definition at line 3769 of file cityturn.c.

Referenced by update_city_activity().

## ◆ city_incite_cost()

int city_incite_cost | ( | struct player * | pplayer,
|  | struct city * | pcity
| ) |  |

Returns the cost to incite a city. This depends on the size of the city, the number of happy, unhappy and angry citizens, whether it is celebrating, how close it is to a capital, how many units it has and upkeeps, presence of courthouse, its buildings and wonders, and who originally built it.

Definition at line 3438 of file cityturn.c.

Referenced by dai_action_value_unit_vs_city(), dai_choose_diplomat_offensive(), diplomat_incite(), find_city_to_diplomat(), and handle_unit_action_query().

## ◆ city_increase_size()

static bool city_increase_size | ( | struct city * | pcity | ) |

static

Increase city size by one. We do not refresh borders or send info about the city to the clients as part of this function. There might be several calls to this function at once, and those actions are needed only once.

Definition at line 919 of file cityturn.c.

Referenced by city_change_size(), city_populate(), and do_city_migration().

## ◆ city_migration_score()

static float city_migration_score | ( | struct city * | pcity | ) |

static

Helper function to calculate a "score" of a city. The score is used to get an estimate of the "migration desirability" of the city. The higher the score the more likely citizens will migrate to it.

The score depends on the city size, the feeling of its citizens, the cost of all buildings in the city, and the surplus of trade, luxury and science.

formula: score = ([city size] + feeling) * factors

feeling of the citizens feeling = 1.00 * happy citizens

- 0.00 * content citizens
- 0.25 * unhappy citizens
- 0.50 * angry citizens

factors the build costs of all buildings f = (1 + (1 - exp(-[build shield cost]/1000))/5) the trade of the city f = (1 + (1 - exp(-[city surplus trade]/100))/5) the luxury within the city f = (1 + (1 - exp(-[city surplus luxury]/100))/5) the science within the city f = (1 + (1 - exp(-[city surplus science]/100))/5)

all factors f have values between 1 and 1.2; the overall factor will be between 1.0 (smaller cities) and 2.0 (bigger cities)

[build shield cost], [city surplus trade], [city surplus luxury] and [city surplus science] must be >= 0!

The food furplus is considered by an additional factor

    the food surplus of the city
    f = (1 + [city surplus food; interval -10..20]/10)

The health factor is defined as:

    the health of the city
    f = (100 - [city illness; tenth of %]/25)

if the city has at least one wonder a factor of 1.25 is added for the capital an additional factor of 1.25 is used the score is also modified by the effect EFT_MIGRATION_PCT

Definition at line 3894 of file cityturn.c.

Referenced by check_city_migrations_player().

## ◆ city_populate()

static void city_populate | ( | struct city * | pcity,
|  | struct player * | nationality
| ) |  |

static

Check whether the population can be increased or if the city is unable to support a 'settler'...

Definition at line 1081 of file cityturn.c.

Referenced by update_city_activity().

## ◆ city_reduce_size()

bool city_reduce_size | ( | struct city * | pcity,
|  | citizens | pop_loss,
|  | struct player * | destroyer,
|  | const char * | reason
| ) |  |

Reduce the city size. Return TRUE if the city survives the population loss. Even if the city has wrong sum of nationalities entering this function, leaves it with correct citizens.

Definition at line 761 of file cityturn.c.

Referenced by apply_disaster(), city_build_unit(), city_change_size(), city_distribute_surplus_shields(), city_illness_strike(), city_populate(), diplomat_incite(), do_city_migration(), do_nuke_tile(), spy_poison(), unit_attack_civilian_casualties(), and unit_conquer_city().

## ◆ city_reduce_specialists()

static citizens city_reduce_specialists | ( | struct city * | pcity,
|  | citizens | change
| ) |  |

static

Reduce the city specialists by some (positive) value. Return the amount of reduction.

Definition at line 717 of file cityturn.c.

Referenced by city_reduce_size(), and city_repair_size().

## ◆ city_reduce_workers()

static citizens city_reduce_workers | ( | struct city * | pcity,
|  | citizens | change
| ) |  |

static

Reduce the city workers by some (positive) value. Return the amount of reduction.

Definition at line 737 of file cityturn.c.

Referenced by city_reduce_size(), and city_repair_size().

## ◆ city_refresh()

bool city_refresh | ( | struct city * | pcity | ) |

Updates unit upkeeps and city internal cached data. Returns whether city radius has changed.

Definition at line 158 of file cityturn.c.

Referenced by api_edit_create_building(), auto_arrange_workers(), building_lost(), city_add_unit(), city_build_building(), city_map_update_tile_direct(), city_reduce_size(), city_refresh_after_city_size_increase(), city_refresh_for_player(), city_refresh_queue_processing(), city_thaw_workers(), create_city(), do_city_migration(), do_unit_establish_trade(), found_new_tech(), handle_city_change(), handle_city_change_specialist(), handle_city_make_specialist(), handle_city_make_worker(), handle_city_refresh(), handle_city_rename(), package_city(), place_unit(), really_handle_city_buy(), really_handle_city_sell(), reestablish_city_trade_routes(), remove_obsolete_buildings_city(), remove_trade_route(), research_tech_lost(), resolve_city_emergency(), send_player_cities(), server_remove_unit_full(), sg_load_players(), sg_load_players(), sg_save_player_cities(), spy_poison(), spy_spread_plague(), transfer_city(), unit_attack_civilian_casualties(), unit_change_homecity_handling(), unit_move_consequences(), and update_city_activity().

## ◆ city_refresh_after_city_size_increase()

static void city_refresh_after_city_size_increase | ( | struct city * | pcity,
|  | struct player * | nationality
| ) |  |

static

Do the city refresh after its size has increased, by any amount.

Definition at line 996 of file cityturn.c.

Referenced by city_change_size(), city_populate(), and do_city_migration().

## ◆ city_refresh_for_player()

void city_refresh_for_player | ( | struct player * | pplayer | ) |

Called on government change or wonder completion or stuff like that – Syela

Definition at line 181 of file cityturn.c.

Referenced by create_city(), government_change(), handle_city_refresh(), handle_player_change_government(), handle_player_rates(), remove_city(), and transfer_city().

## ◆ city_refresh_queue_add()

void city_refresh_queue_add | ( | struct city * | pcity | ) |

Queue pending city_refresh() for later.

Definition at line 196 of file cityturn.c.

Referenced by handle_edit_city(), map_unit_homecity_enqueue(), sell_random_building(), server_remove_player(), and transfer_city().

## ◆ city_refresh_queue_processing()

void city_refresh_queue_processing | ( | void |  | ) |

Refresh the listed cities. Called after significant changes to borders, and arranging workers.

Definition at line 212 of file cityturn.c.

Referenced by create_city(), end_phase(), handle_edit_city(), map_calculate_borders(), map_claim_base(), remove_city(), server_remove_player(), and transfer_city().

## ◆ city_repair_size()

void city_repair_size | ( | struct city * | pcity,
|  | int | change
| ) |  |

Repair the city population without affecting city size. Used by savegame.c and sanitycheck.c

Definition at line 850 of file cityturn.c.

Referenced by sg_load_player_city(), and sg_load_player_city().

## ◆ city_reset_foodbox()

static void city_reset_foodbox | ( | struct city * | pcity,
|  | int | new_size,
|  | bool | shrink
| ) |  |

static

Reset the foodbox, usually when a city grows or shrinks. By default it is reset to zero, but this can be increased by Growth_Food of Shrink_Food effects. Usually this should be called before the city changes size.

Definition at line 904 of file cityturn.c.

Referenced by city_populate().

## ◆ city_shrink_granary_savings()

int city_shrink_granary_savings | ( | const struct city * | pcity | ) |

Return the percentage of food that is kept in this city after city shrinks.

Normally this value is 0% but this can be increased by EFT_SHRINK_FOOD effects.

Definition at line 891 of file cityturn.c.

Referenced by city_reset_foodbox(), and unit_foodbox_cost().

## ◆ city_style_refresh()

void city_style_refresh | ( | struct city * | pcity | ) |

Recheck and store style of the city.

Definition at line 4594 of file cityturn.c.

Referenced by city_refresh().

## ◆ city_tc_effect_refresh()

void city_tc_effect_refresh | ( | struct player * | pplayer | ) |

Recalculate some city related effects on turn change

Definition at line 4624 of file cityturn.c.

Referenced by begin_phase().

## ◆ city_turn_notify()

static void city_turn_notify | ( | const struct city * | pcity,
|  | struct conn_list * | dest,
|  | const struct player * | cache_for_player
| ) |  |

static

Send turn notifications for specified city to specified connections. If 'pplayer' is not NULL, the message will be cached for this player.

Definition at line 510 of file cityturn.c.

Referenced by send_city_turn_notifications().

## ◆ define_orig_production_values()

static void define_orig_production_values | ( | struct city * | pcity | ) |

static

Called every turn, at beginning of turn, for every city.

Definition at line 3519 of file cityturn.c.

Referenced by city_build_stuff().

## ◆ disband_city()

static bool disband_city | ( | struct city * | pcity | ) |

static

Disband a city into the built unit, supported by the closest city. Returns TRUE if the city was disbanded.

Definition at line 3782 of file cityturn.c.

Referenced by city_build_unit().

## ◆ do_city_migration()

static bool do_city_migration | ( | struct city * | pcity_from,
|  | struct city * | pcity_to
| ) |  |

static

Do the migrations between the cities that overlap, if the growth of the target city is not blocked due to a missing improvement or missing food.

Returns TRUE if migration occurred.

Definition at line 3978 of file cityturn.c.

Referenced by check_city_migrations_player().

## ◆ nullify_caravan_and_disband_plus()

static void nullify_caravan_and_disband_plus | ( | struct city * | pcity | ) |

static

Let the advisor set up city building target.

Definition at line 3540 of file cityturn.c.

Referenced by city_build_stuff(), and nullify_prechange_production().

## ◆ nullify_prechange_production()

void nullify_prechange_production | ( | struct city * | pcity | ) |

Initialize all variables containing information about production before it was changed.

Definition at line 3550 of file cityturn.c.

Referenced by apply_disaster(), diplomat_incite(), diplomat_sabotage(), do_unit_strike_city_production(), and raze_city().

## ◆ place_pollution()

static bool place_pollution | ( | struct city * | pcity,
|  | enum extra_cause | cause
| ) |  |

static

Add some Pollution if we have waste

Definition at line 3382 of file cityturn.c.

Referenced by apply_disaster(), and check_pollution().

## ◆ player_balance_treasury_units()

bool player_balance_treasury_units | ( | struct player * | pplayer | ) |

Balance the gold of a nation by selling some units which need gold upkeep.

Definition at line 3266 of file cityturn.c.

Referenced by update_national_activities().

## ◆ player_balance_treasury_units_and_buildings()

bool player_balance_treasury_units_and_buildings | ( | struct player * | pplayer | ) |

Balance the gold of a nation by selling some random units and buildings.

Definition at line 3203 of file cityturn.c.

Referenced by update_national_activities().

## ◆ remove_obsolete_buildings()

void remove_obsolete_buildings | ( | struct player * | pplayer | ) |

Sell obsolete buildings from all cities of the player

Definition at line 269 of file cityturn.c.

Referenced by found_new_tech().

## ◆ remove_obsolete_buildings_city()

void remove_obsolete_buildings_city | ( | struct city * | pcity,
|  | bool | refresh
| ) |  |

Automatically sells obsolete buildings from city.

Definition at line 234 of file cityturn.c.

Referenced by remove_obsolete_buildings(), and transfer_city().

## ◆ sell_random_building()

static bool sell_random_building | ( | struct player * | pplayer,
|  | struct cityimpr_list * | imprs
| ) |  |

static

Randomly sell a building from the given list. Returns TRUE if a building was sold.

NB: It is assumed that gold upkeep for the buildings has already been paid this turn, hence when a building is sold its upkeep is given back to the player. NB: The contents of 'imprs' are usually mangled by this function. NB: It is assumed that all buildings in 'imprs' can be sold.

Definition at line 3017 of file cityturn.c.

Referenced by city_balance_treasury_buildings(), and player_balance_treasury_units_and_buildings().

## ◆ sell_random_unit()

static struct unit * sell_random_unit | ( | struct player * | pplayer,
|  | struct unit_list * | punitlist
| ) |  |

static

Randomly "sell" a unit from the given list. Returns pointer to sold unit. This pointer is not valid any more, but is used to remove the unit from the main list in case of recursive call. The unit is already removed from the list given as a parameter within the function.

NB: It is assumed that gold upkeep for the units has already been paid this turn, hence when a unit is "sold" its upkeep is given back to the player. NB: The contents of 'units' are usually mangled by this function. NB: It is assumed that all units in 'units' have positive gold upkeep.

Definition at line 3120 of file cityturn.c.

Referenced by city_balance_treasury_units(), player_balance_treasury_units(), player_balance_treasury_units_and_buildings(), and sell_random_unit().

## ◆ send_city_turn_notifications()

void send_city_turn_notifications | ( | struct connection * | pconn | ) |

Send global and player specific city turn notifications. If 'pconn' is NULL, it will send to all connections and cache the events.

Definition at line 575 of file cityturn.c.

Referenced by end_turn().

## ◆ set_default_city_manager()

static void set_default_city_manager | ( | struct cm_parameter * | cmp,
|  | struct city * | pcity
| ) |  |

static

Set default city manager parameter for the city.

Definition at line 312 of file cityturn.c.

Referenced by auto_arrange_workers().

## ◆ uk_rem_gold_append()

static void uk_rem_gold_append | ( | struct unit * | punit | ) |

static

Add a unit to uk_rem_gold and make the unit remove it self from it if it dies before it is processed.

Definition at line 3084 of file cityturn.c.

Referenced by city_balance_treasury_units(), player_balance_treasury_units(), and player_balance_treasury_units_and_buildings().

## ◆ uk_rem_gold_callback()

static void uk_rem_gold_callback | ( | struct unit * | punit | ) |

static

Call back for when a unit in uk_rem_gold dies.

A unit can die as a side effect of an action another unit in the list is forced to perform. This isn't limited to "Explode Nuclear". A Lua call back for another action could cause more collateral damage than "Explode Nuclear".

Definition at line 3063 of file cityturn.c.

Referenced by uk_rem_gold_append().

## ◆ unit_list_referred_destroy()

static void unit_list_referred_destroy | ( | struct unit_list * | punitlist | ) |

static

Destroy a unit list and make the units it contains aware that it no longer refers to them.

Definition at line 3097 of file cityturn.c.

Referenced by city_balance_treasury_units(), player_balance_treasury_units(), and player_balance_treasury_units_and_buildings().

## ◆ unit_upgrades_to()

static const struct unit_type * unit_upgrades_to | ( | struct city * | pcity,
|  | const struct unit_type * | punittype
| ) |  |

static

Follow the list of obsoleted_by units until we hit something that we can build. Return NULL when we can't upgrade at all. NB: returning something doesn't guarantee that pcity really can build it; just that pcity can't build whatever obsoletes it.

FIXME: this function is a duplicate of can_upgrade_unittype.

Definition at line 2487 of file cityturn.c.

Referenced by upgrade_unit_prod(), and worklist_change_build_target().

## ◆ update_city_activities()

void update_city_activities | ( | struct player * | pplayer | ) |

Update all cities of one nation (costs for buildings, unit upkeep, ...).

Definition at line 601 of file cityturn.c.

Referenced by end_phase().

## ◆ update_city_activity()

static void update_city_activity | ( | struct city * | pcity | ) |

static

Called every turn, at end of turn, for every city.

Definition at line 3559 of file cityturn.c.

Referenced by update_city_activities().

## ◆ upgrade_building_prod()

static void upgrade_building_prod | ( | struct city * | pcity | ) |

static

Try to upgrade production in pcity.

Definition at line 2462 of file cityturn.c.

Referenced by city_build_building().

## ◆ upgrade_unit_prod()

static void upgrade_unit_prod | ( | struct city * | pcity | ) |

static

Try to upgrade production in pcity.

Definition at line 2508 of file cityturn.c.

Referenced by city_build_unit().

## ◆ upkeep_kill_unit()

static bool upkeep_kill_unit | ( | struct unit * | punit,
|  | Output_type_id | outp,
|  | enum unit_loss_reason | wipe_reason,
|  | bool | wipe_in_the_end
| ) |  |

static

Try to get rid of a unit because of missing upkeep.

Won't try to get rid of a unit without any action auto performers for AAPC_UNIT_UPKEEP. Those are seen as protected from being destroyed because of missing upkeep.

Can optionally wipe the unit in the end if it survived the actions in the selected action auto performer.

Returns TRUE if the unit went away.

Definition at line 685 of file cityturn.c.

Referenced by city_distribute_surplus_shields(), city_populate(), and sell_random_unit().

## ◆ worklist_change_build_target()

static bool worklist_change_build_target | ( | struct player * | pplayer,
|  | struct city * | pcity
| ) |  |

static

Examine the worklist and change the build target. Return 0 if no targets are available to change to. Otherwise return non-zero. Has the side-effect of removing from the worklist any no-longer-available targets as well as the target actually selected, if any.

Definition at line 2184 of file cityturn.c.

Referenced by choose_build_target().

## ◆ worklist_item_postpone_req_vec()

static bool worklist_item_postpone_req_vec | ( | struct universal * | target,
|  | struct city * | pcity,
|  | struct player * | pplayer,
|  | int | saved_id
| ) |  |

static

Examine an unbuildable build target from a city's worklist to see if it can be postponed. Returns TRUE if it never can be build and should be purged or if the city is gone. Returns FALSE if the item can be postponed.

Definition at line 1158 of file cityturn.c.

Referenced by worklist_change_build_target().

## Variable Documentation

## ◆ city_refresh_queue

struct city_list* city_refresh_queue = NULL

static

Definition at line 87 of file cityturn.c.

Referenced by city_refresh_queue_add(), and city_refresh_queue_processing().

## ◆ uk_rem_gold

struct unit_list* uk_rem_gold = NULL

static

Definition at line 93 of file cityturn.c.

Referenced by city_balance_treasury_units(), player_balance_treasury_units(), player_balance_treasury_units_and_buildings(), uk_rem_gold_append(), and uk_rem_gold_callback().