32 int act[ACTIVITY_LAST];
38 const struct tile *ptile);
40 const struct tile *ptile);
42 const struct tile *ptile);
46 const struct tile *ptile,
58 const struct tile *ptile)
61 struct terrain *old_terrain, *new_terrain;
68 if (new_terrain != old_terrain && new_terrain !=
T_NONE) {
98 const struct tile *ptile)
101 struct terrain *old_terrain, *new_terrain;
108 if (old_terrain != new_terrain && new_terrain !=
T_NONE) {
138 const struct tile *ptile)
142 struct terrain *old_terrain, *new_terrain;
149 if (old_terrain == new_terrain || new_terrain ==
T_NONE) {
219 const struct tile *ptile,
306 int foodneed,
int prodneed)
337 enum unit_activity act_id,
int value)
339 if (pcity->
server.adv->act_cache_radius_sq
341 log_debug(
"update activity cache for %s: radius_sq changed from "
355 (pcity->
server.adv->act_cache[city_tile_index]).act[act_id] = value;
363 enum unit_activity act_id)
373 return (pcity->
server.adv->act_cache[city_tile_index]).act[act_id];
383 if (pcity->
server.adv->act_cache_radius_sq
385 log_debug(
"update activity cache for %s: radius_sq changed from "
399 (pcity->
server.adv->act_cache[city_tile_index])
410 if (pcity->
server.adv->act_cache_radius_sq
412 log_debug(
"update activity cache for %s: radius_sq changed from "
426 (pcity->
server.adv->act_cache[city_tile_index])
445 return (pcity->
server.adv->act_cache[city_tile_index])
465 return (pcity->
server.adv->act_cache[city_tile_index])
480 if (pcity->
server.adv->act_cache ==
nullptr
481 || pcity->
server.adv->act_cache_radius_sq == -1
482 || pcity->
server.adv->act_cache_radius_sq != radius_sq) {
486 *
sizeof(*(pcity->
server.adv->act_cache))));
488 memset(pcity->
server.adv->act_cache, 0,
490 *
sizeof(*(pcity->
server.adv->act_cache)));
491 pcity->
server.adv->act_cache_radius_sq = radius_sq;
501 pcity->
server.adv->act_cache =
nullptr;
502 pcity->
server.adv->act_cache_radius_sq = -1;
515 if (pcity->
server.adv->act_cache) {
516 free(pcity->
server.adv->act_cache);
517 pcity->
server.adv->act_cache =
nullptr;
519 delete[] pcity->
server.adv;
520 pcity->
server.adv =
nullptr;
#define action_id_get_activity(act_id)
#define as_transform_action_iterate_end
#define as_transform_action_iterate(_act_)
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
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.
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
int city_map_tiles(int city_radius_sq)
Return the number of tiles for the given city radius.
#define city_list_iterate(citylist, pcity)
#define city_tile_iterate_index_end
#define city_list_iterate_end
#define city_map_iterate_end
#define city_map_iterate(_radius_sq, _index, _x, _y)
#define city_tile_iterate_index(_radius_sq, _city_tile, _tile, _index)
#define city_map_tiles_from_city(_pcity)
void adv_city_free(struct city *pcity)
Free advisors related city data.
int adv_city_worker_act_get(const struct city *pcity, int city_tile_index, enum unit_activity act_id)
Return the value for activity 'doing' on tile 'city_tile_index' of city 'pcity'.
static int adv_calc_transform(const struct city *pcity, const struct tile *ptile)
Calculate the benefit of transforming the given tile.
void adv_city_worker_extra_set(struct city *pcity, int city_tile_index, const struct extra_type *pextra, int value)
Set the value for extra on tile 'city_tile_index' of city 'pcity'.
void adv_city_update(struct city *pcity)
Update the memory allocated for AI city handling.
static int adv_calc_extra(const struct city *pcity, const struct tile *ptile, const struct extra_type *pextra)
Calculate the benefit of building an extra at the given tile.
int adv_city_worker_extra_get(const struct city *pcity, int city_tile_index, const struct extra_type *pextra)
Return the value for extra on tile 'city_tile_index' of city 'pcity'.
static int adv_calc_mine_transform(const struct city *pcity, const struct tile *ptile)
Calculate the benefit of mining the given tile.
void initialize_infrastructure_cache(struct player *pplayer)
Do all tile improvement calculations and cache them for later.
void adv_city_worker_act_set(struct city *pcity, int city_tile_index, enum unit_activity act_id, int value)
Set the value for activity 'doing' on tile 'city_tile_index' of city 'pcity'.
void adv_city_worker_rmextra_set(struct city *pcity, int city_tile_index, const struct extra_type *pextra, int value)
Set the value for extra removal on tile 'city_tile_index' of city 'pcity'.
int adv_city_worker_rmextra_get(const struct city *pcity, int city_tile_index, const struct extra_type *pextra)
Return the value for extra removal on tile 'city_tile_index' of city 'pcity'.
static int adv_calc_rmextra(const struct city *pcity, const struct tile *ptile, const struct extra_type *pextra)
Calculate the benefit of removing an extra from the given tile.
int city_tile_value(const struct city *pcity, const struct tile *ptile, int foodneed, int prodneed)
Returns a measure of goodness of a tile to pcity.
static int adv_calc_irrigate_transform(const struct city *pcity, const struct tile *ptile)
Calculate the benefit of irrigating the given tile.
void adv_city_alloc(struct city *pcity)
Allocate advisors related city data.
#define fc_assert_ret(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
bool terrain_surroundings_allow_change(const struct tile *ptile, const struct terrain *pterrain)
Returns FALSE if a terrain change to 'pterrain' would be prevented by not having enough similar terra...
struct city::@15::@17 server
struct city_list * cities
struct terrain * irrigation_result
struct terrain * mining_result
struct terrain * transform_result
int rmextra[MAX_EXTRA_TYPES]
int extra[MAX_EXTRA_TYPES]
#define fc_realloc(ptr, sz)
#define terrain_has_flag(terr, flag)
void tile_add_extra(struct tile *ptile, const struct extra_type *pextra)
Adds extra to tile.
void tile_virtual_destroy(struct tile *vtile)
Frees all memory used by the virtual tile, including freeing virtual units in the tile's unit list an...
void tile_remove_extra(struct tile *ptile, const struct extra_type *pextra)
Removes extra from tile if such exist.
void tile_change_terrain(struct tile *ptile, struct terrain *pterrain)
Change the terrain to the given type.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
struct tile * tile_virtual_new(const struct tile *ptile)
Returns a virtual tile.
#define tile_terrain(_tile)
#define tile_has_extra(ptile, pextra)