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

Freeciv-3.3

Loading...
Searching...
No Matches
Functions
cityturn.h File Reference
`#include "support.h"`
`#include "fc_types.h"`

Go to the source code of this file.

## Functions

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 | auto_arrange_workers (struct city *pcity)
void | apply_cmresult_to_city (struct city *pcity, const struct cm_result *cmr)
bool | city_change_size (struct city *pcity, citizens new_size, struct player *nationality, const char *reason)
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)
bool | city_empty_food_stock (struct city *pcity)
int | city_growth_granary_savings (const struct city *pcity)
int | city_shrink_granary_savings (const struct city *pcity)
void | send_city_turn_notifications (struct connection *pconn)
void | update_city_activities (struct player *pplayer) fc__attribute((nonnull(1)))
int | city_incite_cost (struct player *pplayer, struct city *pcity)
void | remove_obsolete_buildings_city (struct city *pcity, bool refresh)
void | remove_obsolete_buildings (struct player *pplayer)
void | choose_build_target (struct player *pplayer, struct city *pcity)
void | nullify_prechange_production (struct city *pcity)
bool | check_city_migrations (void)
void | check_disasters (void)
void | city_tc_effect_refresh (struct player *pplayer)
void | city_style_refresh (struct city *pcity)
bool | player_balance_treasury_units_and_buildings (struct player *pplayer)
bool | player_balance_treasury_units (struct player *pplayer)
void | city_counters_refresh (struct city *pcity)

## 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().

## ◆ 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().

## ◆ 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_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().

## ◆ 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_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_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_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_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_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_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_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_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().

## ◆ 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().

## ◆ 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().

## ◆ 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().

## ◆ 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().