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

On 1/28/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  They should request only one point of free transport capacity from
> other ferries and none from the ferry they are already in.

 Fix


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c
--- freeciv/ai/aiunit.c	2007-01-27 18:26:36.000000000 +0200
+++ freeciv/ai/aiunit.c	2007-01-28 22:14:49.000000000 +0200
@@ -1314,8 +1314,24 @@
   generate_warmap(tile_get_city(*dest_tile), punit);
 
   if (is_ground_unit(punit)) {
-    int boatid = aiferry_find_boat(punit, 2, NULL);
-    ferryboat = player_find_unit_by_id(pplayer, boatid);
+
+    /* First check if we can use the boat we are currently loaded to */
+    if (punit->transported_by != -1) {
+      ferryboat = player_find_unit_by_id(unit_owner(punit),
+                                         punit->transported_by);
+
+      /* We are already in, so don't ask for free capacity */
+      if (ferryboat == NULL || !is_boat_free(ferryboat, punit, 0)) {
+        /* No, we cannot control current boat */
+        ferryboat = NULL;
+      }
+    }
+
+    if (ferryboat == NULL) {
+      /* Try to find new boat */
+      int boatid = aiferry_find_boat(punit, 1, NULL);
+      ferryboat = player_find_unit_by_id(pplayer, boatid);
+    }
   }
 
   if (ferryboat) {
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to