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

 This gets rid of last is_heli_unit() calls from AI code. Two calls
has been replaced with more accurate check and one is removed
completely. As AI has not been using threats.air for anything, it is
removed for now.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aidata.c freeciv/ai/aidata.c
--- freeciv/ai/aidata.c	2007-01-26 16:25:47.000000000 +0200
+++ freeciv/ai/aidata.c	2007-01-26 23:34:05.000000000 +0200
@@ -242,7 +242,6 @@
   ai->num_oceans        = map.num_oceans;
   ai->threats.continent = fc_calloc(ai->num_continents + 1, sizeof(bool));
   ai->threats.invasions = FALSE;
-  ai->threats.air       = FALSE;
   ai->threats.nuclear   = 0; /* none */
   ai->threats.ocean     = fc_calloc(ai->num_oceans + 1, sizeof(bool));
   ai->threats.igwall    = FALSE;
@@ -298,13 +297,6 @@
         continue;
       }
 
-      /* The next idea is that if our enemies don't have any offensive
-       * airborne units, we don't have to worry. Go on the offensive! */
-      if ((is_air_unit(punit) || is_heli_unit(punit))
-           && unit_type(punit)->attack_strength > 1) {
-        ai->threats.air = TRUE;
-      }
-
       /* If our enemy builds missiles, worry about missile defence. */
       if (unit_class_flag(get_unit_class(unit_type(punit)), UCF_MISSILE)
           && unit_type(punit)->attack_strength > 1) {
diff -Nurd -X.diff_ignore freeciv/ai/aidata.h freeciv/ai/aidata.h
--- freeciv/ai/aidata.h	2006-07-17 23:56:47.000000000 +0300
+++ freeciv/ai/aidata.h	2007-01-26 23:34:26.000000000 +0200
@@ -87,7 +87,6 @@
     bool invasions;   /* check if we need to consider invasions */
     bool *continent;  /* non-allied cities on continent? */
     bool *ocean;      /* non-allied offensive ships in ocean? */
-    bool air;         /* check for non-allied offensive aircraft */
     bool missile;     /* check for non-allied missiles */
     int nuclear;      /* nuke check: 0=no, 1=capability, 2=built */
     bool igwall;      /* enemies have igwall units */
diff -Nurd -X.diff_ignore freeciv/ai/aitools.c freeciv/ai/aitools.c
--- freeciv/ai/aitools.c	2006-07-21 23:18:09.000000000 +0300
+++ freeciv/ai/aitools.c	2007-01-26 23:29:43.000000000 +0200
@@ -747,7 +747,10 @@
     parameter->get_TB = no_fights;
   } else if (is_air) {
     /* Default tile behaviour */
-  } else if (is_heli_unit(punit)) {
+  } else if (get_player_bonus(unit_owner(punit), EFT_UNIT_RECOVER)
+             < (unit_type(punit)->hp *
+                get_unit_class(unit_type(punit))->hp_loss_pct / 100)) {
+    /* Losing hitpoints over time (helicopter in default rules) */
     /* Default tile behaviour */
   } else if (is_military_unit(punit)) {
     switch (punit->ai.ai_role) {
diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c
--- freeciv/ai/aiunit.c	2007-01-25 23:31:33.000000000 +0200
+++ freeciv/ai/aiunit.c	2007-01-26 23:35:57.000000000 +0200
@@ -2156,7 +2156,11 @@
     ai_manage_airunit(pplayer, punit);
     TIMING_LOG(AIT_AIRUNIT, TIMER_STOP);
     return;
-  } else if (is_heli_unit(punit)) {
+  } else if (get_player_bonus(unit_owner(punit), EFT_UNIT_RECOVER)
+             < (unit_type(punit)->hp *
+                get_unit_class(unit_type(punit))->hp_loss_pct / 100)) {
+    /* This unit is losing hitpoints over time */
+
     /* TODO: We can try using air-unit code for helicopters, just
      * pretend they have fuel = HP / 3 or something. */
     punit->ai.done = TRUE; /* we did our best, which was ... nothing */
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to