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

After looking at airgoto code some more, found (more than one) function on
the server side that looks for an airbase.  Copied part here.

Essentially no change for AI.

The user can run the aircraft any direction for 1/2 move, *and* another
1/2 move that takes it near a possible airbase.  This allows setting
waypoints anywhere on a path (outgoing and incoming) near an airbase.

I ran many trials removing the restriction on single flight paths (that is,
letting it self-select a refueling base on the way to P1, as it did
initially).  The code already exists.  It works sometimes....

As you may remember, in the early messages of this PR, it refueled at P5
for me, but not for you.  After many boring tests (restart, test, quit, ...),
it has become clear that some code doesn't work consistently.

Sometimes it refuels at P5, other times P7, and sometimes, it just jogs
around P5 and dies.  Trying to go to P3 or P8, it always makes a straight
path just past P5 over the engineer, never refuels, and dies.

There must be some kind of random path selection between equal paths, but
they didn't use a standard function, and I cannot find it!  Or maybe it's
an uninitialized variable.

Therefore, for 2.1.1, I'm leaving in the restriction.  If you need to
specify refueling on a long path, use waypoints.  They always work.

For 2.2 (or 2.3), we can look at better combining the 4 different path
selection methods (with 2 different Dijkstra implementations)!

Committed S2_1 revision 13958.

Index: common/aicore/pf_tools.c
===================================================================
--- common/aicore/pf_tools.c    (revision 13957)
+++ common/aicore/pf_tools.c    (working copy)
@@ -550,8 +550,9 @@
 {
   int moves = SINGLE_MOVE * real_map_distance(param->start_tile, ptile);
   int have = get_moves_left_initially(param);
+  int left = have - moves;
 
-  if (have < moves) {
+  if (left < 0) {
     /* not enough fuel. */
     return TRUE;
   }
@@ -576,6 +577,14 @@
     return FALSE;
   }
 
+  /* similar to find_nearest_airbase() */
+  iterate_outward(ptile, left / SINGLE_MOVE, atile) {
+    if (TILE_UNKNOWN != tile_get_known(atile, param->owner)
+     && is_possible_base_fuel(atile, param)) {
+      return FALSE;
+    }
+  } iterate_outward_end;
+  
   /* Carriers are ignored since they are likely to move. */
   return TRUE;
 }
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to