Feature #374 » 0030-Unhardcode-wld.map-from-city_map_to_tile.patch
ai/default/daicity.c | ||
---|---|---|
struct city *pcity)
|
||
{
|
||
struct tile *pcenter = city_tile(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
log_base(LOG_EMERGENCY,
|
||
"Emergency in %s (%s, angry%d, unhap%d food%d, prod%d)",
|
||
... | ... | |
pcity->surplus[O_FOOD],
|
||
pcity->surplus[O_SHIELD]);
|
||
city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, atile) {
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, atile) {
|
||
struct city *acity = tile_worked(atile);
|
||
if (acity && acity != pcity && city_owner(acity) == city_owner(pcity)) {
|
||
... | ... | |
{
|
||
adv_want want = 0;
|
||
int prod[O_LAST], bonus[O_LAST], waste[O_LAST];
|
||
const struct civ_map *nmap = &(wld.map);
|
||
memset(prod, 0, O_LAST * sizeof(*prod));
|
||
if (NULL != pimprove
|
||
... | ... | |
/* The below calculation mostly duplicates get_worked_tile_output().
|
||
* We do this only for buildings that we know may change tile
|
||
* outputs. */
|
||
city_tile_iterate(city_map_radius_sq_get(acity), acenter, ptile) {
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(acity), acenter, ptile) {
|
||
if (tile_worked(ptile) == acity) {
|
||
output_type_iterate(o) {
|
||
prod[o] += city_tile_output(acity, ptile, celebrating, o);
|
ai/default/daisettler.c | ||
---|---|---|
bool handicap = has_handicap(pplayer, H_MAP);
|
||
struct adv_data *adv = adv_data_get(pplayer, NULL);
|
||
struct cityresult *result;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
fc_assert_ret_val(adv != NULL, NULL);
|
||
fc_assert_ret_val(center != NULL, NULL);
|
||
... | ... | |
result->city_radius_sq = city_map_radius_sq_get(pcity);
|
||
city_tile_iterate_index(result->city_radius_sq, result->tile, ptile,
|
||
city_tile_iterate_index(nmap, result->city_radius_sq, result->tile, ptile,
|
||
cindex) {
|
||
int tindex = tile_index(ptile);
|
||
int reserved = citymap_read(ptile);
|
ai/tex/texaicity.c | ||
---|---|---|
struct texai_tile_state state = { .uw_max = 0, .uw_max_base = 0, .worst_worked = FC_INFINITY,
|
||
.orig_worst_worked = 0, .old_worst_worked = FC_INFINITY };
|
||
struct unit_list *units = NULL;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
switch (limit) {
|
||
case TWTL_CURRENT_UNITS:
|
||
... | ... | |
break;
|
||
}
|
||
city_tile_iterate_index(city_map_radius_sq_get(pcity), city_tile(pcity),
|
||
city_tile_iterate_index(nmap, city_map_radius_sq_get(pcity), city_tile(pcity),
|
||
ptile, cindex) {
|
||
texai_tile_worker_task_select(pplayer, pcity, ptile, cindex, units,
|
||
&worked, &unworked, &state, limit);
|
client/agents/cma_core.c | ||
---|---|---|
connection_do_buffer(&client.conn);
|
||
/* Remove all surplus workers */
|
||
city_tile_iterate_skip_free_worked(city_radius_sq, pcenter, ptile, idx,
|
||
x, y) {
|
||
city_tile_iterate_skip_free_worked(&(wld.map), city_radius_sq, pcenter,
|
||
ptile, idx, x, y) {
|
||
if (tile_worked(ptile) == pcity
|
||
&& !result->worker_positions[idx]) {
|
||
log_apply_result("Removing worker at {%d,%d}.", x, y);
|
||
... | ... | |
/* Set workers */
|
||
/* FIXME: This code assumes that any toggled worker will turn into a
|
||
* DEFAULT_SPECIALIST! */
|
||
city_tile_iterate_skip_free_worked(city_radius_sq, pcenter, ptile, idx,
|
||
city_tile_iterate_skip_free_worked(&(wld.map), city_radius_sq, pcenter, ptile, idx,
|
||
x, y) {
|
||
if (NULL == tile_worked(ptile)
|
||
&& result->worker_positions[idx]) {
|
client/citydlg_common.c | ||
---|---|---|
city_radius_sq = city_map_radius_sq_get(pcity);
|
||
fc_assert(is_valid_city_coords(city_radius_sq, city_x, city_y));
|
||
ptile = city_map_to_tile(city_tile(pcity), city_radius_sq,
|
||
ptile = city_map_to_tile(&(wld.map), city_tile(pcity), city_radius_sq,
|
||
city_x, city_y);
|
||
if (NULL == ptile) {
|
||
return 0;
|
client/gui-gtk-3.22/citydlg.c | ||
---|---|---|
struct city *pcity = pdialog->pcity;
|
||
popup_workertask_dlg(pdialog->pcity,
|
||
city_map_to_tile(pcity->tile, city_map_radius_sq_get(pcity),
|
||
city_map_to_tile(&(wld.map), pcity->tile,
|
||
city_map_radius_sq_get(pcity),
|
||
city_x, city_y));
|
||
}
|
||
}
|
client/gui-gtk-4.0/citydlg.c | ||
---|---|---|
struct city *pcity = pdialog->pcity;
|
||
popup_workertask_dlg(pdialog->pcity,
|
||
city_map_to_tile(pcity->tile, city_map_radius_sq_get(pcity),
|
||
city_map_to_tile(&(wld.map), pcity->tile,
|
||
city_map_radius_sq_get(pcity),
|
||
city_x, city_y));
|
||
}
|
||
client/gui-qt/citydlg.cpp | ||
---|---|---|
return;
|
||
}
|
||
ptile = city_map_to_tile(mcity->tile, city_map_radius_sq_get(mcity),
|
||
ptile = city_map_to_tile(&(wld.map), mcity->tile, city_map_radius_sq_get(mcity),
|
||
city_x, city_y);
|
||
pterr = tile_terrain(ptile);
|
||
for_terr.kind = VUT_TERRAIN;
|
client/mapview_common.c | ||
---|---|---|
closest_city = NULL;
|
||
/* Check within maximum (squared) city radius */
|
||
city_tile_iterate(max_rad, ptile, tile1) {
|
||
city_tile_iterate(&(wld.map), max_rad, ptile, tile1) {
|
||
pcity = tile_city(tile1);
|
||
if (pcity
|
||
&& (NULL == client.conn.playing
|
||
... | ... | |
if (!game.scenario.prevent_new_cities) {
|
||
/* Check within maximum (squared) city radius */
|
||
city_tile_iterate(max_rad, ptile, tile1) {
|
||
city_tile_iterate(&(wld.map), max_rad, ptile, tile1) {
|
||
unit_list_iterate(tile1->units, psettler) {
|
||
if ((NULL == client.conn.playing
|
||
|| unit_owner(psettler) == client.conn.playing)
|
client/packhand.c | ||
---|---|---|
} else if (city_owner(pcity) != powner) {
|
||
/* Remember what were the worked tiles. The server won't
|
||
* send them to us again. */
|
||
city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity),
|
||
city_tile_iterate_skip_free_worked(&(wld.map), city_map_radius_sq_get(pcity),
|
||
ptile, pworked, _index, _x, _y) {
|
||
if (pcity == tile_worked(pworked)) {
|
||
if (NULL == worked_tiles) {
|
||
... | ... | |
} else if (city_owner(pcity) != powner) {
|
||
/* Remember what were the worked tiles. The server won't
|
||
* send to us again. */
|
||
city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), ptile,
|
||
city_tile_iterate_skip_free_worked(&(wld.map), city_map_radius_sq_get(pcity), ptile,
|
||
pworked, _index, _x, _y) {
|
||
if (pcity == tile_worked(pworked)) {
|
||
if (NULL == worked_tiles) {
|
common/aicore/citymap.c | ||
---|---|---|
**************************************************************************/
|
||
void citymap_turn_init(struct player *pplayer)
|
||
{
|
||
/* The citymap is reinitialized at the start of ever turn. This includes
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* The citymap is reinitialized at the start of ever turn. This includes
|
||
* a call to realloc, which only really matters if this is the first turn
|
||
* of the game (but it's easier than a separate function to do this). */
|
||
citymap = fc_realloc(citymap, MAP_INDEX_SIZE * sizeof(*citymap));
|
||
... | ... | |
city_list_iterate(pother->cities, pcity) {
|
||
struct tile *pcenter = city_tile(pcity);
|
||
/* reserve at least the default (squared) city radius */
|
||
city_tile_iterate(MAX(city_map_radius_sq_get(pcity),
|
||
/* Reserve at least the default (squared) city radius */
|
||
city_tile_iterate(nmap, MAX(city_map_radius_sq_get(pcity),
|
||
CITY_MAP_DEFAULT_RADIUS_SQ),
|
||
pcenter, ptile) {
|
||
struct city *pwork = tile_worked(ptile);
|
||
... | ... | |
if (unit_is_cityfounder(punit)
|
||
&& punit->server.adv->task == AUT_BUILD_CITY) {
|
||
/* use default (squared) city radius */
|
||
city_tile_iterate(CITY_MAP_DEFAULT_RADIUS_SQ, punit->goto_tile,
|
||
/* Use default (squared) city radius */
|
||
city_tile_iterate(nmap, CITY_MAP_DEFAULT_RADIUS_SQ, punit->goto_tile,
|
||
ptile) {
|
||
if (citymap[tile_index(ptile)] >= 0) {
|
||
citymap[tile_index(ptile)]++;
|
||
... | ... | |
**************************************************************************/
|
||
void citymap_reserve_city_spot(struct tile *ptile, int id)
|
||
{
|
||
const struct civ_map *nmap = &(wld.map);
|
||
#ifdef FREECIV_DEBUG
|
||
log_citymap("id %d reserving (%d, %d), was %d",
|
||
id, TILE_XY(ptile), citymap[tile_index(ptile)]);
|
||
... | ... | |
/* Tiles will now be "reserved" by actual workers, so free excess
|
||
* reservations. Also mark tiles for city overlapping, or 'crowding'.
|
||
* Uses the default city map size / squared city radius. */
|
||
city_tile_iterate(CITY_MAP_DEFAULT_RADIUS_SQ, ptile, ptile1) {
|
||
city_tile_iterate(nmap, CITY_MAP_DEFAULT_RADIUS_SQ, ptile, ptile1) {
|
||
if (citymap[tile_index(ptile1)] == -id) {
|
||
citymap[tile_index(ptile1)] = 0;
|
||
}
|
||
... | ... | |
**************************************************************************/
|
||
void citymap_free_city_spot(struct tile *ptile, int id)
|
||
{
|
||
city_tile_iterate(CITY_MAP_DEFAULT_RADIUS_SQ, ptile, ptile1) {
|
||
const struct civ_map *nmap = &(wld.map);
|
||
city_tile_iterate(nmap, CITY_MAP_DEFAULT_RADIUS_SQ, ptile, ptile1) {
|
||
if (citymap[tile_index(ptile1)] == -(id)) {
|
||
citymap[tile_index(ptile1)] = 0;
|
||
} else if (citymap[tile_index(ptile1)] > 0) {
|
common/aicore/cm.c | ||
---|---|---|
{
|
||
struct cm_tile_type type;
|
||
struct tile *pcenter = city_tile(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* add all the fields into the lattice */
|
||
tile_type_init(&type); /* init just once */
|
||
/* Add all the fields into the lattice */
|
||
tile_type_init(&type); /* Init just once */
|
||
city_tile_iterate_index(city_map_radius_sq_get(pcity), pcenter, ptile,
|
||
city_tile_iterate_index(nmap, city_map_radius_sq_get(pcity), pcenter, ptile,
|
||
ctindex) {
|
||
if (is_free_worked(pcity, ptile)) {
|
||
continue;
|
||
} else if (city_can_work_tile(pcity, ptile)) {
|
||
compute_tile_production(pcity, ptile, &type); /* clobbers type */
|
||
tile_type_lattice_add(lattice, &type, ctindex); /* copy type if needed */
|
||
compute_tile_production(pcity, ptile, &type); /* Clobbers type */
|
||
tile_type_lattice_add(lattice, &type, ctindex); /* Copy type if needed */
|
||
}
|
||
} city_tile_iterate_index_end;
|
||
... | ... | |
int production[],
|
||
int check_choice, bool negative_ok)
|
||
{
|
||
struct partial_solution solnplus; /* will be soln, plus some tiles */
|
||
struct partial_solution solnplus; /* Will be soln, plus some tiles */
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* Production is whatever the solution produces, plus the
|
||
most possible of each kind of production the idle workers could
|
||
produce */
|
||
if (soln->idle == 1) {
|
||
/* Then the total solution is soln + this new worker. So we know the
|
||
/* Then the total solution is soln + this new worker. So we know the
|
||
production exactly, and can shortcut the later code. */
|
||
const struct cm_tile_type *ptype = tile_type_get(state, check_choice);
|
||
... | ... | |
output_type_iterate(stat_index) {
|
||
int base = production[stat_index];
|
||
city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, ptile) {
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, ptile) {
|
||
if (is_free_worked(pcity, ptile)) {
|
||
base += city_tile_output(pcity, ptile, is_celebrating, stat_index);
|
||
}
|
||
... | ... | |
citizens workers = city_size;
|
||
int food_needed = city_granary_size(city_size) - pcity->food_stock;
|
||
int min_turns;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
city_map_iterate(city_radius_sq, cindex, x, y) {
|
||
struct tile *ptile = city_map_to_tile(pcity->tile, city_radius_sq, x, y);
|
||
struct tile *ptile = city_map_to_tile(nmap, pcity->tile, city_radius_sq, x, y);
|
||
if (!ptile) {
|
||
continue;
|
||
}
|
||
... | ... | |
const struct city *pcity, bool *workers_map)
|
||
{
|
||
struct tile *pcenter = city_tile(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* clear worker positions */
|
||
/* Clear worker positions */
|
||
memset(result->worker_positions, 0,
|
||
sizeof(*result->worker_positions)
|
||
* city_map_tiles(result->city_radius_sq));
|
||
city_tile_iterate_index(result->city_radius_sq, pcenter, ptile, ctindex) {
|
||
city_tile_iterate_index(nmap, result->city_radius_sq, pcenter, ptile, ctindex) {
|
||
if (workers_map == NULL) {
|
||
/* use the main map */
|
||
/* Use the main map */
|
||
struct city *pwork = tile_worked(ptile);
|
||
result->worker_positions[ctindex] = (NULL != pwork && pwork == pcity);
|
||
... | ... | |
}
|
||
} city_tile_iterate_index_end;
|
||
/* copy the specialist counts */
|
||
/* Copy the specialist counts */
|
||
specialist_type_iterate(spec) {
|
||
result->specialists[spec] = pcity->specialists[spec];
|
||
} specialist_type_iterate_end;
|
||
/* find the surplus production numbers */
|
||
/* Find the surplus production numbers */
|
||
get_city_surplus(pcity, result->surplus,
|
||
&result->disorder, &result->happy);
|
||
/* this is a valid result, in a sense */
|
||
/* This is a valid result, in a sense */
|
||
result->found_a_valid = TRUE;
|
||
}
|
||
... | ... | |
void cm_print_city(const struct city *pcity)
|
||
{
|
||
struct tile *pcenter = city_tile(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
log_test("cm_print_city(city %d=\"%s\")", pcity->id, city_name_get(pcity));
|
||
log_test(" size=%d, specialists=%s",
|
||
city_size_get(pcity), specialists_string(pcity->specialists));
|
||
log_test(" workers at:");
|
||
city_tile_iterate_index(city_map_radius_sq_get(pcity), pcenter, ptile,
|
||
city_tile_iterate_index(nmap, city_map_radius_sq_get(pcity), pcenter, ptile,
|
||
cindex) {
|
||
struct city *pwork = tile_worked(ptile);
|
||
common/city.c | ||
---|---|---|
Finds the map position for a given city map coordinate of a certain
|
||
city. Returns true if the map position found is real.
|
||
**************************************************************************/
|
||
struct tile *city_map_to_tile(const struct tile *city_center,
|
||
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)
|
||
{
|
||
... | ... | |
tile_x += CITY_ABS2REL(city_map_x);
|
||
tile_y += CITY_ABS2REL(city_map_y);
|
||
return map_pos_to_tile(&(wld.map), tile_x, tile_y);
|
||
return map_pos_to_tile(nmap, tile_x, tile_y);
|
||
}
|
||
/**********************************************************************//**
|
||
... | ... | |
void citylog_map_workers(enum log_level level, struct city *pcity)
|
||
{
|
||
int *city_map_data = NULL;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
fc_assert_ret(pcity != NULL);
|
||
... | ... | |
sizeof(*city_map_data));
|
||
city_map_iterate(city_map_radius_sq_get(pcity), cindex, x, y) {
|
||
struct tile *ptile = city_map_to_tile(city_tile(pcity),
|
||
struct tile *ptile = city_map_to_tile(nmap,
|
||
city_tile(pcity),
|
||
city_map_radius_sq_get(pcity),
|
||
x, y);
|
||
city_map_data[cindex] = (ptile && tile_worked(ptile) == pcity)
|
||
... | ... | |
bool city_exists_within_max_city_map(const struct tile *ptile,
|
||
bool may_be_on_center)
|
||
{
|
||
city_tile_iterate(CITY_MAP_MAX_RADIUS_SQ, ptile, ptile1) {
|
||
const struct civ_map *nmap = &(wld.map);
|
||
city_tile_iterate(nmap, CITY_MAP_MAX_RADIUS_SQ, ptile, ptile1) {
|
||
if (may_be_on_center || !same_pos(ptile, ptile1)) {
|
||
if (tile_city(ptile1)) {
|
||
return TRUE;
|
||
... | ... | |
bool is_celebrating = base_city_celebrating(pcity);
|
||
#endif
|
||
struct tile *pcenter = city_tile(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
memset(output, 0, O_LAST * sizeof(*output));
|
||
city_tile_iterate_index(city_map_radius_sq_get(pcity), pcenter, ptile,
|
||
city_tile_iterate_index(nmap, city_map_radius_sq_get(pcity), pcenter, ptile,
|
||
city_tile_index) {
|
||
if (workers_map == NULL) {
|
||
struct city *pwork = tile_worked(ptile);
|
||
... | ... | |
{
|
||
bool is_celebrating = base_city_celebrating(pcity);
|
||
int radius_sq = city_map_radius_sq_get(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* initialize tile_cache if needed */
|
||
/* Initialize tile_cache if needed */
|
||
if (pcity->tile_cache == NULL || pcity->tile_cache_radius_sq == -1
|
||
|| pcity->tile_cache_radius_sq != radius_sq) {
|
||
pcity->tile_cache = fc_realloc(pcity->tile_cache,
|
||
... | ... | |
/* Any unreal tiles are skipped - these values should have been memset
|
||
* to 0 when the city was created. */
|
||
city_tile_iterate_index(radius_sq, pcity->tile, ptile, city_tile_index) {
|
||
city_tile_iterate_index(nmap, radius_sq, pcity->tile, ptile, city_tile_index) {
|
||
output_type_iterate(o) {
|
||
(pcity->tile_cache[city_tile_index]).output[o]
|
||
= city_tile_output(pcity, ptile, is_celebrating, o);
|
common/city.h | ||
---|---|---|
* _city_tile is the center of the (possible) city.
|
||
* (_index) will be the city tile index in the interval
|
||
* [0, city_map_tiles(_radius_sq)] */
|
||
#define city_tile_iterate_index(_radius_sq, _city_tile, _tile, \
|
||
#define city_tile_iterate_index(_nmap, _radius_sq, _city_tile, _tile, \
|
||
_index) { \
|
||
city_map_iterate_outwards_radius_sq_index(CITY_MAP_CENTER_RADIUS_SQ, \
|
||
_radius_sq, _index, _x, _y) \
|
||
struct tile *_tile = city_map_to_tile(_city_tile, _radius_sq, \
|
||
struct tile *_tile = city_map_to_tile(_nmap, _city_tile, _radius_sq, \
|
||
_x, _y); \
|
||
if (NULL != _tile) {
|
||
... | ... | |
} city_map_iterate_outwards_radius_sq_index_end;
|
||
/* simple extension to skip is_free_worked() tiles. */
|
||
#define city_tile_iterate_skip_free_worked(_radius_sq, _city_tile, \
|
||
_tile, _index, _x, _y) { \
|
||
city_map_iterate(_radius_sq, _index, _x, _y) { \
|
||
if (!is_free_worked_index(_index)) { \
|
||
struct tile *_tile = city_map_to_tile(_city_tile, _radius_sq, \
|
||
_x, _y); \
|
||
#define city_tile_iterate_skip_free_worked(_nmap, _radius_sq, _city_tile, \
|
||
_tile, _index, _x, _y) { \
|
||
city_map_iterate(_radius_sq, _index, _x, _y) { \
|
||
if (!is_free_worked_index(_index)) { \
|
||
struct tile *_tile = city_map_to_tile(_nmap, _city_tile, _radius_sq, \
|
||
_x, _y); \
|
||
if (NULL != _tile) {
|
||
#define city_tile_iterate_skip_free_worked_end \
|
||
... | ... | |
/* Does the same thing as city_tile_iterate_index(), but keeps the city
|
||
* coordinates hidden. */
|
||
#define city_tile_iterate(_radius_sq, _city_tile, _tile) { \
|
||
const struct tile *_center##_tile = _city_tile; \
|
||
city_map_iterate_outwards_radius_sq(CITY_MAP_CENTER_RADIUS_SQ, \
|
||
_radius_sq, _x, _y) \
|
||
struct tile *_tile = city_map_to_tile(_center##_tile, _radius_sq, \
|
||
_x, _y); \
|
||
#define city_tile_iterate(_nmap, _radius_sq, _city_tile, _tile) { \
|
||
const struct tile *_center##_tile = _city_tile; \
|
||
city_map_iterate_outwards_radius_sq(CITY_MAP_CENTER_RADIUS_SQ, \
|
||
_radius_sq, _x, _y) \
|
||
struct tile *_tile = city_map_to_tile(_nmap, _center##_tile, _radius_sq, \
|
||
_x, _y); \
|
||
if (NULL != _tile) {
|
||
#define city_tile_iterate_end \
|
||
... | ... | |
} \
|
||
}
|
||
/* output type functions */
|
||
/* Output type functions */
|
||
const char *get_output_identifier(Output_type_id output);
|
||
const char *get_output_name(Output_type_id output);
|
||
... | ... | |
void add_specialist_output(const struct city *pcity, int *output);
|
||
void set_city_production(struct city *pcity);
|
||
/* properties */
|
||
/* Properties */
|
||
const char *city_name_get(const struct city *pcity);
|
||
void city_name_set(struct city *pcity, const char *new_name);
|
||
... | ... | |
const struct tile *city_center,
|
||
const struct tile *map_tile);
|
||
struct tile *city_map_to_tile(const struct tile *city_center,
|
||
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);
|
||
common/game.c | ||
---|---|---|
{
|
||
struct tile *pcenter = city_tile(pcity);
|
||
struct player *powner = city_owner(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (NULL != powner) {
|
||
/* always unlink before clearing data */
|
||
/* Always unlink before clearing data */
|
||
city_list_remove(powner->cities, pcity);
|
||
}
|
||
... | ... | |
nation_rule_name(nation_of_player(powner)),
|
||
city_name_get(pcity));
|
||
city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, ptile) {
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, ptile) {
|
||
if (tile_worked(ptile) == pcity) {
|
||
tile_set_worked(ptile, NULL);
|
||
}
|
common/improvement.c | ||
---|---|---|
static bool impr_provides_buildable_extras(const struct city *pcity,
|
||
const struct impr_type *pimprove)
|
||
{
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* Fast check */
|
||
if (!pimprove->allows_extras) {
|
||
... | ... | |
extra_type_iterate(pextra) {
|
||
if (requirement_needs_improvement(pimprove, &pextra->reqs)) {
|
||
city_tile_iterate(city_map_radius_sq_get(pcity),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(pcity),
|
||
city_tile(pcity), ptile) {
|
||
if (player_can_build_extra(pextra, city_owner(pcity), ptile)) {
|
||
return TRUE;
|
common/metaknowledge.c | ||
---|---|---|
static bool is_tile_seen_city(const struct player *pow_player,
|
||
const struct city *target_city)
|
||
{
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* Don't know the city radius. */
|
||
if (!can_player_see_city_internals(pow_player, target_city)) {
|
||
return FALSE;
|
||
}
|
||
/* A tile of the city is unseen */
|
||
city_tile_iterate(city_map_radius_sq_get(target_city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(target_city),
|
||
city_tile(target_city), ptile) {
|
||
if (!tile_is_seen(ptile, pow_player)) {
|
||
return FALSE;
|
common/player.c | ||
---|---|---|
}
|
||
/*******************************************************************//**
|
||
Return true iff x,y is inside any of the player's city map.
|
||
Return true iff tile is inside any of the player's city map.
|
||
***********************************************************************/
|
||
bool player_in_city_map(const struct player *pplayer,
|
||
const struct tile *ptile)
|
||
{
|
||
city_tile_iterate(CITY_MAP_MAX_RADIUS_SQ, ptile, ptile1) {
|
||
const struct civ_map *nmap = &(wld.map);
|
||
city_tile_iterate(nmap, CITY_MAP_MAX_RADIUS_SQ, ptile, ptile1) {
|
||
struct city *pcity = tile_city(ptile1);
|
||
if (pcity
|
common/requirements.c | ||
---|---|---|
if (!context->city) {
|
||
return TRI_MAYBE;
|
||
}
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
if (tile_has_extra(ptile, pextra)) {
|
||
return TRI_YES;
|
||
... | ... | |
if (!context->city) {
|
||
return TRI_MAYBE;
|
||
}
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
if (tile_has_extra(ptile, pextra)) {
|
||
return TRI_YES;
|
||
... | ... | |
if (trade_partner == NULL) {
|
||
ret = TRI_MAYBE;
|
||
} else {
|
||
city_tile_iterate(city_map_radius_sq_get(trade_partner),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
|
||
city_tile(trade_partner), ptile) {
|
||
if (tile_has_extra(ptile, pextra)) {
|
||
return TRI_YES;
|
||
... | ... | |
return TRI_MAYBE;
|
||
}
|
||
if (pterrain != NULL) {
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
if (tile_terrain(ptile) == pterrain) {
|
||
return TRI_YES;
|
||
... | ... | |
if (pterrain != NULL) {
|
||
enum fc_tristate ret;
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
if (tile_terrain(ptile) == pterrain) {
|
||
return TRI_YES;
|
||
... | ... | |
if (trade_partner == NULL) {
|
||
ret = TRI_MAYBE;
|
||
} else {
|
||
city_tile_iterate(city_map_radius_sq_get(trade_partner),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
|
||
city_tile(trade_partner), ptile) {
|
||
if (tile_terrain(ptile) == pterrain) {
|
||
return TRI_YES;
|
||
... | ... | |
if (!context->city) {
|
||
return TRI_MAYBE;
|
||
}
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
const struct terrain *pterrain = tile_terrain(ptile);
|
||
... | ... | |
if (!context->city) {
|
||
return TRI_MAYBE;
|
||
}
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
const struct terrain *pterrain = tile_terrain(ptile);
|
||
... | ... | |
if (trade_partner == NULL) {
|
||
ret = TRI_MAYBE;
|
||
} else {
|
||
city_tile_iterate(city_map_radius_sq_get(trade_partner),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
|
||
city_tile(trade_partner), ptile) {
|
||
const struct terrain *pterrain = tile_terrain(ptile);
|
||
... | ... | |
if (!context->city) {
|
||
return TRI_MAYBE;
|
||
}
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
const struct terrain *pterrain = tile_terrain(ptile);
|
||
... | ... | |
if (!context->city) {
|
||
return TRI_MAYBE;
|
||
}
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
const struct terrain *pterrain = tile_terrain(ptile);
|
||
... | ... | |
if (trade_partner == NULL) {
|
||
ret = TRI_MAYBE;
|
||
} else {
|
||
city_tile_iterate(city_map_radius_sq_get(trade_partner),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
|
||
city_tile(trade_partner), ptile) {
|
||
const struct terrain *pterrain = tile_terrain(ptile);
|
||
... | ... | |
if (!context->city) {
|
||
return TRI_MAYBE;
|
||
}
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
if (tile_has_road_flag(ptile, roadflag)) {
|
||
return TRI_YES;
|
||
... | ... | |
if (!context->city) {
|
||
return TRI_MAYBE;
|
||
}
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
if (tile_has_road_flag(ptile, roadflag)) {
|
||
return TRI_YES;
|
||
... | ... | |
if (trade_partner == NULL) {
|
||
ret = TRI_MAYBE;
|
||
} else {
|
||
city_tile_iterate(city_map_radius_sq_get(trade_partner),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
|
||
city_tile(trade_partner), ptile) {
|
||
if (tile_has_road_flag(ptile, roadflag)) {
|
||
return TRI_YES;
|
||
... | ... | |
if (!context->city) {
|
||
return TRI_MAYBE;
|
||
}
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
if (tile_has_extra_flag(ptile, extraflag)) {
|
||
return TRI_YES;
|
||
... | ... | |
if (!context->city) {
|
||
return TRI_MAYBE;
|
||
}
|
||
city_tile_iterate(city_map_radius_sq_get(context->city),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
city_tile(context->city), ptile) {
|
||
if (tile_has_extra_flag(ptile, extraflag)) {
|
||
return TRI_YES;
|
||
... | ... | |
if (trade_partner == NULL) {
|
||
ret = TRI_MAYBE;
|
||
} else {
|
||
city_tile_iterate(city_map_radius_sq_get(trade_partner),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
|
||
city_tile(trade_partner), ptile) {
|
||
if (tile_has_extra_flag(ptile, extraflag)) {
|
||
return TRI_YES;
|
common/traderoutes.c | ||
---|---|---|
int tile_trade[city_map_tiles(radius_sq)];
|
||
size_t size = 0;
|
||
bool is_celebrating = base_city_celebrating(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (pcity->tile == NULL) {
|
||
return 0;
|
||
}
|
||
city_map_iterate(radius_sq, cindex, cx, cy) {
|
||
struct tile *ptile = city_map_to_tile(pcity->tile, radius_sq, cx, cy);
|
||
struct tile *ptile = city_map_to_tile(nmap, pcity->tile, radius_sq, cx, cy);
|
||
if (ptile == NULL) {
|
||
continue;
|
server/advisors/autosettlers.c | ||
---|---|---|
struct tile *pcenter = city_tile(pcity);
|
||
/* Try to work near the city */
|
||
city_tile_iterate_index(city_map_radius_sq_get(pcity), pcenter, ptile,
|
||
city_tile_iterate_index(nmap, city_map_radius_sq_get(pcity), pcenter, ptile,
|
||
cindex) {
|
||
bool consider = TRUE;
|
||
bool in_use = (tile_worked(ptile) == pcity);
|
server/advisors/infracache.c | ||
---|---|---|
Do all tile improvement calculations and cache them for later.
|
||
These values are used in settler_evaluate_improvements() so this function
|
||
must be called before doing that. Currently this is only done when handling
|
||
must be called before doing that. Currently this is only done when handling
|
||
auto-settlers or when the AI contemplates building worker units.
|
||
**************************************************************************/
|
||
void initialize_infrastructure_cache(struct player *pplayer)
|
||
{
|
||
const struct civ_map *nmap = &(wld.map);
|
||
city_list_iterate(pplayer->cities, pcity) {
|
||
struct tile *pcenter = city_tile(pcity);
|
||
int radius_sq = city_map_radius_sq_get(pcity);
|
||
... | ... | |
} as_transform_action_iterate_end;
|
||
} city_map_iterate_end;
|
||
city_tile_iterate_index(radius_sq, pcenter, ptile, cindex) {
|
||
city_tile_iterate_index(nmap, radius_sq, pcenter, ptile, cindex) {
|
||
adv_city_worker_act_set(pcity, cindex, ACTIVITY_MINE,
|
||
adv_calc_plant(pcity, ptile));
|
||
adv_city_worker_act_set(pcity, cindex, ACTIVITY_IRRIGATE,
|
server/citytools.c | ||
---|---|---|
void city_map_update_all(struct city *pcity)
|
||
{
|
||
struct tile *pcenter = city_tile(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), pcenter,
|
||
city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity), pcenter,
|
||
ptile, _index, _x, _y) {
|
||
/* bypass city_map_update_tile_now() for efficiency */
|
||
city_map_update_tile_direct(ptile, FALSE);
|
||
... | ... | |
****************************************************************************/
|
||
bool city_map_update_radius_sq(struct city *pcity)
|
||
{
|
||
fc_assert_ret_val(pcity != NULL, FALSE);
|
||
int city_tiles_old, city_tiles_new;
|
||
int city_radius_sq_old = city_map_radius_sq_get(pcity);
|
||
int city_radius_sq_new = game.info.init_city_radius_sq
|
||
+ get_city_bonus(pcity, EFT_CITY_RADIUS_SQ);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* check minimum / maximum allowed city radii */
|
||
/* Check minimum / maximum allowed city radii */
|
||
city_radius_sq_new = CLIP(CITY_MAP_MIN_RADIUS_SQ, city_radius_sq_new,
|
||
CITY_MAP_MAX_RADIUS_SQ);
|
||
if (city_radius_sq_new == city_radius_sq_old) {
|
||
/* no change */
|
||
/* No change */
|
||
return FALSE;
|
||
}
|
||
/* get number of city tiles for each radii */
|
||
/* Get number of city tiles for each radii */
|
||
city_tiles_old = city_map_tiles(city_radius_sq_old);
|
||
city_tiles_new = city_map_tiles(city_radius_sq_new);
|
||
if (city_tiles_old == city_tiles_new) {
|
||
/* a change of the squared city radius but no change of the number of
|
||
/* A change of the squared city radius but no change of the number of
|
||
* city tiles */
|
||
return FALSE;;
|
||
}
|
||
... | ... | |
log_debug("[%s (%d)] city_map_radius_sq: %d => %d", city_name_get(pcity),
|
||
pcity->id, city_radius_sq_old, city_radius_sq_new);
|
||
/* workers map before */
|
||
/* Workers map before */
|
||
log_debug("[%s (%d)] city size: %d; specialists: %d (before change)",
|
||
city_name_get(pcity), pcity->id, city_size_get(pcity),
|
||
city_specialists(pcity));
|
||
... | ... | |
city_map_radius_sq_set(pcity, city_radius_sq_new);
|
||
if (city_tiles_old < city_tiles_new) {
|
||
/* increased number of city tiles */
|
||
/* Increased number of city tiles */
|
||
city_refresh_vision(pcity);
|
||
} else {
|
||
/* reduced number of city tiles */
|
||
/* Reduced number of city tiles */
|
||
int workers = 0;
|
||
/* remove workers from the tiles removed rom the city map */
|
||
/* Remove workers from the tiles removed rom the city map */
|
||
city_map_iterate_radius_sq(city_radius_sq_new, city_radius_sq_old,
|
||
city_x, city_y) {
|
||
struct tile *ptile = city_map_to_tile(city_tile(pcity),
|
||
struct tile *ptile = city_map_to_tile(nmap, city_tile(pcity),
|
||
city_radius_sq_old, city_x,
|
||
city_y);
|
||
... | ... | |
/* add workers to free city tiles */
|
||
if (workers > 0) {
|
||
int radius_sq = city_map_radius_sq_get(pcity);
|
||
city_map_iterate_without_index(radius_sq, city_x, city_y) {
|
||
struct tile *ptile = city_map_to_tile(city_tile(pcity), radius_sq,
|
||
struct tile *ptile = city_map_to_tile(nmap, city_tile(pcity), radius_sq,
|
||
city_x, city_y);
|
||
if (ptile && !is_free_worked(pcity, ptile)
|
server/cityturn.c | ||
---|---|---|
}
|
||
/**********************************************************************//**
|
||
Rearrange workers according to a cm_result struct. The caller must make
|
||
Rearrange workers according to a cm_result struct. The caller must make
|
||
sure that the result is valid.
|
||
**************************************************************************/
|
||
void apply_cmresult_to_city(struct city *pcity,
|
||
const struct cm_result *cmr)
|
||
{
|
||
struct tile *pcenter = city_tile(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* Now apply results */
|
||
city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), pcenter,
|
||
city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity), pcenter,
|
||
ptile, idx, x, y) {
|
||
struct city *pwork = tile_worked(ptile);
|
||
... | ... | |
{
|
||
struct tile *pcenter = city_tile(pcity);
|
||
int want = change;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
fc_assert_ret_val(0 < change, 0);
|
||
city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), pcenter,
|
||
city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity), pcenter,
|
||
ptile, _index, _x, _y) {
|
||
if (0 < want && tile_worked(ptile) == pcity) {
|
||
city_map_update_empty(pcity, ptile);
|
||
... | ... | |
struct tile *pcenter = city_tile(pcity);
|
||
struct player *powner = city_owner(pcity);
|
||
const struct impr_type *pimprove = pcity->production.value.building;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (!city_can_grow_to(pcity, city_size_get(pcity) + 1)) {
|
||
/* Need improvement */
|
||
... | ... | |
* make new citizens into scientists or taxmen -- Massimo */
|
||
/* Ignore food if no square can be worked */
|
||
city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), pcenter,
|
||
city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity), pcenter,
|
||
ptile, _index, _x, _y) {
|
||
if (tile_worked(ptile) != pcity /* quick test */
|
||
if (tile_worked(ptile) != pcity /* Quick test */
|
||
&& city_can_work_tile(pcity, ptile)) {
|
||
have_square = TRUE;
|
||
}
|
||
... | ... | |
struct tile *pcenter = city_tile(pcity);
|
||
int city_radius_sq = city_map_radius_sq_get(pcity);
|
||
int k = 100;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
while (k > 0) {
|
||
/* place pollution on a random city tile */
|
||
/* Place pollution on a random city tile */
|
||
int cx, cy;
|
||
int tile_id = fc_rand(city_map_tiles(city_radius_sq));
|
||
struct extra_type *pextra;
|
||
... | ... | |
city_tile_index_to_xy(&cx, &cy, tile_id, city_radius_sq);
|
||
/* Check for a real map position */
|
||
if (!(ptile = city_map_to_tile(pcenter, city_radius_sq, cx, cy))) {
|
||
if (!(ptile = city_map_to_tile(nmap, pcenter, city_radius_sq, cx, cy))) {
|
||
continue;
|
||
}
|
||
... | ... | |
const char *nation_from, *nation_to;
|
||
struct city *rcity = NULL;
|
||
int to_id = pcity_to->id;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (!pcity_from || !pcity_to) {
|
||
return FALSE;
|
||
... | ... | |
ptile_from = city_tile(pcity_from);
|
||
ptile_to = city_tile(pcity_to);
|
||
/* check food supply in the receiver city */
|
||
/* Check food supply in the receiver city */
|
||
if (game.server.mgr_foodneeded) {
|
||
bool migration = FALSE;
|
||
if (pcity_to->surplus[O_FOOD] >= game.info.food_cost) {
|
||
migration = TRUE;
|
||
} else {
|
||
/* check if there is a free tile for the new citizen which, when worked,
|
||
/* Check if there is a free tile for the new citizen which, when worked,
|
||
* leads to zero or positive food surplus for the enlarged city */
|
||
int max_food_tile = -1; /* no free tile */
|
||
city_tile_iterate(city_map_radius_sq_get(pcity_to),
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(pcity_to),
|
||
city_tile(pcity_to), ptile) {
|
||
if (city_can_work_tile(pcity_to, ptile)
|
||
&& tile_worked(ptile) != pcity_to) {
|
||
... | ... | |
**************************************************************************/
|
||
void city_tc_effect_refresh(struct player *pplayer)
|
||
{
|
||
const struct civ_map *nmap = &(wld.map);
|
||
city_list_iterate(pplayer->cities, pcity) {
|
||
bool changed = FALSE;
|
||
city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity),
|
||
city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity),
|
||
city_tile(pcity), ptile, idx, x, y) {
|
||
if (ptile->worked == pcity
|
||
&& get_city_tile_output_bonus(pcity, ptile, NULL, EFT_TILE_WORKABLE) <= 0) {
|
server/generator/startpos.c | ||
---|---|---|
int *tile_value = NULL;
|
||
int min_goodies_per_player = 1500;
|
||
int total_goodies = 0;
|
||
/* this is factor is used to maximize land used in extreme little maps */
|
||
/* This is factor is used to maximize land used in extreme little maps */
|
||
float efactor = player_count() / map_size_checked() / 4;
|
||
bool failure = FALSE;
|
||
bool is_tmap = temperature_is_initialized();
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (wld.map.num_continents < 1) {
|
||
/* Currently we can only place starters on land terrain, so fail
|
||
... | ... | |
tile_value_aux = fc_calloc(MAP_INDEX_SIZE, sizeof(*tile_value_aux));
|
||
tile_value = fc_calloc(MAP_INDEX_SIZE, sizeof(*tile_value));
|
||
/* get the tile value */
|
||
/* Get the tile value */
|
||
whole_map_iterate(&(wld.map), value_tile) {
|
||
tile_value_aux[tile_index(value_tile)] = get_tile_value(value_tile);
|
||
} whole_map_iterate_end;
|
||
/* select the best tiles */
|
||
/* Select the best tiles */
|
||
whole_map_iterate(&(wld.map), value_tile) {
|
||
int this_tile_value = tile_value_aux[tile_index(value_tile)];
|
||
int lcount = 0, bcount = 0;
|
||
/* check all tiles within the default city radius */
|
||
city_tile_iterate(CITY_MAP_DEFAULT_RADIUS_SQ, value_tile, ptile1) {
|
||
/* Check all tiles within the default city radius */
|
||
city_tile_iterate(nmap, CITY_MAP_DEFAULT_RADIUS_SQ, value_tile, ptile1) {
|
||
if (this_tile_value > tile_value_aux[tile_index(ptile1)]) {
|
||
lcount++;
|
||
} else if (this_tile_value < tile_value_aux[tile_index(ptile1)]) {
|
||
... | ... | |
}
|
||
tile_value[tile_index(value_tile)] = 100 * this_tile_value;
|
||
} whole_map_iterate_end;
|
||
/* get an average value */
|
||
/* Get an average value */
|
||
smooth_int_map(tile_value, TRUE);
|
||
initialize_isle_data();
|
server/maphand.c | ||
---|---|---|
struct player *pfrom, struct player *pdest)
|
||
{
|
||
struct tile *pcenter = city_tile(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
buffer_shared_vision(pdest);
|
||
city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, ptile) {
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, ptile) {
|
||
give_tile_info_from_player_to_player(pfrom, pdest, ptile);
|
||
} city_tile_iterate_end;
|
||
server/sanitycheck.c | ||
---|---|---|
int delta;
|
||
int citizen_count = 0;
|
||
struct tile *pcenter = city_tile(pcity);
|
||
const struct civ_map *nmap = &(wld.map);
|
||
SANITY_CITY(pcity, city_size_get(pcity) >= 1);
|
||
city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), pcenter,
|
||
ptile, _index, _x, _y) {
|
||
city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity), pcenter,
|
||
ptile, _index, _x, _y) {
|
||
if (tile_worked(ptile) == pcity) {
|
||
citizen_count++;
|
||
}
|
server/savegame/savegame2.c | ||
---|---|---|
int nat_x, nat_y;
|
||
citizens size;
|
||
const char *stylename;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
sg_warn_ret_val(secfile_lookup_int(loading->file, &nat_x, "%s.x", citystr),
|
||
FALSE, "%s", secfile_error());
|
||
... | ... | |
pcity->style = city_style(pcity);
|
||
}
|
||
pcity->server.synced = FALSE; /* must re-sync with clients */
|
||
pcity->server.synced = FALSE; /* Must re-sync with clients */
|
||
/* Initialise list of city improvements. */
|
||
for (i = 0; i < ARRAY_SIZE(pcity->built); i++) {
|
||
... | ... | |
city_freeze_workers(pcity);
|
||
/* load new savegame with variable (squared) city radius and worked
|
||
/* Load new savegame with variable (squared) city radius and worked
|
||
* tiles map */
|
||
int radius_sq
|
||
... | ... | |
citystr);
|
||
city_map_radius_sq_set(pcity, radius_sq);
|
||
city_tile_iterate(CITY_MAP_MAX_RADIUS_SQ, city_tile(pcity), ptile) {
|
||
city_tile_iterate(nmap, CITY_MAP_MAX_RADIUS_SQ, city_tile(pcity), ptile) {
|
||
if (loading->worked_tiles[ptile->index] == pcity->id) {
|
||
if (sq_map_distance(ptile, pcity->tile) > radius_sq) {
|
||
log_sg("[%s] '%s' (%d, %d) has worker outside current radius "
|
||
... | ... | |
}
|
||
#ifdef FREECIV_DEBUG
|
||
/* set this tile to unused; a check for not resetted tiles is
|
||
/* Set this tile to unused; a check for not resetted tiles is
|
||
* included in game_load_internal() */
|
||
loading->worked_tiles[ptile->index] = -1;
|
||
#endif /* FREECIV_DEBUG */
|
server/savegame/savegame3.c | ||
---|---|---|
int partner;
|
||
int want;
|
||
int tmp_int;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
sg_warn_ret_val(secfile_lookup_int(loading->file, &nat_x, "%s.x", citystr),
|
||
FALSE, "%s", secfile_error());
|
||
... | ... | |
citystr);
|
||
city_map_radius_sq_set(pcity, radius_sq);
|
||
city_tile_iterate(CITY_MAP_MAX_RADIUS_SQ, city_tile(pcity), ptile) {
|
||
city_tile_iterate(nmap, CITY_MAP_MAX_RADIUS_SQ, city_tile(pcity), ptile) {
|
||
if (loading->worked_tiles[ptile->index] == pcity->id) {
|
||
if (sq_map_distance(ptile, pcity->tile) > radius_sq) {
|
||
log_sg("[%s] '%s' (%d, %d) has worker outside current radius "
|
server/score.c | ||
---|---|---|
static void build_landarea_map(struct claim_map *pcmap)
|
||
{
|
||
bv_player *claims = fc_calloc(MAP_INDEX_SIZE, sizeof(*claims));
|
||
const struct civ_map *nmap = &(wld.map);
|
||
memset(pcmap, 0, sizeof(*pcmap));
|
||
... | ... | |
city_list_iterate(pplayer->cities, pcity) {
|
||
struct tile *pcenter = city_tile(pcity);
|
||
city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, tile1) {
|
||
city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, tile1) {
|
||
BV_SET(claims[tile_index(tile1)], player_index(city_owner(pcity)));
|
||
} city_tile_iterate_end;
|
||
} city_list_iterate_end;
|
||
} players_iterate_end;
|
||
whole_map_iterate(&(wld.map), ptile) {
|
||
whole_map_iterate(nmap, ptile) {
|
||
struct player *owner = NULL;
|
||
bv_player *pclaim = &claims[tile_index(ptile)];
|
||