DELTA 22819 2026 1351
SVN  Š9¼_‚›= …i €‚> Y†+€„( dˆ+€‡j K €3 K €n K €z O €r O €‚U K €‚ K €‚ K €ƒZ K €ƒ K €{ K €†# K €‚. K €‚
 K €‚Y K €‚+ O €ƒ! O €ƒ O €ƒD O €…' O €„; O €„B O €‡h O €„: O €„N O €‰ O €‰b O €†V O €‚/ O €‚6 O €h K €‚] K €ƒC K €ƒ K €ƒ K €ƒ K €‚= K €‚C K €ƒ7 K €ƒ) K €>utility */
#include "rand.h"
#include "string_vector.h"

/* common */
#include "base.h"
#include "game.h"
#include "map.h"
#include "road.h"

#include "extras.h"

static struct extra_type extras[MAX_EXTRA_TYPES];

static struct extra_type_list *caused_by[EC_LAST];
static struct extra_type_list *removed_by[ERM_COUNT];int i;

  for (i = 0; i < EC_LAST; i++) {
    caused_by[i] = extra_type_list_new();
  }
  for (i = 0; i < ERM_COUNT; i++) {
    removed_by[i] = extra_type_list_new();
  }

  for (i = 0; i < MAX_EXTRA_TYPES; i++) {
    requirement_vector_init(&(extras[i].reqs));
    requirement_vector_init(&(extras[i].rmreqs));
    extras[i].id = i;
    extras[i].hiders = NULL;
    extras[i].data.special_idx = -1;
    extras[i].data.base = NULL;
    extras[i].data.road = NULL;
    extras[i].causes = 0;
    extras[i].rmcauses = 0;
    extras[i].helptext = NULL;
  }int i;

  base_types_free();
  road_types_free();

  for (i = 0; i < game.control.num_extra_types; i++) {
    if (extras[i].data.base != NULL) {
      FC_FREE(extras[i].data.base);
      extras[i].data.base = NULL;
    }
    if (extras[i].data.road != NULL) {
      FC_FREE(extras[i].data.road);
      extras[i].data.road = NULL;
    }
  }

  for (i = 0; i < EC_LAST; i++) {
    extra_type_list_destroy(caused_by[i]);
    caused_by[i] = NULL;
  }

  for (i = 0; i < ERM_COUNT; i++) {
    extra_type_list_destroy(removed_by[i]);
    removed_by[i] = NULL;
  }

  for (i = 0; i < MAX_EXTRA_TYPES; i++) {
    requirement_vector_free(&(extras[i].reqs));
    requirement_vector_free(&(extras[i].rmreqs));

    if (NULL != extras[i].helptext) {
      strvec_destroy(extras[i].helptext);
      extras[i].helptext = NULL;
    }
  }

  extra_type_iterate(pextra) {
    if (pextra->hiders != NULL) {
      extra_type_list_destroy(pextra->hiders);
      pextra->hiders = NULL;
    }
  } extra_type_iterate_end;
}


  Return the number of extra_types.
**************************************************************************/
int extra_count(void)
{
  return game.control.num_extra_types;
}


  Return the extra id.
**************************************************************************/
int extra_number(const struct extra_type *pextra)
{
  fc_assert_ret_val(NULL != pextra, -1);

  return pextra->id;
}

#ifndef extra_index

  Return the extra index.
**************************************************************************/
int extra_index(const struct extra_type *pextra)
{
  fc_assert_ret_val(NULL != pextra, -1);

  return pextra - extras;
}
#endif /* extra_index */

 Return extras type of given id.
****************************************************************************/
struct extra_type *extra_by_number(int id)
{
  fc_assert_ret_val(id >= 0 && id < MAX_EXTRA_TYPES, NULL);

  return &extras[id];
}

 Get extra of the given special
****************************************************************************/
struct extra_type *special_extra_get(int spe)
{
  struct extra_type_list *elist = extra_type_list_by_cause(EC_SPECIAL);

  if (spe < extra_type_list_size(elist)) {
    return extra_type_list_get(elist, spe);
  }

  return NULL;
}


  Return the (translated) name of the extra type.
  You don't have to free the return pointer.
**************************************************************************/
const char *extra_name_translation(const struct extra_type *pextra)
{
  return name_translation(&pextra->name);
}


  Return the (untranslated) rule name of the extra type.
  You don't have to free the return pointer.
**************************************************************************/
const char *extra_rule_name(const struct extra_type *pextra)
{
  return rule_name(&pextra->name);
}


  Returns extra type matching rule name or NULL if there is no extra type
  with such name.
**************************************************************************/
struct extra_type *extra_type_by_rule_name(const char *name)
{
  const char *qs;

  if (name == NULL) {
    return NULL;
  }

  qs = Qn_(name);

  extra_type_iterate(pextra) {
    if (!fc_strcasecmp(extra_rule_name(pextra), qs)) {
      return pextra;
    }
  } extra_type_iterate_end;

  return NULL;
}


  Returns extra type matching the translated name, or NULL if there is no
  extra type with that name.
**************************************************************************/
struct extra_type *extra_type_by_translated_name(const char *name)
{
  extra_type_iterate(pextra) {
    if (0 == strcmp(extra_name_translation(pextra), name)) {
      return pextra;
    }
  } extra_type_iterate_end;

  return NULL;
}


  Returns extra type for given cause.
**************************************************************************/
struct extra_type_list *extra_type_list_by_cause(enum extra_cause cause)
{
  fc_assert(cause < EC_LAST);

  return caused_by[cause];
}


  Return random extra type for given cause that is native to the tile.
**************************************************************************/
struct extra_type *rand_extra_for_tile(struct tile *ptile, enum extra_cause cause)
{
  struct extra_type_list *full_list = extra_type_list_by_cause(cause);
  struct extra_type_list *potential = extra_type_list_new();
  int options;
  struct extra_type *selected = NULL;

  extra_type_list_iterate(full_list, pextra) {
    if (is_native_tile_to_extra(pextra, ptile)) {
      extra_type_list_append(potential, pextra);
    }
  } extra_type_list_iterate_end;

  options = extra_type_list_size(potential);

  if (options > 0) {
    selected = extra_type_list_get(potential, fc_rand(options));
  }

  extra_type_list_destroy(potential);

  return selected;
}


  Add extra type to list of extra caused by given cause.
**************************************************************************/
void extra_to_caused_by_list(struct extra_type *pextra, enum extra_cause cause)
{
  fc_assert(cause < EC_LAST);

  extra_type_list_append(caused_by[cause], pextra);
}


  Returns extra type for given rmcause.
**************************************************************************/
struct extra_type_list *extra_type_list_by_rmcause(enum extra_rmcause rmcause)
{
  fc_assert(rmcause < ERM_COUNT);

  return removed_by[rmcause];
}


  Add extra type to list of extra removed by given cause.
**************************************************************************/
void extra_to_removed_by_list(struct extra_type *pextra,
                              enum extra_rmcause rmcause)
{
  fc_assert(rmcause < ERM_COUNT);

  extra_type_list_append(removed_by[rmcause], pextra);
}


  Is given cause one of the removal causes for given extra?
**************************************************************************/
bool is_extra_removed_by(const struct extra_type *pextra,
                         enum extra_rmcause rmcause)
{
  return (pextra->rmcauses & (1 << rmcause));
}

 Is there extra of the given type cardinally near tile?
  (Does not check ptile itself.)
****************************************************************************/
bool is_extra_card_near(const struct tile *ptile, const struct extra_type *pextra)
{
  cardinal_adjc_iterate(ptile, adjc_tile) {
    if (tile_has_extra(adjc_tile, pextra)) {
      return TRUE;
    }
  } cardinal_adjc_iterate_end;

  return FALSE;
}

 Is there extra of the given type near tile?
  (Does not check ptile itself.)
****************************************************************************/
bool is_extra_near_tile(const struct tile *ptile, const struct extra_type *pextra)
{
  adjc_iterate(ptile, adjc_tile) {
    if (tile_has_extra(adjc_tile, pextra)) {
      return TRUE;
    }
  } adjc_iterate_end;

  return FALSE;
}

 Tells if extra can build to tile if all other requirements are met.
****************************************************************************/
bool extra_can_be_built(const struct extra_type *pextra,
                        const struct tile *ptile)
{
  if (!pextra->buildable) {
    /* Extra type not buildable */
    return FALSE;
  }

  if (tile_has_extra(ptile, pextra)) {
    /* Extra exist already */
    return FALSE;
  }

  return TRUE;
}

 Tells if player can build extra to tile with suitable unit.
****************************************************************************/
static bool can_build_extra_base(const struct extra_type *pextra,
                                 const struct player *pplayer,
                                 const struct tile *ptile)
{
  if (is_extra_caused_by(pextra, EC_BASE)
      && !base_can_be_built(extra_base_get(pextra), ptile)) {
    return FALSE;
  }

  if (is_extra_caused_by(pextra, EC_ROAD)
      && !can_build_road_base(extra_road_get(pextra), pplayer, ptile)) {
    return FALSE;
  }

  if (!extra_can_be_built(pextra, ptile)) {
    return FALSE;
  }

  return TRUE;
}

 Tells if player can build extra to tile with suitable unit.
****************************************************************************/
bool player_can_build_extra(const struct extra_type *pextra,
                            const struct player *pplayer,
                            const struct tile *ptile)
{
  if (!can_build_extra_base(pextra, pplayer, ptile)) {
    return FALSE;
  }

  return are_reqs_active(pplayer, tile_owner(ptile), NULL, NULL, ptile,
                         NULL, NULL, NULL, NULL, &pextra->reqs,
                         RPT_POSSIBLE);
}

 Tells if unit can build extra on tile.
****************************************************************************/
bool can_build_extra(struct extra_type *pextra,
                     const struct unit *punit,
                     const struct tile *ptile)
{
  struct player *pplayer = unit_owner(punit);

  if (!can_build_extra_base(pextra, pplayer, ptile)) {
    return FALSE;
  }

  return are_reqs_active(pplayer, tile_owner(ptile), NULL, NULL, ptile,
                         punit, unit_type(punit), NULL, NULL, &pextra->reqs,
                         RPT_CERTAIN);
}

 Is it possible at all to remove this extra now
****************************************************************************/
static bool can_extra_be_removed(const struct extra_type *pextra,
                                 const struct tile *ptile)
{
  struct city *pcity = tile_city(ptile);

  /* Cannot remove EF_ALWAYS_ON_CITY_CENTER extras from city center. */
  if (pcity != NULL) {
    if (extra_has_flag(pextra, EF_ALWAYS_ON_CITY_CENTER)) {
      return FALSE;
    }
    if (extra_has_flag(pextra, EF_AUTO_ON_CITY_CENTER)) {
      struct tile *vtile = tile_virtual_new(ptile);

      /* Would extra get rebuilt if removed */ 
      tile_remove_extra(vtile, pextra);
      if (player_can_build_extra(pextra, city_owner(pcity), vtile)) {
        /* No need to worry about conflicting extras - extra would had
         * not been here if conflicting one is. */
        tile_virtual_destroy(vtile);

        return FALSE;
      }

      tile_virtual_destroy(vtile);
    }
  }

  return TRUE;
}

 Tells if player can remove extra from tile with suitable unit.
****************************************************************************/
bool player_can_remove_extra(const struct extra_type *pextra,
                             const struct player *pplayer,
                             const struct tile *ptile)
{
  if (!can_extra_be_removed(pextra, ptile)) {
    return FALSE;
  }

  return are_reqs_active(pplayer, tile_owner(ptile), NULL, NULL, ptile,
                         NULL, NULL, NULL, NULL, &pextra->rmreqs,
                         RPT_POSSIBLE);
}

 Tells if unit can remove extra from tile.
****************************************************************************/
bool can_remove_extra(struct extra_type *pextra,
                      const struct unit *punit,
                      const struct tile *ptile)
{
  struct player *pplayer;

  if (!can_extra_be_removed(pextra, ptile)) {
    return FALSE;
  } 

  pplayer = unit_owner(punit);

  return are_reqs_active(pplayer, tile_owner(ptile), NULL, NULL, ptile,
                         punit, unit_type(punit), NULL, NULL,
                         &pextra->rmreqs, RPT_CERTAIN);
}

 Is tile native to extra?
****************************************************************************/
bool is_native_tile_to_extra(const struct extra_type *pextra,
                             const struct tile *ptile)
{
  struct terrain *pterr = tile_terrain(ptile);

  if (is_extra_caused_by(pextra, EC_IRRIGATION)
      && pterr->irrigation_result != pterr) {
    return FALSE;
  }

  if (is_extra_caused_by(pextra, EC_MINE)
      && pterr->mining_result != pterr) {
    return FALSE;
  }

  if (is_extra_caused_by(pextra, EC_BASE)) {
    if (pterr->base_time == 0) {
      return FALSE;
    }
    if (tile_city(ptile) != NULL && extra_base_get(pextra)->border_sq >= 0) {
      return FALSE;
    }
  }

  if (is_extra_caused_by(pextra, EC_ROAD)) {
    struct road_type *proad = extra_road_get(pextra);

    if (road_has_flag(proad, RF_RIVER)) {
      if (!terrain_has_flag(pterr, TER_CAN_HAVE_RIVER)) {
        return FALSE;
      }
    } else if (pterr->road_time == 0) {
      return FALSE;
    }
  }

  return are_reqs_active(NULL, NULL, NULL, NULL, ptile,
                         NULL, NULL, NULL, NULL,
                         &pextra->reqs, RPT_POSSIBLE);
}

 Returns next extra by cause that unit or player can build to tile.
****************************************************************************/
struct extra_type *next_extra_for_tile(const struct tile *ptile, enum extra_cause cause,
                                       const struct player *pplayer,
                                       const struct unit *punit)
{
  if (cause == EC_IRRIGATION) {
    struct terrain *pterrain = tile_terrain(ptile);

    if (pterrain->irrigation_result != pterrain) {
      /* No extra can be created by irrigation the tile */
      return NULL;
    }
  }
  if (cause == EC_MINE) {
    struct terrain *pterrain = tile_terrain(ptile);

    if (pterrain->mining_result != pterrain) {
      /* No extra can be created by mining the tile */
      return NULL;
    }
  }

  extra_type_by_cause_iterate(cause, pextra) {
    if (!tile_has_extra(ptile, pextra)) {
      if (punit != NULL) {
        if (can_build_extra(pextra, punit, ptile)) {
          return pextra;
        }
      } else {
        /* punit is certainly NULL, pplayer can be too */
        if (player_can_build_extra(pextra, pplayer, ptile)) {
          return pextra;
        }
      }
    }
  } extra_type_by_cause_iterate_end;

  return NULL;
}

 Returns prev extra by cause that unit or player can remove from tile.
****************************************************************************/
struct extra_type *prev_extra_in_tile(const struct tile *ptile,
                                      enum extra_rmcause rmcause,
                                      const struct player *pplayer,
                                      const struct unit *punit)
{
  fc_assert(punit != NULL || pplayer != NULL);

  extra_type_by_rmcause_iterate(rmcause, pextra) {
    if (tile_has_extra(ptile, pextra)) {
      if (punit != NULL) {
        if (can_remove_extra(pextra, punit, ptile)) {
          return pextra;
        }
      } else {
        if (player_can_remove_extra(pextra, pplayer, ptile)) {
          return pextra;
        }
      }
    }
  } extra_type_by_rmcause_iterate_end;

  return NULL;
}

 Is extra native to unit class?
****************************************************************************/
bool is_native_extra_to_uclass(const struct extra_type *pextra,
                               const struct unit_class *pclass)
{
  return BV_ISSET(pextra->native_to, uclass_index(pclass));
}

 Is extra native to unit type?
****************************************************************************/
bool is_native_extra_to_utype(const struct extra_type *pextra,
                              const struct unit_type *punittype)
{
  return is_native_extra_to_uclass(pextra, utype_class(punittype));
}

 Check if extra has given flag
****************************************************************************/
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
{
  return BV_ISSET(pextra->flags, flag);
}


  Can two extras coexist in same tile?
**************************************************************************/
bool can_extras_coexist(const struct extra_type *pextra1,
                        const struct extra_type *pextra2)
{
  if (pextra1 == pextra2) {
    return TRUE;
  }

  return !BV_ISSET(pextra1->conflicts, extra_index(pextra2));
}


  Does the extra count toward environment upset?
**************************************************************************/
bool extra_causes_env_upset(struct extra_type *pextra,
                            enum environment_upset_type upset)
{
  switch (upset) {
  case EUT_GLOBAL_WARMING:
    return extra_has_flag(pextra, EF_GLOBAL_WARMING);
  case EUT_NUCLEAR_WINTER:
    return extra_has_flag(pextra, EF_NUCLEAR_WINTER);
  }

  return FALSE;
}


  Is given cause one of the causes for given extra?
**************************************************************************/
bool is_extra_caused_by(const struct extra_type *pextra, enum extra_cause cause)
{
  /* There's some extra cause lists above EC_COUNT that do not have equivalent
   * bit in pextra->causes */
  fc_assert(cause < EC_COUNT);

  return (pextra->causes & (1 << cause));
}


  Is the extra caused by some kind of worker action?
**************************************************************************/
bool is_extra_caused_by_worker_action(const struct extra_type *pextra)
{
  /* Is any of the worker build action bits set? */
  return (pextra->causes
          & (1 << EC_IRRIGATION
             | 1 << EC_MINE
             | 1 << EC_BASE
             | 1 << EC_ROAD));
}


  Is the extra removed by some kind of worker action?
**************************************************************************/
bool is_extra_removed_by_worker_action(const struct extra_type *pextra)
{
  /* Is any of the worker remove action bits set? */
  return (pextra->rmcauses
          & (1 << ERM_CLEANPOLLUTION
             | 1 << ERM_CLEANFALLOUT
             | 1 << ERM_PILLAGE));
}


  Is the extra caused by specific worker action?
**************************************************************************/
bool is_extra_caused_by_action(const struct extra_type *pextra,
                               enum unit_activity act)
{
  return is_extra_caused_by(pextra, activity_to_extra_cause(act));
}


  Is the extra removed by specific worker action?
**************************************************************************/
bool is_extra_removed_by_action(const struct extra_type *pextra,
                                enum unit_activity act)
{
  return is_extra_removed_by(pextra, activity_to_extra_rmcause(act));
}


  What extra cause activity is considered to be?
**************************************************************************/
enum extra_cause activity_to_extra_cause(enum unit_activity act)
{
  switch(act) {
  case ACTIVITY_IRRIGATE:
    return EC_IRRIGATION;
  case ACTIVITY_MINE:
    return EC_MINE;
  case ACTIVITY_BASE:
    return EC_BASE;
  case ACTIVITY_GEN_ROAD:
    return EC_ROAD;
  default:
    break;
  }

  return EC_NONE;
}


  What extra rmcause activity is considered to be?
**************************************************************************/
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act)
{
  switch(act) {
  case ACTIVITY_PILLAGE:
    return ERM_PILLAGE;
  case ACTIVITY_POLLUTION:
    return ERM_CLEANPOLLUTION;
  case ACTIVITY_FALLOUT:
    return ERM_CLEANFALLOUT;
  default:
    break;
  }

  return ERM_NONE;
}


  Who owns extras on tile
**************************************************************************/
struct player *extra_owner(const struct tile *ptile)
{
  return ptile->extras_owner;
}
ENDREP
DELTA 22819 997 1016
SVN  ‡jÓ 
Ì] † €Ì]‡d/* common */
#include "base.h"
#include "fc_types.h"
#include "road.h"
#include "terrain.h"

/* Used in the network protocol. */
#define SPECENUM_NAME extra_flag_id
/* Tile with this extra is considered native for units in tile. */
#define SPECENUM_VALUE0 EF_NATIVE_TILE
#define SPECENUM_VALUE0NAME "NativeTile"
/* Refuel native units */
#define SPECENUM_VALUE1 EF_REFUEL
#define SPECENUM_VALUE1NAME "Refuel"
#define SPECENUM_VALUE2 EF_TERR_CHANGE_REMOVES
#define SPECENUM_VALUE2NAME "TerrChangeRemoves"
/* Extra will be built in cities automatically */
#define SPECENUM_VALUE3 EF_AUTO_ON_CITY_CENTER
#define SPECENUM_VALUE3NAME "AutoOnCityCenter"
/* Extra is always present in cities */
#define SPECENUM_VALUE4 EF_ALWAYS_ON_CITY_CENTER
#define SPECENUM_VALUE4NAME "AlwaysOnCityCenter"
/* Road style gfx from ocean extra connects to nearby land */
#define SPECENUM_VALUE5 EF_CONNECT_LAND
#define SPECENUM_VALUE5NAME "ConnectLand"
/* Counts towards Global Warming */
#define SPECENUM_VALUE6 EF_GLOBAL_WARMING
#define SPECENUM_VALUE6NAME "GlobalWarming"
/* Counts towards Nuclear Winter */
#define SPECENUM_VALUE7 EF_NUCLEAR_WINTER
#define SPECENUM_VALUE7NAME "NuclearWinter"
/* Owner's flag will be shown on the tile */
#define SPECENUM_VALUE8 EF_SHOW_FLAG
#define SPECENUM_VALUE8NAME "ShowFlag"
/* Extra's defense bonus will be counted to
 * separate "Natural" defense layer. */
#define SPECENUM_VALUE9 EF_NATURAL_DEFENSE
#define SPECENUM_VALUE9NAME "NaturalDefense"
#define SPECENUM_COUNT EF_COUNT
#define SPECENUM_BITVECTOR bv_extra_flags
#include "specenum_gen.h"

#define EXTRA_NONE (-1)

struct extra_type
{
  int id;
  struct name_translation name;
  enum extra_category category;
  enum extra_cause causes;
  enum extra_rmcause rmcauses;

  char graphic_str[MAX_LEN_NAME];
  char graphic_alt[MAX_LEN_NAME];
  char activity_gfx[MAX_LEN_NAME];
  char act_gfx_alt[MAX_LEN_NAME];
  char rmact_gfx[MAX_LEN_NAME];
  char rmact_gfx_alt[MAX_LEN_NAME];

  struct requirement_vector reqs;
  struct requirement_vector rmreqs;

  /* 'buildable' is unclean. Clean solution would be to rely solely on extra_cause:
   * if the extra cannot be built, it's not in the cause's list.
   * But we currently rely on actually-not-buildable extras to be on the lists,
   * for example for the editor to list non-buildable but editor-placeable
   * extras. */
  bool buildable;
  int build_time;
  int build_time_factor;
  int removal_time;
  int removal_time_factor;

  int defense_bonus;

  bv_unit_classes native_to;

  bv_extra_flags flags;
  bv_extras conflicts;
  bv_extras hidden_by;

  /* Same information as in hidden_by, but iterating through this list is much
   * faster than through all extra types to check which ones are hiding this one.
   * Only used client side. */
  struct extra_type_list *hiders;

  struct strvec *helptext;

  struct
  {
    int special_idx;
    struct base_type *base;
    struct road_type *road;
  } data;
};

/* get 'struct extra_type_list' and related functions: */
#define SPECLIST_TAG extra_type
#define SPECLIST_TYPE struct extra_type
#include "speclist.h"

#define extra_type_list_iterate(extralist, pextra) \
    TYPED_LIST_ITERATE(struct extra_type, extralist, pextra)
#define extra_type_list_iterate_end LIST_ITERATE_END

#define extra_type_list_iterate_rev(extralist, pextra) \
    TYPED_LIST_ITERATE_REV(struct extra_type, extralist, pextra)
#define extra_type_list_iterate_rev_end LIST_ITERATE_REV_END

void extras_init(void);
void extras_free(void);

int extra_count(void);
int extra_number(const struct extra_type *pextra);
struct extra_type *extra_by_number(int id);

/* For optimization purposes (being able to have it as macro instead of function
 * call) this is now same as extra_number(). extras.c does have sematically correct
 * implementation too. */
#define extra_index(_e_) (_e_)->id

struct extra_type *special_extra_get(int spe);

const char *extra_name_translation(const struct extra_type *pextra);
const char *extra_rule_name(const struct extra_type *pextra);
struct extra_type *extra_type_by_rule_name(const char *name);
struct extra_type *extra_type_by_translated_name(const char *name);

#define extra_base_get(_e_) (_e_)->data.base
#define extra_road_get(_e_) (_e_)->data.road

void extra_to_caused_by_list(struct extra_type *pextra, enum extra_cause cause);
struct extra_type_list *extra_type_list_by_cause(enum extra_cause cause);
struct extra_type *rand_extra_for_tile(struct tile *ptile, enum extra_cause cause);

bool is_extra_caused_by(const struct extra_type *pextra, enum extra_cause cause);
bool is_extra_caused_by_worker_action(const struct extra_type *pextra);
bool is_extra_caused_by_action(const struct extra_type *pextra,
                               enum unit_activity act);

void extra_to_removed_by_list(struct extra_type *pextra, enum extra_rmcause rmcause);
struct extra_type_list *extra_type_list_by_rmcause(enum extra_rmcause rmcause);

bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause);
bool is_extra_removed_by_worker_action(const struct extra_type *pextra);
bool is_extra_removed_by_action(const struct extra_type *pextra,
                                enum unit_activity act);

bool is_extra_card_near(const struct tile *ptile, const struct extra_type *pextra);
bool is_extra_near_tile(const struct tile *ptile, const struct extra_type *pextra);

bool extra_can_be_built(const struct extra_type *pextra, const struct tile *ptile);
bool can_build_extra(struct extra_type *pextra,
                     const struct unit *punit,
                     const struct tile *ptile);
bool player_can_build_extra(const struct extra_type *pextra,
                            const struct player *pplayer,
                            const struct tile *ptile);

bool can_remove_extra(struct extra_type *pextra,
                      const struct unit *punit,
                      const struct tile *ptile);
bool player_can_remove_extra(const struct extra_type *pextra,
                             const struct player *pplayer,
                             const struct tile *ptile);

bool is_native_extra_to_uclass(const struct extra_type *pextra,
                               const struct unit_class *pclass);
bool is_native_extra_to_utype(const struct extra_type *pextra,
                              const struct unit_type *punittype);
bool is_native_tile_to_extra(const struct extra_type *pextra,
                             const struct tile *ptile);

bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag);

bool extra_causes_env_upset(struct extra_type *pextra,
                            enum environment_upset_type upset);

bool can_extras_coexist(const struct extra_type *pextra1,
                        const struct extra_type *pextra2);

struct extra_type *next_extra_for_tile(const struct tile *ptile, enum extra_cause cause,
                                       const struct player *pplayer,
                                       const struct unit *punit);
struct extra_type *prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause,
                                      const struct player *pplayer,
                                      const struct unit *punit);

enum extra_cause activity_to_extra_cause(enum unit_activity act);
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act);

struct player *extra_owner(const struct tile *ptile);

#define extra_type_iterate(_p)                                \
{                                                             \
  int _i_##_p;                                                \
  for (_i_##_p = 0; _i_##_p < game.control.num_extra_types; _i_##_p++) {  \
    struct extra_type *_p = extra_by_number(_i_##_p);

#define extra_type_iterate_end                    \
  }                                               \
}

#define extra_type_by_cause_iterate(_cause, _extra)                 \
{                                                                   \
  struct extra_type_list *_etl_##_extra = extra_type_list_by_cause(_cause); \
  if (_etl_##_extra != NULL) {                                              \
    extra_type_list_iterate(_etl_##_extra, _extra) {

#define extra_type_by_cause_iterate_end                    \
    } extra_type_list_iterate_end                          \
  }                                                        \
}

#define extra_type_by_cause_iterate_rev(_cause, _extra)                 \
{                                                                      \
 struct extra_type_list *_etl_ = extra_type_list_by_cause(_cause);     \
  extra_type_list_iterate_rev(_etl_, _extra) {

#define extra_type_by_cause_iterate_rev_end                \
  } extra_type_list_iterate_rev_end                        \
}

#define extra_type_by_rmcause_iterate(_rmcause, _extra)                   \
{                                                                         \
  struct extra_type_list *_etl_ = extra_type_list_by_rmcause(_rmcause);   \
  extra_type_list_iterate_rev(_etl_, _extra) {

#define extra_type_by_rmcause_iterate_end                \
  } extra_type_list_iterate_rev_end                      \
}

#define extra_deps_iterate(_reqs, _dep)                 \
{                                                       \
  requirement_vector_iterate(_reqs, preq) {             \
    if (preq->source.kind == VUT_EXTRA                  \
        && preq->present) {                             \
      struct extra_type *_dep;                          \
      _dep = preq->source.value.extra;

#define extra_deps_iterate_end                          \
    }                                                   \
  } requirement_vector_iterate_end;                     \
}

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif  /* FC__EXTRASENDREP
id: o9u.5qi.r29786/30079
type: file
pred: o9u.5qi.r29758/25471
count: 64
text: 29786 0 20179 24159 248e285efbc78c270a533cb6b99b4f8b
props: 26905 205525 34 0 25e6c2f7558b7484000d4d090dea5b92
cpath: /branches/S2_6/common/extras.c
copyroot: 27474 /branches/S2_6

id: o9w.5qi.r29786/30339
type: file
pred: o9w.5qi.r29758/25729
count: 64
text: 29786 20208 9843 10624 df8d3070dfab7b1666962a993e72fd4d
props: 26905 205815 34 0 25e6c2f7558b7484000d4d090dea5b92
cpath: /branches/S2_6/common/extras.h
copyroot: 27474 /branches/S2_6

PLAIN
K 11
Makefile.am
V 24
file 5h.5ck.r25801/35234
K 14
achievements.c
V 25
file qhc.5qi.r28854/18023
K 14
achievements.h
V 26
file qhe.5ck.r26905/215849
K 9
actions.c
V 24
file r7a.5qi.r29772/5564
K 9
actions.h
V 24
file r7c.5qi.r29501/3784
K 4
ai.c
V 23
file 4go.5qi.r29098/627
K 4
ai.h
V 24
file 4gp.5qi.r29401/9045
K 6
aicore
V 23
dir 18t.5qi.r29774/1099
K 6
base.c
V 25
file 3jw.5qi.r28854/18549
K 6
base.h
V 25
file 3jx.5qi.r29646/20289
K 9
borders.c
V 25
file 4f0.5qi.r28854/19065
K 9
borders.h
V 26
file 4f1.5ck.r26905/213493
K 10
calendar.c
V 27
file 147p.5ck.r26905/214086
K 10
calendar.h
V 27
file 147r.5ck.r26905/215265
K 8
capstr.c
V 22
file dv.5ck.r24976/289
K 8
capstr.h
V 24
file dw.5ck.r18858/97074
K 10
citizens.c
V 26
file 6mx.5ck.r26905/203234
K 10
citizens.h
V 26
file 6my.5ck.r26905/204108
K 6
city.c
V 22
file q.5qi.r29571/6849
K 6
city.h
V 23
file 3q.5qi.r29373/6009
K 13
clientutils.c
V 26
file zj9.5ck.r26905/212022
K 13
clientutils.h
V 26
file zjb.5ck.r26905/213199
K 8
combat.c
V 22
file wp.5ck.r27137/126
K 8
combat.h
V 24
file wq.5ck.r24573/25814
K 12
connection.c
V 23
file un.5qi.r29192/5199
K 12
connection.h
V 24
file uo.5qi.r29503/20247
K 9
culture.c
V 27
file 104t.5ck.r26905/202652
K 9
culture.h
V 27
file 104v.5ck.r26905/203523
K 8
dataio.c
V 24
file 15r.5qi.r29445/7623
K 8
dataio.h
V 24
file 15s.5ck.r26834/4081
K 11
diptreaty.c
V 23
file 3r.5qi.r29571/7104
K 11
diptreaty.h
V 23
file 3s.5qi.r27518/9734
K 10
disaster.c
V 26
file b2m.5ck.r26905/214973
K 10
disaster.h
V 26
file b2o.5ck.r26905/216145
K 9
effects.c
V 24
file 2eo.5qi.r29571/7364
K 9
effects.h
V 24
file 2ep.5qi.r29180/3668
K 8
events.c
V 24
file 33h.5qi.r28399/2883
K 8
events.h
V 23
file 3t.5qi.r28399/3138
K 8
extras.c
V 25
file o9u.5qi.r29786/30079
K 8
extras.h
V 25
file o9w.5qi.r29786/30339
K 12
fc_cmdhelp.c
V 26
file 76j.5ck.r26905/216438
K 12
fc_cmdhelp.h
V 26
file 76k.5ck.r26905/216731
K 14
fc_interface.c
V 23
file 4up.5qi.r29369/494
K 14
fc_interface.h
V 25
file 4uq.5qi.r28204/10610
K 10
fc_types.h
V 25
file 2ll.5qi.r29733/11389
K 15
featured_text.c
V 26
file 4h3.5ck.r26905/212899
K 15
featured_text.h
V 26
file 4h4.5ck.r26905/213786
K 6
game.c
V 24
file 3u.5qi.r29590/18634
K 6
game.h
V 24
file 3v.5qi.r29590/18891
K 19
generate_packets.py
V 25
file 2f4.5ck.r27339/27191
K 12
government.c
V 25
file he.5ck.r25382/101248
K 12
government.h
V 24
file hf.5ck.r25151/83855
K 6
idex.c
V 24
file qo.5ck.r25151/84101
K 6
idex.h
V 24
file qp.5ck.r18858/92434
K 13
improvement.c
V 24
file vb.5qi.r28819/92105
K 13
improvement.h
V 23
file vc.5ck.r26605/3666
K 5
map.c
V 21
file r.5qi.r29763/300
K 5
map.h
V 24
file 41.5qi.r29646/20546
K 8
mapimg.c
V 26
file 6n9.5ck.r26905/214381
K 8
mapimg.h
V 26
file 6na.5ck.r26905/215559
K 15
metaknowledge.c
V 23
file siq.5qi.r29487/153
K 15
metaknowledge.h
V 26
file sis.5ck.r26905/206455
K 10
movement.c
V 25
file 2xv.5qi.r29758/25988
K 10
movement.h
V 25
file 2xw.5ck.r26369/89711
K 13
multipliers.c
V 26
file 197b.5qi.r29058/37897
K 13
multipliers.h
V 26
file 197d.5qi.r29118/55021
K 18
name_translation.h
V 26
file 4k1.5ck.r26905/217596
K 8
nation.c
V 24
file il.5ck.r26881/35006
K 8
nation.h
V 22
file im.5ck.r27000/284
K 9
packets.c
V 22
file 43.5qi.r28613/342
K 11
packets.def
V 24
file 2f5.5qi.r29777/8219
K 9
packets.h
V 24
file 44.5qi.r28854/17506
K 8
player.c
V 23
file 45.5qi.r29571/8394
K 8
player.h
V 24
file 46.5qi.r29646/20801
K 14
requirements.c
V 25
file 2wq.5qi.r29460/31716
K 14
requirements.h
V 24
file 2wr.5qi.r29445/8145
K 10
research.c
V 24
file 4ro.5qi.r29571/8650
K 10
research.h
V 23
file 4rp.5qi.r27751/838
K 10
rgbcolor.c
V 26
file 6i6.5ck.r26905/218776
K 10
rgbcolor.h
V 26
file 6i7.5ck.r26905/219068
K 6
road.c
V 25
file 6pq.5qi.r29758/26250
K 6
road.h
V 24
file 6pr.5qi.r29571/8911
K 10
scriptcore
V 24
dir 75a.5qi.r28854/16989
K 11
spaceship.c
V 23
file 98.5ck.r26349/9773
K 11
spaceship.h
V 24
file 99.5ck.r26349/10015
K 12
specialist.c
V 24
file 33f.5qi.r29571/9164
K 12
specialist.h
V 24
file 33g.5qi.r29571/9422
K 7
style.c
V 26
file zzb.5ck.r26905/204398
K 7
style.h
V 26
file zzd.5ck.r26905/204988
K 6
team.c
V 23
file 33i.5ck.r25891/212
K 6
team.h
V 23
file 33j.5ck.r26183/314
K 6
tech.c
V 21
file t.5qi.r29318/128
K 6
tech.h
V 21
file u.5qi.r29318/376
K 9
terrain.c
V 23
file 2fp.5qi.r28914/744
K 9
terrain.h
V 24
file qs.5qi.r27880/14146
K 6
tile.c
V 25
file 2ys.5qi.r29733/11652
K 6
tile.h
V 25
file 2yt.5ck.r26109/28279
K 13
traderoutes.c
V 25
file bf8.5qi.r27552/33422
K 13
traderoutes.h
V 25
file bfa.5qi.r27552/33689
K 8
traits.h
V 26
file 7k3.5ck.r26905/202065
K 6
unit.c
V 23
file v.5qi.r29213/75445
K 6
unit.h
V 24
file 48.5qi.r29213/75696
K 10
unitlist.c
V 25
file 39m.5qi.r27612/25885
K 10
unitlist.h
V 25
file 39n.5qi.r27612/26147
K 10
unittype.c
V 23
file v9.5qi.r29660/7864
K 10
unittype.h
V 23
file va.5qi.r29660/8124
K 9
version.c
V 23
file oe.5ck.r26171/7093
K 9
version.h
V 23
file e7.5ck.r26171/7331
K 9
victory.c
V 26
file qex.5ck.r26905/217020
K 9
victory.h
V 26
file qez.5ck.r26905/217896
K 8
vision.c
V 22
file 4dm.5qi.r27639/98
K 8
vision.h
V 24
file 4dn.5ck.r24742/9986
K 12
workertask.c
V 26
file llw.5ck.r26905/206753
K 12
workertask.h
V 25
file lly.5qi.r28927/25134
K 10
worklist.c
V 22
file o8.5qi.r28027/169
K 10
worklist.h
V 24
file o9.5ck.r18858/98299
END
ENDREP
id: p.5qi.r29786/35889
type: dir
pred: p.5qi.r29777/13766
count: 4266
text: 29786 30602 5274 0 49f878f90bd50e0c4e56b87816d6bd72
props: 23743 0 112 0 b2bc91bf125d83375389d51f25ff2c2f
cpath: /branches/S2_6/common
copyroot: 27474 /branches/S2_6

PLAIN
K 9
ABOUT-NLS
V 24
file fu.5ck.r27270/69307
K 7
AUTHORS
V 24
file 5u.5ck.r22143/14016
K 7
COPYING
V 22
file 1h.5qi.r29455/952
K 9
ChangeLog
V 26
file 6l.5ck.r27473/7455495
K 7
INSTALL
V 21
file 6.5qi.r29706/131
K 11
Makefile.am
V 22
file 59.5qi.r29568/735
K 4
NEWS
V 24
file 6m.5ck.r25634/30702
K 6
README
V 20
file 7.0.r4421/96382
K 2
ai
V 21
dir 8.5qi.r29782/3634
K 10
autogen.sh
V 24
file 12o.5ck.r25794/4003
K 9
bootstrap
V 23
dir 2p5.5qi.r29679/3655
K 6
client
V 21
dir d.5qi.r29777/7974
K 6
common
V 22
dir p.5qi.r29786/35889
K 12
configure.ac
V 23
file 149.5qi.r29706/372
K 4
data
V 21
dir w.5qi.r29770/3844
K 12
dependencies
V 23
dir 2yu.5qi.r29381/5956
K 3
doc
V 22
dir k7.5qi.r29753/2191
K 10
fc_version
V 25
file 2lo.5qj.r29777/14007
K 11
gen_headers
V 25
dir 1hsw.5qi.r29185/55201
K 2
m4
V 23
dir 12p.5qi.r29627/3033
K 7
scripts
V 23
dir 2yo.5qi.r28717/5437
K 6
server
V 21
dir z.5qi.r29780/5158
K 5
tests
V 22
dir 2g9.5ck.r27023/734
K 5
tools
V 23
dir 4pj.5qp.r29784/2802
K 12
translations
V 24
dir t0a.5qi.r29715/91584
K 7
utility
V 23
dir 1c.5qi.r29760/12716
K 3
vms
V 25
dir u9.5ck.r21528/1396085
K 5
win32
V 23
dir 2eu.5qi.r28346/1712
END
ENDREP
id: 3.5qi.r29786/37301
type: dir
pred: 3.5qi.r29784/4213
count: 19666
text: 29786 36132 1156 0 9e9ef70fb66dfbc6ed3cb281690fa404
props: 28037 14463 292 0 9e1d5de0253c723466868990c52c129f
cpath: /branches/S2_6
copyroot: 27474 /branches/S2_6

PLAIN
K 5
S1_14
V 21
dir 3.21.r18109/18803
K 4
S2_0
V 21
dir 3.10x.r21862/4178
K 4
S2_1
V 22
dir 3.59e.r20026/11014
K 4
S2_2
V 21
dir 3.5cy.r21861/5036
K 4
S2_3
V 21
dir 3.5f2.r29458/5135
K 4
S2_4
V 24
dir 3.5ii.r29512/2246126
K 4
S2_5
V 22
dir 3.5kv.r29778/25063
K 4
S2_6
V 22
dir 3.5qi.r29786/37301
K 11
freeciv-web
V 22
dir 3.5bl.r13594/14918
END
ENDREP
id: 1.0.r29786/37898
type: dir
pred: 1.0.r29784/4807
count: 9706
text: 29786 37541 344 0 a6c9546a430c8a13485619f4c8f62407
cpath: /branches
copyroot: 0 /

PLAIN
K 8
branches
V 20
dir 1.0.r29786/37898
K 4
tags
V 19
dir 2.0.r29519/6475
K 5
trunk
V 21
dir 3.5ck.r29785/7507
K 7
website
V 21
dir 3ge.0.r22980/2263
END
ENDREP
id: 0.0.r29786/38218
type: dir
pred: 0.0.r29785/7894
count: 29786
text: 29786 38052 153 0 14a768f4e21b7be2cb6a43542b6bc13e
cpath: /
copyroot: 0 /

o9u.5qi.t29785-1 modify true false /branches/S2_6/common/extras.c

o9w.5qi.t29785-1 modify true false /branches/S2_6/common/extras.h


38218 38365
