Exemplo n.º 1
0
/**************************************************************************
  Returns city_tile_value of the best tile worked by or available to pcity.
**************************************************************************/
static int best_worker_tile_value(struct city *pcity)
{
  struct tile *pcenter = city_tile(pcity);
  int best = 0;

  city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, ptile) {
    if (is_free_worked(pcity, ptile)
	|| tile_worked(ptile) == pcity /* quick test */
	|| city_can_work_tile(pcity, ptile)) {
      int tmp = city_tile_value(pcity, ptile, 0, 0);

      if (best < tmp) {
	best = tmp;
      }
    }
  } city_tile_iterate_end;

  return best;
}
Exemplo n.º 2
0
  return best;
}

/**************************************************************************
  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
  auto-settlers or when the AI contemplates building worker units.
**************************************************************************/
void initialize_infrastructure_cache(struct player *pplayer)
{
  city_list_iterate(pplayer->cities, pcity) {
    struct tile *pcenter = city_tile(pcity);
    int radius_sq = city_map_radius_sq_get(pcity);
    int best = best_worker_tile_value(pcity);

    city_map_iterate(radius_sq, city_index, city_x, city_y) {
      activity_type_iterate(act) {
        adv_city_worker_act_set(pcity, city_index, act, -1);
      } activity_type_iterate_end;
    } city_map_iterate_end;

    city_tile_iterate_index(radius_sq, pcenter, ptile, cindex) {
      adv_city_worker_act_set(pcity, cindex, ACTIVITY_POLLUTION,
                              adv_calc_pollution(pcity, ptile, best));
      adv_city_worker_act_set(pcity, cindex, ACTIVITY_FALLOUT,
                              adv_calc_fallout(pcity, ptile, best));
      adv_city_worker_act_set(pcity, cindex, ACTIVITY_MINE,
                              adv_calc_mine(pcity, ptile));
Exemplo n.º 3
0
void city_map_click(struct city* pCity, int canvas_x, int canvas_y) {
    int city_x, city_y;
    if (canvas_to_city_pos(&city_x, &city_y, city_map_radius_sq_get(pCity), canvas_x, canvas_y)) {
        city_toggle_worker(pCity, city_x, city_y);
    }
}