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

 Instead of checking move_type AIR_MOVING, check for class properties
in aiair code.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aiair.c freeciv/ai/aiair.c
--- freeciv/ai/aiair.c	2007-03-06 03:34:32.000000000 +0200
+++ freeciv/ai/aiair.c	2007-03-08 17:08:07.000000000 +0200
@@ -395,7 +395,13 @@
   }
 
   unit_type_iterate(punittype) {
-    if (get_unit_move_type(punittype) != AIR_MOVING) {
+    struct unit_class *pclass = get_unit_class(punittype);
+
+    if (pclass->ai.land_move == MOVE_NONE
+        || pclass->ai.sea_move == MOVE_NONE
+        || unit_class_flag(pclass, UCF_TERRAIN_SPEED)
+        || unit_type_is_losing_hp(pplayer, punittype)) {
+      /* We don't consider this a plane */
       continue;
     }
     if (can_build_unit(pcity, punittype)) {
diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c	2007-03-06 03:34:32.000000000 +0200
+++ freeciv/common/unit.c	2007-03-08 16:54:26.000000000 +0200
@@ -1461,7 +1461,16 @@
 **************************************************************************/
 bool is_losing_hp(const struct unit *punit)
 {
-  return get_player_bonus(unit_owner(punit), EFT_UNIT_RECOVER)
-    < (unit_type(punit)->hp *
-       get_unit_class(unit_type(punit))->hp_loss_pct / 100);
+  return unit_type_is_losing_hp(unit_owner(punit), unit_type(punit));
+}
+
+/**************************************************************************
+  Does unit lose hitpoints each turn?
+**************************************************************************/
+bool unit_type_is_losing_hp(const struct player *pplayer,
+                            const struct unit_type *punittype)
+{
+  return get_player_bonus(pplayer, EFT_UNIT_RECOVER)
+    < (punittype->hp *
+       get_unit_class(punittype)->hp_loss_pct / 100);
 }
diff -Nurd -X.diff_ignore freeciv/common/unit.h freeciv/common/unit.h
--- freeciv/common/unit.h	2007-03-05 21:11:49.000000000 +0200
+++ freeciv/common/unit.h	2007-03-08 16:53:11.000000000 +0200
@@ -299,5 +299,7 @@
 					       const struct unit *punit);
 
 bool is_losing_hp(const struct unit *punit);
+bool unit_type_is_losing_hp(const struct player *pplayer,
+                            const struct unit_type *punittype);
 
 #endif  /* FC__UNIT_H */
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to