DELTA 5299 984 6685
SVN  ô~û@ß^ …* €ƒ} f‡/€‚	 @@€† G €_ @@€ ‚w€| u”=€p @@€ ‚(˜)€[ t›-˜ !œ8€‚
 i¢{€	 V¥J€ƒq  ª€‚Y @@€† Vµ*€„u G €J @@€' G €‚ @@€›[ D €d @@ ré_ ƒ5êh€‰`fdef HAVE_CONFIG_H
#include <config.h>
#endif

/* utility */
#include "log.h"

/* common */
#include "combat.h"
#include "game.h"
#include "map.h"
#include "movement.h"
#include "player.h"
#include "pf_tools.h"
#include "unit.h"

/* server */
#include "citytools.h"
#include "gotohand.h"
#include "maphand.h"
#include "srv_log.h"
#include "unithand.h"
#include "unittools.h"

/* server/advisors */
#include "advgoto.h"

/* ai */
#include "aicity.h"
#include "aitools.h"
#include "aiunit.h"
#include "defaultai Looks for nearest airbase for punit reachable imediatly.
  Returns NULL if not found.  The path is stored in the path
  argument if not NULL.
  TODO: Special handicaps for planes running out of fuel
        IMO should be less restrictive than general H_MAP, H_FOG
*********/
static struct tile *find_nearest_airbase(const struct unit *punit,
                                         struct pf_path **path)
{
  struct player *pplayer = unit_owner(punit);
  const struct unit_type *punittype = unit_type(punit);
  struct pf_parameter parameter;
  struct pf_map *pfm;

  pft_fill_unit_parameter(&parameter, punit);
  pfm = pf_map_new(&parameter);

  pf_map_move_costs_iterate(pfm, ptile, move_cost, TRUE) {
    if (move_cost > punit->moves_left) {
      /* Too far! */
      break;
    }

    if (is_airunit_refuel_point(ptile, pplayer, punittype, FALSE)) {
      if (path) {
        *path = pf_map_path(pfm, ptile);
      }
      pf_map_destroy(pfm);
      return ptile;
    }
  } pf_map_move_costs_iterate_end;

  pf_map_destroy(pfm);
  return NULL;
}


  Very preliminary estimate for our intent to attack the tile (x, y).
  Used by bombers only.
******/
static bool ai_should_we_air_attack_tile(struct unit *punit,
					 struct tile *ptile)
{
  struct city *acity = tile_city(ptilepunit->id != 0
      && def_ai_city_data(acity)->invasion.occupy == 0
      && !unit_can_take_over(punit)) {
    /* No units capable of occupying are invading */
    log_debug("Don't want to attack %s, although we could",
              city_name(acity) Returns an estimate for the profit gained through attack.
  Assumes that the victim is within one day's flight
******/
static int ai_evaluate_tile_for_air_attack(struct unit *punit, 
					   struct tile *dst_tile)
{
  struct unit *pdefender!can_unit_attack_tile(punit, dst_tile)
      || !(pdefender = get_defender(punit, dst_tile)build_shield_cost(punit)victim_cost = stack_cost(punit, pdefender);
  if (0 == victim_cost) {
    return 0;
  }

  /* Missile would die 100% so we adjust the victim_cost -- GB */
  if (uclass_has_flag(unit_class(punit), UCF_MISSILE)) {
    victim_cost -= unit_build_shield_cost(punit);
  }
victim_defence = PROB_MULTIPLIER - unit_attack;

  balanced_cost = build_cost_balanced(unit_type(punit));

  sortie_time = (unit_has_typeunit_owner(punit), 
                               game_city_by_number(punit->homecity),
                               profit, sortie_time, balanced_cost);
    log_debug("%s at (%d, %d) is a worthy target with profit %d", 
              unit_rule_name(pdefender), TILE_XY(dst_tile), profit);
  } else {
    log_debug("%s(%d, %d): %s at (%d, %d) is unworthy with profit %d",
              unit_rule_name(punit), TILE_XY(unit_tile(punit)),
              unit_rule_name(pdefender), TILE_XY(dst_tile) Find something to bomb
  Air-units specific victim search
  Returns the want for the best target.  The targets are stored in the
  path and pptile arguments if not NULL.
  TODO: take counterattack dangers into account
  TODO: make separate handicaps for air units seeing targets
        IMO should be more restrictive than general H_MAP, H_FOG
*****/
static int find_something_to_bomb(struct unit *punit, struct pf_path **path,
                                  struct tile **pptile)
{
  struct player *pplayer = unit_owner(punit);
  struct pf_parameter parameter;
  struct pf_map *pfm;
  struct tile *best_tile = NULL;
  int best = 0;

  pft_fill_unit_parameter(&parameter, punit);
  pfm = pf_map_new(&parameter);

  /* Let's find something to bomb */
  pf_map_move_costs_iterate(pfm, ptile, move_cost, FALSE) {
    if (move_cost >= punit->moves_left) {
      /* Too far! */
      break;
    }

    if (ai_handicap(pplayer, H_MAP) && !map_is_known(ptile, pplayer)) {
      /* The target tile is unknown */
      continue;
    }

    if (ai_handicap(pplayer, H_FOG) 
        && !map_is_known_and_seen(ptile, pplayer, V_MAINptile, pplayer)
        && ai_should_we_air_attack_tile(punit, ptile)
        && can_unit_attack_tile(punit, ptile)) {
      int new_best = ai_evaluate_tile_for_air_attack(punit, ptile);

      if (new_best > best) {
        best_tile = ptile;
        best = new_best;
        log_debug("%s wants to attack tile (%d, %d)", 
                  unit_rule_name(punit), TILE_XY(ptile));
      }
    }
  } pf_map_positions_iterate_end;

  /* Return the best values. */
  if (pptile) {
    *pptile = best_tile;
  }
  if (path) {
    *path = best_tile ? pf_map_path(pfm, best_tile) : NULL;
  }

  pf_map_destroy(pfm);
  return best;
} 

*
  Iterates through reachable cities and appraises them as a possible 
  base for air operations by (air)unit punit.  Returns NULL if not
  found.  The path is stored in the path argument if not NULL.
******/
static struct tile *ai_find_strategic_airbase(const struct unit *punit,
                                              struct pf_path **path)
{
  struct player *pplayer = unit_owner(punit);
  struct pf_parameter parameter;
  struct pf_map *pfm;
  struct tile *best_tile = NULL;
  struct city *pcity;
  struct unit *pvirtual = NULL;
  int best_worth = 0, target_worth;

  pft_fill_unit_parameter(&parameter, punit);
  pfm = pf_map_new(&parameter);
  pf_map_move_costs_iterate(pfm, ptile, move_cost, FALSE) {
    if (move_cost >= punit->moves_left) {
      break; /* Too far! */
    }

    if (!is_airunit_refuel_point(ptile, pplayer,
                                 unit_type(punit), FALSE)) {
      continue; /* Cannot refuel here. */
    }

    if ((pcity = tile_city(ptile))
        && def_ai_city_data(pcity)->grave_danger != 0) {
      best_tile = ptile;
      break; /* Fly there immediately!! */
    }

    if (!pvirtual) {
      pvirtual =
        create_unit_virtual(pplayer,
                            player_city_by_number(pplayer, punit->homecity),
                            unit_type(punit), punit->veteran);
    }

    pvirtual->tile = ptile;
    target_worth = find_something_to_bomb(pvirtual, NULL, NULL);
    if (target_worth > best_worth) {
      /* It's either a first find or it's better than the previous. */
      best_worth = target_worth;
      best_tile = ptile;
      /* We can still look for something better. */
    }
  } pf_map_move_costs_iterate_end;

  if (pvirtual) {
    destroy_unit_virtual(pvirtual);
  }

  if (path) {
    /* Stores the path. */
    *path = best_tile ? pf_map_path(pfm, best_tile) : NULL;
  }
  pf_map_destroy(pfm);

  return best_tile;
}

**
  Trying to manage bombers and stuff.
  If we are in the open {
    if moving intelligently on a valid GOTO, {
      carry on doing it.
    } else {
      go refuel
    }
  } else {
    try to attack something
  } 
  TODO: distant target selection, support for fuel > 2
*******/
void ai_manage_airunit(struct player *pplayer, struct unit *punit)
{
  struct tile *dst_tile = punit->tile;
  /* Loop prevention */
  int moves = punit->moves_left;
  int id = punit->id;
  struct pf_parameter parameter;
  struct pf_map *pfm;
  struct pf_path *path;

  CHECK_UNIT(punit);

  if (!is_unit_being_refueled(punit)) {
    /* We are out in the open, what shall we do? */
    if (punit->activity == ACTIVITY_GOTO
        /* We are on a GOTO.  Check if it will get us anywhere */
        && NULL != punit->goto_tile
        && !same_pos(unit_tile(punit), punit->goto_tile)
        && is_airunit_refuel_point(punit->goto_tile, 
                                   pplayer, unit_type(punit), FALSE)) {
      pfm = pf_map_new(&parameter);
      path = pf_map_path(pfm, punit->goto_tile);
      if (path) {
        bool alive = adv_follow_path(punit, path, punit->goto_tile);

        pf_path_destroy(path);
        pf_map_destroy(pfm);
        if (alive && punit->moves_left > 0) {
          /* Maybe do something else. */
          ai_manage_airunit(pplayer, punit);
        }
        return;
      }
      pf_map_destroy(pfm);
    } else if ((dst_tile = find_nearest_airbase(punit, &path))) {
      /* Go refuelling */
      if (!adv_follow_path(punit, path, dst_tile)) {
        pf_path_destroy(path);
        return; /* The unit died. */
      }
      pf_path_destroy(path);
    } else {
      if (punit->fuel == 1) {
	UNIT_LOG(LOG_DEBUG, punit, "Oops, fallin outta the sky");
      }
      def_ai_unit_data(punit)->done = TRUE; /* Won't help trying again */
      return;
    }

  } else if (punit->fuel == unit_type(punit)->fuel) {
    /* We only leave a refuel point when we are on full fuel */

    if (find_something_to_bomb(punit, &path, &dst_tile) > 0) {
      /* Found target, coordinates are in punit's goto_dest.
       * TODO: separate attacking into a function, check for the best 
       * tile to attack from */
      fc_assert_ret(path != NULL && dst_tile != NULL);
      if (!adv_follow_path(punit, path, dst_tile)) {
        pf_path_destroy(path);
        return; /* The unit died. */
      }
      pf_path_destroy(path);

      /* goto would be aborted: "Aborting GOTO for AI attack procedures"
       * now actually need to attack */
      /* We could use ai_military_findvictim here, but I don't trust it... */
      unit_activity_handling(punit, ACTIVITY_IDLE);
      if (is_tiles_adjacent(unit_tile(punit), dst_tile)) {
        (void) unit_move_handling(punit, dst_tile, TRUE, FALSE);
      }
    } else if ((dst_tile = ai_find_strategic_airbase(punit, &path))) {
      log_debug("%s will fly to (%i, %i) (%s) to fight there",
                unit_rule_name(punit), TILE_XY(dst_tile),
                tile_city(dst_tile) ? city_name(tile_city(dst_tile)) : "");
      def_ai_unit_data(punit)->done = TRUE; /* Wait for next turn */
      if (!adv_follow_path(punit, path, dst_tile)) {
        pf_path_destroy(path);
        return; /* The unit died. */
      }
      pf_path_destroy(path);
    } else {
      log_debug("%s cannot find anything to kill and is staying put", 
                unit_rule_name(punit));
      def_ai_unit_data(punit)->done = TRUE;
      unit_activity_handling(punit, ACTIVITY_IDLE);
    }
  }

  if ((punit = game_unit_by_number(id)) != NULL && punit->moves_left > 0
      && punit->moves_left != moves) {
    /* We have moved this turn, might have ended up stuck out in the fields
     * so, as a safety measure, let's manage again */
    ai_manage_airunit(pplayer, punit);
  }

}


  Chooses the best available and usable air unit and records it in 
  choice, if it's better than previous choice
  The interface is somewhat different from other ai_choose, but
  that's what it should be like, I believe -- GB

  unit_type_iterate(punittype) {
    struct unit_class *pclass = utype_class(punittype);

    if (pclass->ai.land_move == MOVE_NONE
        || pclass->ai.sea_move == MOVE_NONE
        || uclass_has_flag(pclass, UCF_TERRAIN_SPEED)
        || unit_type_is_losing_hp(pplayer, punittype)) {
      /* We don't consider this a plane */
      continue;
    }
    if (can_city_build_unit_now(pcity, punittype)) {
      struct unit *virtual_unit = 
	create_unit_virtual(pplayer, pcity, punittype, 
                            do_make_unit_veteran(pcity, punittype));
      int profit = find_something_to_bomb(virtual_unit, NULL, NULL);

      if (profit > choice->want){
        /* Update choice */
        choice->want = profit;
        choice->value.utype = punittype;
        choice->type = CT_ATTACKER;
        choice->need_boat = FALSE;
        want_something = TRUE;
        log_debug("%s wants to build %s (want=%d)",
                  city_name(pcity), utype_rule_name(punittype), profit);
      } else {
        log_debug("%s doesn't want to build %s (want=%d)",
                  city_name(pcity), utype_rule_name(punittype), profit);
      }
      destroy_unit_virtual(virtual_unit);
    }
  } unit_type_iterate_end;

  return want_something;
}
ENDREP
DELTA 18308 266 442
SVN  Å<Å0D äh ’ ˆoäz’ †Bí{’ Yäz ˆ
õ(© Sí „þ.‘ Ž%‚] †M‘‘ 3—d —U¨ …H¿tmove_costs_iteratemove_costs_iteratemove_costs_iteratemove_costs_iterate_end;

  return ctargetpositions_iteratepositions_iterateENDREP
DELTA 17796 19432 2662
SVN  ‚¹8‚¸fv ­m ‡ ¼Z­Ž (êh‘ ‹ú! 5…7‘ •4†} žwœ5 †q»1 ‡BÂ' ˜}Én …Râx Œ	èW‘ Žgôq‘ ‹;‚ƒi‡ K‚8 ƒo‚ [‚ | Œe‚¡\‡ Ša‚®W = gameunit_by_numberpositions_iteratepositions_iteratetiles_iteratetiles_iteratepositions_iteratepositions_iterate = game = gameENDREP
DELTA 18308 1245 301
SVN  “V“R#H Ç	 ’ ŠuÇ’ –6Ò"’ ¢èj ‡4‹’ ’Nmove_costs_iteratemove_costs_iteratemove_costs_iteratemove_costs_iterateENDREP
DELTA 7965 74 9474
SVN  ¦ð}‚T† …k €…< ~Š!€U PÈ ƒa™€‚` zŸ0€‡C o¥y€ƒ3 tª ‡ dªx€„) „6°HŒ ‚µ&’ …
·J€„% fÀH€‚ JÅ%€ ‚sÈ^€R ‚hËz€w XÈx ‚IÐ€X ƒKÓGœ ƒZ×A€{ ƒ~êg’ Vîq€g rñ1€P Kòu€V ‚	ôKœ ‚jövƒ ‚ù`€~ TÈ{ „/üe´ w‚-€‚ s…,´ )†^€‚ Mˆ „ &ˆX‰ ‚iŠ
˜ ƒW
€ H‘?² n“0€R HÊ  •f€ƒB #˜z Tš&€h [j€…p ƒ¡l¥ R¥7€s TÈ{© HÊ €¢ RÈ}µ HÊ €Š0 SÈ|€ HÊ €‰y
#include <string.h>

/* utility */
#include "mem.h"
#include "log.h"
#include "support.h" 
#include "timing.h"

/* common */
#include "city.h"
#include "game.h"
#include "government.h"
#include "map.h"
#include "movement.h"
#include "packets.h"
#include "player.h"

/* aicore */
#include "pf_tools.h"

/* server */
#include "citytools.h"
#include "gotohand.h"
#include "maphand.h"
#include "srv_log.h"
#include "unithand.h"
#include "unittools.h"

/* server/advisors */
#include "advdata.h"
#include "advtools.h"
#include "autosettlers.h"

/* ai */
#include "aicity.h"
#include "aiferry.h"
#include "aitools.h"
#include "aiunit.h"
#include "citymap.h"
#include "defaultai.h"

#include "aisettler.h"
*cachemap;

static bool ai_do_build_city(struct player *pplayer, struct unit *punit);tile_city(result->tile);
  struct government *curr_govt = government_of_player(pplayer);
  struct player *saved_owner = NULL;
  struct tile *saved_claimer = NULL;
  int sum = 0;
  bool virtual_city = FALSE;
  bool handicap = ai_handicap(pplayer, H_MAP);

  pplayer->government = ai->goal.govt.gov;

  result->best_other = 0;
  result->other_tile = NULLtile, "Virtuaville");
    saved_owner = tile_owner(result->tile);
    saved_claimer = tile_claimer(result->tile);
    tile_set_owner(result->tile, pplayer, result->tile); /* temporarily */
    city_choose_build_default(pcity);  /* ?? */
    virtual_city = TRUE;
  }

  result->city_radius_sq = city_map_radius_sq_get(pcity);

  city_tile_iterate_index(result->city_radius_sq, result->tile, ptile,
                          cindex) {
    int i, j;
    city_tile_index_to_xy(&i, &j, cindex, result->city_radius_sq);

    int reserved = citymap_read(ptile);
    bool city_center = (result->tile == ptile); /*is_city_center()*/

    if (reserved < 0
        || (handicap && !map_is_known(ptile, pplayer))
        || NULL != tile_worked(ptile)) {
      /* Tile is reserved or we can't see it */
      result->citymap[i][j].shield = 0;
      result->citymap[i][j].trade = 0;
      result->citymap[i][j].food = 0;
      sum = 0;
    } else if (cachemap[tile_index(ptile)citymap[i][j].food
	= city_tile_output(pcity, ptile, FALSE, O_FOOD);

      /* Shields */
      result->citymap[i][j].shield
	= city_tile_output(pcity, ptile, FALSE, O_SHIELD);

      /* Trade */
      result->citymap[i][j].trade
	= city_tile_output(pcity, ptile, FALSE, O_TRADE);

      sum = result->citymap[i][j].food * ai->food_priority
            + result->citymap[i][j].trade * ai->science_priority
            + result->citymapcitymaptile_index(ptile)].sum = sum;
        cachemap[tile_index(ptile)].trade = result->citymap[i][j].trade;
        cachemap[tile_index(ptile)].shield = result->citymap[i][j].shield;
        cachemap[tile_index(ptile)].food = result->citymap[i][j].food;
      }
    } else {
      sum = cachemap[tile_index(ptile)].sum;
      result->citymap[i][j].shield = cachemap[tile_index(ptile)].shield;
      result->citymap[i][j].trade = cachemap[tile_index(ptile)].trade;
      result->citymap[i][j].food = cachemap[tile_index(ptile)].food;
    }
    result->citymaptile = ptiletile_iterate_index#define CMMR CITY_MAP_MAX_RADIUS
    if (game.info.fulltradesize == 1) {
      result->corruption = ai->science_priority
        * city_waste(pcity, O_TRADE,
                     result->citymap[result->o_x][result->o_y].trade
                     + result->citymap[CMMR][CMMR].trade);
    } else {
      result->corruption = 0;
    }

    result->waste = ai->shield_priority
      * city_waste(pcity, O_SHIELD,
                   result->citymap[result->o_x][result->o_y].shield
                   + result->citymap[CMMR][CMMR].shield);
#undef CMMR* (city_waste(pcity, O_TRADE,
		    result->citymap[result->o_x][result->o_y].trade)
	 - pcity->waste[O_TRADE]);
    result->waste = ai->shield_priority
      * (city_waste(pcity, O_SHIELD,
		    result->citymap[result->o_x][result->o_y].shield)
	 - pcity->waste[O_SHIELD]destroy_city_virtual(pcity);
    tile_set_owner(result->tile, saved_owner, saved_claimer);
  }

  fc_assert(result->city_center >= 0);
  fc_citymap[CITY_MAP_MAX_RADIUS][CITY_MAP_MAX_RADIUS].food
          + result->citymapcitymap[CITY_MAP_MAX_RADIUS][CITY_MAP_MAX_RADIUS].shield
          + result->citymap[result->o_x][result->o_y].shield =10 + tile_terrain(result->tile)->defense_bonus / 10;
  if (tile_has_special(result->tileocean_near_tile(result->tileint *city_map_data;

  city_map_data = fc_calloc(city_map_tiles(cr->city_radius_sq),
                            sizeof(*city_map_data));

  /* print reservations */
  city_map_iterate(cr->city_radius_sq, index, x, y) {
    city_map_data[index] = cr->citymap[x][y].reserved;
  } city_map_iterate_end;
  log_test("cityresult for (x,y,radius_sq) = (%d, %d, %d) - Reservations:",
           cr->tile->x, cr->tile->y, cr->city_radius_sq);
  citylog_map_data(LOG_TEST, cr->city_radius_sq, city_map_data);

  /* print food */
  city_map_iterate(cr->city_radius_sq, index, x, y) {
    city_map_data[index] = cr->citymap[x][y].food;
  } city_map_iterate_end;
  log_test("cityresult for (x,y,radius_sq) = (%d, %d, %d) - Food:",
           cr->tile->x, cr->tile->y, cr->city_radius_sq);
  citylog_map_data(LOG_TEST, cr->city_radius_sq, city_map_data);

  /* print shield */
  city_map_iterate(cr->city_radius_sq, index, x, y) {
    city_map_data[index] = cr->citymap[x][y].shield;
  } city_map_iterate_end;
  log_test("cityresult for (x,y,radius_sq) = (%d, %d, %d) - Shield:",
           cr->tile->x, cr->tile->y, cr->city_radius_sq);
  citylog_map_data(LOG_TEST, cr->city_radius_sq, city_map_data);

  /* print trade */
  city_map_iterate(cr->city_radius_sq, index, x, y) {
    city_map_data[index] = cr->citymap[x][y].trade;
  } city_map_iterate_end;
  log_test("cityresult for (x,y,radius_sq) = (%d, %d, %d) - Trade:",
           cr->tile->x, cr->tile->y, cr->city_radius_sq);
  citylog_map_data(LOG_TEST, cr->city_radius_sq, city_map_data);

  FC_FREE(city_map_data);

  log_test("city center (%d, %d) %d + best other (abs: %d, %d)"
           " (rel: %d,%d) %d", cr->tile->x, cr->tile->y, cr->city_center,
           cr->other_tile->x, cr->other_tile->y, cr->o_x, cr->o_y,
           cr->best_other);
  log_test("- corr %d - waste %d + remaining %d"
           " + defense bonus %d + naval bonus %d", cr->corruption,
           cr->waste, cr->remaining, defense_bonus(cr, ai),
           naval_bonus(cr, ai));
  log_test("= %d (%d)", cr->total, cr->result);

  if (food_starvation(cr)) {
    log_test(" ** FOOD STARVATION **");
  }
  if (shield_starvation(cr)) {
    log_test(struct tile *ptiletile_city(ptile);

  fc_assert_ret(punit && ai && pplayer && result);

  result->tile = ptile;
  result->total = 0;

  if (!city_can_be_built_here(ptile, punit)
      || (ai_handicap(pplayer, H_MAP)
          && !map_is_known(ptileptile, game.info.min_dist_bw_cities-1, tile1) {
    if (citymap_is_reserved(tileptile)) {
    return;
  }

  if (pcity && (pcity->size + unit_pop_value(punit)
		> game.info.add_to_size_limit)) {
    /* Can't exceed population limit. */
    return;
  }

  if (!pcity && citymap_is_reserved(ptilecity_owner(pcity) == pplayerfc_cachemap = fc_realloc(cachemap, MAP_INDEX_SIZE * sizeof(*cachemap));
  memset(cachemap, -1, MAP_INDEX_SIZE * sizeof(*cachemap)				struct unit *punit,
				struct cityresult *best,player *pplayer = unit_owner(punit);
  struct ai_data *ai = ai_data_get(pplayer);
  struct pf_map *pfm;
  bool found = FALSE; /* The return value */

  pfm = pf_map_new(parameter);
  pf_map_move_costs_iterate(pfm, ptile, move_cost, FALSE) {
    int turns;

    if (is_ocean_tile(ptiletile_continent(ptile) != tile_continent(punit->tile)    if (BORDERS_DISABLED != game.info.borders) {
      struct player *powner = tile_owner(ptile);
      if (NULL != powner
       && powner != pplayer
       && pplayers_in_peace(powner, pplayer)) {
        /* Land theft does not make for good neighbours. */
        continue;
      }tilemove_costbuild_shield_cost(punit)info.min_dist_bw_cities*/) {
      break;
    }
  } pf_map_positions_iterate_end;

  pf_map_destroy(pfm);

  fc_assert(!found || 0 <= best->result);us to find a (real) boat before cosidering
  going  If (!look_for_boat && !use_virt_boat), will not consider placements
  overseas.
f_parameter parameter;
  struct player *pplayer = unit_owner(punit);
  struct unit *ferry = NULL;
  struct unit_class *ferry_class = NULL;

  fc_assert_ret(pplayer->ai_controlled);
  /* Only virtual units may use virtual boats: */
  fc_assert_ret(0 == punit->id || !use_virt_boat);

  best->tile = NULL;
  best->result = 0;
  best->total = 0;
  best->overseas = FALSE;
  best->virt_boat = FALSE;
  best->city_radius_sq = game.info.init_city_radius_sqgame_unit_by_number(ferry_id);
  }

  if (ferry 
      || (use_virt_boat && is_ocean_near_tile(punit->tile) 
          && tile_city(punit->tile))) {
    if (!ferry) {
      /* No boat?  Get a virtual one! */
      struct unit_type *NULL) {
        /* Sea travel not possible yet. Bump tech want for ferries. */
        boattype = get_role_unit(L_FERRYBOAT, 0);

        if (NULL != boattype
         && A_NEVER != boattype->require_advance) {
          pplayer->ai_common.tech_want[advance_index(boattype->require_advance)]
            += FERRY_TECH_WANT;
          TECH_LOG(LOG_DEBUG, pplayer, boattype->require_advance,
                   "+ %d for %s to ferry settler",
                   FERRY_TECH_WANT,
                   utype_rule_name(boattype));
        }
        return;
      }
      ferry = create_unit_virtual(pplayer, NULL, boattype, 0);
      ferry->tile = punit->tile;
    }

    ferry_class = unit_class(ferry);

    fc_assert(ferry_class->ai.sea_move != MOVE_NONE);
			    unit_build_shield_cost(ferry)
    if (ferry->id == 0) {
      destroy_unit_virtual(ferry);
    }
  }
  /* If we use a virtual boat, we must have permission and be emigrating: */
  fc_assert(!best->virt_boat || use_virt_boat);
  fc_assert(!best->virt_boat || best->overseasAuto settler that can also build cities.
**/
void ai_auto_settler(struct player *pplayer, struct unit *punit,
                     struct settlermap *state)
{
  struct cityresult result;
  int best_impr = 0;            /* best terrain improvement we can do */
  enum unit_activity best_act;
  struct tile *best_tile = NULL;
  struct pf_path *path = NULL;
  struct ai_data *ai = ai_data_get(pplayer);

  /* time it will take worker to complete its given task */
  int completion_time = 0;

  CHECK_UNIT(punit);

  /*** If we are on a city mission: Go where we should ***/

BUILD_CITY:

  if (punit->server.adv->role == AIUNIT_BUILD_CITY) {
    struct tile *ptile = punit->goto_tile;
    int sanity = punit->id;

    /* Check that the mission is still possible.  If the tile has become
     * unavailable, call it off. */
    if (!city_can_be_built_here(ptile, punit)) {
      ai_unit_new_role(punit, AIUNIT_NONE, NULL);
      set_unit_activity(punit, ACTIVITY_IDLE);
      send_unit_info(NULL, punit);
      return; /* avoid recursion at all cost */
    } else {
     /* Go there */
      if ((!ai_gothere(pplayer, punit, ptile)
           && NULL == game_unit_by_number(sanity))
          || punit->moves_left <= 0) {
        return;
      }
      if (same_pos(punit->tile, ptile)) {
        if (!ai_do_build_city(pplayer, punit)) {
          UNIT_LOG(LOG_DEBUG, punit, "could not make city on %s",
                   tile_get_info_text(punit->tile, 0));
          ai_unit_new_role(punit, AIUNIT_NONE, NULL);
          /* Only known way to end in here is that hut turned in to a city
           * when settler entered tile. So this is not going to lead in any
           * serious recursion. */
          ai_auto_settler(pplayer, punit, state);

          return;
       } else {
          return; /* We came, we saw, we built... */
        }
      } else {
        UNIT_LOG(LOG_DEBUG, punit, "could not go to target");
        /* ai_unit_new_role(punit, AIUNIT_NONE, NULL); */
        return;
      }
    }
  }

  /*** Try find some work ***/

  if (unit_has_type_flag(punit, F_SETTLERS)) {
    TIMING_LOG(AIT_WORKERS, TIMER_START);
    best_impr = settler_evaluate_improvements(punit, &best_act, &best_tile, 
                                              &path, state);
    if (path) {
      completion_time = pf_path_last_position(path)->turn;
    }
    TIMING_LOG(AIT_WORKERS, TIMER_STOP);
  }

  if (unit_has_type_flag(punit, F_CITIES)) {
    /* may use a boat: */
    TIMING_LOG(AIT_SETTLERS, TIMER_START);
    find_best_city_placement(punit, &result, TRUE, FALSE);
    UNIT_LOG(LOG_DEBUG, punit, "city want %d (impr want %d)", result.result,
             best_impr);
    TIMING_LOG(AIT_SETTLERS, TIMER_STOP);
    if (result.result > best_impr) {
      if (tile_city(result.tile)) {
        UNIT_LOG(LOG_DEBUG, punit, "immigrates to %s (%d, %d)", 
                 city_name(tile_city(result.tile)),
                 TILE_XY(result.tile));
      } else {
        UNIT_LOG(LOG_DEBUG, punit, "makes city at (%d, %d)", 
                 TILE_XY(result.tile));
        if (punit->server.debug) {
          print_cityresult(pplayer, &result, ai);
        }
      }
      /* Go make a city! */
      ai_unit_new_role(punit, AIUNIT_BUILD_CITY, result.tile);
      if (result.other_tile) {
        /* Reserve best other tile (if there is one). */
        /* FIXME: what is an "other tile" and why would we want to reserve
         * it? */
        citymap_reserve_tile(result.other_tile, punit->id);
      }
      punit->goto_tile = result.tile; /* TMP */

      /*** Go back to and found a city ***/
      pf_path_destroy(path);
      path = NULL;
      goto BUILD_CITY;
    } else if (best_impr > 0) {
      UNIT_LOG(LOG_DEBUG, punit, "improves terrain instead of founding");
      /* Terrain improvements follows the old model, and is recalculated
       * each turn. */
      ai_unit_new_role(punit, AIUNIT_AUTO_SETTLER, best_tile);
    } else {
      UNIT_LOG(LOG_DEBUG, punit, "cannot find work");
      ai_unit_new_role(punit, AIUNIT_NONE, NULL);
      goto CLEANUP;
    }
  } else {
    /* We are a worker or engineer */
    ai_unit_new_role(punit, AIUNIT_AUTO_SETTLER, best_tile);
  }

  auto_settler_setup_work(pplayer, punit, state, 0, path,
                          best_tile, best_act,
                          completion_time);

CLEANUP:
  if (NULL != path) {
    pf_path_destroy(path);
  }Build a city and initialize AI infrastructure cache.
**/
static bool ai_do_build_city(struct player *pplayer, struct unit *punit)
{
  struct tile *ptile = punit->tile;
  struct city *pcity;

  fc_assert_ret_val(pplayer == unit_owner(punit), FALSE);
  unit_activity_handling(punit, ACTIVITY_IDLE);

  /* Free city reservations */
  ai_unit_new_role(punit, AIUNIT_NONE, NULL);

  pcity = tile_city(ptile);
  if (pcity) {
    /* This can happen for instance when there was hut at this tile
     * and it turned in to a city when settler entered tile. */
    log_debug("%s: There is already a city at (%d, %d)!",
              player_name(pplayer), TILE_XY(ptile));
    return FALSE;
  }
  handle_unit_build_city(pplayer, punit->id,
                         city_name_suggestion(pplayer, ptile));
  pcity = tile_city(ptile);
  if (!pcity) {
    log_error("%s: Failed to build city at (%d, %d)",
              player_name(pplayer), TILE_XY(ptile));
    return FALSE;
  }

  /* We have to rebuild at least the cache for this city.  This event is
   * rare enough we might as well build the whole thing.  Who knows what
   * else might be cached in the future? */
  fc_assert_ret_val(pplayer == city_owner(pcity), FALSE);
  initialize_infrastructure_cache(pplayer);

  /* Init ai.choice. Handling ferryboats might use it. */
  init_choice(&def_ai_city_data(pcity)->choice);

  return TRUEReturn want for city settler. Note that we rely here on the fact that
  ai_settler_init() has been run while doing autosettlers.
**/
void contemplate_new_city(struct city *pcity)
{
  struct unit *virtualunit;
  struct tile *pcenter = city_tile(pcity);
  struct player *pplayer = city_owner(pcity);
  struct unit_type *unit_type = best_role_unit(pcity, F_CITIES); 

  if (unit_type == NULL) {
    log_debug("No F_CITIES role unit available");
    return;
  }

  /* Create a localized "virtual" unit to do operations with. */
  virtualunit = create_unit_virtual(pplayer, pcity, unit_type, 0);
  virtualunit->tile = pcenter;

  fc_assert_ret(pplayer->ai_controlled);

  if (pplayer->ai_controlled) {
    struct cityresult result;
    bool is_coastal = is_ocean_near_tile(pcenter);
    struct ai_city *city_data = def_ai_city_data(pcity);

    find_best_city_placement(virtualunit, &result, is_coastal, is_coastal);
    fc_assert(0 <= result.result);

    CITY_LOG(LOG_DEBUG, pcity, "want(%d) to establish city at"
	     " (%d, %d) and will %s to get there", result.result, 
	     TILE_XY(result.tile), 
	     (result.virt_boat ? "build a boat" : 
	      (result.overseas ? "use a boat" : "walk")));

    city_data->founder_want = (result.virt_boat ? 
                               -result.result : result.result);
    city_data->founder_boat = result.overseas;
  }
  destroy_unit_virtual(virtualunit);
}
ENDREP
DELTA 18308 1714 1087
SVN  ‚Ñ|‚Ñp  Ôk  ŠÔo &ß	 ãIî3ENDREP
DELTA 18308 2917 2368
SVN  …ù"…ùo ¯X ’ ‡/¯j€] „Á(·zmove_costs_iteratemove_costs_iterate_end;

  if (max_want > 0) {
    /* We found something */
    path = pf_mapENDREP
DELTA 18308 10694 230
SVN  ††r†‹3e‰N †-  ‚¦+†? Š.‚¬n¼ Mó €‚Z M…é@ ƒ1‚·€S ‚&‚ºl€X R‚¾7Š }‚¿	€‚ .‚Â¸ g‚Ãp‰ ‚Ä`€V b‚Ç<€h SƒÍ  ƒ½;‚É7Defines specific hash tables needed for request_unit_select(**/
#define SPECHASH_TAG unit_type
#define SPECHASH_KEY_TYPE struct unit_type *
#define SPECHASH_DATA_TYPE void *
#include "spechash.h"

#define SPECHASH_TAG continent
#define SPECHASH_KEY_TYPE Continent_id
#define SPECHASH_DATA_TYPE void *
#define SPECHASH_KEY_TO_PTR FC_INT_TO_PTR
#define SPECHASH_PTR_TO_KEY FC_PTR_TO_INT
#include "spechash.h"tile_hash *tile_table;
  struct unit_type_hash *type_table;
  struct continent_hashtile_hash_new();
  type_table = unit_type_hash_new();
  cont_table = continent_hash_new(unit_type_tile_hash_insert(tile_table, ptile, NULL);
    } else if (selloc == SELLOC_CONT) {
      continent_hash_insert(cont_table, tile_continent(ptile), NULL);
    }
  } unit_list_iterate_end;

  if (selloc == SELLOC_TILE) {
    tile_hash_iterate(tile_table, ptile) {unit_type_hash_lookup(type_table, unit_type(punit), NULLtile_hashunit_type_hash_lookup(type_table, unit_type(punit), NULL))
          || (selloc == SELLOC_CONT
              && !continent_hash_lookup(cont_table, tile_continent(ptile),
                                        NULLtile_hash_destroy(tile_table);
  unit_type_hash_destroy(type_table);
  continent_hash_destroy(cont_tableENDREP
DELTA 17392 90875 2490
SVN  ‚¸6‚¸*p «*  ’W«.€v u¿ Æ2Á  ˆV‚‡6 ¦E‚ c‚¶b€mlast_position(p->path)->moves_left;
  p->end_fuel_left = pf_path_last_position(p->path)->fuel_left;

  p->mp = pf_pathtiles_iteratepath(pfm, ptile);
      break;
    }
  } pf_map_tiles_iterate_end;

  pf_map_destroy(pfm);

  return path;
}
ENDREP
DELTA 17392 2231 1432
SVN  ÌAÌ85| ¸O ‘ ¸`‘ Kºp µxË@ Œ=¸ ‰wx ”T—t 0¬M¢ ¼%positions_iteratepositions_iteratecity_by_number(caravan->homecity),
                     city_by_number(caravan->homecity),ENDREP
DELTA 18311 0 13281
SVN  …å%†  ‘]‚ão ‡L €3 Š€x Q‹}€Š6 b”{ •]€q d…¹p v—r€P Ež@† Ÿ™ o›! ƒ ™   $€E Mƒƒ  ‚+£› ‚¥f« Mƒƒ €e 	ªˆ «&´ Lú@€4 Pœ@€, Mƒƒ ˜ TƒÊq k²% ³˜ ‚´P€7 ¶f€Š …¿%– Ä@° )ÅQ© _…¹u€v Mƒƒ  _É€= @Ë)“ zÌs¸ ‚qÎ€z Nƒ¹;€T ‚FÓ2ˆ ‚Õxˆ ‚AØ ³ N…¯| VÛC€ [Þ& :ß<€ bõ€S Pœ@€| Mƒƒ  1å1€ ~çr ƒ{é3¡ ^íO¡ ‚pïN¼ H°  uó; ‚#ô)€c 4÷4€X Z…ª+€‚} J‚¡@§ J·=€†. mÿS€ƒ+ w‚€‚ '„F€ƒC ]¥=² Z…ª+€ƒD J‚¡@ Š2€‰2 O‘ˆ /’m ‚~”¢ a—=ˆ ˜€ƒ 
›H€„q ]¥=¯ Mƒƒ  ~¡2€„ {¥¥ Z¦< |§&€N c©5€^ „öx€Q r…£l€D L‚ü<€ N®z¿ vƒhŸ K‚¡?€R J…‚6€/ _´L¤ Mƒƒ  ~·Ÿ Mƒƒ  Wº$“ v¼ €P ½a€1 a…‘3€5 Áf€- |ƒ—n€ŽO ‚ÑB€ iÁ| DÕS– ×-° (Ø>© `…¹t€v Mƒƒ  _Ût€= @Ë)“ zÌs¸ ‚qÎ ;ƒ¸N€T ‚<Ó2“ <Õx K×5ˆ Ø ¤ Dƒ»® `ëz— H°  RÙo³ N…¯| Vï;€ ^Þ;š :ß<€ bõ€S Pœ@ L÷z‡  ƒßN #ùn² ûE€D nƒã9 eý{‹ dÿb  dƒçr² lè š cé3€ ƒD‚‚k ^‚;€s 	‚ˆt€D 	‚Š@  Hƒõ-€z ‚'‚Ž*€Z ‚‘ t‚’,¢ ƒ‚“A€‚K N‚™
 ƒA‚šX€U ‚Ÿd€…* Mƒƒ  ‚¢	€= g‚¤a€ Y‚¦>¡ W‚§8¡ ‚©0ˆ ‚H‚ªB· d‚­1© H°  ‚®y t‚°‚ ‚	‚±|€†j O„¥w ‚º}€ˆ@ Mƒƒ  '‚¾$€‚I ‚Àc v‚Áx¬ ‚Âe€„n N‚Ç:€" _‚È5€F {„¹* {„º% u‚ÍL€; f‚Ïw™ '‚Ðm€ƒj z‚Ô/€a ‚Õ€‚\ w‚Ù€ƒo ƒx‚Þ]€ƒ3 W‚ä4‚ y‚å€ƒ H‚çy» `‚è6€‚n „æv m‚ë"€E H° ´ Mƒƒ  ~‚ï5€„G {¥€ t§.€N c‚÷j€^ „öx€Q r…£l€D s‚ü<€w ‚‚ÿ[‚ ‚ƒh± J…‚6€/ _ƒ…<¤ Mƒƒ  ƒˆ	» ‚Gƒ‰X  Mƒƒ  Wƒ+¨ a¼5€P ;ƒY€ xƒ“€‚9 ‚ƒ—S€”( …Oƒ¦"” ‚/ƒ¬§ `…¹t€v Mƒƒ  Uƒ°@€= @Ë)“ zÌs¸ ‚qÎ ;ƒ¸N€T ‚<Ó2“ <Õx K×5ˆ Ø  ƒ<ƒÀf ƒÄ$¤ Dƒ»€I H° ¹ Mƒƒ  ƒ,ƒÇA– bƒËˆ ƒ!ƒÌm¤ F…«  ‚!ƒÐP€ mƒÔ± N…¯| NƒÖs€1 sƒÙ}š ß<€K *ƒÝX kƒß ‚ƒào€G Mƒƒ  Wƒä&‹ Fƒå¡ pƒæf² lè š cé3€‚z ‚&ƒë€‚ ƒïK 	‚ˆt€D )ƒò‹ >ƒóJ mƒõ“ ƒ÷ˆ pƒøž m„®~ ‚>ƒû‹ ‚‘ t‚’,¢ sƒÿo€ h„‚^ N‚™
€‚U ‚Ÿd€†' Mƒƒ  ‚C„ŠG· X‚¦?€ˆc V„’K „”! K‚¬?€[ H°  ‚„—u …Q„š	€†c O„¥w ‚º}€‡| Mƒƒ  !„©d€‚G f‚Àc f„­ 4„®h€g C„±>– 9„²€‚[ ‚Ç:€^ |„¶l€F {„¹* †P„º%€D f‚Ïw™ .‚Ðm r„ÃX€j ‚V„Å4‚ z„È‚ Zšk r„Éeˆ O„ËW€ƒx  „Û. $„Ï=€‚M {„Ò4€‚: s„Õ5† t„Ö.‚ Zšk w„Ø €w %„Û0€E >„Ý€‚' P‚ã:€I 8„àU€…: „äd€‚t „æv „è T‚ì7€X H° ´ Mƒƒ  v„ìB€„[ {¥€ |§&œ k„óv€‚a „öx€O w‚ú}€A J‚ü>€D  „þ€Y @ƒ‚ ½ K‚¡?€P r…‚8€ […ƒ%¢ Mƒƒ  ……n¹ ‚@…‡4¦ Mƒƒ  Q…Šv¨ a¼5€N >…Ž€d …‘3€‚L |ƒ—n€V 9…˜Y .…š …U…›> v…„y …¡{€ ~¬?€` U…¥@€‚* n…£pœ …¤z¶"path_finding.h". */

#define INITIAL_QUEUE_SIZE 100

#ifdef DEBUG
/* Extra checks for debugging. */
#define PF_DEBUG
#endif

/* ======================== Internal structures =====        /* Usual goto */
  PF_DANGER,            /* Goto with dangerous positions */
  PF_FUEL               /* Goto for        /* memory is calloced, hence zero means
                         * uninitialised. */
  NS_INIT,              /* node initialized, but we didn't search a route
                         * yet. */
  NS_NEW,               /* the optimal route isn't found yet. */
  NS_WAITING,           /* the optimal route is found, considering waiting.
                         * Only used for pf_danger_map and pf_fuel_map, it
                         * means we are waiting on a safe place for full
                         * moves before crossing a dangerous area. */
  NS_PROCESSED          /* the optimal route is found. */
};

enum pf_zoc_type {
  ZOC_NO = 0,           /* No ZoC. */
  ZOC_ALLIED,           /* Allied ZoC. */
  ZOC_MINE              /* My ZoC. */
};

/* Abstract base class for pf_normal_map, pf_danger_map, and pf_fuel_map. */
struct pf_map {
#ifdef PF_DEBUG
  enum pf_mode mode;    /* The mode of the map, for conversion checking. */
#endif /* PF_DEBUG */

  /* "Virtual" function table. */
  void (*destroy) (struct pf_map *pfm); /* Destructor. */
  int (*get_move_cost) (struct pf_map *pfm, struct tile *ptile);
  struct pf_path * (*get_path) (struct pf_map *pfm, struct tile *ptile);
  bool (*get_position) (struct pf_map *pfm, struct tile *ptile,
                        struct pf_position *pos);
  bool (*iterate)  (aka iterator)/* Used as an enum direction8. */
#define PF_DIR_NONE (-1)


/* ========================== Common functions =====For
  units with fuel > 1 all moves on the same tank of fuel are considered to
  the
 ***/
static inline int pf***/
static inline int pf********
  Number of turns required to reach node. See comment in the body of
  pf_normal_map_new(), pf_danger_map_new(), and pf_fuel_map_new() functions
  about the usage of moves_left_initially()*/
static inline int pf_turnsAlthough this may be a bug,********
  Moves left after node is reached*/
static inline int pf_moves_left(const struct pf_parameter *param, int cost)
{
  int move_rate = pfpf_turns*
  Obtain cost-of-path from pure cost and extra cos**/
static inline int pf_total_CC(const struct pf_parameter *param,
                              int cost, int extra)
{
  return PF_TURN_FACTOR * cost + extra * pf_move_rate(param***
  Take a position previously filled out (as by fill_position) and "finalize"
  it by reversing all fuel multipliers.

  See pf_moves_left_initially() and pf_move_rate()*/
static inline void pf0 < move_rate ut->fuel] not from [0,  /* or 1? */
  }
}

/* Determine if we can enter the node at all. Set it as a macro, because it
 * is used as many node types (pf_normal_node, pf_danger_node,
 * and pf_fuel_node). */static struct pf_path *
pf_path_new_to_start_tile(const struct pf_parameter *param);
static void pf_position_fill_start_tile(struct pf_position *pos,
                                        const struct pf_parameter *param);


/* ================ Specific pf_normal_* mode structures ================= */

/* Normal path-finding maps are used for most of units with standard rules.
 * See what units make pf_map_new() to pick danger or fuel maps instead. */

/* Node definition. Note we try to have the smallest data as possible. */
struct pf_normal_node {
  signed short cost;    /* total_MC. 'cost' may be negative, see comment in
                         * pf_turns(). */
  unsigned extra_cost;  /* total_EC. Can be huge, (higher than 'cost'). */
  signed dir_to_here : 4; /* Direction from which we came. It can be either
                           * an 'enum direction8' or PF_DIR_NONE (so we need
                           * 4 bits instead of 3). */
  unsigned status : 3;  /* 'enum pf_node_status' really. */

  /* Cached values */
  bool can_invade : 1;
  unsigned node_known_type : 2; /* 'enum known_type' really. */
  unsigned behavior : 2;        /* 'enum tile_behavior' really. */
  unsigned zoc_number : 2;      /* 'enum pf_zoc_type' really. */
  unsigned short extra_tile;    /* EC */PF_NORMAL == pfm->mode                                                ===  Specific pf_normal_* mode functions ****
  Calculates cached values of the target node. Set the node status to
  NS_INIT to avoid recalculating all valuesparameter(PF_MAP(pfnm));

#ifdef PF_DEBUG
  fc_assert(NS_UNINIT == node->status);
  /* Else, not a critical problem, but waste of time. */
#endif

  /* Establish the "known" status of node.. */
  if (NULL != . */
    node->behavior = TB_NORMAL;
  }

  if (NULL != 
     * tile. Other rules can, but we don't care about them here. */
    bool occupied = (0 < unit_list_size(ptile->units) ZOC_ALLIED means
     * can move unrestricted into it, but not necessarily from it.NULL != NULL != pf_normal_map_position(). This also "finalizes" theint index = tile_index(ptile);
  struct pf_normal_node *node = pfnm->lattice + index;
  const struct pf_parameter *params = pf_mappf_move_rate(params)
                   + pf_moves_left_initially(params));
  pos->turn = pf_turns(params, node->cost);
  pos->moves_left = pfPF_DIR_NONE;   /* This field does not apply. */

  pf_finalize_position(params, pos***
  Read off the path to the node dest_tile, which must already be discovered.
  A helper for pf_normal_map_path functionspfnm->lattice + tile_index(dest_tile);
  const struct pf_parameter *params = pf_map_parameter(PF_MAP(pfnm));
  enum direction8 dir_next = PF_DIR_NONEpfnm->lattice + tile_index(ptile)pfnm->lattice + tile_index(ptile)pfnm->lattice + tile_index(ptile);
    }
  }

  return path;parameter(PF_MAP(pfnm));
  node = pfnm->lattice + tile_index(PF_MAP(pfnm)->tile);
  moves_left = pf**
  Bare-bones PF iterator. All Freeciv rules logic is hidden in 'get_costs'
  callback (compare to pf_normal_map_iterate function). This function is
  called when the pf_map was created with a 'get_cost' callback.

  During the iteration, the node status will be changed:
  A. NS_UNINIT: The node is not initialized, we didn't reach it at all.
  (NS_INIT not used here)
  B. NS_NEW: We have reached this node, but we are not sure it was the best
     path.
  (NS_WAITING not used here)
  C. NS_PROCESSED: Now, we are sure we have the best path. Then, we won't
     do anything more with this nod*****/
static bool pf_jumbo_map_iterate  struct tile *tile = pfm->tile;
  int index = tile_index(tile);
  struct pf_normal_node *node = pfnm->lattice + index;
  const struct pf_parameter *params = pf_map_parameter(pfm);

  /* Processing Stage */

  /* The previous position is defined by 'tile' (tile pointer), 'node'
   * (the data of the tile for the pf_map), and index (the index of the
   * position in the Freeciv map). */

  adjc_dir_iterate(tile, tile1, dir) {
    /* Calculate the cost of every adjacent position and set them in the
     * priority queue for next call to pf_jumbo_map_iterate(). */
    int index1 = tile_index(tile1);
    struct pf_normal_node *node1 = pfnm->lattice + index1;
    int priority, cost1, extra_cost1;

    /* As for the previous position, 'tile1', 'node1' and 'index1' are
     * defining the adjacent position. */NS_UNINIT == node1->status) {
      /* Set cost as impossible for initializing, params->get_costs(), will
       * overwrite with the right value. */
      cost1 = PF_IMPOSSIBLE_MC;
      extra_cost1 = 0;
    } else {
      cost1 = node1->cost;
      extra_cost1 = node1->extra_cost;
    }

    /* User-supplied callback 'get_costs' takes care of everything (ZOC,
     * known, costs etc). See explanations in "path_finding.h".cost1,
                                 &extra_cost1, params);
    node1->cost = cost1;
    node1->extra_cost = extra_cost1;
    if (priority >= 0) {
      /* We found a better route to 'tile1', record it (the costs are
       * recorded already). Node status step A. to B.ode (the index with the highest priority). */
  do {
    if (!pq_remove(pfnm->queue, &index)) {
      /* No more indexes in the priority queue, iteration end. */
      return FALSE;
    }
    /* If the node has already been processed, get the next one. */
  } while (NS_NEW != pfnm->lattice[index].status);

  /* Change the pf_map iterator. Node status step B. to C. */
  pfm->tile = index_to_tile(index);
  pfnm->lattice[index].status = NS_PROCESSED;****
  Primary method for iterative path-finding.

  During the iteration, the node status will be changed:
  A. NS_UNINIT: The node is not initialized, we didn't reach it at all.
  B. NS_INIT: We have initialized the cached values, however, we failed to
     reach this node.
  C. NS_NEW: We have reached this node, but we are not sure it was the best
     path.
  (NS_WAITING not used here)
  D. NS_PROCESSED: Now, we are sure we have the best path. Then, we won't
     do anything more with this nodint index = tile_index(tile);
  struct pf_normal_node *node = pfnm->lattice + index;
  const struct pf_parameter *params = pf_map_parameter(pfm);
  int cost_of_path;

  /* There is no exit from DONT_LEAVE tiles! */
  if (node->behavior != TB_DONT_LEAVE) {
    /* Processing Stage */

    /* The previous position is defined by 'tile' (tile pointer), 'node'
     * (the data of the tile for the pf_map), and index (the index of the
     * position in the Freeciv map). */

    adjc_dir_iterate(tile, tile1, dir) {
      /* Calculate the cost of every adjacent position and set them in the
       * priority queue for next call to pf_normal_map_iterate(). */
      int index1 = tile_index(tile1);
      struct pf_normal_node *node1 = pfnm->lattice + index1;
      int cost;
      int extra = 0;

      /* As for the previous position, 'tile1', 'node1' and 'index1' are
       * defining the adjacent position. */

      if (node1->status == NS_PROCESSED) {
        /* This gives 15% speedup. Node status already at step D. */
        continue;
      }

      if (node1->status == NS_UNINIT) {
        /* Only initialize once. See comment for pf_normal_node_init().
         * Node status step A. to B. */NULL != .Cost may be negative; see pf_turnsNULL != . */
      cost_of_path = pf_total_CC(params, cost, extra);

      if (NS_INIT == node1->status
          || cost_of_path < pf_total_CC(params, node1->cost,
                                        node1->extra_cost)) {
        /* We are reaching this node for the first time, or we found a
         * better route to 'tile1'. Let's register 'index1' to the
         * priority queue. Node status step B. to C. *//* As we prefer lower costs, let's reverse the cost of the path. */
        pq_insert(pfnm->queue, index1, -cost_of_path);
      }
    } adjc_dir_iterate_end;
  }

  /* Get the next node (the index with the highest priority). */
  do {
    if (!pq_remove(pfnm->queue, &index)) {
      /* No more indexes in the priority queue, iteration end. */
      return FALSE;
    }
    /* Discard if this node has already been processed. */
  } while (NS_NEW != pfnm->lattice[index].status);

  /* Change the pf_map iterator. Node status step C. to D. */
  pfm->tile = index_to_tile(index);
  pfnm->lattice[index].status = NS_PROCESSED;****
  Iterate the map until 'ptile' is reached/* Start position is handled in every function calling this function. */
  if (NS_UNINIT == node->status) {
    /* Initialize the node, for doing the following tests. */
    pf_normal_node_init(pfnm, node, ptile);
  }

  /* Simpliciation: if we cannot enter this node at all, don't iterate the
   * whole map. */
  if (!CAN_ENTER_NODE(node)) {
    return FALSE;
  }

  while (NS_PROCESSED != node->status) {
    if (!pf_map_iterate(pfm)) {
      /* All reachable destination have been iterated, 'ptile' is
       * unreachable. */****
  Return the move cost at ptile. This function
 ****/
static int pf_normal_map_move_cost(struct pf_map *pfm, struct tile *ptile)
{
  struct pf_normal_map *pfnm = PF_NORMAL_MAP(pfm);

  if (same_pos(ptile, pfm->params.start_tile)) {
    return 0;
  } else            - pf_move_rate(pf_map_parameter(pfm))
            + pf_moves_left_initially(pf_map****
  Return the path to ptile. If ptile has not been reached yet, iterate the
 ****/
static struct pf_path *pf_normal_map_path(struct pf_map *pfm,
normal_map *pfnm = PF_NORMAL_MAP(pfm);

  if (same_pos(ptile, pfm->params.start_tile)) {
    return pf_path_new_to_start_tile(pf_map_parameter(pfm));
  } else*********
  Get info about position at ptile and put it in pos.the position might be unreachab*****/
static bool pf_normal_map_position(struct pf_map *pfm, struct tile *ptile,
normal_map *pfnm = PF_NORMAL_MAP(pfm);

  if (same_pos(ptile, pfm->params.start_tile)) {
    pf_position_fill_start_tile(pos, pf_map_parameter(pfm));
    return TRUE;
  } else*******
  'pf_normal_map' destructor*
  'pf_normal_map' constructormalloc(sizeof(*pfnm. */
  base_map->mode = PF_NORMAL;
#endif /* PF_DEBUG */

  /* Allocate the map.'get_MC' or 'get_costs' callback must be set. */
  fc_assert_ret_val(NULL != parameter->get_MC
                    || NULL != parameter->get_costs, NULL);

  /* Copy parameters.normal_map_destroy;
  base_map->get_move_cost = pf_normal_map_move_cost;
  base_map->get_path = pf_normal_map_path;
  base_map->get_position = pf_normal_map_position;
  if (NULL != the iterator. */
  base_map->tile = params->start_tile;

  /* Initialise starting node. */
  node = pfnm->lattice + tile_index(params->start_tile);
  pf_normal_node_init(pfnpf_turns()). */
  node->cost = pf_move_rate(params) - pf_moves_left_initially(params);
  node->extra_cost = 0;
  node->dir_to_here = PF_DIR_NONE;
  node->status = NS_PROCESSED;

  return PF_MAP(pfnm);
}


/* ================ Specific pf_danger_* mode structures ================= */

/* Danger path-finding maps are used for units which can cross some areas
 * but not ending their turn there. It used to be used for triremes notably.
 * But since Freeciv 2.2, units with the "Trireme" flag just have
 * restricted moves, then it is not use anymore. */

/* Node definition. Note we try to have the smallest data as possible. */
struct pf_danger_node {
  signed short cost;    /* total_MC. 'cost' may be negative, see comment in
                         * pf_turns(). */
  unsigned extra_cost;  /* total_EC. Can be huge, (higher than 'cost'). */
  signed dir_to_here : 4; /* Direction from which we came. It can be either
                           * an 'enum direction8' or PF_DIR_NONE (so we need
                           * 4 bits instead of 3). */
  unsigned status : 3;  /* 'enum pf_node_status' really. */

  /* Cached values */
  bool can_invade : 1;
  unsigned node_known_type : 2; /* 'enum known_type' really. */
  unsigned behavior : 2;        /* 'enum tile_behavior' really. */
  unsigned zoc_number : 2;      /* 'enum pf_zoc_type' really. */
  bool is_dangerous : 1;        /* Whether we cannot end the turn there. */
  bool waited : 1;              /* TRUE if waited to get there. */
  unsigned short extra_tile;    /* EC */

  /* Segment leading across the danger area back to the nearest safe node:
   * need to remeber costs and stuff. */
  struct pf_danger_pos {
    signed short cost;          /* See comment above. */
    unsigned extra_cost;        /* See comment above. */
    signed dir_to_here : 4;     /* See comment above. */
  } *danger_segment; and NS_WAITING),
                                 * sorted by their total_CC. */
  struct pqueue *danger_queue;  /* Dangerous positions. */
  struct pf_dangerPF_DANGER == pfm->mode                                                ===  Specific pf_danger_* mode functions ****
  Calculates cached values of the target node. Set the node status to
  NS_INIT to avoid recalculating all valuesparameter(PF_MAP(pfdm));

#ifdef PF_DEBUG
  fc_assert(NS_UNINIT == node->status);
  /* Else, not a critical problem, but waste of time. */
#endif

  /* Establish the "known" status of node.. */
  if (NULL != . */
    node->behavior = TB_NORMAL;
  }

  if (NULL != 
     * tile. ZOC_ALLIED means
     * can move unrestricted into it, but not necessarily from it.. */
  if (NULL != NULL != #ifdef ZERO_VARIABLES_FOR_SEARCHING

   * FALSE. */
  node->waited = FALSE;
#endifnode->status = NS_INIT;pf_danger_map_position(). This also "finalizes" theint index = tile_index(ptile);
  struct pf_danger_node *node = pfdm->lattice + index;
  const struct pf_parameter *params = pf_map_parameter(PF_MAP(pfdNS_WAITING == node->statuspf_move_rate(params)
                   + pf_moves_left_initially(params));
  pos->turn = pf_turns(params, node->cost);
  pos->moves_left = pfPF_DIR_NONE;   /* This field does not apply. */

  pf_finalize_position(params, pos
  fullpf_moves_left(param, cost);

  if (moves_left < pf*********
  Read off the path to the node 'ptile', but with dangers.PF_DIR_NONEpfdm->lattice + tile_index(ptileparameter(PF_MAP(pfdm));
  struct pf_position *posNS_WAITING == node->statusptile));
#endif /* PF_DEBUG */

  /* First iterate to find path length. */
  while (!same_pos(iter_tile, params->start_tile)) {. */
      dir_next = danger_seg->dir_to_here;
      danger_seg++;
    }

    /* Step backward. */
    iter_tile = mapstep(iter_tile, DIR_REVERSE(dir_next));
    node = pfdm->lattice + tile_index(iter_tile);
  }

  /* Allocate memory for path.. */
  iter_tile = ptile;
  node = pfdm->lattice + tile_index(ptile). */
    if (!node->is_dangerouspath->positions + i;
        pos->tile = iter_tile;
        pos->total_EC = node->extra_cost;
        pos->turn = pf_turnspf_finalize_position(params, pos);
        /* Set old_waited so that we record PF_DIR_NONE. */
    pos = path->positions + ipf_turns(params, pos->total_MC);
    pos->moves_left = pf_moves_left(params, pos->total_MC);
    pos->total_MC -= (pf_move_rate(params)
                      - pf_moves_left_initially(params));
    pos->dir_to_next_pos = (old_waited ? PF_DIR_NONE : dir_next);
    pf_finalize_position(params, pos);

    /* 3: Check if we finished... */
      dir_next = danger_seg->dir_to_here;
      danger_seg++;
    }

    /* 5: Step further back. */
    iter_tile = mapstep(iter_tile, DIR_REVERSE(dir_next));
    node = pfdm->lattice + tile_index(iter_tile)*****
  Creating path segment going back from node1 to a safe tile. We need to
  remember the whole segment because any node can be crossed by many danger
  segments.

  Example: be A, B, C and D points safe positions, E a dangerous one.
    A B
     E 
    C D
  We have found dangerous path from A to D, and later one from C to B:
    A B             A B
     \               / 
    C D             C D
  If we didn't save the segment from A to D when a new segment passing by E
  is found, then finding the path from A to D will produce an error. (The
  path is always done in reverse order.) D->dir_to_here will point to E,
  which is correct, but E->dir_to_here will point to Cstruct tile *ptile = PF_MAP(pfdm)->tile;
  struct pf_danger_node *node = pfdm->lattice + tile_index(ptile);
  struct pf_danger_pos *pos;
  int length = 0, i;

#ifdef PF_DEBUG
  if (NULL != #endif /* PF_DEBUG */

  /* First iteration for determining segment length */
  while (node->is_dangerous && PF_DIR_NONE != node->dir_to_herepfdm->lattice + tile_index(ptile)pfdm->lattice + tile_index(ptile)_to_herepfdm->lattice + tile_index(ptile);
  }

#ifdef PF_DEBUGPF_DIR_NONE == node->dir_to_here);
#endifpf
  Primary method for iterative path-finding in presence of danger
  Notes:
  1. Whenever the path-finding stumbles upon a dangerous location, it goes
     into a sub-Dijkstra which processes _only_ dangerous locations, by
     means of a separate queue. When this sub-Dijkstra reaches a safe
     location, it records the segment of the path going across the dangerous
     tiles. Hence danger_segment is an extended (and reversed) version of
     the dir_to_here field (see comment for pf_danger_map_create_segment()).
     It can be re-recorded multiple times as we find shorter and shorter
     routes.
  2. Waiting is realised by inserting the (safe) tile back into the queue
     with a lower priority P. This tile might pop back sooner than P,
     because there might be several copies of it in the queue already. But
     that does not seem to present any problems. dangerous
     region. However it will find a safe segment if there is one. To
     gurantee the best (in terms of total_CC) safe segments across danger,
     supply 'get_EC' which returns small extra on dangerous tiles.

  During the iteration, the node status will be changed:
  A. NS_UNINIT: The node is not initialized, we didn't reach it at all.
  B. NS_INIT: We have initialized the cached values, however, we failed to
     reach this node.
  C. NS_NEW: We have reached this node, but we are not sure it was the best
     path. Dangerous tiles never get upper status.
  D. NS_PROCESSED: Now, we are sure we have the best path.
  E. NS_WAITING: The safe node (never the dangerous ones) is re-inserted in
     the priority queue, as explained above (2.). We need to consider if
     waiting for full moves open or not new possibilities for moving accross
     dangerous areas.
  F. NS_PROCESSED: When finished to consider waiting at the node, revert the
     status to NS_PROCESSED.
  In points D., E., and F., the best path to the node can be considered as
  found (only safe nodes)parameter(pfm);
  struct tile *tile = pfm->tile;
  int index = tile_index(tile);
  struct pf_danger_node *node = pfdm->lattice + index;

  /* The previous position is defined by 'tile' (tile pointer), 'node'
   * (the data of the tile for the pf_map), and index (the index of the
   * position in the Freeciv map). */

  for (;;)./* We have waited, so we have full moves. */adjc_dir_iterate(tile, tile1, dir) {
        /* Calculate the cost of every adjacent position and set them in
         * the priority queues for next call to pf_danger_map_iterate(). */
        int index1 = tile_index(tile1);
        struct pf_danger_node *node1 = pfdm->lattice + index1;
        int cost;
        int extra = 0;

        /* As for the previous position, 'tile1', 'node1' and 'index1' are
         * defining the adjacent position. */

        if (node1->status == NS_PROCESSED || node1->status == NS_WAITING) {
          /* This gives 15% speedup. Node status already at step D., E.
           * or F. */. */
        if (node1->status == NS_UNINIT) {
          /* Only initialize once. See comment for pf_danger_node_init().
           * Node status step A. to B. */NULL != params->get_zoc
            && !(node->zoc_number == ZOC_MINE
.pf_moves_left(params, loc_cost));

        if (cost == PF_IMPOSSIBLE_MC) {
          /* This move is deemed impossible. */
          continue;
        }

        /* Total cost at 'tile1'.. */
        if (NULL != 'tile1'. */
        if (!node1->is_dangerous) {
          int cost_of_path = pf_total_CC(params, cost, extra);

          if (NS_INIT == node1->status
              || (cost_of_path < pf_total_CC(params, node1->cost,
                                             node1->extra_cost))) {
            /* We are reaching this node for the first time, or we found a
             * better route to 'tile1'. Let's register 'index1' to the
             * priority queue. Node status step B. to C. */if (NULL != node1->danger_segment) {
              /* Clear the previously recorded path back. */We came from a dangerous tile. So we need to record the
               * path we came from until the previous safe position is
               * found. See comment for pf_danger_map_create_segment(). */
              pf_danger_map_create_segment(pfdm, node1);
            } else {
              /* Maybe clear previously "waited" status of the node..
           * We will update costs if:
           * 1. we are here for the first time;
           * 2. we can possibly go further across dangerous area; or
           * 3. we can have lower extra and will not overwrite anything
           * useful. Node status step B. to C. */
          if (node1->status == NS_INIT
              || (pf_moves_left(params, cost)
                  > pf_moves_left(params, node1->cost))
              || ((pf_total_CC(params, cost, extra)
                   < pfNS_WAITING == node->status) {
      /* Node status final step E. to F. */
#ifdef PF_DEBUG
      fc_assert(!node->is_dangerous);
#endif
      node->status = NS_PROCESSED;
    } else if (!node->is_dangerous
               && (pf_moves_left(params, node->cost)
                   < pf_move_rate(params))) {
      int fc, cc;
      /* Consider waiting at this node. To do it, put it back into queue.
       * Node status final step D. to Epf

    /* Get the next node (the index with the highest priority). First try
     * to get it from danger_queue. */
    if (pq_remove(pfdm->danger_queue, &index)) {
      /* Change the pf_map iterator and reset data. */
      tile = index_to_tile(index);
      pfm->tile = tile;
      node = pfdm->lattice + index;
    } else {
      /* No dangerous nodes to process, go for a safe one./* No more indexes in the priority queue, iteration end. */
      /* Change the pf_map iterator and reset data. */
      tile = index_to_tile(index);
      pfm->tile = tile;
      node = pfdm->lattice + index;
      if (NS_WAITING != node->status) {
        /* Node status step C. and D. */
#ifdef PF_DEBUG
        fc_assert(!node->is_dangerous);
#endif
        node->status = NS_PROCESSED;
        return TRUE;
      }
    }

  log_error("%s(): internal error.", __FUNCTION__);
  return FALSE;*********
  Iterate the map until 'ptile' is reached/* Start position is handled in every function calling this function. */

  if (NS_UNINIT == node->status) {
    /* Initialize the node, for doing the following tests. */
    pf_danger_node_init(pfdm, node, ptile);
  }

  /* Simpliciation: if we cannot enter this node at all, don't iterate the
   * whole map. */
  if (!CAN_ENTER_NODE(node) || node->is_dangerous) {
    return FALSE;
  }

  while (NS_PROCESSED != node->status && NS_WAITING != node->status) {
    if (!pf_map_iterate(pfm)) {
      /* All reachable destination have been iterated, 'ptile' is
       * unreachable. */****
  Return the move cost at ptile. If ptile has not been reached yet, iterate
  the map until we reach it or run out of map. This function returns
 ****/
static int pf_danger_map_move_cost(struct pf_map *pfm, struct tile *ptile)
{
  struct pf_danger_map *pfdm = PF_DANGER_MAP(pfm);

  if (same_pos(ptile, pfm->params.start_tile)) {
    return 0;
  } else            - pf_move_rate(pf_map_parameter(pfm))
            + pf_moves_left_initially(pf_map****
  Return the path to ptile. If ptile has not been reached yet, iterate the
 ****/
static struct pf_path *pf_danger_map_path(struct pf_map *pfm,

  if (same_pos(ptile, pfm->params.start_tile)) {
    return pf_path_new_to_start_tile(pf_map_parameter(pfm));
  } else .position(struct pf_map *pfm, struct tile *ptile,
danger_map *pfdm = PF_DANGER_MAP(pfm);

  if (same_pos(ptile, pfm->params.start_tile)) {
    pf_position_fill_start_tile(pos, pf_map_parameter(pfm));
    return TRUE;
  } else*******
  'pf_danger_map' destructorint i;

  /* Need to clean up the dangling danger segments.**
  'pf_danger_map' constructormalloc(sizeof(*pfdm));
  base_map = &pfd. */
  base_map->mode = PF_DANGER;
#endif /* PF_DEBUG */

  /* Allocate the map.'get_MC' callback must be set. */
  fc_assert_ret_val(parameter->get_MC != NULL, NULL);

  /* 'is_pos_dangerous' callback must be set.move_cost;
  base_map->get_path = pf_danger_map_path;
  base_map->get_position = pf_danger_map_position;
  base_map->iterate = pf_danger_map_iterate;

  /* Initialise the iterator. */
  base_map->tile = params->start_tile;

  /* Initialise starting node. */
  node = pfdm->lattice + tile_index(params->start_tile)pf_turns()). */
  node->cost = pf_move_rate(params) - pf_moves_left_initially(params);
  node->extra_cost = 0;
  node->dir_to_here = PF_DIR_NONE;
  node->status = (node->is_dangerous ? NS_NEW : NS_PROCESSED);

  return PF_MAP(pfdm);
}


/* ================= Specific pf_fuel_* mode structures ================== */

/* Fuel path-finding maps are used for units which need to refuel. Usually
 * for air units such as planes or missiles.
 *
 * A big difference with the danger path-finding maps is that the tiles
 * which are not refuel points are not considered as dangerous because the
 * server uses to move the units at the end of the turn to refuels points. */

/* Node definition. Note we try to have the smallest data as possible. */
struct pf_fuel_node {
  signed short cost;    /* total_MC. 'cost' may be negative, see comment in
                         * pf_turns(). */
  unsigned extra_cost;  /* total_EC. Can be huge, (higher than 'cost'). */
  unsigned moves_left : 12; /* Moves left at this position. */
  signed dir_to_here : 4; /* Direction from which we came. It can be either
                           * an 'enum direction8' or PF_DIR_NONE (so we need
                           * 4 bits instead of 3). */
  unsigned status : 3;  /* 'enum pf_node_status' really. */

  /* Cached values */
  bool can_invade : 1;
  unsigned node_known_type : 2; /* 'enum known_type' really. */
  unsigned behavior : 2;        /* 'enum tile_behavior' really. */
  unsigned zoc_number : 2;      /* 'enum pf_zoc_type' really. */
  bool is_enemy_tile : 1;
  bool waited : 1;              /* TRUE if waited to get here. */
  unsigned moves_left_req : 12; /* The minimum required moves left to reach
                                 * this tile. It the number of moves we need
                                 * to reach the nearest refuel point. A
                                 * value of 0 means this is a refuel point.
                                 * FIXME: this is right only for units with
                                 * constant move costs! */
  unsigned short extra_tile;    /* EC */

  /* Segment leading across the danger area back to the nearest safe node:
   * need to remeber costs and stuff. */
  unsigned size_alloc : 8;      /* The number of allocated
                                 * 'struct pf_fuel_pos'. */
  struct pf_fuel_pos {
    signed short cost;          /* See comment above. */
    unsigned extra_cost;        /* See comment above. */
    unsigned moves_left : 12;   /* See comment above. */
    signed dir_to_here : 4;     /* See comment above. */
  } *fuel_segment;PF_FUEL == pfm->mode===  Specific pf_fuel_* mode functions ****
  Calculates cached values of the target node. Set the node status to
  NS_INIT to avoid recalculating all valuesparameter(PF_MAP(pffm));

#ifdef PF_DEBUG
  fc_assert(NS_UNINIT == node->status);
  /* Else, not a critical problem, but waste of time. */
#endif

  /* Establish the "known" status of node.. */
  if (NULL != . */
    node->behavior = TB_NORMAL;
  }

  if (NULL != 
     * tile. ZOC_ALLIED means
     * can move unrestricted into it, but not necessarily from it.. */
  if (NULL != NULL != 
     * FALSE#ifdef ZERO_VARIABLES_FOR_SEARCHING

   * FALSE. */
  node->waited = FALSE;
#endif

  node->status = NS_INIT;*********
  Returns whether this node is dangerous or notfinalize_position_basepf_turns If we have a fuel segment, then usefinalize_position_base(params, pos,
                                   head->cost, head->moves_left);
  } else {
    pf_fuel_finalize_position_basepf_fuel_map_position(). This also "finalizes" theint index = tile_index(ptile);
  struct pf_fuel_node *node = pffm->lattice + index;
  struct pf_fuel_pos *head = node->fuel_segment;
  const struct pf_parameter *params = pf_mapNS_WAITING == node->statushead->extra_cost;
  pos->total_MC = (head->cost - pf_move_rate(params)
                   + pf_moves_left_initially(params));
  pos->dir_to_here = head->dir_to_here;
  pos->dir_to_next_pos = PF_DIR_NONE;*********
  Read off the path to the node 'ptile', but with fuel dangerPF_DIR_NONEpffm->lattice + tile_index(ptile)parameter(PF_MAP(pffm));
  struct pf_position *posNS_WAITING == node->statusptile));
#endif /* PF_DEBUG */

  /* First iterate to find path length. */
  /* NB: the start point could be reached in the middle of a segment.
   * See comment for pf_fuel_map_create_segment(). */
  while (!same_pos(iter_tile, params->start_tile)
         || (segment && PF_DIR_NONE != segment->dir_to_here)) {

    if (node->moves_left_req == 0) {
      /* A refuel point. */. */
      dir_next = segment->dir_to_here;
      segment++;
    } else {
      /* Classical node. */
      dir_next = node->dir_to_here;
    }

    /* Step backward. */
    iter_tile = mapstep(iter_tile, DIR_REVERSE(dir_next));
    node = pffm->lattice + tile_index(iter_tile).. */
  iter_tile = ptile;
  node = pffm->lattice + tile_index(ptile)PF_DIR_NONE.path->positions + ipf_turnspf_turns(params,
             PF_DIR_NONE. */
    pos = path->positions + ipf_move_rate(params)
                      - pf_moves_left_initially(params));
    pos->dir_to_next_pos = (old_waited ? PF_DIR_NONE.. */
    if (segment) {
      /* We are in a fuel segment. */
      dir_next = segment->dir_to_here;
      segment++;
    } else {
      /* Classical node. */
      dir_next = node->dir_to_here;
    }

    /* 5: Step further back. */
    iter_tile = mapstep(iter_tile, DIR_REVERSE(dir_next));
    node = pffm->lattice + tile_index(iter_tile)*****
  Creating path segment going back from node1 to a safe tile. We need to
  remember the whole segment because any node can be crossed by many fuel
  segments.

  Example: be A, a refuel point, A and C not. We start the path from B and
  have only (3 * SINGLE_MOVE) moves lefts:
    A B C
  B cannot move to C because we would have only (1 * SINGLE_MOVE) move left
  reaching it, and the refuel point is too far. So C->moves_left_req =
  (4 * SINGLE_MOVE).
  The path would be to return to A, wait the end of turn to get full moves,
  and go to C. In a single line: B A B C. So, the point B would be reached
  twice. but, it needs to stores different data for B->cost, B->extra_cost,
  B->moves_left, and B->dir_to_here. That's why we need to record every
  path to unsafe nodes (not for refuel points)First iteration for determining segment length. */
  dopffm->lattice + tile_index(ptile);
    /* 0 != node->moves_left_req means this is not a refuel point.
     * PF_DIR_NONE != node->dir_to_here means we are not at start point. */
  } while (0 != node->moves_left_req && PF_DIR_NONE != node->dir_to_here);

  /* Allocate memory for segment, if needed (for performance). Maybe we can
   * use the previous one. As nodes are allocated with fc_calloc(), initial
   * node1->size_alloc is set to 0. */
  if (length > node1->size_alloc) {
    /* We don't nee fc_realloc() because we don't need to keep old data. */
    if (NULL != node1->fuel_segment) {
      free(node1->fuel_segment);        /* Clear previous segment. */
    }
    node1->fuel_segment = fc_malloc(length * sizeof(*node1->fuel_segment));
#ifdef PF_DEBUG
    fc_assert(256 > length);    /* node1->size_alloc has only 8 bits. */
#endif
    node1->size_alloc = length;
  }

  /* Reset tile and node pointers for main iteration. */
  ptile = tile1;
  node = node1;

  /* Now fill the positions. */
  for (i = 0, pos = node1->fuel_segment; i < length; i++, pos++) {
    /* Record the direction. */
    pos->dir_to_here..pffm->lattice + tile_index(ptile);
  }

#ifdef PF_DEBUG
  /* Make sure we reached a safe node, or the start tile. */
  fc_assert_ret(0 == node->moves_left_req
                || PF_DIR_NONE == node->dir_to_here);
#endif*
  Primary method for iterative path-finding in presence of fuel dangers.
  Notes:
  1. Whenever the path-finding stumbles upon a dangerous location, it goes
     into a sub-Dijkstra which processes _only_ dangerous locations, by
     means of a separate queue. When this sub-Dijkstra reaches any
     location, it records the segment of the path going across the unsafe
     tiles. Hence segment is an extended (and reversed) version of the
     dir_to_here field (see comment for pf_fuel_map_create_segment()). It
     can be re-recorded multiple times as we find shorter and shorter
     routes.
  2. Waiting is realised by inserting the (safe) tile back into the queue
     with a lower priority P. This tile might pop back sooner than P,
     because there might be several copies of it in the queue already. But
     that does not seem to present any problems. dangerous
     region. However it will find a safe segment if there is one. To
     gurantee the best (in terms of total_CC) safe segments across danger,
     supply 'get_EC' which returns small extra on dangerous tiles.

  During the iteration, the node status will be changed:
  A. NS_UNINIT: The node is not initialized, we didn't reach it at all.
  B. NS_INIT: We have initialized the cached values, however, we failed to
     reach this node.
  C. NS_NEW: We have reached this node, but we are not sure it was the best
     path.
  D. NS_PROCESSED: Now, we are sure we have the best path. Not refuel node
     can even be processed.
  E. NS_WAITING: The refuel node is re-inserted in the priority queue, as
     explained above (2.). We need to consider if waiting for full moves
     open or not new possibilities for moving.
  F. NS_PROCESSED: When finished to consider waiting at the node, revert the
     status to NS_PROCESSED.
  In points D., E., and F., the best path to the node can be considered as
  foundparameter(pfm);
  struct tile *tile = pfm->tile;
  int index = tile_index(tile);
  struct pf_fuel_node *node = pffm->lattice + index;

  /* The previous position is defined by 'tile' (tile pointer), 'node'
   * (the data of the tile for the pf_map), and index (the index of the
   * position in the Freeciv map). */

  for (;;).pf_move_rate(params);
      }

      adjc_dir_iterate(tile, tile1, dir) {
        /* Calculate the cost of every adjacent position and set them in
         * the priority queues for next call to pf_fuel_map_iterate(). */
        inpffm->lattice + index1As for the previous position, 'tile1', 'node1' and 'index1' are
         * defining the adjacent position. */

        /* Non-full fuel tiles can be updated even after being processed. */
        if ((NS_PROCESSED == node1->status || NS_WAITING == node1->status)
            && 0 == node1->moves_left_req) {
          /* This gives 15% speedup. *//* Only initialize once. See comment for pf_fuel_node_init().
           * Node status step A. to B. */
          pf_fuel_node_init(pffm, node1, tile1);
        }

        /* Cannot move there, this is an unreachable tile.NULL != params->get_zoc
            && !(node->zoc_number == ZOC_MINE
.. */
          continue;
        }

        /* Total cost at 'tile1'. */
        if (NULL != pf_total_CC(params, cost, extra);
        if (node1->status == NS_INIT) {
          /* Not calculated yet.pfpf_to_here/* Step 1: We test if this route is the best to this tile, by a
         * direct way, not taking in account waiting. */

        if (NS_INIT == node1->status
            || cost_of_path < old_cost_of_path
            || (prev_tile && mlr > node->moves_left_req)) {
          /* We are reaching this node for the first time, or we found a
           * better route to 'tile1', or we would have more moves lefts
           * at previous position. Let's register 'index1' to the
           * priority queue/* It is the first part of a fuel segment. */
          node1->waited = (NS_WAITING == node->status);
          node1->waited = TRUE;
          if (NS_PROCESSED != node1->status) {
            /* Node status B. to C. */
            node1->status = NS_NEW;
          } /* else staying at D. */
          if (0 == node1->moves_left_req     /* adjc_dir_iterate() */
        }

        /* Step 2: We test if this route could open better routes for other
         * tiles, if we waited somewhere. */

        if (0 == node1->moves_left_req) {
          /* Waiting to cross over a refuel is senseless. */
          continue;     /* adjc_dir_iterate() */currenpfWe will update costs if:
           * 1. we would have more moves left than previously on this node.
           * 2. we can have lower extra and will not overwrite anything
           *    useful.
           * Node status step B. to C. or D. to D.waited = (NS_WAITING == node->status);
          if (NS_PROCESSED != node1->status) {
            /* Node status B. to C. */
            node1->status = NS_NEW;
          } /* else staying at D. */NS_WAITING == node->status) {
      /* Node status final step E. to F. */
#ifdef PF_DEBUG
      fc_assert(0 == node->moves_left_req);
#endif
      node->status = NS_PROCESSED;
    } else if (0 == node->moves_left_req
               && !node->is_enemy_tile
               && node->moves_left < pfTo do it, put it back into queue.
       * Node status final step D. to Epf_total_CC(params, fc, node->extra_cost);
      pq_insert(pffm->queue, index, -cc);
    }

    /* Get the next node (the index with the highest priority). First try
     * to get it from danger_queue. */
    if (pq_remove(pffm->out_of_fuel_queue, &index)) {
      /* Change the pf_map iterator and reset data. */
      tile = index_to_tile(index);
      pfm->tile = tile;
      node = pffm->lattice + index;
      if (!pf_fuel_node_dangerous(node)) {
        /* Node status step C. and D. */
#ifdef PF_DEBUG
        fc_assert(0 < node->moves_left_req);
#endif
        node->status = NS_PROCESSED;
        return TRUE;
      }
    } else {
      /* No dangerous nodes to process, go for a safe one.
      /* Change the pf_map iterator and reset data. */
      tile = index_to_tile(index);
      pfm->tile = tile;
      node = pffm->lattice + index;
      if (NS_WAITING != node->status) {
        /* Node status step C. and D. */
#ifdef PF_DEBUG
        fc_assert(0 == node->moves_left_req);
#endif
        node->status = NS_PROCESSED;
        return TRUE;
      }
    }. /* PF_DEBUG */
  }

  log_error("%s(): internal error.", __FUNCTION__);
  return FALSE;*********
  Iterate the map until 'ptile' is reached/* Start position is handled in every function calling this function. */

  if (NS_UNINIT == node->status) {
    /* Initialize the node, for doing the following tests. */
    pf_fuel_node_init(pffm, node, ptile);
  }

  /* Simpliciation: if we cannot enter this node at all, don't iterate the
   * whole map. */
  if (!CAN_ENTER_NODE(node) || PF_IMPOSSIBLE_MC == node->moves_left_req) {
    return FALSE;
  }

  while (NS_PROCESSED != node->status && NS_WAITING != node->status) {
    if (!pf_map_iterate(pfm)) {
      /* All reachable destination have been iterated, 'ptile' is
       * unreachable. */****
  Return the move cost at ptile. If 'ptile' has not been reached yet,
  iterate the map until we reach it or run out of map. This function
 ****/
static int pf_fuel_mapsame_pos(ptile, pfm->params.start_tile)) {
    return 0;
  } else if (pf_fuel_map_iterate_until(pffm, ptile)) {
    const struct pf_fuel_node *node = pffm->lattice + tile_index(ptile);

    return ((node->fuel_segment ? node->fuel_segment->cost : node->cost)
            - pf_move_rate(pf_map_parameter(pfm))
            + pf_moves_left_initially(pf_map****
  Return the path to ptile. If 'ptile' has not been reached yet, iterate
 ***/
static struct pf_path *pf_fuel_map_path(struct pf_map *pfm,
fuel_map *pffm = PF_FUEL_MAP(pfm);

  if (same_pos(ptile, pfm->params.start_tile)) {
    return pf_path_new_to_start_tile(pf_map_parameter(pfm));
  } else if (pf_fuel_map_iterate_until(pffm, ptile*********
  Get info about position at ptile and put it in pos. If 'ptile' has not
  been
  check the return value, forthe position might be unreachab*****/
static bool pf_fuel_map_position(struct pf_map *pfm, struct tile *ptile,
same_pos(ptile, pfm->params.start_tile)) {
    pf_position_fill_start_tile(pos, pf_map_parameter(pfm));
    return TRUE;
  } else*******
  'pf_fuel_map' destructorint i;

  /* Need to clean up the dangling fuel segments.**********
  'pf_fuel_map' constructormalloc(sizeof(*pffm));
  base_map = &pff. */
  base_map->mode = PF_FUEL;
#endif /* PF_DEBUG */

  /* Allocate the map.'get_MC' callback must be set. */
  fc_assert_ret_val(parameter->get_MC != NULL, NULL);

  /* 'get_moves_left_req' callback must be set. */
  fc_assert_ret_val(parameter->get_moves_left_req != NULL, NULL);

  /* Copy parameters.move_cost;
  base_map->get_path = pf_fuel_map_path;
  base_map->get_position = pf_fuel_map_position;
  base_map->iterate = pf_fuel_map_iterate;

  /* Initialise the iterator. */
  base_map->tile = params->start_tile;

  /* Initialise starting node. */
  node = pffm->lattice + tile_index(params->start_tile);
  pf_fuel_node_init(pffpf_turns()). */
  node->moves_left = pf_moves_left_initially(params);
  node->cost = pf_move_rate(params) - node->moves_left;
  node->extra_cost = 0;
  node->dir_to_here = PF_DIR_NONE;
  node->status = NS_PROCESSED****
  Tries to find the minimal move cost to reach ptile. Returns
  PF_IMPOSSIBLE_MC if not reachable. If ptile has not been reached yet,
 ****/
int pf_map_move_cost(struct pf_map *pfm, struct tile *ptile)
{
  return pfm->get_move_cost********
  Tries to find the best path in the given map to the position ptile.
  If NULL is returned no path could be found. The pf_path_last_position()
  of such path would be the same (almost) as the result of the call to 
  pf_map_position(). If ptile has not been reached yet, iterate the map
 ****/
struct pf_path *pf_map*********
  Get info about position at ptile and put i…å% Îs’ŠQ€GF!šD6ED7DƒE"‡@K"ŽH‡Gt‡G‚EEƒT‚-J‚I‡JkˆJ{E‚F‚&D‡@L"„F0E6¢D~…E6ŽI•D„4IƒE6„EƒiD„ˆDj‹DƒsGuD/M…DƒjD…ƒD„&L…H}ŠEƒq…EoH„	K„&‹DDE„E‹E	FvJ…J‚xJ…E…(M†<E…xOvK†<EDF5D‡ƒN…3ƒD…D7F/D’E@\ H‡/R‚F‚Y„D†gD…E‡2I†I‡D†v‰D‚[„F„2‚F„hDDˆcŽE‰GnE…fŠG‰	L‚_H‡/Dˆ~E‰G@Tƒ	F…^F‡…F‚@P N‚Jˆ6YˆCL‚_D@UƒKŠIE‰$D…ƒMŠOO„)ŠEŠXK‡$P†2K‹>Eˆ~@P DŒgU…d‹ID‚kQG‹j@VƒKŠIH„`ƒRŒa_ŒtK†P@`#K‚BD„aL‹<FyhŽLz@_ŽVƒD‡E„=„VŒ\…F`[N†oO#ƒDƒ@P „V…5[‚V‚IDˆ\X‚fH‘9FƒK‰E[†I‰2ˆE†:d”1@d‰pElGˆvD{…D‚dDw@P …L‚AI–H‹<JˆtP–vU‹SE”~E—Eƒ…U—\Ik‹F† V—\D‰3@QƒD‡IMD–D7„G‚…I—@R…H“^H’i†E™DK“wM‚LW‚+SšP\–vD–F‚YƒF‹k‚F™!‚JšD‰GF›
DŠLƒI›'Dˆc†J›J›AŠI›'„O›FI›rS›_ˆM›4Fœ!Nœ(‡D„Dš,E‰FLœFƒD›Mœ]@Sƒ
ƒD3D™ F„b@t™PeGl„DœNKšfšdQeDiD”sŽEŸDF•#Wš#VŸIF•!DœiDƒk…EŸGEœh[šDš7F™!E•$F J…|DœkD‰GH‚_ƒ@U
‚D–„HeƒEE4E„5F˜š@X“EžxG¡pLš"IŸ@J”#E¢D›‚H‰…O ]E•$K£<@Z•$‚FŒ\‚D„]H‚I9@a–&J‚MG¢}D¤DJ’hR–vN£K vL a‚G£BG $ƒ@Vƒ…GeI„1G¢ES‚EG‡ŒDjH¥G‹E„x„EžxGƒoƒ@]¢'E§E…[¥\‘E¨uZš:F–v‡E”KM©G§D’?…QŸ/L‚MD‰GD©BE Eˆ\K£3‡F©&J©8D©F‡S¨z„Fg†D…K†D¤Q‚J…{‚M‚+E“^‚E£1D QJ  F•$L‰LiªKª9‚E¢G£RFnF‰p‚E™	‚D›4EƒE›M¦…M«…Eƒ‚e©}E…fYª&”D§,…EŒU„F¬~ŠNªe…N« ‰D MGŽWM‚+DœKD‚kƒE LQœID…LœM‚+I›+G®J›AM®‚J•$Z—XE—q„E:a˜I˜!‚PƒgH®|F†„JaJŒPDƒdGŒ[D‰ŠD„FHE‡„DD–z„DeF—0D–…F‰„E‰2D¯,‚F‡GJ/F†DŒZƒF„F­E‰2F§MI¯+I®|F‚‚F°;J‚D®|E—1PŸ1H–E±KG‰„L™D°‚E°(„F°;LŸfE‚D¯FE±ZE²!D”\‡D¤QU°"I°8‚@R˜&N§…G‡DŒWE±yD‰E›AQ° I†E±E¯dD†ˆF§RE‡:“DD‚EG³sG¯{H¯oD´,…I³^E….E‡D‡<@W™+GŽH±4E­oE³tN¥\F‚ ‚Ešcš:E¨lF§-„D¶.cš:SµmD‡Th¶D©B‚EµfF©@ˆg¶|F¶rJ·&F¶rh·3fšdD©BD³tI©pG›ŠDjD¸i‚F­LŠEµyE­oD´0‚H¶ H›…I”SE³BŒL‰FE¸P‰EšDœN†G›E¹bD„EšN‚,„E¹ZD³cH¹I”SGnƒE²%‡D†DˆcG‰2K¹DF¹o‰P¹g‘I”SDˆ\ˆI¹gD²HDºfŠI”SI¹,„NJ¶sI¹vL¹4G£RM«I¹,a»QG¼ P‰HW¹.H©qG·#‚F¼SI°}Wº#GFF„U‡H´$D¡wPºKJ·_D¸}‹D¹9H²"‚G›`‚F'I‰2I¾‚H·"H¼zK·^H‰L½UO¾ F£SˆD½"‚D§‰E‡SF·tH½CD«nˆJ³}‰DƒzG½CGn‡L¹4‚E¼Sƒ@VƒKµWF¸D‚@S™*Q±,D¥FIµZƒN¥\E®|‚D³cPŸ/LÁ+‚TŸIRÁ!G Dº7I½~G9H™$F½DˆDÁwG—KD«zGŸVKÂRF•#KÂRIµcD lTµXPÂvJš‚EÁQG HEÁYPÂvE¹ HÃAE¹ XÃMJ¸]QÃl‡XÂ"D°ZF²,GÂCFÂRE¯FEŸJD‡„D°8„D§HIÂ`O‚G I‚_‚@c¿cE¡p@UÀLH“^IµZR£NÁmGŸ/„H©mI”t„J£)DÇ"FÇ3I«sF¬MÅ E¬%L»LÇFFÄmƒJ»<G’wH£NÈK¼=DÇ5E£?IÈEÈAIÈP@VƒH¤<P¯^E³KV¯{J…[‚R½bF¤SEE‰@YPµSTŽNÁm\š:M–vI²GƒD»(D°8\š:R‚F‚YH²H‚D§S…GÇgEÌ.IËdOŸcH‚EÃJÈDÌ/K¸K‚K‰…E`N¾LÂzF¹oIÌ3G¹bMÌCOÍ$I»)D lHËe‚E»-HÍQFÌaIÁ<LÂQMÍPKÌkEÃI¼f`Ž5IŽYt in pos. If ptile has not been
  reached yet, iterate the map until we it. Should _always_ checkturn value, forposition migh unable.
*/
bool pf_map_(struct *pfm, *,
 *pos)
{pfm->get);
}

/
  Ispath-finding algorithm one step fur, tonext nearest
 . This full info on tandbestit can bobtained us_move_cost(),and) correspoly. Rs FALSE if nos are availmap.

  NB:o called befor toatewill resume from ''if (rameter)) <= 0)   /*un by itself. */;
  } elseurren atis equivaliourad abou into, &void!A failsfc_asser giveconst&s
/* =public func=Fstarof a atic _fill__pos =->= 0s_left_initiallyfueltotal_MCEdir_to_ = PF_DIR_NONherCre
_new=malloc(sizeof(>leng1=athAfuse,musdestroyed. No accept NULL as
  argument!thfree(Gelaof+ - 1Debugsn'directly, seprint() defin ".h"_real, enum log_level char *f, lineido_log(, TRUE,"PF:(at %pnsists%d:"(*)is"
 (i; i <; i++++  %2d/%2d: (%2d,%2d)=%-2s=%2d %d) EC=%di + 1, TILE_XYnamECcity Tuseds
 * needsitieoreseverytypeWemaxi# MAX_COST 255ur;Keepdyusag* vector_};estimycalculatnvert order becausewa know
  how manyREACHto leavtoion8toto_extra!omniscienc&&UNKNOWN ==n(owner= SINGLE_MOVis_nativeclass(u)&& !-1;Impossi_has_flagUCF_TERRAIN_SPEEDBV_ISSETs, F_IGTERMIN(, +>WemaximumPF_IMPOSSIBCUniz||</* N.B.:dodeal with/* Let's some priyMAX(3 * -, 0''onew*pcmmemset(&,. = = !ai_handicap(, H_MAPoc(u_coucmize__ret[i]
 i *pU_idex =(]fmNot c->mENDREP
DELTA 13959 0 4660
SVN  @³‚ìg …a €H i…`€s ‡C -ˆS {‹
’ ~Œ ‚D ‚]] ƒ$’|• %–6 j—b ˜M &™^ F› œL€h žJ€X \ / "¢ ]£/ =¤€% \¦r€F S¨‰ a©s€] n¬3 ­"€‚V ƒU´€‚j [º3€…$ ¾p€‹% sÆ#š bÇ(€F FÉWŒ ƒ(Ë* {ÎS |ÏZ€U k×<€† mÛµ KÜ?€K Þ 	ß!€…7 ås€† ê@€‚ ‚Tíi€„S „fó ÷r€V ù}€²	/* utility */
#include "log.h"        /* enum log_level */

/* common */= Explanations =============================== */

/*
 * Functions in this file help to find a path from A to B.
 *MC is always >= 0.Now, each path has
 *
 * Note, that the user is expected to ask "So this best path, how long will
 * it take me to walk it?".
 * The above setup allows us to find elegant solutions to rather involved
 * questions.
 * In some cases we would like to impose extra restrictions on the
 * paths/tiles we want to consider. For example, a trireme might want to
 * never enter deep sea.This can be achieved
 * through an additional tile_behaviour callback,If the
 *If
 * the fuel parameters are provided then the unit is considered to have
 * that much fuel.Setting fuel == 1
 * in the pf_parameter disables fuel support.
 *
 * There are few other options in the path-finding. For further info about
 * them, see comment for the pf_parameter structure below.
 *
 *
 * FORMULAE:
 *   For calculating total_MC (given particular tile_behaviour)
 *     total_MC = ((turn + 1) * move_rate - moves_left)
 *map_move_cost(), pf_map_path(), and
 * pf_map_position() (the latter will only tell us the distance but not the
 * path to take). In the second case we use pf_map_iterate() to iterate
 * through all tiles in the order of increased distance and break when we
 * found what we were looking for. In this case we use pf_map_iter_*() to
 * get information about the "
 * path:
 *
 *    struct pf_parameter parameter;
 *    struct pf_map *pfm;
 *    struct pf_path *path;
 *
 *    // fill parameter (see below)
 *
 *    // create the map: the main path-finding object.
 *    pfm = pf_map_new(&parameter);
 *
 *    // create the path to the tile 'ptile'.
 *    if ((path = pf_map_path(pfm, ptile))) {
 *      // success, use path
 *      pf_path_destroy(path);
 *    } else {
 *      // no path could be found
 *    }
 *
 *    // don't forget to destroy the map after usage.
 *    pf_map_destroy(pfm);
 *
 * You may call pf_map_path() multiple times with the same pfm.
 *
 * B) the caller doesn't know the map position of the goal yet (but knows   struct pf_parameter parameter;
 *    struct pf_map *pfm;
 *
 *    // fill parameter (see below)
 *
 *    // create the map: the main path-finding object.
 *    pfm = pf_map_new(&parameter);
 *
 *    // iterate the map, using macros defined on this header.
 *    pf_map_*_iterate(pfm, something, TRUE) {
 *      // do something
 *    } pf_map_*_iterate_end;
 *
 *    // don't forget to destroy the map after usage.
 *    pf_map_destroy(pfm);
 *
 * Depending on the kind of information required, the iteration macro
 * should be:
 *
 *  1) tile iteration:
 *     pf_map_tiles_iterate(pfm, ptile, TRUE) {
 *       // do something
 *     } pf_map_tiles_iterate_end;
 *
 *  2) move cost iteration on the nearest position:
 *     pf_map_move_costs_iterate(pfm, ptile, move_cost, TRUE) {
 *       // do something
 *     } pf_map_move_costs_iterate_end;
 *
 *  3) information (for example the total MC and the number of turns) on the
 *  next nearest position:
 *     pf_map_positions_iterate(pfm, pos, TRUE) {
 *       // do something
 *     } pf_map_positions_iterate_end;
 *
 *  4) information about the whole path (leading to the next nearest
 *  position):
 *     pf_map_paths_iterate(pfm, path, TRUE) {
 *       // do something
 *       pf_path_destroy(path);
 *     } pf_map_paths_iterate_end;
 *
 * The third argument passed to the iteration macros is a condition that
 * controls if the start tile of the pf_parameter should iterated or not."common/aicore/pf_tools.h", you are
 * not guaranteed to get the one with the least steps in it.
 * occupied== Structures = = 0,        /* This one will be ignored. */
  TB_DONT_LEAVE,        /* Paths can lead _to_ such tile, but are not
                         * allowed to go _through_. */
  TB_NORMAL             /* Well, normal .*/     /* The tile. */
  int turn;              /* The number of turns to the target. */
  int moves_left;       /* The number of moves left the unit would have when
                         * reaching the tile. */
  int fuel_left;        /* The number of turns of fuel left the unit would
                         * have when reaching the tile. It is always set to
                         * 1 when unit types are not fueled. */

  int total_MC;         /* Total MC to reach this point */
  int total_EC;         /* Total EC to reach this point */

  enum direction8 dir_to_next_pos; /* Used only in 'struct pf_path'. */
  enum direction8 dir_to_here; /* Where did we come from. */
};

/* Full specification of a path. */
struct pf_path {
  int length;                   Normally should use functions
 * from "pf_tools.[ch]"map_new() as the last
 * argument.
 *
 * Examples of callbacks can be found in "pf_tools.c"
 * NB: It should be safe to struct copy pf_parameter. */
struct pf_parameter {
  struct tile *start_tile;                      const struct unit_class *uclass;

  bv_unit_type_flags unit_flags; /* Like F_MARINE and F_TRIREME */
  bool omniscience;             /* Do we care if the tile is visible? */

  /* Callback to get MC of a move from 'from_tile' to 'to_tile' and in the
   * direction 'dir'. Note that the callback can calculate 'to_tile' by
   * itself based on 'from_tile' and 'dir'. Excessive information 'to_tile'
   * is provided to ease the implementation of the callback. */
  int (*get_MC) (const struct tile *from_tile, enum direction8 dir,
                 const struct tile *to_tile,
                 const struct pf_parameter *param);
  int unknown_MC; /* Move cost into unknown - very large by default."path_finding.h" will cache this value. */
  enum tile_behavior (*get_TB) (const struct tile *ptile,
                                enum known_type known,
                                const struct pf_parameter *param);

  /* Callback which can be used to provide extra costs depending on the
   * tile. Can be NULL. It can be assumed that the implementation of
   * "path_finding.h" will cache this value. */
  int (*get_EC) (const struct tile *ptile, enum known_type known,
                 const struct pf_parameter *param);

  /* Callback to determines if we could invade the tile. Returns TRUE if we
   * can enter in the territory of the tile owner. */
  bool (*can_invade_tile) (const struct player *pplayer,
                           const struct tile *ptile
   * compensate for it, we might need to supply our own version
   * of "common" is_my_zoc. Also AI might need to partially ignore
   * ZoC for strategic planning purposes (take into account enemy cities
   * but not units for example).
   * If this callback is NULL, ZoC are ignored. const struct pf_parameter *param);

  /* If this callback is non-NULL and returns the required moves left to
   * move to this tile and to leave the position safely. Can be NULL. */
  int (*get_moves_left_req) (const struct tile *ptile, enum known_type,
                             const struct pf_parameter *param);

  /* This is a jumbo callback which overrides all previous ones.  It takes
   * care of everything (ZOC, known, costs etc).
   * Variables:
   *   from_tile             -- the source tile
   *   from_cost, from_extra -- costs of the source tile
   *   to_tile               --                    enum direction8 dir,
                    const struct tile *to_tile,
                    int from_cost, int from_extra,
                    int *to_cost, int *to_extra,
                    constOpaque type. */
struct pf_map;

/* The city map strucure. Opaque type. */
struct pf_city_map;



/* ========================= Public Interface ============================ */

/* Create and free. */
struct pf_map *pf_map_new(const struct pf_parameter *parameter)
               fc__warn_unused_result;
void pf_map_destroy(struct pf_map *pfm);

/* Method A) functions. */
int pf_map_move_cost(struct pf_map *pfm, struct tile *ptile);
struct pf_path *pf_map_path(struct pf_map *pfm, struct tile *ptile)
                fc__warn_unused_result;
bool pf_map_position(struct pf_map *pfm, struct tile *ptile,
                     struct pf_position *pos)
                     fc__warn_unused_result;

/* Method B) functions. */
bool pf_map_iterate(struct pf_map *pfm);
struct tile *pf_map_iter(struct pf_map *pfm);
int pf_map_iter_move_cost(struct pf_map *pfm);
struct pf_path *pf_map_iter_path(struct pf_map *pfm)
                fc__warn_unused_result;
void pf_map_iter_position(struct pf_map *pfm, struct pf_position *pos);

/* Other related functions. */
const struct pf_parameter *pf_map_parameter(const struct pf_map *pfm);


/* Paths functions. */
void pf_path_destroy(struct pf_path *path);
const struct pf_position *pf_path_last_position(const struct pf_path *path);
void pf_path_print_real(const struct pf_path *path, enum log_level level,
                        const char *file, const char *function, int line);
#define pf_path_print(path, level)                                          \
  if (log_do_output_for_level(level)) {                                     \
    pf_path_print_real(path, level, __FILE__, __FUNCTION__, __LINE__);      \
  }


/* City map functions (special implementation for AI city usage). */
struct pf_city_map *pf_city_map_new(const struct city *pcity)
                    fc__warn_unused_result;
void pf_city_map_destroy(struct pf_city_map *pfcm);

int pf_city_map_move_cost(struct pf_city_map *pfcm,
                          const struct unit_type *punittype,
                          struct tile *ptile);



/* This macro iterates all reachable tiles.
 *
 * ARG_pfm - A pf_map structure pointer.
 * NAME_tile - The name of the iterator to use (type struct tile *). This
 *             is defined inside the macro.
 * COND_from_start - A boolean value (or equivalent, it can be a function)
 *                   which indicate if the start tile should be iterated or
 *                   not. */
#define pf_map_tiles_iterate(ARG_pfm, NAME_tile, COND_from_start)           \
if ((COND_from_start) || pf_map_iterate((ARG_pfm))) {                       \
  struct pf_map *_MY_pf_map_ = (ARG_pfm);                                   \
  struct tile *NAME_tile;                                                   \
  do {                                                                      \
    NAME_tile = pf_map_iter(_MY_pf_map_);
#define pf_map_tiles_iterate_end                                            \
  } while (pf_map_iterate(_MY_pf_map_));                                    \
}

/* This macro iterates all reachable tiles and their move costs.
 *
 * ARG_pfm - A pf_map structure pointer.
 * NAME_tile - The name of the iterator to use (type struct tile *). This
 *             is defined inside the macro.
 * NAME_cost - The name of the variable containing the move cost info (type
 *             integer).  This is defined inside the macro.
 * COND_from_start - A boolean value (or equivalent, it can be a function)
 *                   which indicate if the start tile should be iterated or
 *                   not. */
#define pf_map_move_costs_iterate(ARG_pfm, NAME_tile, NAME_cost,            \
                                  COND_from_start)                          \
if ((COND_from_start) || pf_map_iterate((ARG_pfm))) {                       \
  struct pf_map *_MY_pf_map_ = (ARG_pfm);                                   \
  struct tile *NAME_tile;                                                   \
  int NAME_cost;                                                            \
  do {                                                                      \
    NAME_tile = pf_map_iter(_MY_pf_map_);                              \
    NAME_cost = pf_map_iter_move_cost(_MY_pf_map_);
#define pf_map_move_costs_iterate_end                                       \
  } while (pf_map_iterate(_MY_pf_map_));                                    \
}

/* This macro iterates all reachable tiles and fill a pf_position structure.
 * structure as info.
 *
 * ARG_pfm - A pf_map structure pointer.
 * NAME_pos - The name of the iterator to use (type struct pf_position).
 *            This is defined inside the macro.
 * COND_from_start - A boolean value (or equivalent, it can be a function)
 *                   which indicate if the start tile should be iterated or
 *                   not. */
#define pf_map_positions_iterate(ARG_pfm, NAME_pos, COND_from_start)        \
if ((COND_from_start) || pf_map_iterate((ARG_pfm))) {                       \
  struct pf_map *_MY_pf_map_ = (ARG_pfm);                                   \
  struct pf_position NAME_pos;                                              \
  do {                                                                      \
    pf_map_iter_position(_MY_pf_map_, &NAME_pos);
#define pf_map_positions_iterate_end                                        \
  } while (pf_map_iterate(_MY_pf_map_));                                    \
}

/* This macro iterates all possible pathes.
 * NB: you need to free the pathes with pf_path_destroy(path_iter).
 *
 * ARG_pfm - A pf_map structure pointer.
 * NAME_path - The name of the iterator to use (type struct pf_path *). This
 *             is defined inside the macro.
 * COND_from_start - A boolean value (or equivalent, it can be a function)
 *                   which indicate if the start tile should be iterated or
 *                   not. */
#define pf_map_paths_iterate(ARG_pfm, NAME_path, COND_from_start)           \
if ((COND_from_start) || pf_map_iterate((ARG_pfm))) {                       \
  struct pf_map *_MY_pf_map_ = (ARG_pfm);                                   \
  struct pf_path *NAME_path;\
  do {\
    NAME_path = pf_map_iter_path(_MY_pf_map_);
#define pf_map_paths_iterate_end                                            \
  } while (pf_map_iterate(_MY_pf_map_));                                    \
}

#endif /* FC__PATH_FINDING_H */
ENDREP
DELTA 17928 30008 483
SVN  ‚®f‚®^  ‚¢  z‚¢ ‹X‚£ENDREP
DELTA 18136 1578 18019
SVN  ‚á‚àDMq šP ’ ‚šb’ „N „d¡X’ ‚%¦N’ ™}©ˆ …^Ã ‚JÈf µ+Ë1 ÅX‚€] ƒ	‚Æ:¡ ‚Ê •f‚Ë move_costs_iteratemove_costs_iteratemove_costs_iteratemove_costs_iterateNULL != >= wonder_city->surplus[O_SHIELD]ENDREP
DELTA 17928 20317 532
SVN  îNîN$ Ô ’ 8Ô!’ Šcãkmove_costs_iteratemove_costs_iterateENDREP
DELTA 18308 98105 176
SVN  ÁÁ  Ý   ]Ý	 Œ?ýj šŠ- œ\¤6ENDREP
DELTA 18381 3195 191
SVN  †  †  ( Û# ’ ƒqÛ5 Šß*’ …µEê;„move_costs_iteratemove_costs_iterate
   †   v r   rENDREP
id: 7s.5ei.r18383/99203
type: file
pred: 7s.5ei.r18308/131815
count: 299
text: 18383 99015 39 24706 1abb300657ea242ea341c7598a819b31
props: 10755 35320 112 0 af1f871c1c0b4609250c3dc553658fcc
cpath: /trunk/server/advisors/autosettlers.c
copyroot: 17592 /trunk/server/advisors/autosettlers.c

id: 50r.5ck.r18383/99494
type: file
pred: 50r.5ck.r18374/92
count: 4
text: 18383 98690 203 45124 a6b204410c6d7fe9c5a506f6d2171351
cpath: /trunk/server/advisors/advbuilding.c
copyroot: 15280 /trunk

id: 2lj.5eo.r18383/99692
type: file
pred: 2lj.5eo.r17928/38162
count: 35
text: 18383 98923 63 14158 5b657f4eb0c69b19fef3d7c9517f988e
props: 10624 241 111 0 8e6f231ffe21dad0a34f68090b1c0b69
cpath: /trunk/server/advisors/autoexplorer.c
copyroot: 17685 /trunk/server/advisors/autoexplorer.c

PLAIN
K 11
Makefile.am
V 25
file 4n3.5ck.r18136/21469
K 13
advbuilding.c
V 25
file 50r.5ck.r18383/99494
K 13
advbuilding.h
V 25
file 50s.5ck.r18136/21838
K 9
advdata.c
V 23
file 15o.5eq.r18373/624
K 9
advdata.h
V 23
file 15p.5er.r18373/900
K 9
advgoto.c
V 26
file 4p5.5ck.r18308/132106
K 9
advgoto.h
V 25
file 4p6.5ck.r17677/20336
K 10
advtools.c
V 24
file 4of.5ck.r17647/8273
K 10
advtools.h
V 24
file 4og.5ck.r17647/7632
K 14
autoexplorer.c
V 25
file 2lj.5eo.r18383/99692
K 14
autoexplorer.h
V 24
file 2lk.5ep.r17685/7079
K 14
autosettlers.c
V 24
file 7s.5ei.r18383/99203
K 14
autosettlers.h
V 23
file 7t.5ej.r17819/4685
K 12
infracache.c
V 25
file 4pw.5ck.r17752/34182
K 12
infracache.h
V 25
file 4px.5ck.r17745/18645
END
ENDREP
id: 4n2.5ck.r18383/100713
type: dir
pred: 4n2.5ck.r18374/1016
count: 24
text: 18383 99981 719 719 c979ae7f215240c1f719082cd441f8a0
props: 17871 2121 53 0 a527b216afb99426b763a1e313c531be
cpath: /trunk/server/advisors
copyroot: 15280 /trunk

id: 1a.5ck.r18383/100954
type: file
pred: 1a.5ck.r18381/6080
count: 583
text: 18383 99083 92 122994 663c0338588b0184d6c67fe10a7da37d
props: 11095 1637 112 0 c5bfe3670c093a84ebf28b66298044e4
cpath: /trunk/server/unittools.c
copyroot: 15280 /trunk

PLAIN
K 11
Makefile.am
V 22
file 5q.5ck.r17686/505
K 8
advisors
V 25
dir 4n2.5ck.r18383/100713
K 9
aiiface.c
V 24
file 4gm.5ck.r18039/1242
K 9
aiiface.h
V 25
file 4gn.5ck.r17797/11328
K 6
auth.c
V 26
file 39c.5ck.r18308/131570
K 6
auth.h
V 23
file 39d.0.r13513/10535
K 11
barbarian.c
V 24
file lw.5ck.r18300/14850
K 11
barbarian.h
V 24
file lx.5ck.r18054/18407
K 10
cityhand.c
V 25
file 10.5ck.r18308/128025
K 10
cityhand.h
V 23
file 4f.0.r13297/423686
K 11
citytools.c
V 23
file 4g.5ck.r18382/8122
K 11
citytools.h
V 24
file 4h.5ck.r18270/28958
K 10
cityturn.c
V 25
file 4i.5ck.r18362/123437
K 10
cityturn.h
V 24
file 4j.5ck.r18054/18647
K 11
civserver.c
V 22
file 4k.5ck.r17075/335
K 11
civserver.h
V 21
file 4l.0.r2805/33121
K 10
commands.c
V 26
file 2ly.5ck.r18362/121940
K 10
commands.h
V 24
file 2lz.5ck.r18097/4802
K 13
connecthand.c
V 26
file 2dw.5ck.r18362/122683
K 13
connecthand.h
V 25
file 2dx.5ck.r18054/16767
K 9
console.c
V 23
file dd.5ck.r18091/5268
K 9
console.h
V 24
file de.5ck.r18054/16526
K 10
diplhand.c
V 25
file 4m.5ck.r18362/124371
K 10
diplhand.h
V 21
file 4n.0.r13421/6826
K 11
diplomats.c
V 23
file vz.5ck.r18382/8367
K 11
diplomats.h
V 24
file w0.5bk.r13745/13943
K 10
edithand.c
V 24
file 3bk.5ck.r18347/1710
K 10
edithand.h
V 23
file 4ez.5ck.r15317/588
K 10
gamehand.c
V 24
file 4o.5ck.r18279/84987
K 10
gamehand.h
V 24
file 4p.5ck.r15698/24111
K 9
generator
V 23
dir 2me.5ck.r18296/6085
K 11
ggzserver.c
V 25
file 39a.5ck.r17625/26065
K 11
ggzserver.h
V 25
file 39b.5bk.r15001/48999
K 10
gotohand.c
V 24
file 11.5ck.r17700/11700
K 10
gotohand.h
V 25
file 7r.5ck.r16929/301579
K 10
handchat.c
V 25
file 4q.5ck.r18362/122188
K 10
handchat.h
V 24
file dj.5ck.r18270/28229
K 9
maphand.c
V 25
file 13.5ck.r18308/134469
K 9
maphand.h
V 24
file 14.5ck.r18079/38932
K 6
meta.c
V 25
file 4s.5ck.r18308/135671
K 6
meta.h
V 24
file 4t.5ck.r18054/19078
K 8
notify.c
V 24
file 4i2.5ck.r18098/4991
K 8
notify.h
V 24
file 4i3.5ck.r18282/3660
K 9
plrhand.c
V 23
file 4u.5ck.r18312/2810
K 9
plrhand.h
V 24
file 4v.5ck.r18309/12023
K 8
report.c
V 25
file vi.5ck.r18308/133485
K 8
report.h
V 24
file vj.5ck.r18270/29203
K 9
ruleset.c
V 25
file 8w.5ck.r18362/123684
K 9
ruleset.h
V 22
file 8x.5ck.r17946/997
K 13
sanitycheck.c
V 25
file wi.5ck.r18308/136908
K 13
sanitycheck.h
V 25
file wj.5ck.r16578/437729
K 10
savegame.c
V 25
file vl.5ck.r18362/126117
K 10
savegame.h
V 24
file vm.5ck.r17289/22938
K 11
savegame2.c
V 26
file 4m0.5ck.r18362/124178
K 11
savegame2.h
V 25
file 4m1.5ck.r18078/67503
K 7
score.c
V 26
file 2eg.5ck.r18308/128519
K 7
score.h
V 24
file 2eh.5ck.r17332/6378
K 9
scripting
V 23
dir 31x.5ck.r18346/4002
K 8
sernet.c
V 25
file 15.5ck.r18362/125118
K 8
sernet.h
V 23
file 4y.5ck.r17707/4012
K 10
settings.c
V 26
file 2m0.5ck.r18362/123183
K 10
settings.h
V 24
file 2m1.5ck.r18294/3094
K 11
spacerace.c
V 25
file 9a.5ck.r18362/123929
K 11
spacerace.h
V 21
file 9b.0.r11338/1129
K 9
srv_log.c
V 26
file 15t.5el.r18308/134909
K 9
srv_log.h
V 25
file 15u.5em.r17928/40497
K 10
srv_main.c
V 25
file vg.5ck.r18362/122435
K 10
srv_main.h
V 24
file vh.5ck.r18279/84001
K 11
stdinhand.c
V 25
file 4z.5ck.r18362/125865
K 11
stdinhand.h
V 24
file 50.5ck.r18023/25156
K 11
techtools.c
V 26
file 33n.5ck.r18362/125365
K 11
techtools.h
V 26
file 33o.5ck.r17839/175626
K 10
unithand.c
V 23
file 18.5ck.r18381/6570
K 10
unithand.h
V 23
file 19.5ck.r16959/4142
K 11
unittools.c
V 25
file 1a.5ck.r18383/100954
K 11
unittools.h
V 23
file 1b.5ck.r18381/6327
K 8
voting.c
V 26
file 4ex.5ck.r18308/137159
K 8
voting.h
V 25
file 4ey.5ck.r18054/19315
END
ENDREP
id: z.5ck.r18383/104773
type: dir
pred: z.5ck.r18382/12181
count: 4274
text: 18383 101201 3559 3559 cccac0bbc9bc8ed425b12d3a535cf374
props: 17175 659 139 0 d1c9699dde7f9d81e54426750008041d
cpath: /trunk/server
copyroot: 15280 /trunk

id: 2dt.5ck.r18383/105007
type: file
pred: 2dt.5ck.r17616/5111
count: 24
text: 18383 84391 14215 22917 aa22ad15041e15c96e0458b73a547c04
props: 10719 7043 111 0 d4514082fc7e52be026d3360dec4dcb0
cpath: /trunk/common/aicore/path_finding.h
copyroot: 15280 /trunk

id: 2du.5ck.r18383/105267
type: file
pred: 2du.5ck.r17928/48875
count: 77
text: 18383 98632 29 38750 d1450a2c5b3bfcc002ecbe8fb086a982
props: 10728 522 111 0 7a0697bf766451f41e947e71ce1310bc
cpath: /trunk/common/aicore/pf_tools.c
copyroot: 15280 /trunk

id: 2ds.5ck.r18383/105520
type: file
pred: 2ds.5ck.r18311/13311
count: 61
text: 18383 32831 51533 112499 c913ae004b9b6afcad8663e628a078eb
props: 10728 881 111 0 1767e81bb248f04892a3d72080d82dc5
cpath: /trunk/common/aicore/path_finding.c
copyroot: 15280 /trunk

id: 33l.5ck.r18383/105781
type: file
pred: 33l.5ck.r18308/145529
count: 14
text: 18383 32612 190 26168 fbcd7ff9f81c5fcfa7bbbd5d4a08bbf6
props: 10779 44053 110 0 fd27c383f48a4fbbd90a59fbcfc8b3be
cpath: /trunk/common/aicore/caravan.c
copyroot: 15280 /trunk

PLAIN
K 11
Makefile.am
V 24
file 18u.5ck.r15407/8822
K 11
aisupport.c
V 25
file 2em.5ck.r16015/33732
K 11
aisupport.h
V 22
file 2en.0.r8119/19806
K 9
caravan.c
V 26
file 33l.5ck.r18383/105781
K 9
caravan.h
V 26
file 33m.5ck.r16578/406062
K 9
citymap.c
V 25
file 2gj.5ck.r17772/56602
K 9
citymap.h
V 25
file 2gk.5ck.r18054/24427
K 4
cm.c
V 25
file 18x.5ck.r18268/16802
K 4
cm.h
V 25
file 18y.5ck.r18054/24184
K 14
path_finding.c
V 26
file 2ds.5ck.r18383/105520
K 14
path_finding.h
V 26
file 2dt.5ck.r18383/105007
K 10
pf_tools.c
V 26
file 2du.5ck.r18383/105267
K 10
pf_tools.h
V 24
file 2dv.5ck.r15868/6236
END
ENDREP
id: 18t.5ck.r18383/106654
type: dir
pred: 18t.5ck.r18311/14178
count: 240
text: 18383 106037 604 604 8811a62f4132d71e076eaa467b738ee8
props: 11108 8037 65 0 8b44e87f657ecca3b8458ca1746fb7c6
cpath: /trunk/common/aicore
copyroot: 15280 /trunk

PLAIN
K 11
Makefile.am
V 23
file 5h.5ck.r17932/7536
K 4
ai.c
V 24
file 4go.5ck.r18039/5198
K 4
ai.h
V 24
file 4gp.5ck.r18039/5375
K 6
aicore
V 25
dir 18t.5ck.r18383/106654
K 6
base.c
V 26
file 3jw.5ck.r18308/142652
K 6
base.h
V 26
file 3jx.5ck.r18308/143381
K 9
borders.c
V 25
file 4f0.5ck.r18297/35065
K 9
borders.h
V 24
file 4f1.5ck.r15975/2116
K 8
capstr.c
V 24
file dv.5ck.r17617/51579
K 8
capstr.h
V 24
file dw.5bk.r14881/38989
K 6
city.c
V 24
file q.5ck.r18308/145043
K 6
city.h
V 25
file 3q.5ck.r18308/145285
K 8
combat.c
V 24
file wp.5ck.r18226/16047
K 8
combat.h
V 24
file wq.5ck.r18086/20783
K 12
connection.c
V 23
file un.5ck.r18345/2081
K 12
connection.h
V 23
file uo.5ck.r18345/2323
K 8
dataio.c
V 25
file 15r.5ck.r17928/47899
K 8
dataio.h
V 25
file 15s.5ck.r18054/23274
K 11
diptreaty.c
V 23
file 3r.5ck.r18298/9103
K 11
diptreaty.h
V 24
file 3s.5ck.r18054/23946
K 9
effects.c
V 25
file 2eo.5ck.r18270/34465
K 9
effects.h
V 25
file 2ep.5ck.r18270/34711
K 8
events.c
V 26
file 33h.5ck.r18335/592472
K 8
events.h
V 24
file 3t.5ck.r18054/23708
K 14
fc_interface.c
V 25
file 4up.5ck.r17933/11024
K 14
fc_interface.h
V 24
file 4uq.5ck.r17932/7373
K 10
fc_types.h
V 24
file 2ll.5ck.r18298/9593
K 15
featured_text.c
V 26
file 4h3.5ck.r18308/144846
K 15
featured_text.h
V 25
file 4h4.5ck.r18054/23516
K 6
game.c
V 25
file 3u.5ck.r18308/149115
K 6
game.h
V 25
file 3v.5ck.r18308/149609
K 19
generate_packets.py
V 25
file 2f4.5ck.r18382/12661
K 12
government.c
V 24
file he.5ck.r18344/22066
K 12
government.h
V 24
file hf.5ck.r18344/22313
K 6
idex.c
V 23
file qo.5ck.r18342/2669
K 6
idex.h
V 21
file qp.0.r8119/15235
K 13
improvement.c
V 25
file vb.5ck.r18308/142158
K 13
improvement.h
V 25
file vc.5ck.r18308/142895
K 5
map.c
V 22
file r.5ck.r18343/1286
K 5
map.h
V 23
file 41.5ck.r18343/1522
K 10
movement.c
V 26
file 2xv.5ck.r18308/146640
K 10
movement.h
V 26
file 2xw.5ck.r18308/146890
K 18
name_translation.h
V 26
file 4k1.5ck.r18325/122376
K 8
nation.c
V 23
file il.5ck.r18312/6855
K 8
nation.h
V 24
file im.5ck.r18279/91917
K 9
packets.c
V 22
file 43.5ck.r17688/132
K 11
packets.def
V 25
file 2f5.5ck.r18382/12412
K 9
packets.h
V 24
file 44.5ck.r18100/70467
K 8
player.c
V 25
file 45.5ck.r18308/148128
K 8
player.h
V 25
file 46.5ck.r18308/148622
K 14
requirements.c
V 25
file 2wq.5ck.r18326/39682
K 14
requirements.h
V 25
file 2wr.5ck.r17509/18916
K 10
research.c
V 24
file 4ro.5ck.r17856/7997
K 10
research.h
V 26
file 4rp.5ck.r17839/180149
K 11
spaceship.c
V 20
file 98.0.r9977/2632
K 11
spaceship.h
V 24
file 99.5ck.r18054/26016
K 12
specialist.c
V 25
file 33f.5ck.r18326/38937
K 12
specialist.h
V 25
file 33g.5ck.r18326/39185
K 6
team.c
V 24
file 33i.5ck.r18062/9622
K 6
team.h
V 24
file 33j.5ck.r18062/9861
K 6
tech.c
V 24
file t.5ck.r18308/143873
K 6
tech.h
V 24
file u.5ck.r18308/144605
K 9
terrain.c
V 26
file 2fp.5ck.r18308/147138
K 9
terrain.h
V 25
file qs.5ck.r18308/147386
K 6
tile.c
V 25
file 2ys.5ck.r18297/34577
K 6
tile.h
V 24
file 2yt.5ck.r18347/5755
K 6
unit.c
V 24
file v.5ck.r18308/143141
K 6
unit.h
V 25
file 48.5ck.r18308/144114
K 10
unitlist.c
V 26
file 39m.5ck.r18308/149361
K 10
unitlist.h
V 26
file 39n.5ck.r18308/149854
K 10
unittype.c
V 25
file v9.5ck.r18308/143625
K 10
unittype.h
V 25
file va.5ck.r18308/144357
K 9
version.c
V 25
file oe.5ck.r17122/322944
K 9
version.h
V 21
file e7.0.r13518/7887
K 8
vision.c
V 25
file 4dm.5ck.r18000/29175
K 8
vision.h
V 25
file 4dn.5ck.r18000/29420
K 10
worklist.c
V 25
file o8.5ck.r16929/277491
K 10
worklist.h
V 23
file o9.5ck.r18038/1433
END
ENDREP
id: p.5ck.r18383/110425
type: dir
pred: p.5ck.r18382/16440
count: 2887
text: 18383 106896 3516 3516 e5ad331d974f9bb9eb7a6106374d1196
props: 12883 2571 96 0 2763e13ff5d021346ae24ff6c9ced232
cpath: /trunk/common
copyroot: 15280 /trunk

id: 2iw.5ck.r18383/110659
type: file
pred: 2iw.5ck.r18308/154128
count: 62
text: 18383 12691 261 40038 f0344f818587805e508fbd7a356dc328
props: 10806 16634 111 0 45c0e160a790dc8f7645f8a7eabea654
cpath: /trunk/ai/aiferry.c
copyroot: 15280 /trunk

id: 9.5ck.r18383/110904
type: file
pred: 9.5ck.r18308/154613
count: 221
text: 18383 30676 33 43248 21382d84b46b1320f476417481ecc5e8
props: 11015 549 112 0 bb22896f97f507ab8508e233583a40b4
cpath: /trunk/ai/aitools.c
copyroot: 15280 /trunk

id: 16r.5ck.r18383/111143
type: file
pred: 16r.5ck.r18308/155331
count: 91
text: 18383 12453 211 25264 e27b9c8d063d031419cc2d35d5db002c
props: 10756 119 111 0 93121dcfd7714818c8d46f9c51a886fa
cpath: /trunk/ai/aidiplomat.c
copyroot: 15280 /trunk

id: 15y.5ck.r18383/111389
type: file
pred: 15y.5ck.r18308/155817
count: 64
text: 18383 0 12426 15808 93b8874e807617610caf7954b2804719
props: 10755 56241 111 0 1c266b4433d829481714f1852322e965
cpath: /trunk/ai/aiair.c
copyroot: 15280 /trunk

id: 2gc.5ck.r18383/111630
type: file
pred: 2gc.5ck.r18308/156543
count: 53
text: 18383 12982 120 18898 e6a0b04612060731c96f08898fab057d
props: 10843 995 111 0 5515c59917848b493fbf45ffb42836b3
cpath: /trunk/ai/aihunt.c
copyroot: 15280 /trunk

id: b.5ck.r18383/111872
type: file
pred: b.5ck.r18308/156783
count: 435
text: 18383 30738 145 97438 146d848f531998401c22891d9c2a12e0
props: 10755 57649 112 0 77fd11a7d1954721a87806f6d511a224
cpath: /trunk/ai/aiunit.c
copyroot: 15280 /trunk

id: 2lh.5ck.r18383/112113
type: file
pred: 2lh.5ck.r18308/157023
count: 64
text: 18383 13130 17520 30845 e7ea1090c4103d4d79cb4f7c394e2565
props: 10865 31505 111 0 23629f8214b2309975780a037517e920
cpath: /trunk/ai/aisettler.c
copyroot: 15280 /trunk

PLAIN
K 11
Makefile.am
V 24
file 5d.5ck.r17700/26401
K 14
advdiplomacy.c
V 26
file 2ek.5ck.r18362/130174
K 14
advdiplomacy.h
V 25
file 2el.5ck.r17622/41667
K 13
advdomestic.c
V 25
file 1m.5ck.r18308/154370
K 13
advdomestic.h
V 23
file 1n.0.r13297/443238
K 13
advmilitary.c
V 25
file 1u.5ck.r18308/155573
K 13
advmilitary.h
V 23
file 1v.0.r13297/446464
K 10
advspace.c
V 25
file f2.5ck.r16929/287580
K 10
advspace.h
V 21
file f3.0.r8119/28225
K 7
aiair.c
V 26
file 15y.5ck.r18383/111389
K 7
aiair.h
V 25
file 15z.5ck.r18054/30939
K 8
aicity.c
V 24
file 20.5ck.r18136/27193
K 8
aicity.h
V 24
file 21.5ck.r18136/27433
K 12
aidiplomat.c
V 26
file 16r.5ck.r18383/111143
K 12
aidiplomat.h
V 25
file 16s.5ck.r18054/30699
K 9
aiferry.c
V 26
file 2iw.5ck.r18383/110659
K 9
aiferry.h
V 25
file 2ix.5ck.r18054/30227
K 9
aiguard.c
V 26
file 335.5ck.r18308/156303
K 9
aiguard.h
V 25
file 336.5ck.r18054/31175
K 8
aihand.c
V 24
file 22.5ck.r18317/51792
K 8
aihand.h
V 23
file 23.5ck.r18081/6422
K 8
aihunt.c
V 26
file 2gc.5ck.r18383/111630
K 8
aihunt.h
V 25
file 2gd.5ck.r18054/31410
K 15
aiparatrooper.c
V 26
file 36o.5ck.r18308/156056
K 15
aiparatrooper.h
V 23
file 36p.0.r12670/95202
K 11
aisettler.c
V 26
file 2lh.5ck.r18383/112113
K 11
aisettler.h
V 25
file 2li.5ck.r18054/29985
K 8
aitech.c
V 25
file 24.5ck.r17839/186545
K 8
aitech.h
V 22
file 25.0.r10755/53545
K 9
aitools.c
V 24
file 9.5ck.r18383/110904
K 9
aitools.h
V 24
file a.5ck.r18308/155094
K 8
aiunit.c
V 24
file b.5ck.r18383/111872
K 8
aiunit.h
V 23
file c.5ck.r17796/32162
K 11
defaultai.c
V 25
file 4n8.5ck.r17797/19409
K 11
defaultai.h
V 25
file 4n9.5ck.r17796/33605
END
ENDREP
id: 8.5ck.r18383/113997
type: dir
pred: 8.5ck.r18362/132054
count: 1316
text: 18383 112362 1622 1622 e9b2935d6d7fab8343b0c0294f44721a
props: 11108 11315 64 0 abac628483ea4fdfa3bea3a3a56e0532
cpath: /trunk/ai
copyroot: 15280 /trunk

id: gz.5ck.r18383/114229
type: file
pred: gz.5ck.r18352/1368
count: 278
text: 18383 30912 1345 99763 68afb0117d273c2a7e4b5b0904551732
props: 11088 7720 112 0 89a05fc93c37a832d4b63085dac12c4b
cpath: /trunk/client/control.c
copyroot: 15280 /trunk

id: vu.5ck.r18383/114475
type: file
pred: vu.5ck.r17392/129962
count: 125
text: 18383 32286 296 39958 9ed5235ffa444f16cdae3b2de41c0b46
props: 11057 46140 111 0 8ab1a522471ad7dd5014b23b42c49491
cpath: /trunk/client/goto.c
copyroot: 15280 /trunk

PLAIN
K 11
Makefile.am
V 24
file 5f.5ck.r16999/27621
K 6
agents
V 24
dir zf.5ck.r18308/160301
K 11
attribute.c
V 23
file xh.5ck.r18350/7014
K 11
attribute.h
V 19
file xi.0.r4715/844
K 7
audio.c
V 26
file 139.5ck.r17122/401512
K 7
audio.h
V 25
file 13a.5ck.r18054/43658
K 12
audio_none.c
V 23
file 13d.0.r6129/145164
K 12
audio_none.h
V 22
file 13e.0.r4452/27228
K 11
audio_sdl.c
V 26
file 13f.5ck.r16578/477644
K 11
audio_sdl.h
V 22
file 13g.0.r4452/26570
K 17
chatline_common.c
V 25
file 14q.5ck.r18289/38798
K 17
chatline_common.h
V 25
file 14r.5ck.r18289/39050
K 16
citydlg_common.c
V 25
file z4.5ck.r18308/160543
K 16
citydlg_common.h
V 24
file z5.5ck.r18054/34390
K 13
cityrepdata.c
V 24
file mb.5ck.r18326/43954
K 13
cityrepdata.h
V 24
file mc.5ck.r18054/34639
K 11
civclient.c
V 23
file 4f2.5ck.r15408/695
K 13
client_main.c
V 21
file 2f.5cp.r18304/90
K 13
client_main.h
V 23
file hz.5cq.r16632/1773
K 8
climap.c
V 25
file 197.5ck.r16888/19519
K 8
climap.h
V 25
file 198.5ck.r16888/20012
K 9
climisc.c
V 25
file d5.5ck.r18362/136819
K 9
climisc.h
V 25
file i0.5ck.r18151/154767
K 8
clinet.c
V 25
file hc.5ck.r18151/154004
K 8
clinet.h
V 25
file i1.5bk.r14427/324634
K 15
colors_common.c
V 24
file 33a.5ck.r18351/1671
K 15
colors_common.h
V 25
file 33b.5ck.r16397/92170
K 19
connectdlg_common.c
V 23
file 2fw.5ck.r18305/942
K 19
connectdlg_common.h
V 25
file 2fx.5ck.r16532/38983
K 9
control.c
V 25
file gz.5ck.r18383/114229
K 9
control.h
V 22
file i2.5ck.r17128/896
K 7
dummy.c
V 23
file 4f9.5ck.r15641/551
K 8
editor.c
V 24
file 3bg.5ck.r18353/4583
K 8
editor.h
V 25
file 3bh.5ck.r15761/13075
K 11
ggzclient.c
V 25
file 394.5ck.r18061/46733
K 11
ggzclient.h
V 24
file 395.0.r12670/122419
K 17
global_worklist.c
V 25
file 4i6.5ck.r17509/30059
K 17
global_worklist.h
V 26
file 4i7.5ck.r16319/100206
K 6
goto.c
V 25
file vu.5ck.r18383/114475
K 6
goto.h
V 24
file vv.5ck.r15509/18108
K 8
gui-ftwl
V 25
dir 2k2.5ck.r18308/188284
K 11
gui-gtk-2.0
V 23
dir zs.5ck.r18382/20711
K 7
gui-sdl
V 24
dir 16t.5ck.r18382/30171
K 8
gui-stub
V 23
dir mh.5ck.r18314/89816
K 9
gui-win32
V 24
dir np.5ck.r18318/372831
K 7
gui-xaw
V 23
dir 9o.5ck.r18382/24404
K 10
helpdata.c
V 24
file h1.5ck.r18326/54417
K 10
helpdata.h
V 24
file i3.5ck.r18326/54663
K 7
include
V 23
dir b8.5ck.r18326/53931
K 16
mapctrl_common.c
V 26
file 15m.5ck.r18308/189026
K 16
mapctrl_common.h
V 25
file 15n.5ck.r18054/43899
K 16
mapview_common.c
V 23
file z2.5ck.r18354/3124
K 16
mapview_common.h
V 24
file z3.5ck.r18054/44148
K 19
messagewin_common.c
V 25
file 14s.5ck.r18357/12915
K 19
messagewin_common.h
V 25
file 14t.5ck.r18082/46403
K 9
options.c
V 25
file dc.5ck.r18362/137064
K 9
options.h
V 23
file i4.5ck.r18115/6527
K 17
overview_common.c
V 25
file 2yk.5ck.r17735/12797
K 17
overview_common.h
V 25
file 2yl.5ck.r16930/40516
K 10
packhand.c
V 23
file n.5ck.r18326/54172
K 10
packhand.h
V 24
file i5.5bk.r14422/90154
K 15
plrdlg_common.c
V 25
file 14u.5ck.r18042/20931
K 15
plrdlg_common.h
V 25
file 14v.5ck.r18054/42900
K 17
repodlgs_common.c
V 26
file 11i.5ck.r18151/137715
K 17
repodlgs_common.h
V 26
file 11j.5ck.r18151/137972
K 9
reqtree.c
V 25
file 2ym.5ck.r18317/53895
K 9
reqtree.h
V 23
file 2yn.0.r13481/22674
K 9
servers.c
V 26
file 33x.5ck.r17122/406310
K 9
servers.h
V 25
file 33y.5ck.r15505/14398
K 6
text.c
V 26
file 2g3.5ck.r18318/365449
K 6
text.h
V 24
file 2g4.5ck.r17475/5221
K 15
themes_common.c
V 25
file 352.5ck.r16930/48921
K 15
themes_common.h
V 25
file 353.5ck.r16930/49172
K 10
tilespec.c
V 25
file hl.5ck.r18362/136572
K 10
tilespec.h
V 24
file i6.5ck.r16930/49667
K 14
update_queue.c
V 25
file 4jw.5ck.r18357/13168
K 14
update_queue.h
V 25
file 4jx.5ck.r18357/13363
K 10
voteinfo.c
V 23
file 4fe.5ck.r17708/187
K 10
voteinfo.h
V 25
file 4ff.5ck.r16201/17543
END
ENDREP
id: d.5ck.r18383/118488
type: dir
pred: d.5ck.r18382/34180
count: 4996
text: 18383 114720 3755 3755 3e72d06150743905e9801a12f1438a65
props: 17175 1380 160 0 7b3e01f16aae8514c8fa39e5f80a327d
cpath: /trunk/client
copyroot: 15280 /trunk

PLAIN
K 9
ABOUT-NLS
V 22
file fu.0.r13215/85704
K 7
AUTHORS
V 19
file 5u.0.r12982/94
K 7
COPYING
V 19
file 1h.0.r9643/400
K 9
ChangeLog
V 26
file 6l.5ck.r15924/3800068
K 7
INSTALL
V 22
file 6.5ck.r17486/2711
K 11
Makefile.am
V 24
file 59.5ck.r17690/10482
K 4
NEWS
V 23
file 6m.5ck.r16839/2057
K 6
README
V 20
file 7.0.r4421/96382
K 2
ai
V 23
dir 8.5ck.r18383/113997
K 10
autogen.sh
V 24
file 12o.5ck.r16223/7590
K 9
bootstrap
V 24
dir 2p5.5ck.r17613/37512
K 6
client
V 23
dir d.5ck.r18383/118488
K 6
common
V 23
dir p.5ck.r18383/110425
K 12
config.mac.h
V 20
file hb.0.r6045/5982
K 12
configure.ac
V 24
file 149.5ck.r18379/1062
K 4
data
V 23
dir w.5ck.r18380/155402
K 6
debian
V 22
dir 5w.5ck.r17748/2019
K 12
dependencies
V 23
dir 2yu.5ck.r17871/1886
K 11
diff_ignore
V 21
file qq.5ck.r17605/92
K 3
doc
V 22
dir k7.5ck.r18375/2197
K 10
fc_version
V 25
file 2lo.5en.r18326/43705
K 2
m4
V 23
dir 12p.5ck.r17653/2245
K 6
manual
V 24
dir 2m2.5ck.r18214/62476
K 7
modinst
V 24
dir 4pj.5ck.r18314/66348
K 2
po
V 24
dir fs.5ck.r18380/157542
K 7
scripts
V 23
dir 2yo.5bk.r14810/1300
K 6
server
V 23
dir z.5ck.r18383/104773
K 10
stamp-h.in
V 19
file 80.0.r1125/241
K 5
tests
V 22
dir 2g9.5ck.r15661/767
K 7
utility
V 24
dir 1c.5ck.r18362/121706
K 3
vms
V 21
dir u9.0.r11105/70719
K 5
win32
V 24
dir 2eu.5bk.r13732/30345
END
ENDREP
id: 3.5ck.r18383/120046
type: dir
pred: 3.5ck.r18382/35734
count: 13786
text: 18383 118723 1310 1310 9426c0abc4131fe3f9b8af536c85bf65
props: 17175 3052 264 0 91336f1f63d2f606e65376614b5c72e4
cpath: /trunk
copyroot: 15280 /trunk

PLAIN
K 8
branches
V 19
dir 1.0.r18372/5712
K 4
tags
V 19
dir 2.0.r17998/5187
K 5
trunk
V 23
dir 3.5ck.r18383/120046
K 7
website
V 18
dir 3ge.0.r12388/0
END
ENDREP
id: 0.0.r18383/120439
type: dir
pred: 0.0.r18382/36124
count: 18383
text: 18383 120275 151 151 708f9bc8bbd4a1de4d48ecfc4d3b2f49
cpath: /
copyroot: 0 /

16r.5ck.t18382-1 modify true false /trunk/ai/aidiplomat.c

15y.5ck.t18382-1 modify true false /trunk/ai/aiair.c

2du.5ck.t18382-1 modify true false /trunk/common/aicore/pf_tools.c

2gc.5ck.t18382-1 modify true false /trunk/ai/aihunt.c

b.5ck.t18382-1 modify true false /trunk/ai/aiunit.c

2ds.5ck.t18382-1 modify true false /trunk/common/aicore/path_finding.c

2lh.5ck.t18382-1 modify true false /trunk/ai/aisettler.c

vu.5ck.t18382-1 modify true false /trunk/client/goto.c

50r.5ck.t18382-1 modify true false /trunk/server/advisors/advbuilding.c

2lj.5eo.t18382-1 modify true false /trunk/server/advisors/autoexplorer.c

2dt.5ck.t18382-1 modify true false /trunk/common/aicore/path_finding.h

2iw.5ck.t18382-1 modify true false /trunk/ai/aiferry.c

7s.5ei.t18382-1 modify true false /trunk/server/advisors/autosettlers.c

gz.5ck.t18382-1 modify true false /trunk/client/control.c

9.5ck.t18382-1 modify true false /trunk/ai/aitools.c

33l.5ck.t18382-1 modify true false /trunk/common/aicore/caravan.c

1a.5ck.t18382-1 modify true false /trunk/server/unittools.c


120439 120591
