38#include "city_enums_gen.h"
40#define PCT_LAST PCT_COUNT
50#define SPECENUM_NAME city_options
52#define SPECENUM_VALUE0 CITYO_DISBAND
53#define SPECENUM_VALUE0NAME "Disband"
55#define SPECENUM_VALUE1 CITYO_SCIENCE_SPECIALISTS
56#define SPECENUM_VALUE1NAME "Sci_Specialists"
58#define SPECENUM_VALUE2 CITYO_GOLD_SPECIALISTS
59#define SPECENUM_VALUE2NAME "Tax_Specialists"
60#define SPECENUM_COUNT CITYO_LAST
61#define SPECENUM_BITVECTOR bv_city_options
66#define SPECENUM_NAME city_wl_cancel_behavior
67#define SPECENUM_VALUE0 WLCB_SMART
70#define SPECENUM_VALUE0NAME N_("?wlcb:Smart")
71#define SPECENUM_VALUE1 WLCB_ALWAYS_PURGE
72#define SPECENUM_VALUE1NAME N_("?wlcb:Always Purge")
73#define SPECENUM_VALUE2 WLCB_ALWAYS_POSTPONE
74#define SPECENUM_VALUE2NAME N_("?wlcb:Always Postpone")
75#define SPECENUM_COUNT WLCB_LAST
79#define CITY_MAP_DEFAULT_RADIUS_SQ \
80 (CITY_MAP_DEFAULT_RADIUS * CITY_MAP_DEFAULT_RADIUS + 1)
81#define CITY_MAP_MIN_RADIUS_SQ \
82 (CITY_MAP_MIN_RADIUS * CITY_MAP_MIN_RADIUS + 1)
83#define CITY_MAP_MAX_RADIUS_SQ \
84 (CITY_MAP_MAX_RADIUS * CITY_MAP_MAX_RADIUS + 1)
86#define CITY_MAP_CENTER_RADIUS_SQ -1
88#define CITY_MAP_CENTER_TILE_INDEX 0
91#define CITY_MAP_MAX_SIZE (CITY_MAP_MAX_RADIUS * 2 + 1)
93#define INCITE_IMPOSSIBLE_COST (1000 * 1000 * 1000)
103#define MAX_CITY_SIZE 0xFF
112#define CITY_REL2ABS(_coor) (_coor + CITY_MAP_MAX_RADIUS)
113#define CITY_ABS2REL(_coor) (_coor - CITY_MAP_MAX_RADIUS)
124#define city_map_tiles_from_city(_pcity) \
125 city_map_tiles(city_map_radius_sq_get(_pcity))
134#define city_map_iterate_outwards_radius_sq_index(_radius_sq_min, \
138 fc_assert(_radius_sq_min <= _radius_sq_max); \
139 int _x = 0, _y = 0, _index; \
140 int _x##_y##_index = city_map_tiles(_radius_sq_min); \
141 while (city_tile_index_to_xy(&_x, &_y, _x##_y##_index, \
143 _index = _x##_y##_index; \
146#define city_map_iterate_outwards_radius_sq_index_end \
151#define city_map_iterate_outwards_radius_sq(_radius_sq_min, \
155 fc_assert(_radius_sq_min <= _radius_sq_max); \
156 int _x = 0, _y = 0; \
157 int _x##_y##_index = city_map_tiles(_radius_sq_min); \
158 while (city_tile_index_to_xy(&_x, &_y, _x##_y##_index, \
162#define city_map_iterate_outwards_radius_sq_end \
170#define city_map_iterate(_radius_sq, _index, _x, _y) \
171 city_map_iterate_outwards_radius_sq_index(CITY_MAP_CENTER_RADIUS_SQ, \
172 _radius_sq, _index, _x, _y)
174#define city_map_iterate_end \
175 city_map_iterate_outwards_radius_sq_index_end
177#define city_map_iterate_without_index(_radius_sq, _x, _y) \
178 city_map_iterate_outwards_radius_sq(CITY_MAP_CENTER_RADIUS_SQ, \
181#define city_map_iterate_without_index_end \
182 city_map_iterate_outwards_radius_sq_end
185#define city_map_iterate_radius_sq(_radius_sq_min, _radius_sq_max, \
187 city_map_iterate_outwards_radius_sq(_radius_sq_min, _radius_sq_max, \
190#define city_map_iterate_radius_sq_end \
191 city_map_iterate_outwards_radius_sq_end
198#define city_tile_iterate_index(_nmap, _radius_sq, _city_tile, _tile, \
200 city_map_iterate_outwards_radius_sq_index(CITY_MAP_CENTER_RADIUS_SQ, \
201 _radius_sq, _index, _x, _y) \
202 struct tile *_tile = city_map_to_tile(_nmap, _city_tile, _radius_sq, \
206#define city_tile_iterate_index_end \
208 } city_map_iterate_outwards_radius_sq_index_end;
211#define city_tile_iterate_skip_free_worked(_nmap, _radius_sq, _city_tile, \
212 _tile, _index, _x, _y) { \
213 city_map_iterate(_radius_sq, _index, _x, _y) { \
214 if (!is_free_worked_index(_index)) { \
215 struct tile *_tile = city_map_to_tile(_nmap, _city_tile, _radius_sq, \
219#define city_tile_iterate_skip_free_worked_end \
222 } city_map_iterate_end; \
227#define city_tile_iterate(_nmap, _radius_sq, _city_tile, _tile) { \
228 const struct tile *_center##_tile = _city_tile; \
229 city_map_iterate_outwards_radius_sq(CITY_MAP_CENTER_RADIUS_SQ, \
230 _radius_sq, _x, _y) \
231 struct tile *_tile = city_map_to_tile(_nmap, _center##_tile, _radius_sq, \
235#define city_tile_iterate_end \
237 } city_map_iterate_outwards_radius_sq_end;
245#define I_DESTROYED (-2)
501#define SPECLIST_TAG city
502#define SPECLIST_TYPE struct city
505#define city_list_iterate(citylist, pcity) \
506 TYPED_LIST_ITERATE(struct city, citylist, pcity)
507#define city_list_iterate_end LIST_ITERATE_END
509#define cities_iterate(pcity) \
511 players_iterate(pcity##_player) { \
512 city_list_iterate(pcity##_player->cities, pcity) {
514#define cities_iterate_end \
515 } city_list_iterate_end; \
516 } players_iterate_end; \
519#define city_list_iterate_safe(citylist, _city) \
521 struct city_list *_city##_cl = citylist; \
522 int _city##_size = city_list_size(_city##_cl); \
524 if (_city##_size > 0) { \
525 int _city##_numbers[_city##_size]; \
529 city_list_iterate(_city##_cl, _city) { \
530 _city##_numbers[_city##_size++] = _city->id; \
531 } city_list_iterate_end; \
533 for (_city##_index = 0; \
534 _city##_index < _city##_size; \
536 struct city *_city = \
537 game_city_by_number(_city##_numbers[_city##_index]); \
541#define city_list_iterate_safe_end \
560#define city_owner(_pcity_) (_pcity_)->owner
561#define city_tile(_pcity_) (_pcity_)->tile
676 const int city_radius_sq,
677 const struct tile *city_center,
681 const struct tile *city_center,
699 const struct tile *ptile);
703 const struct tile *ptile);
706 const struct tile *ptile,
710 const struct tile *ptile);
726 const struct player *pplayer);
732 const struct player *pplayer)
738 const struct player *pplayer);
744 const struct player *pplayer)
750 const struct player *pplayer);
756 const struct player *pplayer)
762 const struct player *pplayer);
768 const struct player *pplayer)
778 const struct tile *ptile,
781 const struct tile *ptile,
805 struct tile *ptile,
const char *
name);
831#define city_built_iterate(_pcity, _p) \
832 improvement_iterate(_p) { \
833 if ((_pcity)->built[improvement_index(_p)].turn <= I_NEVER) { \
837#define city_built_iterate_end \
838 } improvement_iterate_end;
842#define output_type_iterate(output) \
844 Output_type_id output; \
846 for (output = 0; output < O_LAST; output++) {
848#define output_type_iterate_end \
866 const struct tile *ptile)
877#define is_free_worked_index(city_tile_index) \
878 (CITY_MAP_CENTER_TILE_INDEX == city_tile_index)
879#define FREE_WORKED_TILES (1)
bool base_city_celebrating(const struct city *pcity)
static bool is_non_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
bool city_is_virtual(const struct city *pcity)
int city_turns_to_build(const struct city *pcity, const struct universal *target, bool include_shield_stock)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
bool is_free_worked(const struct city *pcity, const struct tile *ptile)
static bool is_non_attack_city_tile(const struct tile *ptile, const struct player *pplayer)
#define city_tile(_pcity_)
bool city_production_gets_caravan_shields(const struct universal *tgt)
void city_map_radius_sq_set(struct city *pcity, int radius_sq)
int city_production_build_shield_cost(const struct city *pcity)
void city_name_set(struct city *pcity, const char *new_name)
static bool is_enemy_city_tile(const struct tile *ptile, const struct player *pplayer)
int city_granary_size(int city_size)
citizens player_angry_citizens(const struct player *pplayer)
int city_pollution_types(const struct city *pcity, int shield_total, int *pollu_prod, int *pollu_pop, int *pollu_mod)
void city_set_ai_data(struct city *pcity, const struct ai_type *ai, void *data)
@ UNHAPPY_PENALTY_ALL_PRODUCTION
@ UNHAPPY_PENALTY_SURPLUS
bool is_friendly_city_near(const struct civ_map *nmap, const struct player *owner, const struct tile *ptile, int distance)
bool city_built_last_turn(const struct city *pcity)
void city_choose_build_default(const struct civ_map *nmap, struct city *pcity)
static citizens city_size_get(const struct city *pcity)
int city_waste(const struct city *pcity, Output_type_id otype, int total, int *breakdown)
void generate_city_map_indices(void)
int city_build_slots(const struct city *pcity)
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)
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
const char * city_style_name_translation(const int style)
void city_styles_free(void)
void city_rally_point_receive(const struct packet_city_rally_point *packet, struct city *pcity) fc__attribute((nonnull(1)))
Output_type_id output_type_by_identifier(const char *id)
bool is_capital(const struct city *pcity)
struct citystyle * city_styles
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *pimprove)
void city_styles_alloc(int num)
const char * city_name_get(const struct city *pcity)
bool base_city_can_work_tile(const struct player *restriction, const struct city *pcity, const struct tile *ptile)
int city_unit_slots_available(const struct city *pcity)
static bool is_allied_city_tile(const struct tile *ptile, const struct player *pplayer)
void city_production_caravan_shields_init(void)
void city_remove_improvement(struct city *pcity, const struct impr_type *pimprove)
int city_airlift_max(const struct city *pcity)
bool citymindist_prevents_city_on_tile(const struct civ_map *nmap, const struct tile *ptile)
bool can_city_build_later(const struct civ_map *nmap, const struct city *pcity, const struct universal *target)
struct output_type * get_output_type(Output_type_id output)
bool is_city_option_set(const struct city *pcity, enum city_options option)
int city_population(const struct city *pcity)
const char * city_style_rule_name(const int style)
void city_size_add(struct city *pcity, int add)
bool city_can_use_specialist(const struct city *pcity, Specialist_type_id type)
bool city_production_has_flag(const struct city *pcity, enum impr_flag_id flag)
bool city_is_occupied(const struct city *pcity)
void free_city_map_index(void)
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
void add_tax_income(const struct player *pplayer, int trade, int *output)
bool can_city_build_improvement_now(const struct city *pcity, const struct impr_type *pimprove)
bool city_tile_index_to_xy(int *city_map_x, int *city_map_y, int city_tile_index, int city_radius_sq)
struct city * tile_non_allied_city(const struct tile *ptile, const struct player *pplayer)
int city_unit_unhappiness(const struct civ_map *nmap, struct unit *punit, int *free_unhappy)
bool city_got_defense_effect(const struct city *pcity, const struct unit_type *attacker)
citizens player_content_citizens(const struct player *pplayer)
bool city_map_includes_tile(const struct city *const pcity, const struct tile *map_tile)
int get_city_tithes_bonus(const struct city *pcity)
bool is_unit_near_a_friendly_city(const struct civ_map *nmap, const struct unit *punit, int distance)
void citylog_map_data(enum log_level level, int radius_sq, int *map_data)
bool city_rapture_grow(const struct city *pcity)
static bool is_city_center(const struct city *pcity, const struct tile *ptile)
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
bool city_unhappy(const struct city *pcity)
Specialist_type_id best_specialist(Output_type_id otype, const struct city *pcity)
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
void set_city_production(struct city *pcity)
struct city * city_list_find_number(struct city_list *This, int id)
int get_final_city_output_bonus(const struct city *pcity, Output_type_id otype)
bool city_celebrating(const struct city *pcity)
bool city_can_be_built_tile_only(const struct civ_map *nmap, const struct tile *ptile)
bool can_city_build_improvement_direct(const struct city *pcity, const struct impr_type *pimprove)
const char * get_output_identifier(Output_type_id output)
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
const char * get_output_name(Output_type_id output)
bool city_can_grow_to(const struct city *pcity, int pop_size)
int city_change_production_penalty(const struct city *pcity, const struct universal *target)
bool is_valid_city_coords(const int city_radius_sq, const int city_map_x, const int city_map_y)
void city_refresh_from_main_map(const struct civ_map *nmap, struct city *pcity, bool *workers_map)
bool can_city_build_direct(const struct civ_map *nmap, const struct city *pcity, const struct universal *target)
bool city_can_be_built_here(const struct civ_map *nmap, const struct tile *ptile, const struct unit *punit, bool hut_test)
int city_pollution(const struct city *pcity, int shield_total)
bool city_happy(const struct city *pcity)
void city_size_set(struct city *pcity, citizens size)
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
int city_tile_output_now(const struct city *pcity, const struct tile *ptile, Output_type_id otype)
int city_map_radius_sq_get(const struct city *pcity)
struct city * tile_allied_city(const struct tile *ptile, const struct player *pplayer)
struct city * tile_enemy_city(const struct tile *ptile, const struct player *pplayer)
void citylog_map_workers(enum log_level level, struct city *pcity)
bool city_base_to_city_map(int *city_map_x, int *city_map_y, const struct city *const pcity, const struct tile *map_tile)
void destroy_city_virtual(struct city *pcity)
int rs_max_city_radius_sq(void)
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)
citizens city_specialists(const struct city *pcity)
const Output_type_id num_output_types
int city_style_by_translated_name(const char *s)
void add_specialist_output(const struct city *pcity, int *output)
void * city_ai_data(const struct city *pcity, const struct ai_type *ai)
struct city * city_list_find_name(struct city_list *This, const char *name)
int city_tile_output(const struct city *pcity, const struct tile *ptile, bool is_celebrating, Output_type_id otype)
int city_tile_xy_to_index(int city_map_x, int city_map_y, int city_radius_sq)
bool can_city_build_unit_direct(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
bool is_gov_center(const struct city *pcity)
bool can_city_build_now(const struct civ_map *nmap, const struct city *pcity, const struct universal *target)
bool can_city_build_unit_now(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
int city_map_tiles(int city_radius_sq)
struct city * tile_non_attack_city(const struct tile *ptile, const struct player *pplayer)
bool city_can_work_tile(const struct city *pcity, const struct tile *ptile)
bool city_production_is_genus(const struct city *pcity, enum impr_genus_id genus)
int compare_iter_index(const void *a, const void *b)
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
int city_turns_to_grow(const struct city *pcity)
void city_rally_point_clear(struct city *pcity)
struct output_type output_types[]
bool can_city_build_improvement_later(const struct city *pcity, const struct impr_type *pimprove)
bool city_exists_within_max_city_map(const struct civ_map *nmap, const struct tile *ptile, bool may_be_on_center)
bool city_had_recent_plague(const struct city *pcity)
bool city_can_change_build(const struct city *pcity)
bool can_city_build_unit_later(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
int city_total_unit_gold_upkeep(const struct city *pcity)
int city_style_by_rule_name(const char *s)
int city_name_compare(const void *p1, const void *p2)
int city_total_impr_gold_upkeep(const struct city *pcity)
const char * city_production_name_translation(const struct city *pcity)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
enum output_type_id Output_type_id
#define fc_assert_ret_val(condition, val)
struct setting_list * level[OLEVELS_NUM]
struct worker_task_list * task_reqs
struct tile_cache * tile_cache
enum city_wl_cancel_behavior wlcb
struct built_status built[B_LAST]
int last_turns_shield_surplus
enum capital_type capital
struct unit_list * info_units_present
bv_city_options city_options
citizens unit_happy_upkeep
enum city_acquire_type acquire_t
struct unit_list * info_units_supported
void * ais[FREECIV_AI_MOD_LAST]
struct trade_route_list * routes
enum city_needs_arrange needs_arrange
struct universal production
struct unit_order * orders
struct unit_list * collecting_info_units_supported
struct city::@18::@20 server
int unhappy_penalty[O_LAST]
unsigned char first_citizen_index
int before_change_shields
struct city::@17 rally_point
struct unit_list * collecting_info_units_present
struct city::@18::@21 client
citizens feel[CITIZEN_LAST][FEELING_LAST]
citizens specialists[SP_MAX]
struct cm_parameter * cm_parameter
struct universal changed_from
struct unit_list * units_supported
enum city_updates need_updates
struct requirement_vector reqs
char citizens_graphic[MAX_LEN_NAME]
char graphic_alt[MAX_LEN_NAME]
struct name_translation name
char graphic[MAX_LEN_NAME]
enum output_unhappy_penalty unhappy_penalty