Freeciv-3.1
|
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "distribute.h"
#include "fcintl.h"
#include "log.h"
#include "mem.h"
#include "support.h"
#include "ai.h"
#include "citizens.h"
#include "effects.h"
#include "game.h"
#include "government.h"
#include "improvement.h"
#include "map.h"
#include "movement.h"
#include "packets.h"
#include "specialist.h"
#include "traderoutes.h"
#include "unit.h"
#include "cm.h"
#include "city.h"
Go to the source code of this file.
Data Structures | |
struct | tile_cache |
Macros | |
#define | CITYLOG_MAX_VAL 9999 /* maximal value displayed in the citylog */ |
#define | log_ca_s_init log_debug |
Functions | |
static char * | citylog_map_line (int y, int city_radius_sq, int *city_map_data) |
static void | city_tile_cache_update (const struct civ_map *nmap, struct city *pcity) |
static int | city_tile_cache_get_output (const struct city *pcity, int city_tile_index, enum output_type_id o) |
bool | city_tile_index_to_xy (int *city_map_x, int *city_map_y, int city_tile_index, int city_radius_sq) |
int | city_tile_xy_to_index (int city_map_x, int city_map_y, int city_radius_sq) |
int | city_map_radius_sq_get (const struct city *pcity) |
void | city_map_radius_sq_set (struct city *pcity, int radius_sq) |
int | rs_max_city_radius_sq (void) |
int | city_map_tiles (int city_radius_sq) |
bool | is_valid_city_coords (const int city_radius_sq, const int city_map_x, const int city_map_y) |
bool | city_tile_to_city_map (int *city_map_x, int *city_map_y, const int city_radius_sq, const struct tile *city_center, const struct tile *map_tile) |
bool | city_base_to_city_map (int *city_map_x, int *city_map_y, const struct city *const pcity, const struct tile *map_tile) |
bool | city_map_includes_tile (const struct city *const pcity, const struct tile *map_tile) |
struct tile * | city_map_to_tile (const struct civ_map *nmap, const struct tile *city_center, int city_radius_sq, int city_map_x, int city_map_y) |
static int | cmp (int v1, int v2) |
int | compare_iter_index (const void *a, const void *b) |
void | citylog_map_data (enum log_level level, int radius_sq, int *map_data) |
void | citylog_map_workers (enum log_level level, struct city *pcity) |
void | generate_city_map_indices (void) |
void | free_city_map_index (void) |
const char * | get_output_identifier (Output_type_id output) |
const char * | get_output_name (Output_type_id output) |
struct output_type * | get_output_type (Output_type_id output) |
Output_type_id | output_type_by_identifier (const char *id) |
const char * | city_improvement_name_translation (const struct city *pcity, const struct impr_type *pimprove) |
const char * | city_production_name_translation (const struct city *pcity) |
bool | city_production_has_flag (const struct city *pcity, enum impr_flag_id flag) |
int | city_production_build_shield_cost (const struct city *pcity) |
bool | city_production_build_units (const struct city *pcity, bool add_production, int *num_units) |
int | city_production_unit_veteran_level (struct city *pcity, const struct unit_type *punittype) |
int | city_production_turns_to_build (const struct city *pcity, bool include_shield_stock) |
bool | can_city_build_improvement_direct (const struct city *pcity, const struct impr_type *pimprove) |
bool | can_city_build_improvement_now (const struct city *pcity, const struct impr_type *pimprove) |
bool | can_city_build_improvement_later (const struct city *pcity, const struct impr_type *pimprove) |
bool | can_city_build_unit_direct (const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype) |
bool | can_city_build_unit_now (const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype) |
bool | can_city_build_unit_later (const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype) |
bool | can_city_build_direct (const struct civ_map *nmap, const struct city *pcity, const struct universal *target) |
bool | can_city_build_now (const struct civ_map *nmap, const struct city *pcity, const struct universal *target) |
bool | can_city_build_later (const struct civ_map *nmap, const struct city *pcity, const struct universal *target) |
int | city_unit_slots_available (const struct city *pcity) |
bool | city_can_use_specialist (const struct city *pcity, Specialist_type_id type) |
bool | city_can_change_build (const struct city *pcity) |
void | city_choose_build_default (const struct civ_map *nmap, struct city *pcity) |
const char * | city_name_get (const struct city *pcity) |
void | city_name_set (struct city *pcity, const char *new_name) |
void | city_size_add (struct city *pcity, int add) |
void | city_size_set (struct city *pcity, citizens size) |
int | city_population (const struct city *pcity) |
int | city_total_impr_gold_upkeep (const struct city *pcity) |
int | city_total_unit_gold_upkeep (const struct city *pcity) |
bool | city_has_building (const struct city *pcity, const struct impr_type *pimprove) |
int | city_improvement_upkeep (const struct city *pcity, const struct impr_type *b) |
int | city_tile_output (const struct city *pcity, const struct tile *ptile, bool is_celebrating, Output_type_id otype) |
int | city_tile_output_now (const struct city *pcity, const struct tile *ptile, Output_type_id otype) |
bool | base_city_can_work_tile (const struct player *restriction, const struct city *pcity, const struct tile *ptile) |
bool | city_can_work_tile (const struct city *pcity, const struct tile *ptile) |
bool | citymindist_prevents_city_on_tile (const struct civ_map *nmap, const struct tile *ptile) |
bool | city_can_be_built_here (const struct civ_map *nmap, const struct tile *ptile, const struct unit *punit, bool hut_test) |
bool | city_can_be_built_tile_only (const struct civ_map *nmap, const struct tile *ptile) |
bool | is_capital (const struct city *pcity) |
bool | is_gov_center (const struct city *pcity) |
bool | city_got_defense_effect (const struct city *pcity, const struct unit_type *attacker) |
bool | city_happy (const struct city *pcity) |
bool | city_unhappy (const struct city *pcity) |
bool | base_city_celebrating (const struct city *pcity) |
bool | city_celebrating (const struct city *pcity) |
bool | city_rapture_grow (const struct city *pcity) |
bool | city_is_occupied (const struct city *pcity) |
struct city * | city_list_find_number (struct city_list *This, int id) |
struct city * | city_list_find_name (struct city_list *This, const char *name) |
int | city_name_compare (const void *p1, const void *p2) |
int | city_style_by_translated_name (const char *s) |
int | city_style_by_rule_name (const char *s) |
const char * | city_style_name_translation (const int style) |
const char * | city_style_rule_name (const int style) |
void | city_production_caravan_shields_init (void) |
bool | city_production_gets_caravan_shields (const struct universal *tgt) |
int | city_change_production_penalty (const struct city *pcity, const struct universal *target) |
int | city_turns_to_build (const struct city *pcity, const struct universal *target, bool include_shield_stock) |
int | city_turns_to_grow (const struct city *pcity) |
bool | city_can_grow_to (const struct city *pcity, int pop_size) |
struct city * | tile_enemy_city (const struct tile *ptile, const struct player *pplayer) |
struct city * | tile_allied_city (const struct tile *ptile, const struct player *pplayer) |
struct city * | tile_non_attack_city (const struct tile *ptile, const struct player *pplayer) |
struct city * | tile_non_allied_city (const struct tile *ptile, const struct player *pplayer) |
bool | is_unit_near_a_friendly_city (const struct civ_map *nmap, const struct unit *punit) |
bool | is_friendly_city_near (const struct civ_map *nmap, const struct player *owner, const struct tile *ptile) |
bool | city_exists_within_max_city_map (const struct civ_map *nmap, const struct tile *ptile, bool may_be_on_center) |
int | city_granary_size (int city_size) |
static int | player_base_citizen_happiness (const struct player *pplayer) |
citizens | player_content_citizens (const struct player *pplayer) |
citizens | player_angry_citizens (const struct player *pplayer) |
int | get_final_city_output_bonus (const struct city *pcity, Output_type_id otype) |
int | get_city_tithes_bonus (const struct city *pcity) |
void | add_tax_income (const struct player *pplayer, int trade, int *output) |
bool | city_built_last_turn (const struct city *pcity) |
static void | get_worked_tile_output (const struct civ_map *nmap, const struct city *pcity, int *output, bool *workers_map) |
void | add_specialist_output (const struct city *pcity, int *output) |
static void | set_city_bonuses (struct city *pcity) |
static void | set_surpluses (struct city *pcity) |
static void | happy_copy (struct city *pcity, enum citizen_feeling i) |
static void | citizen_base_mood (struct city *pcity) |
static void | citizen_luxury_happy (struct city *pcity, int *luxuries) |
static void | citizen_happy_luxury (struct city *pcity) |
static void | citizen_content_buildings (struct city *pcity) |
static void | citizen_happiness_nationality (struct city *pcity) |
static void | citizen_happy_units (struct city *pcity) |
static void | citizen_happy_wonders (struct city *pcity) |
static void | unhappy_city_check (struct city *pcity) |
int | city_pollution_types (const struct city *pcity, int shield_total, int *pollu_prod, int *pollu_pop, int *pollu_mod) |
int | city_pollution (const struct city *pcity, int shield_total) |
static int | get_trade_illness (const struct city *pcity) |
static int | get_city_health (const struct city *pcity) |
int | city_illness_calc (const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution) |
bool | city_had_recent_plague (const struct city *pcity) |
int | city_build_slots (const struct city *pcity) |
int | city_airlift_max (const struct city *pcity) |
void | set_city_production (struct city *pcity) |
int | city_unit_unhappiness (const struct civ_map *nmap, struct unit *punit, int *free_unhappy) |
static void | city_support (const struct civ_map *nmap, struct city *pcity) |
void | city_refresh_from_main_map (const struct civ_map *nmap, struct city *pcity, bool *workers_map) |
int | city_waste (const struct city *pcity, Output_type_id otype, int total, int *breakdown) |
citizens | city_specialists (const struct city *pcity) |
Specialist_type_id | best_specialist (Output_type_id otype, const struct city *pcity) |
void | city_add_improvement (struct city *pcity, const struct impr_type *pimprove) |
void | city_remove_improvement (struct city *pcity, const struct impr_type *pimprove) |
bool | is_city_option_set (const struct city *pcity, enum city_options option) |
void | city_styles_alloc (int num) |
void | city_styles_free (void) |
struct city * | create_city_virtual (struct player *pplayer, struct tile *ptile, const char *name) |
void | destroy_city_virtual (struct city *pcity) |
bool | city_exist (int id) |
bool | city_is_virtual (const struct city *pcity) |
bool | is_free_worked (const struct city *pcity, const struct tile *ptile) |
void * | city_ai_data (const struct city *pcity, const struct ai_type *ai) |
void | city_set_ai_data (struct city *pcity, const struct ai_type *ai, void *data) |
void | city_rally_point_clear (struct city *pcity) |
void | city_rally_point_receive (const struct packet_city_rally_point *packet, struct city *pcity) |
Variables | |
static struct iter_index * | city_map_index = NULL |
static int | city_map_xy [CITY_MAP_MAX_SIZE][CITY_MAP_MAX_SIZE] |
static int | city_map_numtiles [CITY_MAP_MAX_RADIUS_SQ+1] |
struct citystyle * | city_styles = NULL |
struct output_type | output_types [O_LAST] |
static bv_imprs | caravan_helped_impr |
static bv_unit_types | caravan_helped_utype |
#define CITYLOG_MAX_VAL 9999 /* maximal value displayed in the citylog */ |
#define log_ca_s_init log_debug |
void add_specialist_output | ( | const struct city * | pcity, |
int * | output | ||
) |
Calculate output (gold, science, and luxury) generated by the specialists of a city. The output[] array is not cleared but is just added to.
Definition at line 2304 of file city.c.
Referenced by city_refresh_from_main_map(), and dai_city_want().
void add_tax_income | ( | const struct player * | pplayer, |
int | trade, | ||
int * | output | ||
) |
Add the incomes of a city according to the taxrates (ignore # of specialists). trade should be in output[O_TRADE].
Definition at line 2217 of file city.c.
Referenced by dai_city_want(), get_city_dialog_output_text(), and set_city_production().
bool base_city_can_work_tile | ( | const struct player * | restriction, |
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 (and can continue).
The parameter 'restriction', which is usually client_player(), allow a player to handle with its real knownledge to guess it the work of this tile is possible.
This function shouldn't be called directly, but with city_can_work_tile() (common/city.[ch]) or client_city_can_work_tile() (client/climap.[ch]).
Definition at line 1377 of file city.c.
Referenced by city_can_work_tile(), and client_city_can_work_tile().
Return TRUE if the city was celebrating at the start of the turn, and it still has sufficient size to be in rapture.
Definition at line 1610 of file city.c.
Referenced by city_celebrating(), city_tile_cache_update(), compute_max_stats_heuristic(), compute_tile_production(), dai_city_want(), fill_city_overlays_sprite_array(), get_worked_tile_output(), max_tile_trade(), and min_food_surplus_for_fastest_growth().
Specialist_type_id best_specialist | ( | Output_type_id | otype, |
const struct city * | pcity | ||
) |
Return the "best" specialist available in the game. This specialist will have the most of the given type of output. If pcity is given then only specialists usable by pcity will be considered.
Definition at line 3247 of file city.c.
Referenced by city_increase_size().
bool can_city_build_direct | ( | const struct civ_map * | nmap, |
const struct city * | pcity, | ||
const struct universal * | target | ||
) |
Returns whether city can immediately build given target, unit or improvement. This considers obsolete targets still buildable.
Definition at line 972 of file city.c.
Referenced by base_city_queue_insert().
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.
Definition at line 815 of file city.c.
Referenced by building_upgrades_to(), can_city_build_direct(), can_city_build_improvement_now(), and city_choose_build_default().
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 can never possibly be built in this city.
Definition at line 856 of file city.c.
Referenced by ba_human_wants(), can_city_build_later(), collect_eventually_buildable_targets(), popup_worklist_editor(), and worklist_change_build_target().
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.
Definition at line 839 of file city.c.
Referenced by advisor_choose_build(), base_want(), building_advisor(), building_advisor_choose(), can_city_build_now(), choose_build_target(), city_build_building(), city_global_turn_notify(), collect_eventually_buildable_targets(), dai_build_adv_override(), dai_find_source_building(), military_advisor_choose_build(), popup_worklist_editor(), process_attacker_want(), research_tech_lost(), and upgrade_building_prod().
bool can_city_build_later | ( | const struct civ_map * | nmap, |
const struct city * | pcity, | ||
const struct universal * | target | ||
) |
Returns whether city can ever build given target, unit or improvement.
Definition at line 1009 of file city.c.
Referenced by add_global_worklist(), base_city_queue_insert(), and set_global_worklist().
bool can_city_build_now | ( | const struct civ_map * | nmap, |
const struct city * | pcity, | ||
const struct universal * | target | ||
) |
Returns whether city can immediately build given target, unit or improvement. This considers obsolete targets no longer buildable.
Definition at line 991 of file city.c.
Referenced by can_city_build_now_client(), city_dialog::change_production(), city_dialog_update_building(), city_worklist_commit(), client_change_all(), clipboard_send_production_packet(), city_widget::display_list_menu(), handle_city_change(), city_production_model::populate(), transfer_city(), and worklist_change_build_target().
bool can_city_build_unit_direct | ( | const struct civ_map * | nmap, |
const struct city * | pcity, | ||
const struct unit_type * | punittype | ||
) |
Return whether given city can build given unit, ignoring whether unit is obsolete.
Definition at line 888 of file city.c.
Referenced by can_city_build_direct(), can_city_build_unit_now(), city_build_unit(), city_choose_build_default(), city_gold_worth(), process_attacker_want(), unit_upgrades_to(), and upgrade_unit_prod().
bool can_city_build_unit_later | ( | const struct civ_map * | nmap, |
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 possibly be built in this city.
Definition at line 948 of file city.c.
Referenced by can_city_build_later(), collect_eventually_buildable_targets(), dai_process_defender_want(), dai_wants_defender_against(), dai_wants_role_unit(), popup_worklist_editor(), and worklist_change_build_target().
bool can_city_build_unit_now | ( | const struct civ_map * | nmap, |
const struct city * | pcity, | ||
const struct unit_type * | punittype | ||
) |
Return whether given city can build given unit; returns FALSE if unit is obsolete.
Definition at line 927 of file city.c.
Referenced by best_role_unit(), can_city_build_now(), choose_build_target(), collect_eventually_buildable_targets(), dai_barbarian_choose_build(), dai_choose_attacker(), dai_choose_attacker_air(), dai_choose_bodyguard(), dai_choose_defender_versus(), dai_choose_paratrooper(), dai_hunter_guess_best(), dai_hunter_missile_want(), dai_process_defender_want(), dai_wants_defender_against(), dai_wants_role_unit(), impr_allows_actions(), impr_provides_buildable_units(), popup_worklist_editor(), process_attacker_want(), research_tech_lost(), role_unit_cb(), tai_city_worker_task_select(), and texai_city_worker_task_select().
|
static |
Create content, unhappy and angry citizens.
Definition at line 2407 of file city.c.
Referenced by city_refresh_from_main_map().
|
inlinestatic |
Make citizens content due to city improvements.
Definition at line 2493 of file city.c.
Referenced by city_refresh_from_main_map().
|
inlinestatic |
Apply effects of citizen nationality to happiness
Definition at line 2517 of file city.c.
Referenced by city_refresh_from_main_map().
|
inlinestatic |
Make citizens happy due to luxury.
Definition at line 2483 of file city.c.
Referenced by city_refresh_from_main_map().
|
inlinestatic |
Make citizens happy/unhappy due to units.
This function requires that pcity->martial_law and pcity->unit_happy_cost have already been set in city_support().
Definition at line 2566 of file city.c.
Referenced by city_refresh_from_main_map().
|
inlinestatic |
Make citizens happy due to wonders.
Definition at line 2614 of file city.c.
Referenced by city_refresh_from_main_map().
|
inlinestatic |
Make people happy: angry citizen are eliminated first then content are made happy, then unhappy content, etc. each conversions costs 2 or 4 luxuries.
Definition at line 2446 of file city.c.
Referenced by citizen_happy_luxury().
Adds an improvement (and its effects) to a city.
Definition at line 3270 of file city.c.
Referenced by base_want(), build_free_small_wonders(), build_or_move_building(), city_build_building(), city_build_free_buildings(), edit_buffer_copy(), sg_load_player_city(), sg_load_player_city(), transfer_city(), and update_improvement_from_packet().
Return pointer to ai data of given city and ai type.
Definition at line 3508 of file city.c.
Referenced by def_ai_city_data(), and texai_city_data().
int city_airlift_max | ( | const struct city * | pcity | ) |
A city's maximum airlift capacity. (Note, this still returns a finite number even if airliftingstyle allows unlimited airlifts)
Definition at line 2844 of file city.c.
Referenced by get_airlift_text(), and update_city_activity().
bool city_base_to_city_map | ( | int * | city_map_x, |
int * | city_map_y, | ||
const struct city *const | pcity, | ||
const struct tile * | map_tile | ||
) |
Finds the city map coordinate for a given map position and a city. Returns whether the map position is inside of the city map.
Definition at line 276 of file city.c.
Referenced by adjust_workers_button_pressed(), base_city_can_work_tile(), city_map_includes_tile(), fill_city_overlays_sprite_array(), fill_grid_sprite_array(), fill_sprite_array(), and resolve_city_emergency().
int city_build_slots | ( | const struct city * | pcity | ) |
The maximum number of units a city can build per turn.
Definition at line 2834 of file city.c.
Referenced by city_dialog_update_building(), city_production_build_units(), city_production_cost_str(), and cr_entry_build_slots().
Return TRUE if the city built something last turn (meaning production was completed between last turn and this).
Definition at line 2251 of file city.c.
Referenced by city_change_production_penalty(), dai_city_choose_build(), and should_force_recalc().
bool city_can_be_built_here | ( | const struct civ_map * | nmap, |
const struct tile * | ptile, | ||
const struct unit * | punit, | ||
bool | hut_test | ||
) |
Returns TRUE if the given unit can build a city at the given map coordinates.
punit is the founding unit. It may be NULL if a city is built out of the blue (e.g., through editing).
Definition at line 1460 of file city.c.
Referenced by api_methods_unit_city_can_be_built_here(), city_desirability(), create_city_for_player(), dai_auto_settler_run(), find_city_or_settler_near_tile(), property_page_create_objects(), and unit_drawn_with_city_outline().
Returns TRUE if the given unit can build a city at the given map coordinates.
It may still be illegal for any unit to build a city at the specified tile.
Definition at line 1533 of file city.c.
Referenced by city_can_be_built_here().
Returns TRUE iff the given city can change what it is building
Definition at line 1057 of file city.c.
Referenced by city_build_unit(), city_set_queue(), and handle_city_change().
Return TRUE iff the city can grow to the given size.
Definition at line 1985 of file city.c.
Referenced by city_increase_size(), city_turn_notify(), dai_effect_value(), dai_manage_taxes(), do_city_migration(), expl_act_not_enabl(), and is_action_possible().
bool city_can_use_specialist | ( | const struct city * | pcity, |
Specialist_type_id | type | ||
) |
Returns TRUE iff the given city can use this kind of specialist.
Definition at line 1043 of file city.c.
Referenced by best_specialist(), city_rotate_specialist(), handle_city_change_specialist(), and init_specialist_lattice_nodes().
Returns TRUE when a tile is available to be worked, or the city itself is currently working the tile (and can continue).
See also client_city_can_work_tile() (client/climap.[ch]).
Definition at line 1429 of file city.c.
Referenced by adjust_workers_button_pressed(), apply_result_on_server(), city_increase_size(), city_map_update_radius_sq(), city_map_update_tile_direct(), city_toggle_worker(), do_city_migration(), fill_city_overlays_sprite_array(), handle_city_make_worker(), init_tile_lattice(), max_tile_trade(), settler_evaluate_improvements(), tai_tile_worker_task_select(), and texai_tile_worker_task_select().
cities celebrate only after consecutive happy turns
Definition at line 1618 of file city.c.
Referenced by api_methods_is_city_celebrating(), city_dialog_update_title(), city_incite_cost(), city_tile_output_now(), city_turn_notify(), civil_war_triggered(), cr_entry_hstate_concise(), cr_entry_hstate_verbose(), real_city_dialog_popup(), real_city_report_dialog_update_city(), real_info_city_report_dialog_update(), rebuild_citydlg_title_str(), redraw_city_dialog(), update_city_activity(), and city_dialog::update_title().
Compute and optionally apply the change-production penalty for the given production change (to target) in the given city (pcity). Always returns the number of shields which would be in the stock if the penalty had been applied.
If we switch the "class" of the target sometime after a city has produced (i.e., not on the turn immediately after), then there's a shield loss. But only on the first switch that turn. Also, if ever change back to original improvement class of this turn, restore lost production.
Definition at line 1859 of file city.c.
Referenced by change_build_target(), change_production(), and city_turns_to_build().
Always tile_set_owner(ptile, pplayer) sometime before this!
Definition at line 1065 of file city.c.
Referenced by cityresult_fill(), and create_city().
bool city_exist | ( | int | id | ) |
Check if city with given id still exist. Use this before using old city pointers when city might have disappeared.
Definition at line 3471 of file city.c.
Referenced by building_removed(), check_disasters(), city_build_building(), city_build_unit(), city_change_size(), city_populate(), city_reduce_size(), disband_city(), do_city_migration(), do_unit_conquer_city(), remove_city(), transfer_city(), transfer_city_units(), unit_conquer_city(), unit_do_destroy_city(), worklist_change_build_target(), and worklist_item_postpone_req_vec().
bool city_exists_within_max_city_map | ( | const struct civ_map * | nmap, |
const struct tile * | ptile, | ||
bool | may_be_on_center | ||
) |
Return TRUE iff a city exists within a city radius of the given location. may_be_on_center determines if a city at x,y counts.
Definition at line 2084 of file city.c.
Referenced by api_methods_tile_city_exists_within_max_city_map(), and hut_get_limited().
This can be City Walls, Coastal defense... depending on attacker type. If attacker type is not given, just any defense effect will do.
Definition at line 1569 of file city.c.
Referenced by base_assess_defense_unit(), and dai_process_defender_want().
int city_granary_size | ( | int | city_size | ) |
Generalized formula used to calculate granary size.
The AI may not deal well with non-default settings. See food_weighting().
Definition at line 2104 of file city.c.
Referenced by city_dialog_update_information(), city_dialog_update_information(), city_gold_worth(), city_increase_size(), city_populate(), city_reduce_size(), city_reset_foodbox(), city_turn_notify(), city_turns_to_grow(), cr_entry_growturns(), dai_effect_value(), dai_manage_cities(), get_city_growth_string(), handle_edit_city(), min_food_surplus_for_fastest_growth(), objbind_get_allowed_value_span(), package_city(), redraw_city_dialog(), set_default_city_manager(), unit_foodbox_cost(), and city_dialog::update_info_label().
Returns whether city had a plague outbreak this turn.
Definition at line 2825 of file city.c.
Referenced by city_populate().
Return TRUE iff the city is happy. A happy city will start celebrating soon. A city can only be happy if half or more of the population is happy, none of the population is unhappy or angry, and it has sufficient size.
Definition at line 1587 of file city.c.
Referenced by api_methods_is_city_happy(), city_celebrating(), city_dialog_update_title(), dai_manage_taxes(), get_city_surplus(), handle_city_info(), real_city_dialog_popup(), real_city_report_dialog_update_city(), real_info_city_report_dialog_update(), rebuild_citydlg_title_str(), redraw_city_dialog(), update_city_activity(), update_dumb_city(), and city_dialog::update_title().
Return TRUE iff the city has this building in it.
Definition at line 1216 of file city.c.
Referenced by adjust_ai_unit_choice(), api_edit_create_building(), api_edit_remove_building(), api_methods_city_has_building(), ba_human_wants(), build_or_move_building(), can_city_build_improvement_direct(), can_city_sell_building(), city_build_building(), city_building_present(), city_from_wonder(), dai_build_adv_adjust(), diplomat_sabotage(), city_widget::display_list_menu(), do_unit_strike_city_building(), edit_buffer_copy(), get_economy_report_data(), handle_edit_city(), num_city_buildings(), ok_sell_impr_callback(), package_city(), popup_info_text(), popup_sell_impr_callback(), sell_all_improvements(), sell_impr_iterate(), spy_send_sabotage_list(), tactical_req_cb(), and update_dumb_city().
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:
base illness (the maximum value for illness in percent is given by 'game.info.illness_base_factor')
The illness is reduced by the percentage given by the health effect. Illness cannot exceed 999 (= 99.9%), or be less then 0
Definition at line 2772 of file city.c.
Referenced by city_dialog_update_information(), city_dialog_update_information(), city_illness_strike(), city_migration_score(), cr_entry_plague_risk(), get_city_dialog_illness_text(), redraw_info_city_dialog(), sg_load_players(), sg_load_players(), update_city_activity(), and city_dialog::update_info_label().
const char * city_improvement_name_translation | ( | const struct city * | pcity, |
const struct impr_type * | pimprove | ||
) |
Return the extended name of the building.
Definition at line 658 of file city.c.
Referenced by add_global_worklist(), add_target_to_worklist(), city_build_building(), city_production_name_translation(), create_improvements_list(), get_city_dialog_production_full(), get_production_name(), impr_item::mouseDoubleClickEvent(), name_and_sort_items(), popup_impr_info(), popup_sabotage_dialog(), popup_sabotage_dialog(), popup_worklist_editor(), rebuild_imprm_list(), report_wonders_of_the_world(), sell_callback(), sell_imprvm_dlg_callback(), set_global_worklist(), city_dialog::update_improvements(), worklist_change_build_target(), and worklist_item_postpone_req_vec().
Return the upkeep (gold) needed each turn to upkeep the given improvement in the given city.
Definition at line 1231 of file city.c.
Referenced by city_dialog_update_improvement_list(), city_total_impr_gold_upkeep(), dai_city_want(), get_city_dialog_production_row(), get_economy_report_data(), get_tooltip_improvement(), sell_random_building(), and city_dialog::update_improvements().
Returns TRUE iff the city is occupied.
Definition at line 1638 of file city.c.
Referenced by popup_info_text().
Return TRUE if the city is a virtual city. That is, it is a valid city pointer but does not correspond to a city that exists in the game.
NB: A return value of FALSE implies that either the pointer is NULL or that the city exists in the game.
Definition at line 3488 of file city.c.
Referenced by tile_virtual_destroy().
struct city * city_list_find_name | ( | struct city_list * | This, |
const char * | name | ||
) |
Find city with given name from list.
Definition at line 1668 of file city.c.
Referenced by game_city_by_name(), is_allowed_city_name(), and transfer_city().
struct city * city_list_find_number | ( | struct city_list * | This, |
int | id | ||
) |
Find city with given id from list.
Definition at line 1652 of file city.c.
Referenced by city_freeze_workers_queue(), city_refresh_queue_add(), and dai_goldequiv_clause().
Returns TRUE iff pcity's city map includes the specified tile.
Definition at line 288 of file city.c.
Referenced by handle_city_make_specialist(), and handle_city_make_worker().
int city_map_radius_sq_get | ( | const struct city * | pcity | ) |
Returns the current squared radius of the city.
Definition at line 132 of file city.c.
Referenced by adv_city_update(), adv_city_worker_act_get(), adv_city_worker_act_set(), adv_city_worker_extra_get(), adv_city_worker_extra_set(), adv_city_worker_rmextra_get(), adv_city_worker_rmextra_set(), api_methods_city_map_sq_radius(), apply_cmresult_to_city(), apply_result_on_server(), apply_solution(), build_landarea_map(), button_down_citymap(), check_city_migrations_player(), city_base_to_city_map(), city_increase_size(), city_map_update_all(), city_map_update_radius_sq(), city_reduce_workers(), city_tc_effect_refresh(), city_tile_cache_get_output(), city_tile_cache_update(), city_toggle_worker(), citylog_map_workers(), citymap_turn_init(), cityresult_fill(), cm_print_city(), cm_result_new(), compute_max_stats_heuristic(), city_map::context_menu(), dai_city_want(), dai_effect_value(), do_city_migration(), game_remove_city(), get_worked_tile_output(), give_citymap_from_player_to_player(), handle_city_info(), handle_city_short_info(), handle_tile_info(), impr_provides_buildable_extras(), init_tile_lattice(), initialize_infrastructure_cache(), is_extra_req_active(), is_extraflag_req_active(), is_roadflag_req_active(), is_terrain_req_active(), is_terrainclass_req_active(), is_terrainflag_req_active(), is_tile_seen_city(), left_button_down_citymap(), map_claim_border(), max_tile_trade(), min_food_surplus_for_fastest_growth(), city_map::mousePressEvent(), place_pollution(), player_in_city_map(), resolve_city_emergency(), resource_map_city_dlg_callback(), right_button_down_citymap(), city_map::set_pixmap(), settler_evaluate_improvements(), tai_city_worker_task_select(), and texai_city_worker_task_select().
void city_map_radius_sq_set | ( | struct city * | pcity, |
int | radius_sq | ||
) |
Sets the squared radius for the city.
Definition at line 143 of file city.c.
Referenced by city_map_update_radius_sq(), handle_city_short_info(), handle_tile_info(), sg_load_player_city(), and sg_load_player_city().
int city_map_tiles | ( | int | city_radius_sq | ) |
Return the number of tiles for the given city radius. Special case is the value -1 for no city tiles.
Definition at line 166 of file city.c.
Referenced by adv_city_update(), city_map_update_radius_sq(), city_tile_cache_update(), city_tile_index_to_xy(), citylog_map_workers(), cm_print_result(), cm_result_copy(), cm_result_new(), generate_city_map_indices(), max_tile_trade(), place_pollution(), and print_cityresult().
struct tile * city_map_to_tile | ( | const struct civ_map * | nmap, |
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. Returns true if the map position found is real.
Definition at line 300 of file city.c.
Referenced by button_down_citymap(), city_map_update_radius_sq(), city_toggle_worker(), citylog_map_workers(), city_map::context_menu(), max_tile_trade(), min_food_surplus_for_fastest_growth(), place_pollution(), and right_button_down_citymap().
int city_name_compare | ( | const void * | p1, |
const void * | p2 | ||
) |
Comparison function for qsort for city pointers, sorting by city name. Args are really (struct city**), to sort an array of pointers. (Compare with old_city_name_compare() in game.c, which use city_id's)
Definition at line 1684 of file city.c.
Referenced by create_clause_menu(), popup_add_menu(), and popup_diplomatic_objects().
const char * city_name_get | ( | const struct city * | pcity | ) |
Return the name of the city.
Definition at line 1115 of file city.c.
Referenced by adv_city_worker_act_set(), adv_city_worker_extra_set(), adv_city_worker_rmextra_set(), agents_city_changed(), agents_city_new(), agents_city_remove(), apply_disaster(), apply_result_on_server(), auto_arrange_workers(), caravan_optimize_callback(), change_build_target(), check_city_migrations_player(), choose_build_target(), cities_update_callback(), citizens_convert(), citizens_convert_conquest(), citizens_print(), city_build_unit(), city_choose_build_default(), city_dialog_update_title(), city_from_wonder(), city_link(), city_map_update_radius_sq(), city_migration_score(), city_packet_common(), city_reduce_size(), city_dialog::city_rename(), city_repair_size(), city_tile_link(), citylog_map_workers(), civil_war(), client_diplomacy_clause_string(), client_remove_city(), client_remove_unit(), cm_find_best_solution(), cm_print_city(), cm_state_init(), cma_put_city_under_agent(), cr_entry_cityname(), create_city_dialog(), create_clause_menu(), dai_action_value_unit_vs_city(), dai_airlift(), dai_auto_settler_run(), dai_caravan_goto(), dai_choose_attacker_air(), dai_choose_diplomat_defensive(), dai_choose_diplomat_offensive(), dai_choose_help_wonder(), dai_choose_paratrooper(), dai_city_choose_build(), dai_diplomat_city(), dai_find_strategic_airbase(), dai_goldequiv_clause(), dai_manage_airunit(), dai_manage_diplomat(), dai_manage_hitpoint_recovery(), dai_manage_paratrooper(), dai_manage_taxes(), dai_military_attack_barbarian(), dai_military_defend(), dai_process_defender_want(), dai_should_we_air_attack_tile(), debug_command(), define_orig_production_values(), diplomat_sabotage(), do_capture_units(), edit_buffer_copy(), explain_why_no_action_enabled(), goto_dialog::fill_tab(), find_best_tile_to_paradrop_to(), find_something_to_kill(), game_remove_city(), game_remove_unit(), get_city_citizen_types(), get_city_dialog_output_text(), get_city_mapview_name_and_growth(), get_nearest_city_text(), get_unit_info_label_text2(), handle_city(), handle_city_info(), handle_city_make_specialist(), handle_city_make_worker(), handle_tile_info(), handle_unit_packet_common(), idex_register_city(), idex_unregister_city(), illegal_action_msg(), kill_something_with(), list_store_append_player_cities(), look_for_charge(), plr_widget::nation_selected(), new_name_city_dlg_callback(), package_city(), place_pollution(), popup_action_selection(), popup_add_menu(), popup_advanced_terrain_dialog(), popup_city_cma_dialog(), popup_diplomatic_objects(), popup_find_dialog(), popup_incite_dialog(), popup_incite_dialog(), popup_info_text(), popup_worklist_editor(), process_attacker_want(), rally_set_tile(), real_bodyguard_log(), real_city_dialog_popup(), real_city_log(), real_info_city_report_dialog_update(), real_menus_update(), really_handle_city_buy(), rebuild_citydlg_title_str(), redraw_info_city_dialog(), redraw_unit_info_label(), refresh_city_names(), rename_callback(), report_top_five_cities(), report_wonders_of_the_world(), resolve_city_emergency(), send_player_cities(), sg_load_player_city(), sg_load_player_city(), sg_load_player_city_citizens(), sg_load_player_city_citizens(), sg_save_player_cities(), show_city_descriptions(), teleport_unit_to_city(), text_tag_initv(), text_tag_replace_text(), text_tag_start_sequence(), throw_units_from_illegal_cities(), tile_set_terrain(), transfer_city(), transfer_city_units(), transfer_unit(), try_summon_barbarians(), unit_description(), hud_units::update_actions(), update_dumb_city(), update_find_dialog(), update_goto_dialog(), update_intel_dialog(), update_intel_wonder_dialog(), update_source_label(), city_dialog::update_title(), usdlg_get_unit_descr(), vision_site_new_from_city(), vision_site_update_from_city(), and want_tech_for_improvement_effect().
void city_name_set | ( | struct city * | pcity, |
const char * | new_name | ||
) |
Set a new name for the city.
Definition at line 1123 of file city.c.
Referenced by create_city_virtual(), handle_city_info(), handle_city_rename(), handle_city_short_info(), handle_edit_city(), sg_load_player_city(), sg_load_player_city(), and transfer_city().
int city_pollution | ( | const struct city * | pcity, |
int | shield_total | ||
) |
Calculate pollution for the city. The shield_total must be passed in (most callers will want to pass pcity->shield_prod).
Definition at line 2723 of file city.c.
Referenced by city_refresh_from_main_map(), and dai_city_want().
int city_pollution_types | ( | const struct city * | pcity, |
int | shield_total, | ||
int * | pollu_prod, | ||
int * | pollu_pop, | ||
int * | pollu_mod | ||
) |
Calculate the pollution from production and population in the city.
Definition at line 2689 of file city.c.
Referenced by city_pollution(), and get_city_dialog_pollution_text().
int city_population | ( | const struct city * | pcity | ) |
Returns how many thousand citizen live in this city.
Definition at line 1169 of file city.c.
Referenced by calc_civ_score(), city_dialog_update_title(), civ_population(), popup_city_cma_dialog(), rebuild_citydlg_title_str(), and city_dialog::update_title().
int city_production_build_shield_cost | ( | const struct city * | pcity | ) |
Return the number of shields it takes to build current city production.
Definition at line 722 of file city.c.
Referenced by build_points_left(), city_dialog_update_building(), city_production_cost_str(), get_act_sel_action_custom_text(), get_prod_complete_string(), is_action_possible(), popup_worklist_editor(), really_handle_city_buy(), and city_dialog::update_building().
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. Within 'num_units' the total number of units the city can build considering the current shield stock is returned.
Definition at line 732 of file city.c.
Referenced by city_build_unit(), city_production_cost_str(), get_units_report_data(), units_report_update(), and units_reports::update_units().
void city_production_caravan_shields_init | ( | void | ) |
Initialize the cache of what city production can use shields from caravans.
Definition at line 1751 of file city.c.
Referenced by handle_rulesets_ready(), and load_rulesetdir().
Returns TRUE iff the specified production should get shields from units that has done ACTION_HELP_WONDER.
Definition at line 1833 of file city.c.
Referenced by city_change_production_penalty(), dai_choose_help_wonder(), dai_manage_caravan(), unit_do_help_build(), and wonder_benefit().
Return TRUE when the current production has this flag.
Definition at line 712 of file city.c.
Referenced by city_build_building(), cityrep_buy(), cr_entry_build_cost(), cr_entry_building(), get_city_dialog_production(), get_city_mapview_production(), get_economy_report_data(), get_prod_complete_string(), player_get_expected_income(), popup_worklist_editor(), and really_handle_city_buy().
const char * city_production_name_translation | ( | const struct city * | pcity | ) |
Return the extended name of the current production.
Definition at line 695 of file city.c.
Referenced by city_dialog::buy(), buy_callback(), change_build_target(), city_dialog_update_building(), cityrep_buy(), cr_entry_building(), goto_dialog::fill_tab(), popup_hurry_production_dialog(), popup_worklist_editor(), unit_do_help_build(), and city_dialog::update_building().
Calculates the turns which are needed to build the requested production in the city. GUI Independent.
Definition at line 805 of file city.c.
Referenced by city_global_turn_notify(), cr_entry_build_cost(), get_city_dialog_production(), get_city_mapview_production(), get_units_report_data(), popup_worklist_editor(), real_city_report_dialog_update_city(), real_info_city_report_dialog_update(), and redraw_city_dialog().
How many veteran levels will created unit of this type get?
Definition at line 789 of file city.c.
Referenced by adjust_ai_unit_choice(), city_create_unit(), dai_choose_attacker_air(), dai_choose_diplomat_offensive(), dai_choose_paratrooper(), dai_gothere_bodyguard(), dai_hunter_choice(), dai_unit_consider_bodyguard(), find_something_to_kill(), kill_something_with(), military_advisor_choose_build(), and send_rally_tile().
void city_rally_point_clear | ( | struct city * | pcity | ) |
Clear rally point set for the city.
Definition at line 3525 of file city.c.
Referenced by city_build_unit(), destroy_city_virtual(), and transfer_city().
void city_rally_point_receive | ( | const struct packet_city_rally_point * | packet, |
struct city * | pcity | ||
) |
Fill city rally point from a packet.
Definition at line 3540 of file city.c.
Referenced by handle_city_rally_point(), and handle_city_rally_point().
Returns whether city is growing by rapture.
Definition at line 1626 of file city.c.
Referenced by city_increase_size(), and city_populate().
void city_refresh_from_main_map | ( | const struct civ_map * | nmap, |
struct city * | pcity, | ||
bool * | workers_map | ||
) |
Refreshes the internal cached data in the city structure.
!full_refresh will not update tile_cache[] or bonus[]. These two values do not need to be recalculated for AI CMA testing.
'workers_map' is an boolean array which defines the placement of the workers within the city map. It uses the tile index and its size is defined by city_map_tiles_from_city(_pcity). See also cm_state_init().
If 'workers_map' is set, only basic updates are needed.
Definition at line 3070 of file city.c.
Referenced by apply_solution(), city_refresh(), cm_query_result(), and dai_manage_taxes().
Removes an improvement (and its effects) from a city.
Definition at line 3284 of file city.c.
Referenced by api_edit_remove_building(), base_want(), build_or_move_building(), building_removed(), city_build_building(), client_remove_city(), handle_edit_city(), transfer_city(), and update_improvement_from_packet().
Attach ai data to city
Definition at line 3516 of file city.c.
Referenced by dai_city_alloc(), dai_city_free(), texai_city_alloc(), and texai_city_free().
void city_size_add | ( | struct city * | pcity, |
int | add | ||
) |
Add a (positive or negative) value to the city size. As citizens is an unsigned value use int for the parameter 'add'.
Definition at line 1142 of file city.c.
Referenced by city_add_unit(), city_increase_size(), city_reduce_size(), cityresult_fill(), and handle_city_info().
Set the city size.
Definition at line 1158 of file city.c.
Referenced by city_size_add(), create_city_virtual(), edit_buffer_copy(), handle_city_info(), handle_city_short_info(), sg_load_player_city(), and sg_load_player_city().
Give the number of specialists in a city.
Definition at line 3230 of file city.c.
Referenced by citizen_base_mood(), city_dialog_update_information(), city_dialog_update_information(), city_map_update_radius_sq(), evaluate_solution(), handle_city_make_worker(), redraw_city_dialog(), redraw_happiness_city_dialog(), show_info_popup(), show_info_popup(), and city_dialog::update_info_label().
int city_style_by_rule_name | ( | const char * | s | ) |
Returns the city style that has the given (untranslated) rule name. Returns -1 if none match.
Definition at line 1711 of file city.c.
Referenced by sg_load_player_city(), sg_load_player_city(), sg_load_player_vision_city(), and sg_load_player_vision_city().
int city_style_by_translated_name | ( | const char * | s | ) |
const char * city_style_name_translation | ( | const int | style | ) |
Return the (translated) name of the given city style. You don't have to free the return pointer.
Definition at line 1729 of file city.c.
Referenced by city_style_by_translated_name(), and create_races_dialog().
const char * city_style_rule_name | ( | const int | style | ) |
Return the (untranslated) rule name of the city style. You don't have to free the return pointer.
Definition at line 1738 of file city.c.
Referenced by city_style_by_rule_name(), is_universal_needed(), load_ruleset_styles(), sanity_check_ruleset_data(), sg_save_player_cities(), sg_save_player_vision(), and tileset_setup_city_tiles().
void city_styles_alloc | ( | int | num | ) |
Allocate memory for this amount of city styles.
Definition at line 3309 of file city.c.
Referenced by handle_ruleset_control(), and load_style_names().
void city_styles_free | ( | void | ) |
De-allocate the memory used by the city styles.
Definition at line 3324 of file city.c.
Referenced by game_ruleset_free().
Calculate upkeep costs. This builds the pcity->usage[] array as well as setting some happiness values.
Definition at line 2994 of file city.c.
Referenced by city_refresh_from_main_map().
|
inlinestatic |
This function returns the output of 'o' for the city tile 'city_tile_index' of 'pcity'.
Definition at line 2371 of file city.c.
Referenced by get_worked_tile_output().
|
inlinestatic |
This function sets the cache for the tile outputs, the pcity->tile_cache[] array. It is called near the beginning of city_refresh_from_main_map().
It doesn't depend on anything else in the refresh and doesn't change as workers are moved around, but does change when buildings are built, etc.
TODO: use the cached values elsewhere in the code!
Definition at line 2342 of file city.c.
Referenced by city_refresh_from_main_map().
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.
Definition at line 96 of file city.c.
Referenced by cm_print_city(), and place_pollution().
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. pcity may be NULL. is_celebrating may be speculative. otype is the output type (generally O_FOOD, O_TRADE, or O_SHIELD).
This can be used to calculate the benefits celebration would give.
Definition at line 1259 of file city.c.
Referenced by city_tile_cache_update(), city_tile_output_now(), cityresult_fill(), compute_max_stats_heuristic(), compute_tile_production(), dai_city_want(), do_city_migration(), fill_city_overlays_sprite_array(), get_tile_output_text(), get_tile_value(), get_worked_tile_output(), max_tile_trade(), and min_food_surplus_for_fastest_growth().
int city_tile_output_now | ( | const struct city * | pcity, |
const struct tile * | ptile, | ||
Output_type_id | otype | ||
) |
Calculate the production output the given tile is capable of producing for the city. The output type is given by 'otype' (generally O_FOOD, O_SHIELD, or O_TRADE).
NOTE: As of now, return value does not represent output on end of turn if city stops celebrating, because the server side tile output cache uses base_city_celebrating() instead of city_celebrating() on city_tile_cache_update().
Definition at line 1360 of file city.c.
Referenced by city_tile_value().
bool city_tile_to_city_map | ( | int * | city_map_x, |
int * | city_map_y, | ||
const int | city_radius_sq, | ||
const struct tile * | city_center, | ||
const struct tile * | map_tile | ||
) |
Finds the city map coordinate for a given map position and a city center. Returns whether the map position is inside of the city map.
Definition at line 259 of file city.c.
Referenced by city_base_to_city_map(), and fill_grid_sprite_array().
int city_tile_xy_to_index | ( | int | city_map_x, |
int | city_map_y, | ||
int | city_radius_sq | ||
) |
Returns the index for the given city tile coordinates taking into account the squared city radius.
Definition at line 118 of file city.c.
Referenced by citylog_map_line().
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.
Definition at line 1179 of file city.c.
Referenced by city_support(), player_get_expected_income(), and update_city_activity().
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. Takes into account EFT_UNIT_UPKEEP_FREE_PER_CITY.
Definition at line 1198 of file city.c.
Referenced by city_support(), military_advisor_choose_build(), player_get_expected_income(), and update_city_activity().
int city_turns_to_build | ( | const struct city * | pcity, |
const struct universal * | target, | ||
bool | include_shield_stock | ||
) |
Calculates the turns which are needed to build the requested improvement in the city. GUI Independent.
Definition at line 1938 of file city.c.
Referenced by city_production_turns_to_build(), get_city_dialog_production_full(), get_city_dialog_production_row(), popup_worklist_editor(), and refresh_production_label().
int city_turns_to_grow | ( | const struct city * | pcity | ) |
Calculates the turns which are needed for the city to grow. A value of FC_INFINITY means the city will never grow. A value of 0 means city growth is blocked. A negative value of -x means the city will shrink in x turns. A positive value of x means the city will grow in x turns.
Definition at line 1969 of file city.c.
Referenced by city_dialog_update_information(), city_dialog_update_information(), cr_entry_growturns(), get_city_mapview_name_and_growth(), package_city(), real_city_report_dialog_update_city(), real_info_city_report_dialog_update(), redraw_city_dialog(), and city_dialog::update_info_label().
Return TRUE iff the city is unhappy. An unhappy city will fall into disorder soon.
Definition at line 1599 of file city.c.
Referenced by api_methods_is_city_unhappy(), city_dialog_update_title(), city_gold_worth(), city_incite_cost(), civil_war_triggered(), cr_entry_hstate_concise(), cr_entry_hstate_verbose(), get_city_surplus(), handle_city_info(), real_city_dialog_popup(), real_city_report_dialog_update_city(), real_info_city_report_dialog_update(), rebuild_citydlg_title_str(), redraw_city_dialog(), resolve_city_emergency(), unhappy_city_check(), update_city_activity(), update_dumb_city(), and city_dialog::update_title().
int city_unit_slots_available | ( | const struct city * | pcity | ) |
Return number of free unit slots in a city.
Definition at line 1027 of file city.c.
Referenced by can_city_build_unit_direct(), and is_action_possible().
Query unhappiness caused by a given unit.
Definition at line 2943 of file city.c.
Referenced by city_dialog_update_supported_units(), city_support(), create_unit_surface(), dai_assess_military_unhappiness(), and city_dialog::update_units().
int city_waste | ( | const struct city * | pcity, |
Output_type_id | otype, | ||
int | total, | ||
int * | breakdown | ||
) |
Give corruption/waste generated by city. otype gives the output type (O_SHIELD/O_TRADE). 'total' gives the total output of this type in the city. If non-NULL, 'breakdown' should be an OLOSS_LAST-sized array which will be filled in with a breakdown of the kinds of waste (not cumulative).
Definition at line 3122 of file city.c.
Referenced by cityresult_fill(), dai_city_want(), get_city_dialog_output_text(), and set_city_production().
void citylog_map_data | ( | enum log_level | level, |
int | radius_sq, | ||
int * | map_data | ||
) |
Display 'map_data' on a city map with the given radius 'radius_sq' for the requested log level. The size of 'map_data' is defined by city_map_tiles(radius_sq).
Definition at line 406 of file city.c.
Referenced by citylog_map_workers(), cm_print_result(), and print_cityresult().
|
static |
Definition at line 364 of file city.c.
Referenced by citylog_map_data().
Display the location of the workers within the city map of pcity.
Definition at line 441 of file city.c.
Referenced by city_map_update_radius_sq().
Returns TRUE iff it is illegal to found a city on the specified tile because of citymindist.
Definition at line 1438 of file city.c.
Referenced by city_can_be_built_tile_only(), expl_act_not_enabl(), and is_action_possible().
|
static |
Compare two integer values, as required by qsort.
Definition at line 320 of file city.c.
Referenced by auto_arrange_workers(), compare_iter_index(), dai_manage_taxes(), data_compare(), set_default_city_manager(), and tile_type_lattice_add().
int compare_iter_index | ( | const void * | a, |
const void * | b | ||
) |
Compare two iter_index values from the city_map_index.
This function will be passed to qsort(). It should never return zero, or the sort order will be left up to qsort and will be undefined. This would mean that server execution would not be reproducible.
Definition at line 338 of file city.c.
Referenced by generate_city_map_indices(), and generate_map_indices().
struct city * create_city_virtual | ( | struct player * | pplayer, |
struct tile * | ptile, | ||
const char * | name | ||
) |
Create virtual skeleton for a city. Values are mostly sane defaults.
Always tile_set_owner(ptile, pplayer) sometime after this!
Definition at line 3343 of file city.c.
Referenced by trade_generator::add_tile(), cityresult_fill(), create_city(), edit_buffer_copy(), handle_city_info(), handle_city_short_info(), handle_tile_info(), result_defense_bonus(), sg_load_player_cities(), sg_load_player_cities(), and texai_city_info_recv().
void destroy_city_virtual | ( | struct city * | pcity | ) |
Removes the virtual skeleton of a city. You should already have removed all buildings and units you have added to the city before this.
Definition at line 3419 of file city.c.
Referenced by cityresult_fill(), trade_generator::clear_trade_planing(), game_remove_city(), packhand_free(), sg_load_player_cities(), sg_load_player_cities(), texai_city_destruction_recv(), and tile_virtual_destroy().
void free_city_map_index | ( | void | ) |
Free memory allocated by generate_citymap_index
Definition at line 604 of file city.c.
Referenced by game_free(), game_reset(), handle_map_info(), and srv_ready().
void generate_city_map_indices | ( | void | ) |
Fill the arrays city_map_index, city_map_xy and city_map_numtiles. This may depend on topology and ruleset settings.
Definition at line 522 of file city.c.
Referenced by main_map_allocate().
|
static |
Get any effects regarding health from the buildings of the city. The effect defines the reduction of the possibility of an illness in percent.
Definition at line 2755 of file city.c.
Referenced by city_illness_calc().
int get_city_tithes_bonus | ( | const struct city * | pcity | ) |
Return the amount of gold generated by buildings under "tithe" attribute governments.
Definition at line 2199 of file city.c.
Referenced by dai_city_want(), get_city_dialog_output_text(), and set_city_production().
int get_final_city_output_bonus | ( | const struct city * | pcity, |
Output_type_id | otype | ||
) |
Return the factor (in %) by which the city's output should be multiplied.
Definition at line 2184 of file city.c.
Referenced by calc_civ_score(), dai_city_want(), and set_city_bonuses().
const char * get_output_identifier | ( | Output_type_id | output | ) |
Return an id string for the output type. This string can be used internally by rulesets and tilesets and should not be changed or translated.
Definition at line 614 of file city.c.
Referenced by load_ruleset_game(), load_ruleset_terrain(), load_ruleset_units(), save_game_ruleset(), save_terrain_ruleset(), save_units_ruleset(), tileset_lookup_sprite_tags(), and universal_rule_name().
const char * get_output_name | ( | Output_type_id | output | ) |
Return a translated name for the output type. This name should only be used for user display.
Definition at line 624 of file city.c.
Referenced by choice_is_promising(), cm_print_result(), create_cma_dialog(), helptext_government(), helptext_unit_upkeep_str(), popup_city_cma_dialog(), req_text_insert(), universal_kind_values(), and universal_name_translation().
struct output_type * get_output_type | ( | Output_type_id | output | ) |
Return the output type for this index.
Definition at line 633 of file city.c.
Referenced by city_units_upkeep(), city_waste(), get_specialist_output(), get_tile_output_text(), helptext_government(), upkeep_kill_unit(), and utype_upkeep_cost().
|
static |
Gets whether cities that pcity trades with had the plague. If so, it returns the health penalty in tenth of percent which depends on the size of both cities. The health penalty is given as the product of the ruleset option 'game.info.illness_trade_infection' (in percent) and the square root of the product of the size of both cities.
Definition at line 2735 of file city.c.
Referenced by city_illness_calc().
|
inlinestatic |
Calculate output (food, trade and shields) generated by the worked tiles of a city. This will completely overwrite the output[] array.
'workers_map' is an boolean array which defines the placement of the workers within the city map. It uses the tile index and its size is defined by city_map_tiles_from_city(_pcity). See also cm_state_init().
Definition at line 2264 of file city.c.
Referenced by city_refresh_from_main_map().
|
static |
Copy the happiness array in the city to index i from index i-1.
Definition at line 2395 of file city.c.
Referenced by city_refresh_from_main_map().
Return TRUE iff this city is its nation's capital. The capital city is special-cased in a number of ways.
Definition at line 1552 of file city.c.
Referenced by adjust_improvement_wants_by_effects(), api_methods_is_capital(), building_lost(), check_city_migrations_player(), city_incite_cost(), city_migration_score(), civil_war(), create_clause_menu(), dai_goldequiv_clause(), dai_gov_value(), dai_tech_effect_values(), do_expel_unit(), handle_diplomacy_accept_treaty_req(), popup_add_menu(), popup_diplomatic_objects(), diplo_wdg::show_menu(), unit_bribe_cost(), and unit_conquer_city().
Returns TRUE iff the city has set the given option.
Definition at line 3301 of file city.c.
Referenced by city_build_unit(), city_increase_size(), city_dialog::display_worklist_menu(), and set_cityopt_values().
Return TRUE if the city is worked without using up a citizen.
Definition at line 3500 of file city.c.
Referenced by base_city_can_work_tile(), city_map_update_radius_sq(), city_map_update_tile_direct(), compute_max_stats_heuristic(), handle_city_make_specialist(), handle_city_make_worker(), init_tile_lattice(), resolve_city_emergency(), and tile_change_side_effects().
bool is_friendly_city_near | ( | const struct civ_map * | nmap, |
const struct player * | owner, | ||
const struct tile * | ptile | ||
) |
Return TRUE if there is a friendly city near to this tile (within 3 steps).
Definition at line 2065 of file city.c.
Referenced by is_unit_near_a_friendly_city(), and unit_move_consequences().
Return TRUE iff this city is governmental center.
Definition at line 1560 of file city.c.
Referenced by api_methods_is_gov_center(), and city_waste().
Return TRUE if there is a friendly city near to this unit (within 3 steps).
Definition at line 2055 of file city.c.
Referenced by unit_being_aggressive().
bool is_valid_city_coords | ( | const int | city_radius_sq, |
const int | city_map_x, | ||
const int | city_map_y | ||
) |
Return TRUE if the given city coordinate pair is "valid"; that is, if it is a part of the citymap and thus is workable by the city.
Definition at line 183 of file city.c.
Referenced by canvas_to_city_pos(), city_map_to_tile(), city_tile_to_city_map(), city_tile_xy_to_index(), city_to_canvas_pos(), city_toggle_worker(), and citylog_map_line().
Output_type_id output_type_by_identifier | ( | const char * | id | ) |
Find the output type for this output identifier.
Definition at line 642 of file city.c.
Referenced by universal_value_from_str().
Give base number of angry citizens in any city owned by pplayer.
Definition at line 2168 of file city.c.
Referenced by citizen_base_mood(), create_city(), remove_city(), and transfer_city().
|
static |
Give base happiness in any city owned by pplayer. A positive number is a number of content citizens. A negative number is a number of angry citizens (a city never starts with both).
Definition at line 2132 of file city.c.
Referenced by player_angry_citizens(), and player_content_citizens().
Give base number of content citizens in any city owned by pplayer.
Definition at line 2158 of file city.c.
Referenced by choice_is_promising(), citizen_base_mood(), create_city(), evaluate_solution(), remove_city(), and transfer_city().
int rs_max_city_radius_sq | ( | void | ) |
Maximum city radius in this ruleset.
Definition at line 154 of file city.c.
Referenced by find_city_or_settler_near_tile(), generate_citydlg_dimensions(), and city_map::set_pixmap().
|
inlinestatic |
This function sets all the values in the pcity->bonus[] array. Called near the beginning of city_refresh_from_main_map().
It doesn't depend on anything else in the refresh and doesn't change as workers are moved around, but does change when buildings are built, etc.
Definition at line 2325 of file city.c.
Referenced by city_refresh_from_main_map().
|
inline |
Set food, trade and shields production in a city.
This initializes the prod[] and waste[] arrays. It assumes that the bonus[] and citizen_base[] arrays are alread built.
Definition at line 2855 of file city.c.
Referenced by city_refresh_from_main_map(), and compute_max_stats_heuristic().
|
static |
Set the final surplus[] array from the prod[] and usage[] values.
Definition at line 2385 of file city.c.
Referenced by city_refresh_from_main_map().
Return friendly city on the tile, if one exist
Definition at line 2009 of file city.c.
Referenced by is_allied_city_tile().
Return enemy city on the tile, if one exist
Definition at line 1994 of file city.c.
Referenced by is_enemy_city_tile().
Return non-allied city on the tile, if one exist
Definition at line 2039 of file city.c.
Referenced by is_non_allied_city_tile(), is_plr_zoc_client(), and is_plr_zoc_srv().
Return non-attack city on the tile, if one exist
Definition at line 2024 of file city.c.
Referenced by is_non_attack_city_tile(), and need_war_player_hlp().
|
inlinestatic |
Set food, tax, science and shields production to zero if city is in disorder.
Definition at line 2662 of file city.c.
Referenced by city_refresh_from_main_map().
|
static |
Definition at line 1744 of file city.c.
Referenced by city_production_caravan_shields_init(), and city_production_gets_caravan_shields().
|
static |
Definition at line 1745 of file city.c.
Referenced by city_production_caravan_shields_init(), and city_production_gets_caravan_shields().
|
static |
Definition at line 59 of file city.c.
Referenced by city_tile_index_to_xy(), free_city_map_index(), and generate_city_map_indices().
|
static |
Definition at line 66 of file city.c.
Referenced by city_map_tiles(), and generate_city_map_indices().
|
static |
Definition at line 63 of file city.c.
Referenced by city_tile_xy_to_index(), and generate_city_map_indices().
struct citystyle* city_styles = NULL |
Definition at line 79 of file city.c.
Referenced by basic_city_style_for_style(), city_style(), city_style_name_translation(), city_style_rule_name(), city_styles_alloc(), city_styles_free(), handle_ruleset_city(), is_universal_needed(), load_city_sprite(), load_ruleset_styles(), load_style_names(), sanity_check_ruleset_data(), save_styles_ruleset(), and send_ruleset_cities().
struct output_type output_types[O_LAST] |
Definition at line 83 of file city.c.
Referenced by city_tile_output(), get_city_dialog_output_text(), get_final_city_output_bonus(), get_output_identifier(), get_output_name(), get_output_type(), output_type_by_identifier(), and unhappy_city_check().