<URL: http://bugs.freeciv.org/Ticket/Display.html?id=37295 >

 This adds "native_to" list of unit classes to base.  Base affects
mostly only those units.
 This means several rule changes even in default rules. Fortress is
made native to "Land" units and Airbase to "Air", "Helicopter" and
"Missile" units.

 How this affects each base flag. 'Inside base' means that unit is in
same tile with base and base is native to unit.
 "NoAggressive" - Only units inside base are not considered aggressive
- airplane over fortress is aggressive
 "DefenseBonus" - Only units inside base get defense bonus - airplane
over fortress does not
 "NoStackDeath" - No changes, this applies to units in tile even if
none of them is inside. Airplane stack over fortress dies only one
unit at a time.
 "Watchtower" - This flag was actually useless, this is implemented by
effects. Flag removed.
 "ClaimTerritory" - Only units inside can claim base - airplane flying
over fortress does not claim it.
 "DiplomatDefense" - Only diplomats inside base get defense bonus.
 "Refuel" - Flag removed. Units inside base are always refueled.
 "NoHPLoss" - Flag removed. There is never HP loss inside base
 "AttackUnreachable" - Flag removed. Units inside base can always be attacked.
 "ParadropFrom" - No changes. Units can paradrop from non-native base
(ie. Land unit Paratrooper can paradrop from Airbase)


 Applies on top of #37218. Untested.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aiair.c freeciv/ai/aiair.c
--- freeciv/ai/aiair.c	2007-01-24 16:33:25.000000000 +0200
+++ freeciv/ai/aiair.c	2007-03-01 22:29:19.000000000 +0200
@@ -228,7 +228,8 @@
   bool found = FALSE;
 
   airbase_iterator 
-    = refuel_iterate_init(unit_owner(punit), punit->tile,
+    = refuel_iterate_init(unit_owner(punit), unit_type(punit),
+                          punit->tile,
                           punit->tile, TRUE, 
                           punit->moves_left / SINGLE_MOVE, 
                           unit_move_rate(punit) / SINGLE_MOVE, 
diff -Nurd -X.diff_ignore freeciv/common/aicore/pf_tools.c freeciv/common/aicore/pf_tools.c
--- freeciv/common/aicore/pf_tools.c	2007-02-12 15:27:43.000000000 +0200
+++ freeciv/common/aicore/pf_tools.c	2007-03-01 22:21:36.000000000 +0200
@@ -546,13 +546,17 @@
 				 enum known_type known,
 				 struct pf_parameter *param)
 {
+  struct base_type *pbase;
+
   /* FIXME: bombers with fuel remaining should not worry about danger. */
 
   if (is_allied_city_tile(ptile, param->owner)) {
     return FALSE;
   }
 
-  if (tile_has_base_flag(ptile, BF_REFUEL)) {
+  pbase = tile_get_base(ptile);
+
+  if (pbase && is_native_base_to_class(param->class, pbase)) {
     /* All airbases are considered non-dangerous, although non-allied ones
      * are inaccessible. */
     return FALSE;
diff -Nurd -X.diff_ignore freeciv/common/base.c freeciv/common/base.c
--- freeciv/common/base.c	2007-03-01 22:30:18.000000000 +0200
+++ freeciv/common/base.c	2007-03-01 22:15:35.000000000 +0200
@@ -24,9 +24,8 @@
 static struct base_type base_types[BASE_LAST];
 
 static const char *base_type_flag_names[] = {
-  "NoAggressive", "DefenseBonus", "NoStackDeath", "Watchtower",
-  "ClaimTerritory", "DiplomatDefense", "Refuel", "NoHPLoss",
-  "AttackUnreachable", "ParadropFrom"
+  "NoAggressive", "DefenseBonus", "NoStackDeath",
+  "ClaimTerritory", "DiplomatDefense", "ParadropFrom"
 };
 
 /****************************************************************************
@@ -37,6 +36,35 @@
   return BV_ISSET(pbase->flags, flag);
 }
 
+/****************************************************************************
+  Is base native to unit class?
+****************************************************************************/
+bool is_native_base_to_class(const struct unit_class *pclass,
+                             const struct base_type *pbase)
+{
+  return BV_ISSET(pbase->native_to, pclass->id);
+}
+
+/****************************************************************************
+  Is base native to unit?
+****************************************************************************/
+bool is_native_base(const struct unit_type *punittype,
+                    const struct base_type *pbase)
+{
+  return is_native_base_to_class(get_unit_class(punittype), pbase);
+}
+
+/****************************************************************************
+  Base provides base flag for unit? Checks if base provides flag and if
+  base is native to unit.
+****************************************************************************/
+bool base_flag_affects_unit(const struct unit_type *punittype,
+                            const struct base_type *pbase,
+                            enum base_flag_id flag)
+{
+  return base_flag(pbase, flag) && is_native_base(punittype, pbase);
+}
+
 /**************************************************************************
   Return the translated name of the base type.
 **************************************************************************/
diff -Nurd -X.diff_ignore freeciv/common/base.h freeciv/common/base.h
--- freeciv/common/base.h	2007-03-01 22:30:18.000000000 +0200
+++ freeciv/common/base.h	2007-03-01 22:15:45.000000000 +0200
@@ -26,12 +26,8 @@
                           * if base is close to city */
   BF_DEFENSE_BONUS,      /* Base provides defense bonus for units inside */
   BF_NO_STACK_DEATH,     /* Units inside will not die all at once */
-  BF_WATCHTOWER,         /* Base can act as watchtower */
   BF_CLAIM_TERRITORY,    /* Base claims tile ownership */
   BF_DIPLOMAT_DEFENSE,   /* Base provides bonus for defending diplomat */
-  BF_REFUEL,             /* Base refuels units */
-  BF_NO_HP_LOSS,         /* Units do not lose hitpoints when in base */
-  BF_ATTACK_UNREACHABLE, /* Unreachable units inside base can be attacked */
   BF_PARADROP_FROM,      /* Paratroopers can use base for paradrop */
   BF_LAST                /* This has to be last */
 };
@@ -43,10 +39,19 @@
   char name_orig[MAX_LEN_NAME];
   int id;
   struct requirement_vector reqs;
+  bv_unit_classes native_to;
+
   bv_base_flags flags;
 };
 
 bool base_flag(const struct base_type *pbase, enum base_flag_id flag);
+bool is_native_base(const struct unit_type *punittype,
+                    const struct base_type *pbase);
+bool is_native_base_to_class(const struct unit_class *pclass,
+                             const struct base_type *pbase);
+bool base_flag_affects_unit(const struct unit_type *punittype,
+                            const struct base_type *pbase,
+                            enum base_flag_id flag);
 const char *base_name(const struct base_type *pbase);
 
 bool can_build_base(const struct unit *punit, const struct base_type *pbase,
diff -Nurd -X.diff_ignore freeciv/common/combat.c freeciv/common/combat.c
--- freeciv/common/combat.c	2007-01-23 16:05:15.000000000 +0200
+++ freeciv/common/combat.c	2007-03-01 21:48:55.000000000 +0200
@@ -96,7 +96,7 @@
   /* 2. Only fighters can attack planes, except in city or airbase attacks */
   if (!unit_flag(punit, F_ATTACK_ANY)
       && unit_class_flag(get_unit_class(unit_type(pdefender)), UCF_UNREACHABLE)
-      && !(pcity || tile_has_base_flag(dest_tile, BF_ATTACK_UNREACHABLE))) {
+      && !(pcity || tile_has_native_base(dest_tile, unit_type(pdefender)))) {
     return FALSE;
   }
 
@@ -454,7 +454,7 @@
     }
   }
 
-  if (tile_has_base_flag(ptile, BF_DEFENSE_BONUS) && !pcity) {
+  if (tile_has_base_flag_for_unit(ptile, def_type, BF_DEFENSE_BONUS) && !pcity) {
     defensepower +=
 	(defensepower * terrain_control.fortress_defense_bonus) / 100;
   }
diff -Nurd -X.diff_ignore freeciv/common/movement.c freeciv/common/movement.c
--- freeciv/common/movement.c	2007-02-12 15:27:43.000000000 +0200
+++ freeciv/common/movement.c	2007-03-01 22:19:56.000000000 +0200
@@ -272,14 +272,18 @@
     return TRUE;
   }
 
+  if (tile_has_native_base(ptile, unit_type(punit))) {
+    return TRUE;
+  }
+
   switch (get_unit_move_type(unit_type(punit))) {
   case LAND_MOVING:
   case SEA_MOVING:
     return TRUE;
   case AIR_MOVING:
-    return tile_has_base_flag(punit->tile, BF_REFUEL);
   case HELI_MOVING:
-    return tile_has_base_flag(punit->tile, BF_NO_HP_LOSS);
+    /* FIXME! Should check for fuel and constant HP loss! */
+    return FALSE;
   default:
     die("Invalid move type");
   }
diff -Nurd -X.diff_ignore freeciv/common/tile.c freeciv/common/tile.c
--- freeciv/common/tile.c	2007-02-28 23:02:38.000000000 +0200
+++ freeciv/common/tile.c	2007-03-01 21:39:51.000000000 +0200
@@ -156,6 +156,45 @@
 }
 
 /****************************************************************************
+  Check if tile contains base providing effect for unit
+****************************************************************************/
+bool tile_has_base_flag_for_unit(const struct tile *ptile,
+                                 const struct unit_type *punittype,
+                                 enum base_flag_id flag)
+{
+  struct base_type *pbase;
+
+  pbase = tile_get_base(ptile);
+
+  if (pbase != NULL) {
+    /* Some base at tile, check its flags */
+    return base_flag_affects_unit(punittype, pbase, flag);
+  }
+
+  /* No base at tile */
+  return FALSE;
+}
+
+/****************************************************************************
+  Check if tile contains base native for unit
+****************************************************************************/
+bool tile_has_native_base(const struct tile *ptile,
+                          const struct unit_type *punittype)
+{
+  struct base_type *pbase;
+
+  pbase = tile_get_base(ptile);
+
+  if (pbase != NULL) {
+    /* Some base at tile, check if it's native */
+    return is_native_base(punittype, pbase);
+  }
+
+  /* No base at tile */
+  return FALSE;
+}
+
+/****************************************************************************
   Add the given special or specials to the tile.
 
   Note that this does not erase any existing specials already on the tile
diff -Nurd -X.diff_ignore freeciv/common/tile.h freeciv/common/tile.h
--- freeciv/common/tile.h	2007-02-28 23:02:38.000000000 +0200
+++ freeciv/common/tile.h	2007-03-01 21:32:31.000000000 +0200
@@ -67,6 +67,11 @@
 void tile_add_base(struct tile *ptile, const struct base_type *pbase);
 void tile_remove_base(struct tile *ptile);
 bool tile_has_base_flag(const struct tile *ptile, enum base_flag_id flag);
+bool tile_has_base_flag_for_unit(const struct tile *ptile,
+                                 const struct unit_type *punittype,
+                                 enum base_flag_id flag);
+bool tile_has_native_base(const struct tile *ptile,
+                          const struct unit_type *punittype);
 const struct resource *tile_get_resource(const struct tile *ptile);
 void tile_set_resource(struct tile *ptile, const struct resource *presource);
 void tile_clear_special(struct tile *ptile, enum tile_special_type spe);
diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c	2007-03-01 22:30:18.000000000 +0200
+++ freeciv/common/unit.c	2007-03-01 22:53:12.000000000 +0200
@@ -650,6 +650,8 @@
     return FALSE;
 
   if (tile_has_base_flag(punit->tile, BF_PARADROP_FROM)) {
+    /* Paradrop has to be possible from non-native base.
+     * Paratroopers are "Land" units, but they can paradrom from Airbase. */
     return TRUE;
   }
 
@@ -1209,7 +1211,9 @@
     return FALSE;
   }
   if (is_ground_unit(punit) &&
-      tile_has_base_flag(punit->tile, BF_NOT_AGGRESSIVE)) {
+      tile_has_base_flag_for_unit(punit->tile,
+                                  unit_type(punit),
+                                  BF_NOT_AGGRESSIVE)) {
     return !is_unit_near_a_friendly_city (punit);
   }
   
diff -Nurd -X.diff_ignore freeciv/data/civ1/terrain.ruleset freeciv/data/civ1/terrain.ruleset
--- freeciv/data/civ1/terrain.ruleset	2007-03-01 22:30:18.000000000 +0200
+++ freeciv/data/civ1/terrain.ruleset	2007-03-01 22:02:34.000000000 +0200
@@ -603,12 +603,8 @@
 ;   - "NoAggressive"      = Units inside are not considered aggressive
 ;   - "DefenseBonus"      = Units inside gain defense bonus
 ;   - "NoStackDeath"      = Units inside do not die all at once when attacked
-;   - "Watchtower"        = Units inside see further if required tech known
 ;   - "ClaimTerritory"    = Base will claim land ownership
 ;   - "DiplomatDefense"   = Diplomats inside get bonus to diplomatic defense
-;   - "Refuel"            = Units can refuel at base
-;   - "NoHPLoss"          = Units inside avoid HP loss over time
-;   - "AttackUnreachable" = Unreachable units inside can be attacked
 ;   - "ParadropFrom"      = Paradrop can be initiated from base
 
 [fortress]
@@ -617,7 +613,8 @@
     { "type", "name", "range"
       "Tech", "Construction", "Player"
     }
-flags       = "NoAggressive", "DefenseBonus", "Watchtower", "ClaimTerritory",
+native_to   = "Land"
+flags       = "NoAggressive", "DefenseBonus", "ClaimTerritory",
               "NoStackDeath", "DiplomatDefense"
 
 [airbase]
@@ -626,5 +623,5 @@
     { "type", "name", "range"
       "Tech", "Never", "Player"
     }
-flags       = "NoStackDeath", "DiplomatDefense", "Refuel", "NoHPLoss",
-              "AttackUnreachable", "ParadropFrom"
+native_to   = "Air", "Missile"
+flags       = "NoStackDeath", "DiplomatDefense", "ParadropFrom"
diff -Nurd -X.diff_ignore freeciv/data/civ2/terrain.ruleset freeciv/data/civ2/terrain.ruleset
--- freeciv/data/civ2/terrain.ruleset	2007-03-01 22:30:18.000000000 +0200
+++ freeciv/data/civ2/terrain.ruleset	2007-03-01 22:02:53.000000000 +0200
@@ -695,12 +695,8 @@
 ;   - "NoAggressive"      = Units inside are not considered aggressive
 ;   - "DefenseBonus"      = Units inside gain defense bonus
 ;   - "NoStackDeath"      = Units inside do not die all at once when attacked
-;   - "Watchtower"        = Units inside see further if required tech known
 ;   - "ClaimTerritory"    = Base will claim land ownership
 ;   - "DiplomatDefense"   = Diplomats inside get bonus to diplomatic defense
-;   - "Refuel"            = Units can refuel at base
-;   - "NoHPLoss"          = Units inside avoid HP loss over time
-;   - "AttackUnreachable" = Unreachable units inside can be attacked
 ;   - "ParadropFrom"      = Paradrop can be initiated from base
 
 [fortress]
@@ -709,7 +705,8 @@
     { "type", "name", "range"
       "Tech", "Construction", "Player"
     }
-flags       = "NoAggressive", "DefenseBonus", "Watchtower", "ClaimTerritory",
+native_to   = "Land"
+flags       = "NoAggressive", "DefenseBonus", "ClaimTerritory",
               "NoStackDeath", "DiplomatDefense"
 
 [airbase]
@@ -718,5 +715,5 @@
     { "type", "name", "range"
       "Tech", "Radio", "Player"
     }
-flags       = "NoStackDeath", "DiplomatDefense", "Refuel", "NoHPLoss",
-              "AttackUnreachable", "ParadropFrom"
+native_to   = "Air", "Helicopter", "Missile"
+flags       = "NoStackDeath", "DiplomatDefense", "ParadropFrom"
diff -Nurd -X.diff_ignore freeciv/data/default/terrain.ruleset freeciv/data/default/terrain.ruleset
--- freeciv/data/default/terrain.ruleset	2007-03-01 22:30:18.000000000 +0200
+++ freeciv/data/default/terrain.ruleset	2007-03-01 22:03:07.000000000 +0200
@@ -762,12 +762,8 @@
 ;   - "NoAggressive"      = Units inside are not considered aggressive
 ;   - "DefenseBonus"      = Units inside gain defense bonus
 ;   - "NoStackDeath"      = Units inside do not die all at once when attacked
-;   - "Watchtower"        = Units inside see further if required tech known
 ;   - "ClaimTerritory"    = Base will claim land ownership
 ;   - "DiplomatDefense"   = Diplomats inside get bonus to diplomatic defense
-;   - "Refuel"            = Units can refuel at base
-;   - "NoHPLoss"          = Units inside avoid HP loss over time
-;   - "AttackUnreachable" = Unreachable units inside can be attacked
 ;   - "ParadropFrom"      = Paradrop can be initiated from base
 
 [fortress]
@@ -776,7 +772,8 @@
     { "type", "name", "range"
       "Tech", "Construction", "Player"
     }
-flags       = "NoAggressive", "DefenseBonus", "Watchtower", "ClaimTerritory",
+native_to   = "Land"
+flags       = "NoAggressive", "DefenseBonus", "ClaimTerritory",
               "NoStackDeath", "DiplomatDefense"
 
 [airbase]
@@ -785,5 +782,5 @@
     { "type", "name", "range"
       "Tech", "Radio", "Player"
     }
-flags       = "NoStackDeath", "DiplomatDefense", "Refuel", "NoHPLoss",
-              "AttackUnreachable", "ParadropFrom"
+native_to   = "Air", "Helicopter", "Missile"
+flags       = "NoStackDeath", "DiplomatDefense", "ParadropFrom"
diff -Nurd -X.diff_ignore freeciv/server/airgoto.c freeciv/server/airgoto.c
--- freeciv/server/airgoto.c	2007-01-22 17:18:36.000000000 +0200
+++ freeciv/server/airgoto.c	2007-03-01 22:29:01.000000000 +0200
@@ -63,7 +63,8 @@
   int moves_per_turn;
 } refuels;
 
-static void make_list_of_refuel_points(struct player *pplayer, 
+static void make_list_of_refuel_points(struct player *pplayer,
+                                       const struct unit_type *punittype,
                                        bool cities_only, 
                                        int moves_per_turn, int max_moves);
 
@@ -147,7 +148,8 @@
 matter.
 Can probably do some caching...
 *************************************************************************/
-static void make_list_of_refuel_points(struct player *pplayer, 
+static void make_list_of_refuel_points(struct player *pplayer,
+                                       const struct unit_type *punittype,
                                        bool cities_only, 
                                        int moves_per_turn, 
                                        int max_moves)
@@ -162,7 +164,7 @@
 	&& !is_non_allied_unit_tile(ptile, pplayer) ) {
       add_refuel_point(ptile, FUEL_CITY, 
                        MAP_MAX_HEIGHT + MAP_MAX_WIDTH, 0, FALSE);
-    } else if (tile_has_base_flag(ptile, BF_REFUEL)
+    } else if (tile_has_native_base(ptile, punittype)
                && !is_non_allied_unit_tile(ptile, pplayer)
                && !cities_only) {
       add_refuel_point(ptile, FUEL_AIRBASE, 
@@ -197,6 +199,7 @@
  * max_fuel -- max fuel
  ************************************************************************/
 struct pqueue *refuel_iterate_init(struct player *pplayer,
+                                   const struct unit_type *punittype,
 				   struct tile *ptile,
                                    struct tile *dest_tile,
                                    bool cities_only, int moves_left, 
@@ -208,7 +211,7 @@
 
   /* List of all refuel points of the player!  
    * TODO: Should cache the results */
-  make_list_of_refuel_points(pplayer, cities_only, 
+  make_list_of_refuel_points(pplayer, punittype, cities_only, 
                              moves_per_turn, moves_per_turn * max_fuel);
   /* Add the starting point: we keep it for later backtracking */
   add_refuel_point(ptile, FUEL_START, 0, moves_left, TRUE);
@@ -364,7 +367,7 @@
   unsigned int moves_and_fuel_left 
     = punit->moves_left / SINGLE_MOVE + fullmoves * (punit->fuel - 1);
   struct pqueue *my_list 
-    = refuel_iterate_init(unit_owner(punit), punit->tile, 
+    = refuel_iterate_init(unit_owner(punit), unit_type(punit), punit->tile, 
                           *dest_tile, FALSE, 
                           moves_and_fuel_left, fullmoves, fullfuel);
   struct refuel *next_point;
diff -Nurd -X.diff_ignore freeciv/server/airgoto.h freeciv/server/airgoto.h
--- freeciv/server/airgoto.h	2006-08-18 10:51:27.000000000 +0300
+++ freeciv/server/airgoto.h	2007-03-01 22:28:27.000000000 +0200
@@ -22,7 +22,9 @@
 struct tile *get_refuel_tile(struct refuel *pRefuel);
 unsigned int get_turns_to_refuel(struct refuel *pRefuel);
 
-struct pqueue *refuel_iterate_init(struct player *pplayer, struct tile *ptile,
+struct pqueue *refuel_iterate_init(struct player *pplayer,
+                                   const struct unit_type *punittype,
+                                   struct tile *ptile,
 				   struct tile *dst_tile,
                                    bool cities_only, int moves_left, 
                                    int moves_per_turn, int max_moves);
diff -Nurd -X.diff_ignore freeciv/server/citytools.c freeciv/server/citytools.c
--- freeciv/server/citytools.c	2007-02-28 23:02:37.000000000 +0200
+++ freeciv/server/citytools.c	2007-03-01 21:57:09.000000000 +0200
@@ -927,6 +927,7 @@
   struct city *pcity;
   int x_itr, y_itr;
   struct nation_type *nation = get_nation_by_plr(pplayer);
+  struct base_type *pbase;
 
   freelog(LOG_DEBUG, "Creating city %s", name);
 
@@ -1008,7 +1009,8 @@
   auto_arrange_workers(pcity);
 
   /* Put vision back to normal, if base acted as a watchtower */
-  if (tile_has_base_flag(ptile, BF_WATCHTOWER)) {
+  pbase = tile_get_base(ptile);
+  if (pbase) {
     tile_remove_base(ptile);
     unit_list_refresh_vision(ptile->units);
   }
diff -Nurd -X.diff_ignore freeciv/server/diplomats.c freeciv/server/diplomats.c
--- freeciv/server/diplomats.c	2007-01-22 17:18:36.000000000 +0200
+++ freeciv/server/diplomats.c	2007-03-01 22:01:36.000000000 +0200
@@ -1046,7 +1046,8 @@
     chance -= chance * get_city_bonus(pdefender_tile->city,
                                       EFT_SPY_RESISTANT) / 100;
   } else {
-    if (tile_has_base_flag(pdefender_tile, BF_DIPLOMAT_DEFENSE)) {
+    if (tile_has_base_flag_for_unit(pdefender_tile, unit_type(pdefender),
+                                    BF_DIPLOMAT_DEFENSE)) {
 	chance -= chance * 25 / 100; /* 25% penalty */
     }
   }
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c	2007-03-01 22:30:18.000000000 +0200
+++ freeciv/server/ruleset.c	2007-03-01 21:16:15.000000000 +0200
@@ -1802,6 +1802,22 @@
     reqs = lookup_req_list(file, section, "reqs");
     requirement_vector_copy(&pbase->reqs, reqs);
 
+    slist = secfile_lookup_str_vec(file, &nval, "%s.native_to", section);
+    BV_CLR_ALL(pbase->native_to);
+    for (j = 0; j < nval; j++) {
+      struct unit_class *class = unit_class_from_str(slist[j]);
+
+      if (!class) {
+        /* TRANS: message for an obscure ruleset error. */
+        freelog(LOG_FATAL, _("Base %s is native to unknown unit class %s"),
+                pbase->name, slist[j]);
+        exit(EXIT_FAILURE);
+      } else {
+        BV_SET(pbase->native_to, class->id);
+      }
+    }
+    free(slist);
+
     slist = secfile_lookup_str_vec(file, &nval, "%s.flags", section);
     BV_CLR_ALL(pbase->flags);
     for (j = 0; j < nval; j++) {
diff -Nurd -X.diff_ignore freeciv/server/unithand.c freeciv/server/unithand.c
--- freeciv/server/unithand.c	2007-02-12 15:27:37.000000000 +0200
+++ freeciv/server/unithand.c	2007-03-01 21:50:27.000000000 +0200
@@ -700,7 +700,7 @@
     }
 
     if (!is_air_unit(pdefender)
-	|| (pcity || tile_has_base_flag(ptile, BF_ATTACK_UNREACHABLE))) {
+	|| (pcity || tile_has_native_base(ptile, unit_type(pdefender)))) {
       see_combat(punit, pdefender);
 
       unit_versus_unit(punit, pdefender, TRUE);
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c	2007-02-28 23:02:37.000000000 +0200
+++ freeciv/server/unittools.c	2007-03-01 22:24:37.000000000 +0200
@@ -478,7 +478,7 @@
   /* Bonus recovery HP (traditionally from the United Nations) */
   punit->hp += get_unit_bonus(punit, EFT_UNIT_RECOVER);
 
-  if (!pcity && !tile_has_base_flag(punit->tile, BF_NO_HP_LOSS)
+  if (!pcity && !tile_has_native_base(punit->tile, unit_type(punit))
       && punit->transported_by == -1) {
     punit->hp -= unit_type(punit)->hp * class->hp_loss_pct / 100;
   }
@@ -1206,7 +1206,8 @@
 {
   return (punit->transported_by != -1                   /* Carrier */
           || punit->tile->city                          /* City    */
-          || tile_has_base_flag(punit->tile, BF_REFUEL)); /* Airbase */
+          || tile_has_native_base(punit->tile,
+                                  unit_type(punit))); /* Airbase */
 }
 
 /**************************************************************************
@@ -1222,7 +1223,7 @@
 
   if ((is_allied_city_tile(ptile, pplayer)
        && !is_non_allied_unit_tile(ptile, pplayer))
-      || ((pbase != NULL && base_flag(pbase, BF_REFUEL))
+      || ((pbase != NULL && is_native_base(type, pbase))
 	  && !is_non_allied_unit_tile(ptile, pplayer)))
     return TRUE;
 
@@ -2642,10 +2643,14 @@
     if (homecity) {
       if ((game.info.happyborders > 0 && src_tile->owner != dst_tile->owner)
           ||
-	  (tile_has_base_flag(dst_tile, BF_NOT_AGGRESSIVE)
+	  (tile_has_base_flag_for_unit(dst_tile,
+                                       unit_type(punit),
+                                       BF_NOT_AGGRESSIVE)
 	   && is_friendly_city_near(unit_owner(punit), dst_tile))
 	  ||
-          (tile_has_base_flag(src_tile, BF_NOT_AGGRESSIVE)
+          (tile_has_base_flag_for_unit(src_tile,
+                                       unit_type(punit),
+                                       BF_NOT_AGGRESSIVE)
 	   && is_friendly_city_near(unit_owner(punit), src_tile))) {
         refresh_homecity = TRUE;
       }
@@ -2770,7 +2775,8 @@
   } vision_layer_iterate_end;
 
   /* Claim ownership of fortress? */
-  if (tile_has_base_flag(pdesttile, BF_CLAIM_TERRITORY)
+  if (tile_has_base_flag_for_unit(pdesttile, unit_type(punit),
+                                  BF_CLAIM_TERRITORY)
       && (!pdesttile->owner || pplayers_at_war(pdesttile->owner, pplayer))) {
     map_claim_ownership(pdesttile, pplayer, pdesttile);
   }
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to