Complete.Org: Mailing Lists: Archives: freeciv-ai: September 2003:
[freeciv-ai] Re: (PR#6227) Boats in assess danger
Home

[freeciv-ai] Re: (PR#6227) Boats in assess danger

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory.Berkolaiko@xxxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#6227) Boats in assess danger
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Mon, 22 Sep 2003 05:57:38 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Here is a patch, based heavily on a part of Jordi's ferry patch, that
simplifies the logic of deboarding from transports. This avoids a lot of
bugs that kept transports waiting endlessly.

  - Per

Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.289
diff -u -r1.289 aiunit.c
--- ai/aiunit.c 21 Sep 2003 09:06:43 -0000      1.289
+++ ai/aiunit.c 22 Sep 2003 13:46:14 -0000
@@ -1407,18 +1407,20 @@
     } 
   }
 
-  if (goto_is_sane(punit, dest_x, dest_y, TRUE) && punit->moves_left > 0 
-      && (!ferryboat 
-          || (real_map_distance(punit->x, punit->y, dest_x, dest_y) < 3 
-              && (punit->ai.bodyguard == BODYGUARD_NONE 
-                  || unit_list_find(&(map_get_tile(punit->x, punit->y)->units),
-                                    punit->ai.bodyguard) 
-                  || (dcity && !has_defense(dcity)))))) {
-    /* if we are on a boat, disembark only if we are within two tiles of
-     * our target, and either 1) we don't need a bodyguard, 2) we have a
-     * bodyguard, or 3) we are going to an empty city.  Previously, cannons
-     * would disembark before the cruisers arrived and die. -- Syela */
+  if (ferryboat && is_goto_dest_set(ferryboat)) {
+    /* we are on a ferry! did we arrive? */
+    boat_arrived = same_pos(ferryboat->x, ferryboat->y,
+                            goto_dest_x(ferryboat), goto_dest_y(ferryboat))
+                   || is_tiles_adjacent(ferryboat->x, ferryboat->y,
+                            goto_dest_x(ferryboat), goto_dest_y(ferryboat));
+  } else {
+    boat_arrived = FALSE;
+  }
 
+  /* Go where we should be going if we can, and are at our destination 
+   * if we are on a ferry */
+  if (goto_is_sane(punit, dest_x, dest_y, TRUE) && punit->moves_left > 0
+      && (!ferryboat || boat_arrived)) {
     set_goto_dest(punit, dest_x, dest_y);
     
     /* The following code block is supposed to stop units from running away 

[Prev in Thread] Current Thread [Next in Thread]