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

On 3/6/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  This fixes some problems with air units *without* fuel and non-air
> units *with* fuel.

 - One more case found and fixed: danger in pathfinding


 - ML

diff -Nurd -X.diff_ignore freeciv/common/aicore/pf_tools.c freeciv/common/aicore/pf_tools.c
--- freeciv/common/aicore/pf_tools.c	2007-03-06 03:34:32.000000000 +0200
+++ freeciv/common/aicore/pf_tools.c	2007-03-06 16:13:02.000000000 +0200
@@ -542,9 +542,9 @@
 /****************************************************************************
   Position-dangerous callback for air units.
 ****************************************************************************/
-static bool air_is_pos_dangerous(const struct tile *ptile,
-				 enum known_type known,
-				 struct pf_parameter *param)
+static bool is_pos_dangerous_fuel(const struct tile *ptile,
+                                  enum known_type known,
+                                  struct pf_parameter *param)
 {
   struct base_type *pbase;
 
@@ -612,12 +612,6 @@
     break;
   case AIR_MOVING:
     parameter->get_MC = single_airmove;
-    if (unit_type(punit)->fuel > 0) {
-      parameter->is_pos_dangerous = air_is_pos_dangerous;
-    } else {
-      parameter->is_pos_dangerous = NULL;
-    }
-    parameter->turn_mode = TM_WORST_TIME;
     break;
   case HELI_MOVING:
     /* Helicoptors are treated similarly to airplanes. */
@@ -629,9 +623,10 @@
   }
 
   if (!parameter->is_pos_dangerous
-      && is_losing_hp(punit)) {
-    /* Unit loses hitpoints each turn when not in city/safe base/carrier */
-    parameter->is_pos_dangerous = air_is_pos_dangerous;
+      && (unit_type(punit)->fuel > 0 || is_losing_hp(punit))) {
+    /* Unit loses hitpoints each turn when not in city/safe base/carrier
+     * or needs fuel */
+    parameter->is_pos_dangerous = is_pos_dangerous_fuel;
     parameter->turn_mode = TM_WORST_TIME;
   }
 
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-06 16:09:20.000000000 +0200
@@ -992,7 +992,7 @@
   switch(punit->activity) {
    case ACTIVITY_IDLE:
      moves_str = _("Moves");
-     if (is_air_unit(punit) && unit_type(punit)->fuel > 0) {
+     if (unit_type(punit)->fuel) {
        int rate,f;
        rate=unit_type(punit)->move_rate/SINGLE_MOVE;
        f=((punit->fuel)-1);
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c	2007-03-06 03:34:32.000000000 +0200
+++ freeciv/server/unittools.c	2007-03-06 16:09:20.000000000 +0200
@@ -348,7 +348,7 @@
     }
 
     /* 4) Rescue planes if needed */
-    if (is_air_unit(punit)) {
+    if (unit_type(punit)->fuel) {
       /* Shall we emergency return home on the last vapors? */
 
       /* I think this is strongly against the spirit of client goto.
@@ -441,8 +441,7 @@
 
   /* 7) Check if there are air units without fuel */
   unit_list_iterate_safe(pplayer->units, punit) {
-    if (is_air_unit(punit) && punit->fuel <= 0
-        && unit_type(punit)->fuel > 0) {
+    if (punit->fuel <= 0 && unit_type(punit)->fuel) {
       notify_player(pplayer, punit->tile, E_UNIT_LOST, 
 		       _("Your %s has run out of fuel."),
 		       unit_name(punit->type));
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to