Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] (PR#14277) unitclass req and merge of defend types
Home

[Freeciv-Dev] (PR#14277) unitclass req and merge of defend types

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#14277) unitclass req and merge of defend types
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Oct 2005 10:37:05 -0700
Reply-to: bugs@xxxxxxxxxxx

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

> [jdorje - Wed Oct 12 05:17:17 2005]:

> 2.  Merges the defend types (Sea_Defend, etc.) into one effect 
> Defend_Bonus (which of course uses the unitclass req).  The AI changes 
> here are...tricky.

Here's an updated patch.

The AI may be made slightly stupider by this change...but then again it
might instead be slighly smarter.  It should probably get a closer
inspection, but I'd like to commit this patch shortly regardless.

-jason

Index: doc/README.effects
===================================================================
--- doc/README.effects  (revision 11123)
+++ doc/README.effects  (working copy)
@@ -88,6 +88,9 @@
 
 "Incite_Cost_Pct" - increases revolt cost by AMOUNT percent
 
+"Defend_Bonus"  - Increases defensive bonuses of units.  Any unit requirements
+                  on this effect will be applied to the _attacking_ unit.
+
 "Size_Adj"      - Increases maximum city size by AMOUNT
 
 "Size_Unlimit" - Removes maximum city size limitation
Index: server/gotohand.c
===================================================================
--- server/gotohand.c   (revision 11120)
+++ server/gotohand.c   (working copy)
@@ -1017,12 +1017,9 @@
      */
     defence_multiplier = 2;
     if (pcity) {
-      /* This isn't very accurate. */
-      defence_multiplier += (get_city_bonus(pcity, EFT_LAND_DEFEND)
-                            + get_city_bonus(pcity, EFT_MISSILE_DEFEND)
-                            + get_city_bonus(pcity, EFT_AIR_DEFEND)
-                            + get_city_bonus(pcity, EFT_SEA_DEFEND)) / 100;
+      defence_multiplier += get_city_bonus(pcity, EFT_DEFEND_BONUS) / 100;
     }
+    defence_multiplier = MAX(1, defence_multiplier); /* no division by 0 */
 
     /* 
      * Find the best ally unit at the target tile.
Index: data/civ1/effects.ruleset
===================================================================
--- data/civ1/effects.ruleset   (revision 11120)
+++ data/civ1/effects.ruleset   (working copy)
@@ -433,23 +433,26 @@
     }
 
 [effect_city_walls]
-name   = "Land_Defend"
+name   = "Defend_Bonus"
 value  = 200
 reqs   =
     { "type", "name", "range"
       "Building", "City Walls", "City"
+      "UnitClass", "Land", "Local"
     }
 nreqs  =
     { "type", "name", "range"
       "Building", "Great Wall", "Player"
     }
+; No helicoptors in civ1
 
 [effect_city_walls_1]
-name   = "Sea_Defend"
+name   = "Defend_Bonus"
 value  = 200
 reqs   =
     { "type", "name", "range"
       "Building", "City Walls", "City"
+      "UnitClass", "Sea", "Local"
     }
 nreqs  =
     { "type", "name", "range"
@@ -820,19 +823,21 @@
     }
 
 [effect_great_wall]
-name   = "Land_Defend"
+name   = "Defend_Bonus"
 value  = 200
 reqs   =
     { "type", "name", "range"
       "Building", "Great Wall", "Player"
+      "UnitClass", "Land", "Local"
     }
 
 [effect_great_wall_1]
-name   = "Sea_Defend"
+name   = "Defend_Bonus"
 value  = 200
 reqs   =
     { "type", "name", "range"
       "Building", "Great Wall", "Player"
+      "UnitClass", "Sea", "Local"
     }
 
 [effect_hanging_gardens]
Index: data/civ2/effects.ruleset
===================================================================
--- data/civ2/effects.ruleset   (revision 11120)
+++ data/civ2/effects.ruleset   (working copy)
@@ -541,17 +541,31 @@
     }
 
 [effect_city_walls]
-name   = "Land_Defend"
+name   = "Defend_Bonus"
 value  = 200
 reqs   =
     { "type", "name", "range"
       "Building", "City Walls", "City"
+      "UnitClass", "Land", "Local"
     }
 nreqs  =
     { "type", "name", "range"
       "Building", "Great Wall", "Player"
     }
 
+[effect_city_walls]
+name   = "Defend_Bonus"
+value  = 200
+reqs   =
+    { "type", "name", "range"
+      "Building", "City Walls", "City"
+      "UnitClass", "Helicopter", "Local"
+    }
+nreqs  =
+    { "type", "name", "range"
+      "Building", "Great Wall", "Player"
+    }
+
 [effect_city_walls_1]
 name   = "Unit_No_Lose_Pop"
 value  = 1
@@ -561,11 +575,12 @@
     }
 
 [effect_coastal_defense]
-name   = "Sea_Defend"
+name   = "Defend_Bonus"
 value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "Coastal Defense", "City"
+      "UnitClass", "Sea", "Local"
     }
 
 [effect_colosseum]
@@ -938,11 +953,12 @@
     }
 
 [effect_sam_battery]
-name   = "Air_Defend"
+name   = "Defend_Bonus"
 value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "SAM Battery", "City"
+      "UnitClass", "Air", "Local"
     }
 
 [effect_sdi_defense]
@@ -954,11 +970,12 @@
     }
 
 [effect_sdi_defense_1]
-name   = "Missile_Defend"
+name   = "Defend_Bonus"
 value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "SDI Defense", "City"
+      "UnitClass", "Missile", "Local"
     }
 
 [effect_sewer_system]
@@ -1128,13 +1145,23 @@
     }
 
 [effect_great_wall]
-name   = "Land_Defend"
+name   = "Defend_Bonus"
 value  = 200
 reqs   =
     { "type", "name", "range"
       "Building", "Great Wall", "Player"
+      "UnitClass", "Land", "Local"
     }
 
+[effect_great_wall]
+name   = "Defend_Bonus"
+value  = 200
+reqs   =
+    { "type", "name", "range"
+      "Building", "Great Wall", "Player"
+      "UnitClass", "Helicopter", "Local"
+    }
+
 [effect_great_wall_1]
 name   = "Unit_No_Lose_Pop"
 value  = 1
Index: data/default/effects.ruleset
===================================================================
--- data/default/effects.ruleset        (revision 11120)
+++ data/default/effects.ruleset        (working copy)
@@ -540,17 +540,31 @@
     }
 
 [effect_city_walls]
-name   = "Land_Defend"
+name   = "Defend_Bonus"
 value  = 200
 reqs   =
     { "type", "name", "range"
       "Building", "City Walls", "City"
+      "UnitClass", "Land", "Local"
     }
 nreqs  =
     { "type", "name", "range"
       "Building", "Great Wall", "Player"
     }
 
+[effect_city_walls]
+name   = "Defend_Bonus"
+value  = 200
+reqs   =
+    { "type", "name", "range"
+      "Building", "City Walls", "City"
+      "UnitClass", "Helicopter", "Local"
+    }
+nreqs  =
+    { "type", "name", "range"
+      "Building", "Great Wall", "Player"
+    }
+
 [effect_city_walls_1]
 name   = "Unit_No_Lose_Pop"
 value  = 1
@@ -560,11 +574,12 @@
     }
 
 [effect_coastal_defense]
-name   = "Sea_Defend"
+name   = "Defend_Bonus"
 value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "Coastal Defense", "City"
+      "UnitClass", "Sea", "Local"
     }
 
 [effect_colosseum]
@@ -968,11 +983,12 @@
     }
 
 [effect_sam_battery]
-name   = "Air_Defend"
+name   = "Defend_Bonus"
 value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "SAM Battery", "City"
+      "UnitClass", "Air", "Local"
     }
 
 [effect_sdi_defense]
@@ -984,11 +1000,12 @@
     }
 
 [effect_sdi_defense_1]
-name   = "Missile_Defend"
+name   = "Defend_Bonus"
 value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "SDI Defense", "City"
+      "UnitClass", "Missile", "Local"
     }
 
 [effect_sewer_system]
@@ -1190,13 +1207,23 @@
     }
 
 [effect_great_wall]
-name   = "Land_Defend"
+name   = "Defend_Bonus"
 value  = 200
 reqs   =
     { "type", "name", "range"
       "Building", "Great Wall", "Player"
+      "UnitClass", "Land", "Local"
     }
 
+[effect_great_wall]
+name   = "Defend_Bonus"
+value  = 200
+reqs   =
+    { "type", "name", "range"
+      "Building", "Great Wall", "Player"
+      "UnitClass", "Helicopter", "Local"
+    }
+
 [effect_great_wall_1]
 name   = "Unit_No_Lose_Pop"
 value  = 1
Index: data/history/effects.ruleset
===================================================================
--- data/history/effects.ruleset        (revision 11120)
+++ data/history/effects.ruleset        (working copy)
@@ -206,17 +206,31 @@
     }
 
 [effect_city_walls]
-name   = "Land_Defend"
+name   = "Defend_Bonus"
 value  = 200
 reqs   =
     { "type", "name", "range"
       "Building", "City Walls", "City"
+      "UnitClass", "Land", "Local"
     }
 nreqs  =
     { "type", "name", "range"
       "Building", "Great Wall", "Player"
     }
 
+[effect_city_walls]
+name   = "Defend_Bonus"
+value  = 200
+reqs   =
+    { "type", "name", "range"
+      "Building", "City Walls", "City"
+      "UnitClass", "Helicopter", "Local"
+    }
+nreqs  =
+    { "type", "name", "range"
+      "Building", "Great Wall", "Player"
+    }
+
 [effect_city_walls_1]
 name   = "Unit_No_Lose_Pop"
 value  = 1
@@ -226,11 +240,12 @@
     }
 
 [effect_coastal_defense]
-name   = "Sea_Defend"
+name   = "Defend_Bonus"
 value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "Coastal Defense", "City"
+      "UnitClass", "Sea", "Local"
     }
 
 [effect_colosseum]
@@ -597,11 +612,12 @@
     }
 
 [effect_sam_battery]
-name   = "Air_Defend"
+name   = "Defend_Bonus"
 value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "SAM Battery", "City"
+      "UnitClass", "Air", "Local"
     }
 
 [effect_sdi_defense]
@@ -613,11 +629,12 @@
     }
 
 [effect_sdi_defense_1]
-name   = "Missile_Defend"
+name   = "Defend_Bonus"
 value  = 100
 reqs   =
     { "type", "name", "range"
       "Building", "SDI Defense", "City"
+      "UnitClass", "Missile", "Local"
     }
 
 [effect_sewer_system]
@@ -787,13 +804,23 @@
     }
 
 [effect_great_wall]
-name   = "Land_Defend"
+name   = "Defend_Bonus"
 value  = 200
 reqs   =
     { "type", "name", "range"
       "Building", "Great Wall", "Player"
+      "UnitClass", "Land", "Local"
     }
 
+[effect_great_wall]
+name   = "Defend_Bonus"
+value  = 200
+reqs   =
+    { "type", "name", "range"
+      "Building", "Great Wall", "Player"
+      "UnitClass", "Helicopter", "Local"
+    }
+
 [effect_great_wall_1]
 name   = "Unit_No_Lose_Pop"
 value  = 1
Index: common/combat.c
===================================================================
--- common/combat.c     (revision 11120)
+++ common/combat.c     (working copy)
@@ -258,8 +258,8 @@
   }
 
   if (unit_flag(attacker, F_BADWALLATTACKER)
-      && pcity 
-      && get_city_bonus(pcity, EFT_LAND_DEFEND) > 0) {
+      && get_combat_bonus(defender->tile, attacker->type,
+                         EFT_DEFEND_BONUS) > 0) {
     *att_fp = 1;
   }
 
@@ -451,26 +451,12 @@
        (is_air_unittype(att_type) || is_heli_unittype(att_type))) {
       defensepower *= 5;
     }
-         
-    if (is_air_unittype(att_type) && pcity) {
-      if ((mod = get_city_bonus(pcity, EFT_AIR_DEFEND)) > 0) {
-       defensepower = defensepower * (100 + mod) / 100;
-      }
-      if ((mod = get_city_bonus(pcity, EFT_MISSILE_DEFEND)) > 0
-         && unit_type_flag(att_type, F_MISSILE)) {
-       defensepower = defensepower * (100 + mod) / 100;
-      }
-    } else if (is_sailing_unittype(att_type) && pcity) {
-      if ((mod = get_city_bonus(pcity, EFT_SEA_DEFEND)) > 0) {
-       defensepower = defensepower * (100 + mod) / 100;
-      }
+
+    if (!unit_type_flag(att_type, F_IGWALL)) {
+      /* This applies even if pcity is NULL. */
+      mod = 100 + get_combat_bonus(ptile, att_type, EFT_DEFEND_BONUS);
+      defensepower = MAX(0, defensepower * mod / 100);
     }
-    if (!unit_type_flag(att_type, F_IGWALL)
-       && (is_ground_unittype(att_type) || is_heli_unittype(att_type))
-        && pcity
-        && (mod = get_city_bonus(pcity, EFT_LAND_DEFEND)) > 0) {
-      defensepower = defensepower * (100 + mod) / 100;
-    }
 
     if (unit_type_flag(att_type, F_FIGHTER) && is_heli_unittype(def_type)) {
       defensepower /= 2;
Index: common/city.c
===================================================================
--- common/city.c       (revision 11120)
+++ common/city.c       (working copy)
@@ -971,7 +971,7 @@
 **************************************************************************/
 bool city_got_citywalls(const struct city *pcity)
 {
-  return (get_city_bonus(pcity, EFT_LAND_DEFEND) > 0);
+  return (get_city_bonus(pcity, EFT_DEFEND_BONUS) > 0);
 }
 
 /**************************************************************************
Index: common/effects.c
===================================================================
--- common/effects.c    (revision 11123)
+++ common/effects.c    (working copy)
@@ -96,10 +96,7 @@
   "Sea_Regen",
   "Air_Regen",
   "City_Vision_Radius_Sq",
-  "Land_Defend",
-  "Sea_Defend",
-  "Air_Defend",
-  "Missile_Defend",
+  "Defend_Bonus",
   "No_Incite",
   "Gain_AI_Love",
   "Slow_Down_Timeline",
@@ -830,6 +827,26 @@
 }
 
 /**************************************************************************
+  Returns the effect bonus that applies at a tile for a given unittype.
+
+  For instance with EFT_DEFEND_BONUS the attacker's unittype and the
+  defending tile should be passed in.  Slightly counter-intuitive!
+  See doc/README.effects to see how the unittype applies for each effect
+  here.
+**************************************************************************/
+int get_combat_bonus(const struct tile *pdefender,
+                    const struct unit_type *pattacker,
+                    enum effect_type effect_type)
+{
+  struct player *pplayer = pdefender->city ? pdefender->city->owner : NULL;
+
+  assert(pdefender != NULL && pattacker != NULL);
+  return get_target_bonus_effects(NULL,
+                                 pplayer, pdefender->city, NULL, pdefender,
+                                 pattacker, NULL, NULL, effect_type);
+}
+
+/**************************************************************************
   Returns the effect bonus at a building.
 **************************************************************************/
 int get_unit_bonus(const struct unit *punit, enum effect_type effect_type)
Index: common/effects.h
===================================================================
--- common/effects.h    (revision 11123)
+++ common/effects.h    (working copy)
@@ -84,10 +84,7 @@
   EFT_SEA_REGEN,
   EFT_AIR_REGEN,
   EFT_CITY_VISION_RADIUS_SQ,
-  EFT_LAND_DEFEND,
-  EFT_SEA_DEFEND,
-  EFT_AIR_DEFEND,
-  EFT_MISSILE_DEFEND,
+  EFT_DEFEND_BONUS,
   EFT_NO_INCITE,
   EFT_GAIN_AI_LOVE,
   EFT_SLOW_DOWN_TIMELINE,
@@ -183,6 +180,9 @@
                               enum effect_type effect_type);
 int get_building_bonus(const struct city *pcity, Impr_type_id building,
                       enum effect_type effect_type);
+int get_combat_bonus(const struct tile *pdefender,
+                    const struct unit_type *pattacker,
+                    enum effect_type effect_type);
 int get_unit_bonus(const struct unit *punit, enum effect_type effect_type);
 
 /* miscellaneous auxiliary effects functions */
Index: ai/advdiplomacy.c
===================================================================
--- ai/advdiplomacy.c   (revision 11120)
+++ ai/advdiplomacy.c   (working copy)
@@ -652,8 +652,7 @@
     want += pcity->size * 20;
     want += pcity->surplus[O_SHIELD] * 8;
     want += pcity->surplus[O_TRADE] * 6;
-    fear += get_city_bonus(pcity, EFT_LAND_DEFEND);
-    fear += get_city_bonus(pcity, EFT_SEA_DEFEND);
+    fear += get_city_bonus(pcity, EFT_DEFEND_BONUS);
     built_impr_iterate(pcity, id) {
       want += impr_build_shield_cost(id);
       if (is_great_wonder(id)) {
Index: ai/aicity.c
===================================================================
--- ai/aicity.c (revision 11120)
+++ ai/aicity.c (working copy)
@@ -580,7 +580,7 @@
            v *= 4;
          }
          break;
-       case EFT_SEA_DEFEND:
+       case EFT_DEFEND_BONUS:
          if (ai_handicap(pplayer, H_DEFENSIVE)) {
            v += amount / 10; /* make AI slow */
          }
@@ -598,34 +598,16 @@
            } adjc_iterate_end;
          }
          v += (amount/20 + ai->threats.invasions - 1) * c; /* for wonder */
-         if (capital && ai->threats.invasions) {
-           v += amount; /* defend capital! */
-         }
-         break;
-       case EFT_AIR_DEFEND:
-         if (ai_handicap(pplayer, H_DEFENSIVE)) {
-           v += amount / 15; /* make AI slow */
-         }
-         v += (ai->threats.air && ai->threats.continent[ptile->continent]) 
-           ? amount/10 * 5 + amount/10 * c : c;
-         break;
-       case EFT_MISSILE_DEFEND:
-         if (ai->threats.missile
-             && (ai->threats.continent[ptile->continent] || capital)) {
-           v += amount/10 * 5 + (amount/10 - 1) * c;
-         }
-         break;
-       case EFT_LAND_DEFEND:
-         if (ai_handicap(pplayer, H_DEFENSIVE)) {
-           v += amount / 10; /* make AI slow */
-         }
          if (ai->threats.continent[ptile->continent]
              || capital
              || (ai->threats.invasions
-               && is_water_adjacent_to_tile(pcity->tile))) {
-           v += amount / (!ai->threats.igwall ? (15 - capital * 5) : 15);
+                 && is_water_adjacent_to_tile(pcity->tile))) {
+           if (ai->threats.continent[ptile->continent]) {
+             v += amount;
+           } else {
+             v += amount / (!ai->threats.igwall ? (15 - capital * 5) : 15);
+           }
          }
-         v += (1 + ai->threats.invasions + !ai->threats.igwall) * c;
          break;
        case EFT_NO_INCITE:
          if (get_city_bonus(pcity, EFT_NO_INCITE) <= 0) {
@@ -1069,7 +1051,7 @@
 {
   impr_type_iterate(id) {
     if (can_city_sell_building(pcity, id)
-       && !building_has_effect(id, EFT_LAND_DEFEND)) {
+       && !building_has_effect(id, EFT_DEFEND_BONUS)) {
 /* selling walls to buy defenders is counterproductive -- Syela */
       really_handle_city_sell(pplayer, pcity, id);
       break;
@@ -1363,7 +1345,7 @@
 
   built_impr_iterate(pcity, i) {
     if(can_city_sell_building(pcity, i) 
-       && !building_has_effect(i, EFT_LAND_DEFEND)
+       && !building_has_effect(i, EFT_DEFEND_BONUS)
              /* selling city walls is really, really dumb -- Syela */
        && (is_building_replaced(pcity, i)
           || building_unwanted(city_owner(pcity), i))) {
Index: ai/advmilitary.c
===================================================================
--- ai/advmilitary.c    (revision 11120)
+++ ai/advmilitary.c    (working copy)
@@ -326,6 +326,7 @@
 {
   unsigned int danger;
   bool sailing;
+  int mod;
 
   if (unit_flag(punit, F_NO_LAND_ATTACK)) return 0;
 
@@ -335,12 +336,8 @@
   }
 
   danger = unit_att_rating(punit);
-  if (sailing && get_city_bonus(pcity, EFT_SEA_DEFEND) > 0) {
-    danger /= 2;
-  }
-  if (is_air_unit(punit) && get_city_bonus(pcity, EFT_AIR_DEFEND) > 0) {
-    danger /= 2;
-  }
+  mod = 100 + get_combat_bonus(pcity->tile, punit->type, EFT_DEFEND_BONUS);
+  danger = danger * 100 / MAX(mod, 1);
 
   return danger;
 }
@@ -453,7 +450,7 @@
 static unsigned int assess_danger(struct city *pcity)
 {
   int i;
-  int danger[5], defender[4];
+  int danger[5], defender;
   struct player *pplayer = city_owner(pcity);
   bool pikemen = FALSE;
   unsigned int urgency = 0;
@@ -572,30 +569,12 @@
 
   /* HACK: This needs changing if multiple improvements provide
    * this effect. */
-  defender[0] = ai_find_source_building(pplayer, EFT_LAND_DEFEND);
-  defender[1] = ai_find_source_building(pplayer, EFT_SEA_DEFEND);
-  defender[2] = ai_find_source_building(pplayer, EFT_AIR_DEFEND);
-  defender[3] = ai_find_source_building(pplayer, EFT_MISSILE_DEFEND);
+  defender = ai_find_source_building(pplayer, EFT_DEFEND_BONUS);
 
-  if (defender[0] != B_LAST) {
-    ai_reevaluate_building(pcity, &pcity->ai.building_want[defender[0]],
-       urgency, danger[1], assess_defense(pcity));
+  if (defender != B_LAST) {
+    ai_reevaluate_building(pcity, &pcity->ai.building_want[defender],
+       urgency, danger[1], assess_defense_igwall(pcity));
   }
-  if (defender[1] != B_LAST) {
-    ai_reevaluate_building(pcity, &pcity->ai.building_want[defender[1]],
-       urgency, danger[2], 
-       assess_defense_igwall(pcity));
-  }
-  if (defender[2] != B_LAST) {
-    ai_reevaluate_building(pcity, &pcity->ai.building_want[defender[2]],
-       urgency, danger[3], 
-       assess_defense_igwall(pcity));
-  }
-  if (defender[3] != B_LAST) {
-    ai_reevaluate_building(pcity, &pcity->ai.building_want[defender[3]],
-       urgency, danger[4], 
-       assess_defense_igwall(pcity));
-  }
 
   pcity->ai.danger = danger[0];
   pcity->ai.urgency = urgency;
@@ -1290,7 +1269,7 @@
   /* Otherwise no need to defend yet */
   if (pcity->ai.danger != 0) { 
     int num_defenders = unit_list_size(ptile->units);
-    int land_id, sea_id, air_id, danger;
+    int wall_id, danger;
 
     /* First determine the danger.  It is measured in percents of our 
      * defensive strength, capped at 200 + urgency */
@@ -1322,55 +1301,25 @@
 
     /* HACK: This needs changing if multiple improvements provide
      * this effect. */
-    land_id = ai_find_source_building(pplayer, EFT_LAND_DEFEND);
-    sea_id = ai_find_source_building(pplayer, EFT_SEA_DEFEND);
-    air_id = ai_find_source_building(pplayer, EFT_AIR_DEFEND);
+    wall_id = ai_find_source_building(pplayer, EFT_DEFEND_BONUS);
 
-    if (land_id != B_LAST
-       && pcity->ai.building_want[land_id] != 0 && our_def != 0 
-        && can_build_improvement(pcity, land_id)
+    if (wall_id != B_LAST
+       && pcity->ai.building_want[wall_id] != 0 && our_def != 0 
+        && can_build_improvement(pcity, wall_id)
         && (danger < 101 || num_defenders > 1
             || (pcity->ai.grave_danger == 0 
                 && pplayer->economic.gold > (80 - pcity->shield_stock) * 2)) 
         && ai_fuzzy(pplayer, TRUE)) {
       /* NB: great wall is under domestic */
-      choice->choice = land_id;
+      choice->choice = wall_id;
       /* building_want is hacked by assess_danger */
-      choice->want = pcity->ai.building_want[land_id];
+      choice->want = pcity->ai.building_want[wall_id];
       if (urgency == 0 && choice->want > 100) {
         choice->want = 100;
       }
       choice->type = CT_BUILDING;
-      CITY_LOG(LOG_DEBUG, pcity, "m_a_c_d wants land defense building with %d",
+      CITY_LOG(LOG_DEBUG, pcity, "m_a_c_d wants defense building with %d",
                choice->want);
-    } else if (sea_id != B_LAST
-              && pcity->ai.building_want[sea_id] != 0 && our_def != 0 
-               && can_build_improvement(pcity, sea_id) 
-               && (danger < 101 || num_defenders > 1) 
-               && ai_fuzzy(pplayer, TRUE)) {
-      choice->choice = sea_id;
-      /* building_want is hacked by assess_danger */
-      choice->want = pcity->ai.building_want[sea_id];
-      if (urgency == 0 && choice->want > 100) {
-        choice->want = 100;
-      }
-      choice->type = CT_BUILDING;
-      CITY_LOG(LOG_DEBUG, pcity, "m_a_c_d wants sea defense building with %d",
-               choice->want);
-    } else if (air_id != B_LAST
-              && pcity->ai.building_want[air_id] != 0 && our_def != 0 
-               && can_build_improvement(pcity, air_id) 
-               && (danger < 101 || num_defenders > 1) 
-               && ai_fuzzy(pplayer, TRUE)) {
-      choice->choice = air_id;
-      /* building_want is hacked by assess_danger */
-      choice->want = pcity->ai.building_want[air_id];
-      if (urgency == 0 && choice->want > 100) {
-        choice->want = 100;
-      }
-      choice->type = CT_BUILDING;
-      CITY_LOG(LOG_DEBUG, pcity, "m_a_c_d wants air defense building with %d",
-               choice->want);
     } else if (danger > 0 && num_defenders <= urgency) {
       /* Consider building defensive units units */
       process_defender_want(pplayer, pcity, danger, choice);

[Prev in Thread] Current Thread [Next in Thread]