1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
18 #endif /* __cplusplus */
21 #include "bitvector.h"
25 #include "ai.h" /* FC_AI_LAST */
27 #include "name_translation.h"
28 #include "improvement.h"
31 #include "workertask.h"
34 enum production_class_type
{
36 PCT_NORMAL_IMPROVEMENT
,
41 /* Various city options. These are stored by the server and can be
42 * toggled by the user. Each one defaults to off. Adding new ones
43 * will break network compatibility. Reordering them will break savegame
44 * compatibility. If you want to remove one you should replace it with
45 * a CITYO_UNUSED entry; new options can just be added at the end.
47 * Used in the network protocol.
50 CITYO_DISBAND
, /* If building a settler at size 1 disbands the city */
51 CITYO_NEW_EINSTEIN
, /* If new citizens are science specialists */
52 CITYO_NEW_TAXMAN
, /* If new citizens are gold specialists */
55 BV_DEFINE(bv_city_options
, CITYO_LAST
); /* Used in the network protocol. */
57 /* Changing the max radius requires updating network capabilities and results
58 * in incompatible savefiles. */
59 #define CITY_MAP_MIN_RADIUS 0
60 #define CITY_MAP_DEFAULT_RADIUS 2
61 #define CITY_MAP_MAX_RADIUS 5
63 /* The city includes all tiles dx^2 + dy^2 <= CITY_MAP_*_RADIUS_SQ */
64 #define CITY_MAP_DEFAULT_RADIUS_SQ \
65 (CITY_MAP_DEFAULT_RADIUS * CITY_MAP_DEFAULT_RADIUS + 1)
66 #define CITY_MAP_MIN_RADIUS_SQ \
67 (CITY_MAP_MIN_RADIUS * CITY_MAP_MIN_RADIUS + 1)
68 #define CITY_MAP_MAX_RADIUS_SQ \
69 (CITY_MAP_MAX_RADIUS * CITY_MAP_MAX_RADIUS + 1)
70 /* the id for the city center */
71 #define CITY_MAP_CENTER_RADIUS_SQ -1
72 /* the tile index of the city center */
73 #define CITY_MAP_CENTER_TILE_INDEX 0
75 /* Maximum diameter of the workable city area. */
76 #define CITY_MAP_MAX_SIZE (CITY_MAP_MAX_RADIUS * 2 + 1)
78 #define INCITE_IMPOSSIBLE_COST (1000 * 1000 * 1000)
81 * Size of the biggest possible city.
83 * The constant may be changed since it isn't externally visible.
85 * The city size is saved as unsigned char. Therefore, MAX_CITY_SIZE should
88 #define MAX_CITY_SIZE 0xFF
90 /* Iterate a city map, from the center (the city) outwards */
95 /* City map coordinates are positive integers shifted by the maximum
96 * radius the game engine allows (not the current ruleset) */
97 #define CITY_REL2ABS(_coor) (_coor + CITY_MAP_MAX_RADIUS)
98 #define CITY_ABS2REL(_coor) (_coor - CITY_MAP_MAX_RADIUS)
100 bool city_tile_index_to_xy(int *city_map_x
, int *city_map_y
,
101 int city_tile_index
, int city_radius_sq
);
102 int city_tile_xy_to_index(int city_map_x
, int city_map_y
,
105 int rs_max_city_radius_sq(void);
106 int city_map_radius_sq_get(const struct city
*pcity
);
107 void city_map_radius_sq_set(struct city
*pcity
, int radius_sq
);
108 int city_map_tiles(int city_radius_sq
);
109 #define city_map_tiles_from_city(_pcity) \
110 city_map_tiles(city_map_radius_sq_get(_pcity))
112 void citylog_map_data(enum log_level level
, int radius_sq
, int *map_data
);
113 void citylog_map_workers(enum log_level level
, struct city
*pcity
);
115 /* Iterate over the tiles of a city map. Starting at a given city radius
116 * (the city center is _radius_sq_min = 0) outward to the tiles of
117 * _radius_sq_max. (_x, _y) will be the valid elements of
118 * [0, CITY_MAP_MAX_SIZE] taking into account the city radius. */
119 #define city_map_iterate_outwards_radius_sq_index(_radius_sq_min, \
123 fc_assert(_radius_sq_min <= _radius_sq_max); \
124 int _x = 0, _y = 0, _index; \
125 int _x##_y##_index = city_map_tiles(_radius_sq_min); \
126 while (city_tile_index_to_xy(&_x, &_y, _x##_y##_index, \
128 _index = _x##_y##_index; \
131 #define city_map_iterate_outwards_radius_sq_index_end \
135 /* Same as above, but don't set index */
136 #define city_map_iterate_outwards_radius_sq(_radius_sq_min, \
140 fc_assert(_radius_sq_min <= _radius_sq_max); \
141 int _x = 0, _y = 0; \
142 int _x##_y##_index = city_map_tiles(_radius_sq_min); \
143 while (city_tile_index_to_xy(&_x, &_y, _x##_y##_index, \
147 #define city_map_iterate_outwards_radius_sq_end \
151 /* Iterate a city map. This iterates over all city positions in the city
152 * map starting at the city center (i.e., positions that are workable by
153 * the city) using the index (_index) and the coordinates (_x, _y). It
154 * is an abbreviation for city_map_iterate_outwards_radius_sq(_end). */
155 #define city_map_iterate(_radius_sq, _index, _x, _y) \
156 city_map_iterate_outwards_radius_sq_index(CITY_MAP_CENTER_RADIUS_SQ, \
157 _radius_sq, _index, _x, _y)
159 #define city_map_iterate_end \
160 city_map_iterate_outwards_radius_sq_index_end
162 #define city_map_iterate_without_index(_radius_sq, _x, _y) \
163 city_map_iterate_outwards_radius_sq(CITY_MAP_CENTER_RADIUS_SQ, \
166 #define city_map_iterate_without_index_end \
167 city_map_iterate_outwards_radius_sq_end
169 /* Iterate the tiles between two radii of a city map. */
170 #define city_map_iterate_radius_sq(_radius_sq_min, _radius_sq_max, \
172 city_map_iterate_outwards_radius_sq(_radius_sq_min, _radius_sq_max, \
175 #define city_map_iterate_radius_sq_end \
176 city_map_iterate_outwards_radius_sq_end
178 /* Iterate a city map in checked real map coordinates.
179 * _radius_sq is the squared city radius.
180 * _city_tile is the center of the (possible) city.
181 * (_index) will be the city tile index in the intervall
182 * [0, city_map_tiles(_radius_sq)] */
183 #define city_tile_iterate_index(_radius_sq, _city_tile, _tile, \
185 city_map_iterate_outwards_radius_sq_index(CITY_MAP_CENTER_RADIUS_SQ, \
186 _radius_sq, _index, _x, _y) \
187 struct tile *_tile = city_map_to_tile(_city_tile, _radius_sq, \
191 #define city_tile_iterate_index_end \
193 } city_map_iterate_outwards_radius_sq_index_end;
195 /* simple extension to skip is_free_worked() tiles. */
196 #define city_tile_iterate_skip_free_worked(_radius_sq, _city_tile, \
197 _tile, _index, _x, _y) { \
198 city_map_iterate(_radius_sq, _index, _x, _y) { \
199 if (!is_free_worked_index(_index)) { \
200 struct tile *_tile = city_map_to_tile(_city_tile, _radius_sq, \
204 #define city_tile_iterate_skip_free_worked_end \
207 } city_map_iterate_end; \
210 /* Does the same thing as city_tile_iterate_index, but keeps the city
211 * coordinates hidden. */
212 #define city_tile_iterate(_radius_sq, _city_tile, _tile) { \
213 city_map_iterate_outwards_radius_sq(CITY_MAP_CENTER_RADIUS_SQ, \
214 _radius_sq, _x, _y) \
215 struct tile *_tile = city_map_to_tile(_city_tile, _radius_sq, \
219 #define city_tile_iterate_end \
221 } city_map_iterate_outwards_radius_sq_end;
223 /* Improvement status (for cities' lists of improvements)
224 * (replaced Impr_Status) */
226 struct built_status
{
227 int turn
; /* turn built, negative for old state */
228 #define I_NEVER (-1) /* Improvement never built */
229 #define I_DESTROYED (-2) /* Improvement built and destroyed */
232 /* How much this output type is penalized for unhappy cities: not at all,
233 * surplus knocked down to 0, or all production removed. */
234 enum output_unhappy_penalty
{
235 UNHAPPY_PENALTY_NONE
,
236 UNHAPPY_PENALTY_SURPLUS
,
237 UNHAPPY_PENALTY_ALL_PRODUCTION
242 const char *name
; /* Untranslated name */
243 const char *id
; /* Identifier string (for rulesets, etc.) */
244 bool harvested
; /* Is this output type gathered by city workers? */
245 enum output_unhappy_penalty unhappy_penalty
;
248 enum citizen_category
{
254 CITIZEN_SPECIALIST
= CITIZEN_LAST
,
257 /* changing this order will break network compatibility,
258 * and clients that don't use the symbols. */
259 enum citizen_feeling
{
260 FEELING_BASE
, /* before any of the modifiers below */
261 FEELING_LUXURY
, /* after luxury */
262 FEELING_EFFECT
, /* after building effects */
263 FEELING_NATIONALITY
, /* after citizen nationality effects */
264 FEELING_MARTIAL
, /* after units enforce martial order */
265 FEELING_FINAL
, /* after wonders (final result) */
269 /* Ways city output can be lost. Not currently part of network protocol. */
271 OLOSS_WASTE
, /* regular corruption or waste */
272 OLOSS_SIZE
, /* notradesize/fulltradesize */
276 /* This enumerators are used at client side only (so changing it doesn't
277 * break the compability) to mark that the city need specific gui updates
278 * (e.g. city dialog, or city report). */
281 CU_UPDATE_REPORT
= 1 << 0,
282 CU_UPDATE_DIALOG
= 1 << 1,
283 CU_POPUP_DIALOG
= 1 << 2
286 /* See city_build_here_test(). */
287 enum city_build_result
{
295 struct tile_cache
; /* defined and only used within city.c */
297 struct adv_city
; /* defined in ./server/advisors/infracache.h */
300 char name
[MAX_LEN_NAME
];
301 struct tile
*tile
; /* May be NULL, should check! */
302 struct player
*owner
; /* Cannot be NULL. */
303 struct player
*original
; /* Cannot be NULL. */
308 citizens feel
[CITIZEN_LAST
][FEELING_LAST
];
311 citizens specialists
[SP_MAX
];
313 citizens martial_law
; /* Citizens pacified by martial law. */
314 citizens unit_happy_upkeep
; /* Citizens angered by military action. */
316 citizens
*nationality
; /* Nationality of the citizens. */
319 int trade
[MAX_TRADE_ROUTES
], trade_value
[MAX_TRADE_ROUTES
];
321 /* Tile output, regardless of if the tile is actually worked. It is used
322 * as cache for the output of the tiles within the city map.
323 * (see city_tile_cache_update() and city_tile_cache_get_output()) */
324 struct tile_cache
*tile_cache
;
325 /* The memory allocated for tile_cache is valid for this squared city
327 int tile_cache_radius_sq
;
329 /* the productions */
330 int surplus
[O_LAST
]; /* Final surplus in each category. */
331 int waste
[O_LAST
]; /* Waste/corruption in each category. */
332 int unhappy_penalty
[O_LAST
]; /* Penalty from unhappy cities. */
333 int prod
[O_LAST
]; /* Production is total minus waste and penalty. */
334 int citizen_base
[O_LAST
]; /* Base production from citizens. */
335 int usage
[O_LAST
]; /* Amount of each resource being used. */
337 /* Cached values for CPU savings. */
343 int pollution
; /* not saved */
344 int illness_trade
; /* not saved; illness due to trade; it is
345 calculated within the server and send to
346 the clients as the clients do not have all
347 information about the trade cities */
348 int turn_plague
; /* last turn with an illness in the city */
349 int city_radius_sq
; /* current squared city radius */
357 int anarchy
; /* anarchy rounds count */
358 int rapture
; /* rapture rounds count */
362 int before_change_shields
; /* If changed this turn, shields before penalty */
363 int caravan_shields
; /* If caravan has helped city to build wonder. */
364 int disbanded_shields
; /* If you disband unit in a city. Count them */
365 int last_turns_shield_surplus
; /* The surplus we had last turn. */
367 struct built_status built
[B_LAST
];
369 struct universal production
;
371 /* If changed this turn, what we changed from */
372 struct universal changed_from
;
374 struct worklist worklist
;
376 bv_city_options city_options
;
378 struct unit_list
*units_supported
;
382 /* Only used in the server (./ai/ and ./server/). */
384 float migration_score
; /* updated by city_migration_score. */
385 int mgr_score_calc_turn
; /* turn the migration score was calculated */
389 int steal
; /* diplomats steal once; for spies, gets harder */
391 /* If > 0, workers will not be rearranged until they are unfrozen. */
394 /* If set, workers need to be arranged when the city is unfrozen.
395 * Set inside auto_arrange_workers() and city_freeze_workers_queue(). */
398 /* If set, city needs to be refreshed at a later time.
399 * Set inside city_refresh() and city_refresh_queue_add(). */
402 /* the city map is synced with the client. */
405 bool debug
; /* not saved */
407 struct adv_city
*adv
;
408 void *ais
[FC_AI_LAST
];
410 struct vision
*vision
;
412 struct worker_task task_req
;
416 /* Only used at the client (the server is omniscient; ./client/). */
423 /* The color is an index into the city_colors array in mapview_common */
427 /* info for dipl/spy investigation */
428 struct unit_list
*info_units_supported
;
429 struct unit_list
*info_units_present
;
430 /* Before popup the city dialog, units go there. In normal process,
431 * these pointers are set to NULL. */
432 struct unit_list
*collecting_info_units_supported
;
433 struct unit_list
*collecting_info_units_present
;
435 /* Updates needed for the city. */
436 enum city_updates need_updates
;
442 struct name_translation name
;
443 char graphic
[MAX_LEN_NAME
];
444 char graphic_alt
[MAX_LEN_NAME
];
445 char oceanic_graphic
[MAX_LEN_NAME
];
446 char oceanic_graphic_alt
[MAX_LEN_NAME
];
447 char citizens_graphic
[MAX_LEN_NAME
];
448 char citizens_graphic_alt
[MAX_LEN_NAME
];
449 struct requirement_vector reqs
;
450 int replaced_by
; /* index to replacing style */
451 }; /* not incl. wall and occupied tiles */
453 extern struct citystyle
*city_styles
;
454 extern const Output_type_id num_output_types
;
455 extern struct output_type output_types
[];
457 /* get 'struct city_list' and related functions: */
458 #define SPECLIST_TAG city
459 #define SPECLIST_TYPE struct city
460 #include "speclist.h"
462 #define city_list_iterate(citylist, pcity) \
463 TYPED_LIST_ITERATE(struct city, citylist, pcity)
464 #define city_list_iterate_end LIST_ITERATE_END
466 #define cities_iterate(pcity) \
468 players_iterate(pcity##_player) { \
469 city_list_iterate(pcity##_player->cities, pcity) {
471 #define cities_iterate_end \
472 } city_list_iterate_end; \
473 } players_iterate_end; \
476 #define city_list_iterate_safe(citylist, _city) \
478 int _city##_size = city_list_size(citylist); \
480 if (_city##_size > 0) { \
481 int _city##_numbers[_city##_size]; \
482 int _city##_index = 0; \
484 city_list_iterate(citylist, _city) { \
485 _city##_numbers[_city##_index++] = _city->id; \
486 } city_list_iterate_end; \
488 for (_city##_index = 0; \
489 _city##_index < _city##_size; \
491 struct city *_city = \
492 game_city_by_number(_city##_numbers[_city##_index]); \
496 #define city_list_iterate_safe_end \
502 /* output type functions */
504 const char *get_output_identifier(Output_type_id output
);
505 const char *get_output_name(Output_type_id output
);
506 struct output_type
*get_output_type(Output_type_id output
);
507 Output_type_id
output_type_by_identifier(const char *id
);
508 void add_specialist_output(const struct city
*pcity
, int *output
);
509 void set_city_production(struct city
*pcity
);
513 const char *city_name(const struct city
*pcity
);
514 struct player
*city_owner(const struct city
*pcity
);
515 struct tile
*city_tile(const struct city
*pcity
);
517 citizens
city_size_get(const struct city
*pcity
);
518 void city_size_add(struct city
*pcity
, int add
);
519 void city_size_set(struct city
*pcity
, citizens size
);
521 citizens
city_specialists(const struct city
*pcity
);
523 citizens
player_content_citizens(const struct player
*pplayer
);
525 int city_population(const struct city
*pcity
);
526 int city_total_impr_gold_upkeep(const struct city
*pcity
);
527 int city_total_unit_gold_upkeep(const struct city
*pcity
);
528 int city_unit_unhappiness(struct unit
*punit
, int *free_unhappy
);
529 bool city_happy(const struct city
*pcity
); /* generally use celebrating instead */
530 bool city_unhappy(const struct city
*pcity
); /* anarchy??? */
531 bool base_city_celebrating(const struct city
*pcity
);
532 bool city_celebrating(const struct city
*pcity
); /* love the king ??? */
533 bool city_rapture_grow(const struct city
*pcity
);
535 /* city related improvement and unit functions */
537 int city_improvement_upkeep(const struct city
*pcity
,
538 const struct impr_type
*pimprove
);
540 bool can_city_build_improvement_direct(const struct city
*pcity
,
541 struct impr_type
*pimprove
);
542 bool can_city_build_improvement_later(const struct city
*pcity
,
543 struct impr_type
*pimprove
);
544 bool can_city_build_improvement_now(const struct city
*pcity
,
545 struct impr_type
*pimprove
);
547 bool can_city_build_unit_direct(const struct city
*pcity
,
548 const struct unit_type
*punittype
);
549 bool can_city_build_unit_later(const struct city
*pcity
,
550 const struct unit_type
*punittype
);
551 bool can_city_build_unit_now(const struct city
*pcity
,
552 const struct unit_type
*punittype
);
554 bool can_city_build_direct(const struct city
*pcity
,
555 struct universal target
);
556 bool can_city_build_later(const struct city
*pcity
,
557 struct universal target
);
558 bool can_city_build_now(const struct city
*pcity
,
559 struct universal target
);
561 bool city_can_use_specialist(const struct city
*pcity
,
562 Specialist_type_id type
);
563 bool city_has_building(const struct city
*pcity
,
564 const struct impr_type
*pimprove
);
565 bool is_capital(const struct city
*pcity
);
566 bool is_gov_center(const struct city
*pcity
);
567 bool city_got_citywalls(const struct city
*pcity
);
568 bool city_got_defense_effect(const struct city
*pcity
,
569 const struct unit_type
*attacker
);
571 int city_production_build_shield_cost(const struct city
*pcity
);
572 bool city_production_build_units(const struct city
*pcity
,
573 bool add_production
, int *num_units
);
574 int city_production_buy_gold_cost(const struct city
*pcity
);
576 bool city_production_has_flag(const struct city
*pcity
,
577 enum impr_flag_id flag
);
578 int city_production_turns_to_build(const struct city
*pcity
,
579 bool include_shield_stock
);
581 int city_change_production_penalty(const struct city
*pcity
,
582 struct universal target
);
583 int city_turns_to_build(const struct city
*pcity
,
584 struct universal target
,
585 bool include_shield_stock
);
586 int city_turns_to_grow(const struct city
*pcity
);
587 bool city_can_grow_to(const struct city
*pcity
, int pop_size
);
588 bool city_can_change_build(const struct city
*pcity
);
590 void city_choose_build_default(struct city
*pcity
);
592 /* textual representation of buildings */
594 const char *city_improvement_name_translation(const struct city
*pcity
,
595 struct impr_type
*pimprove
);
596 const char *city_production_name_translation(const struct city
*pcity
);
598 /* city map functions */
599 bool is_valid_city_coords(const int city_radius_sq
, const int city_map_x
,
600 const int city_map_y
);
601 bool city_base_to_city_map(int *city_map_x
, int *city_map_y
,
602 const struct city
*const pcity
,
603 const struct tile
*map_tile
);
604 bool city_tile_to_city_map(int *city_map_x
, int *city_map_y
,
605 const int city_radius_sq
,
606 const struct tile
*city_center
,
607 const struct tile
*map_tile
);
609 struct tile
*city_map_to_tile(const struct tile
*city_center
,
610 int city_radius_sq
, int city_map_x
,
613 /* Initialization functions */
614 int compare_iter_index(const void *a
, const void *b
);
615 void generate_city_map_indices(void);
616 void free_city_map_index(void);
619 int city_tile_output(const struct city
*pcity
, const struct tile
*ptile
,
620 bool is_celebrating
, Output_type_id otype
);
621 int city_tile_output_now(const struct city
*pcity
, const struct tile
*ptile
,
622 Output_type_id otype
);
624 bool base_city_can_work_tile(const struct player
*restriction
,
625 const struct city
*pcity
,
626 const struct tile
*ptile
);
627 bool city_can_work_tile(const struct city
*pcity
, const struct tile
*ptile
);
629 bool city_can_be_built_here(const struct tile
*ptile
,
630 const struct unit
*punit
);
631 enum city_build_result
city_build_here_test(const struct tile
*ptile
,
632 const struct unit
*punit
);
635 struct city
*city_list_find_number(struct city_list
*This
, int id
);
636 struct city
*city_list_find_name(struct city_list
*This
, const char *name
);
638 int city_name_compare(const void *p1
, const void *p2
);
640 /* city style functions */
641 const char *city_style_rule_name(const int style
);
642 const char *city_style_name_translation(const int style
);
644 int city_style_by_rule_name(const char *s
);
645 int city_style_by_translated_name(const char *s
);
647 bool city_style_has_requirements(const struct citystyle
*style
);
648 int city_style_of_player(const struct player
*plr
);
649 int style_of_city(const struct city
*pcity
);
651 struct city
*is_enemy_city_tile(const struct tile
*ptile
,
652 const struct player
*pplayer
);
653 struct city
*is_allied_city_tile(const struct tile
*ptile
,
654 const struct player
*pplayer
);
655 struct city
*is_non_attack_city_tile(const struct tile
*ptile
,
656 const struct player
*pplayer
);
657 struct city
*is_non_allied_city_tile(const struct tile
*ptile
,
658 const struct player
*pplayer
);
660 bool is_unit_near_a_friendly_city(const struct unit
*punit
);
661 bool is_friendly_city_near(const struct player
*owner
,
662 const struct tile
*ptile
);
663 bool city_exists_within_max_city_map(const struct tile
*ptile
,
664 bool may_be_on_center
);
666 /* granary size as a function of city size */
667 int city_granary_size(int city_size
);
669 void city_add_improvement(struct city
*pcity
,
670 const struct impr_type
*pimprove
);
671 void city_remove_improvement(struct city
*pcity
,
672 const struct impr_type
*pimprove
);
674 /* city update functions */
675 void city_refresh_from_main_map(struct city
*pcity
, bool *workers_map
);
677 int city_waste(const struct city
*pcity
, Output_type_id otype
, int total
,
679 Specialist_type_id
best_specialist(Output_type_id otype
,
680 const struct city
*pcity
);
681 int get_final_city_output_bonus(const struct city
*pcity
, Output_type_id otype
);
682 bool city_built_last_turn(const struct city
*pcity
);
684 /* city creation / destruction */
685 struct city
*create_city_virtual(struct player
*pplayer
,
686 struct tile
*ptile
, const char *name
);
687 void destroy_city_virtual(struct city
*pcity
);
688 bool city_is_virtual(const struct city
*pcity
);
691 bool is_city_option_set(const struct city
*pcity
, enum city_options option
);
692 void city_styles_alloc(int num
);
693 void city_styles_free(void);
695 void add_tax_income(const struct player
*pplayer
, int trade
, int *output
);
696 int get_city_tithes_bonus(const struct city
*pcity
);
697 int city_pollution_types(const struct city
*pcity
, int shield_total
,
698 int *pollu_prod
, int *pollu_pop
, int *pollu_mod
);
699 int city_pollution(const struct city
*pcity
, int shield_total
);
700 int city_illness_calc(const struct city
*pcity
, int *ill_base
,
701 int *ill_size
, int *ill_trade
, int *ill_pollution
);
702 bool city_had_recent_plague(const struct city
*pcity
);
703 int city_build_slots(const struct city
*pcity
);
704 int city_airlift_max(const struct city
*pcity
);
706 bool city_exist(int id
);
709 * Iterates over all improvements, skipping those not yet built in the
712 #define city_built_iterate(_pcity, _p) \
713 improvement_iterate(_p) { \
714 if ((_pcity)->built[improvement_index(_p)].turn <= I_NEVER) { \
718 #define city_built_iterate_end \
719 } improvement_iterate_end;
722 /* Iterates over all output types in the game. */
723 #define output_type_iterate(output) \
725 Output_type_id output; \
727 for (output = 0; output < O_LAST; output++) {
729 #define output_type_iterate_end \
736 bool is_city_center(const struct city
*pcity
, const struct tile
*ptile
);
737 bool is_free_worked(const struct city
*pcity
, const struct tile
*ptile
);
739 #define is_free_worked_index(city_tile_index) \
740 (CITY_MAP_CENTER_TILE_INDEX == city_tile_index)
741 #define FREE_WORKED_TILES (1)
743 enum citytile_type
citytile_by_rule_name(const char *name
);
745 void *city_ai_data(const struct city
*pcity
, const struct ai_type
*ai
);
746 void city_set_ai_data(struct city
*pcity
, const struct ai_type
*ai
,
751 #endif /* __cplusplus */
753 #endif /* FC__CITY_H */