Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] AI leaving behind allied units in the ocean (PR#4660)
Home

[Freeciv-Dev] AI leaving behind allied units in the ocean (PR#4660)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: tomg@xxxxx
Subject: [Freeciv-Dev] AI leaving behind allied units in the ocean (PR#4660)
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 9 Aug 2003 14:12:42 -0700
Reply-to: rt@xxxxxxxxxxxxxx

The AI does not bother transporting allied units, leaving them behind to
drown in the ocean, and triggering asserts from sanitycheck.c's
check_units() and combat.c's get_defender(). The attached patch should fix
this, and also give better error reporting on such issues in the future.

A savegame with the bug reproduced is also attached.

   - Per

"This is the future for the world we're in at the moment,"
promised Lawrence Di Rita, special assistant to Rumsfeld.
"We'll get better as we do it more often."

Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.238
diff -u -r1.238 unittools.c
--- server/unittools.c  4 Aug 2003 15:42:48 -0000       1.238
+++ server/unittools.c  9 Aug 2003 20:57:23 -0000
@@ -2390,28 +2390,6 @@
   int capacity = get_transporter_capacity(ptrans);
   struct tile *ptile = map_get_tile(x, y);
 
-  /*** FIXME: We kludge AI compatability problems with the new code away here 
***/
-  if (is_sailing_unit(ptrans)
-      && is_ground_units_transport(ptrans)
-      && unit_owner(ptrans)->ai.control) {
-    unit_list_iterate(ptile->units, pcargo) {
-      if (pcargo->owner == playerid) {
-       pcargo->transported_by = -1;
-      }
-    } unit_list_iterate_end;
-
-    unit_list_iterate(ptile->units, pcargo) {
-      if ((is_ocean(ptile->terrain) || pcargo->activity == ACTIVITY_SENTRY)
-         && capacity > 0
-         && is_ground_unit(pcargo)
-         && pcargo->owner == playerid) {
-       pcargo->transported_by = ptrans->id;
-       capacity--;
-      }
-    } unit_list_iterate_end;
-    return;
-  }
-
   /*** Ground units transports first ***/
   if (is_ground_units_transport(ptrans)) {
     int available =
@@ -2963,6 +2941,17 @@
   maybe_make_contact(dest_x, dest_y, unit_owner(punit));
 
   conn_list_do_unbuffer(&pplayer->connections);
+
+  if (is_ocean(map_get_terrain(src_x, src_y))
+      && ground_unit_transporter_capacity(src_x, src_y, pplayer) < 0) {
+    die("%s's %s (id %d) left a unit stranded in the ocean without a "
+        "transport at position (%d, %d). Capacity on old tile is %d "
+        " and %d on new tile, which is at position (%d, %d). ransport_units "
+        "is %s", pplayer->name, unit_name(punit->type), punit->id, src_x, 
src_y,
+        ground_unit_transporter_capacity(src_x, src_y, pplayer),
+        ground_unit_transporter_capacity(dest_x, dest_y, pplayer),
+        dest_x, dest_y, transport_units ? "true" : "false");
+  }
 
   if (map_has_special(dest_x, dest_y, S_HUT))
     return unit_enter_hut(punit);

Attachment: crashandburn.sav.gz
Description: crashandburn.sav.gz


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] AI leaving behind allied units in the ocean (PR#4660), Per I. Mathisen <=