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

Forwarding to RT where this was meant in the first place. Gmail not
handling reply-to headers correctly...


---------- Forwarded message ----------
From: Marko Lindqvist <[EMAIL PROTECTED]>
Date: Mar 19, 2007 11:04 AM
Subject: Re: [Freeciv-Dev] (PR#20672) Settler ferry assert
To: [EMAIL PROTECTED]


On 3/19/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  S2_1 fix (attached patch): Change assert to check only that move_type
> is not LAND_MOVING (we need to get over sea, and land units cannot
> help) and add checks to is_boat_free() to make sure that it does not
> select land units. Also added checks that ferry is not using fuel, or
> losing hitpoints over time.
>
>  Trunk will need modified version of this patch. I'll make it later.

 Trunk version


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aiferry.c freeciv/ai/aiferry.c
--- freeciv/ai/aiferry.c	2007-03-05 21:11:52.000000000 +0200
+++ freeciv/ai/aiferry.c	2007-03-19 11:02:23.000000000 +0200
@@ -324,7 +324,7 @@
 
 /****************************************************************************
   Runs a few checks to determine if "boat" is a free boat that can carry
-  "cap" units of the same type as "punit".
+  "cap" units of the same type as "punit" over sea.
 ****************************************************************************/
 bool is_boat_free(struct unit *boat, struct unit *punit, int cap)
 {
@@ -335,14 +335,21 @@
    * - Only available boats or boats that are already dedicated to this unit
    *   are eligible.
    * - Only boats with enough remaining capacity are eligible.
+   * - Only units that can travel at sea are eligible.
+   * - Units that require fuel are lose hitpoints are not eligible.
    */
+  struct unit_class *ferry_class = get_unit_class(unit_type(boat));
+
   return (can_unit_transport(boat, punit)
 	  && !unit_has_orders(boat)
 	  && boat->owner == punit->owner
 	  && (boat->ai.passenger == FERRY_AVAILABLE
 	      || boat->ai.passenger == punit->id)
 	  && (get_transporter_capacity(boat) 
-	      - get_transporter_occupancy(boat) >= cap));
+	      - get_transporter_occupancy(boat) >= cap)
+          && ferry_class->ai.sea_move != MOVE_NONE
+          && !unit_type(boat)->fuel
+          && !is_losing_hp(boat));
 }
 
 /****************************************************************************
diff -Nurd -X.diff_ignore freeciv/ai/aisettler.c freeciv/ai/aisettler.c
--- freeciv/ai/aisettler.c	2007-03-05 21:11:52.000000000 +0200
+++ freeciv/ai/aisettler.c	2007-03-19 11:00:06.000000000 +0200
@@ -552,6 +552,7 @@
   struct player *pplayer = unit_owner(punit);
   struct pf_parameter parameter;
   struct unit *ferry = NULL;
+  struct unit_class *ferry_class = NULL;
 
   assert(pplayer->ai.control);
   /* Only virtual units may use virtual boats: */
@@ -605,7 +606,9 @@
       ferry->tile = punit->tile;
     }
 
-    assert(SEA_MOVING == get_unit_move_type(unit_type(ferry)));
+    ferry_class = get_unit_class(unit_type(ferry));
+
+    assert(ferry_class->ai.sea_move != MOVE_NONE);
     pft_fill_unit_overlap_param(&parameter, ferry);
     parameter.get_TB = no_fights_or_unknown;
 
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to