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

On 1/26/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  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.

 - Take advantage of new is_losing_hp() function


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aidata.c freeciv/ai/aidata.c
--- freeciv/ai/aidata.c	2007-02-11 15:41:20.000000000 +0200
+++ freeciv/ai/aidata.c	2007-03-02 18:30:56.000000000 +0200
@@ -243,7 +243,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;
@@ -299,13 +298,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	2007-02-11 15:41:20.000000000 +0200
+++ freeciv/ai/aidata.h	2007-03-02 18:30:56.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	2007-02-12 15:27:44.000000000 +0200
+++ freeciv/ai/aitools.c	2007-03-02 18:32:01.000000000 +0200
@@ -734,7 +734,8 @@
     parameter->get_TB = no_fights;
   } else if (is_air) {
     /* Default tile behaviour */
-  } else if (is_heli_unit(punit)) {
+  } else if (is_losing_hp(punit)) {
+    /* 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-02-01 22:24:32.000000000 +0200
+++ freeciv/ai/aiunit.c	2007-03-02 18:32:22.000000000 +0200
@@ -2196,7 +2196,9 @@
     ai_manage_airunit(pplayer, punit);
     TIMING_LOG(AIT_AIRUNIT, TIMER_STOP);
     return;
-  } else if (is_heli_unit(punit)) {
+  } else if (is_losing_hp(punit)) {
+    /* 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