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

 Magic ruleset problem.

 aisettler code asserts that selected ferry is SEA_MOVING. It gets
ferries from is_boat_free() which does not limit move_type.

 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.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aiferry.c freeciv/ai/aiferry.c
--- freeciv/ai/aiferry.c	2007-03-05 19:14:29.000000000 +0200
+++ freeciv/ai/aiferry.c	2007-03-19 03:32:59.000000000 +0200
@@ -276,7 +276,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)
 {
@@ -287,14 +287,21 @@
    * - Only available boats or boats that are already dedicated to this unit
    *   are eligible.
    * - Only boats with enough remaining capacity are eligible.
+   * - Land moving units cannot transport others over sea
+   * - Units that require fuel are lose hitpoints are not eligible
    */
+  enum unit_move_type boat_move_type = unit_type(boat)->move_type;
+
   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)
+          && boat_move_type != LAND_MOVING
+          && !unit_type(boat)->fuel
+          && get_unit_class(unit_type(boat))->hp_loss_pct <= 0);
 }
 
 /****************************************************************************
diff -Nurd -X.diff_ignore freeciv/ai/aisettler.c freeciv/ai/aisettler.c
--- freeciv/ai/aisettler.c	2007-03-05 19:14:29.000000000 +0200
+++ freeciv/ai/aisettler.c	2007-03-19 03:33:19.000000000 +0200
@@ -605,7 +605,7 @@
       ferry->tile = punit->tile;
     }
 
-    assert(SEA_MOVING == unit_type(ferry)->move_type);
+    assert(LAND_MOVING != unit_type(ferry)->move_type);
     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