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

 count_my_units() determines where units can move from cached values
instead of move_type.
 stats.units.air field is renamed as more generic(?) stats.units.amphibious.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aicity.c freeciv/ai/aicity.c
--- freeciv/ai/aicity.c	2007-03-05 21:11:52.000000000 +0200
+++ freeciv/ai/aicity.c	2007-03-06 05:57:50.000000000 +0200
@@ -510,7 +510,7 @@
   case EFT_MOVE_BONUS:
     /* FIXME: check other reqs (e.g., unitclass) */
     v += (8 * v * amount + ai->stats.units.land
-	  + ai->stats.units.sea + ai->stats.units.air);
+	  + ai->stats.units.sea + ai->stats.units.amphibious);
     break;
   case EFT_UNIT_NO_LOSE_POP:
     v += unit_list_size(pcity->tile->units) * 2;
@@ -518,17 +518,17 @@
   case EFT_HP_REGEN:
     /* FIXME: check other reqs (e.g., unitclass) */
     v += (5 * c + ai->stats.units.land
-	  + ai->stats.units.sea + ai->stats.units.air);
+	  + ai->stats.units.sea + ai->stats.units.amphibious);
     break;
   case EFT_VETERAN_COMBAT:
     /* FIXME: check other reqs (e.g., unitclass) */
     v += (2 * c + ai->stats.units.land + ai->stats.units.sea
-	  + ai->stats.units.air);
+	  + ai->stats.units.amphibious);
     break;
   case EFT_VETERAN_BUILD:
     /* FIXME: check other reqs (e.g., unitclass, unitflag) */
     v += (3 * c + ai->stats.units.land + ai->stats.units.sea
-	  + ai->stats.units.air);
+	  + ai->stats.units.amphibious);
     break;
   case EFT_UPGRADE_UNIT:
     v += ai->stats.units.upgradeable;
diff -Nurd -X.diff_ignore freeciv/ai/aidata.c freeciv/ai/aidata.c
--- freeciv/ai/aidata.c	2007-03-05 21:11:52.000000000 +0200
+++ freeciv/ai/aidata.c	2007-03-06 05:54:36.000000000 +0200
@@ -186,20 +186,18 @@
   memset(&ai->stats.units, 0, sizeof(ai->stats.units));
 
   unit_list_iterate(pplayer->units, punit) {
-    switch (get_unit_move_type(unit_type(punit))) {
-    case LAND_MOVING:
+    struct unit_class *pclass = get_unit_class(unit_type(punit));
+
+    if (pclass->ai.land_move != MOVE_NONE
+        && pclass->ai.sea_move != MOVE_NONE) {
+      /* Can move both land and ocean */
+      ai->stats.units.amphibious++;
+    } else if (pclass->ai.land_move != MOVE_NONE) {
+      /* Can move only at land */
       ai->stats.units.land++;
-      break;
-    case SEA_MOVING:
+    } else if (pclass->ai.sea_move != MOVE_NONE) {
+      /* Can move only at sea */
       ai->stats.units.sea++;
-      break;
-    case HELI_MOVING:
-    case AIR_MOVING:
-      ai->stats.units.air++;
-      break;
-    default:
-      freelog(LOG_ERROR, "Illegal move type in count_my_units()!");
-      break;
     }
 
     if (unit_flag(punit, F_TRIREME)) {
diff -Nurd -X.diff_ignore freeciv/ai/aidata.h freeciv/ai/aidata.h
--- freeciv/ai/aidata.h	2007-03-05 21:11:52.000000000 +0200
+++ freeciv/ai/aidata.h	2007-03-06 05:56:08.000000000 +0200
@@ -111,8 +111,8 @@
       /* Unit-flag counts. */
       int triremes, missiles;
 
-      /* Move-type counts (air includes helicoptor here). */
-      int land, sea, air;
+      /* Move-type counts */
+      int land, sea, amphibious;
 
       /* Upgradeable units */
       int upgradeable;
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to