Author: cazfi
Date: Sat Aug 15 19:34:43 2015
New Revision: 29521

URL: http://svn.gna.org/viewcvs/freeciv?rev=29521&view=rev
Log:
AI ferry code does not take control of the allied units on board. The old 
behavior was wrong in two ways:
- AI type of the ferry owner was used for running the passenger. If the AI type 
of the owner of the passenger
  would be different, bogus data gets used and also produced
- Unit might move outside the phase of its owner (real surprise attack against 
third party!)

See bug #23755

Modified:
    branches/S2_6/ai/default/aiferry.c

Modified: branches/S2_6/ai/default/aiferry.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aiferry.c?rev=29521&r1=29520&r2=29521&view=diff
==============================================================================
--- branches/S2_6/ai/default/aiferry.c  (original)
+++ branches/S2_6/ai/default/aiferry.c  Sat Aug 15 19:34:43 2015
@@ -602,11 +602,17 @@
 **************************************************************************/
 static void dai_activate_passengers(struct ai_type *ait, struct unit *ferry)
 {
+  struct player *ferry_owner = unit_owner(ferry);
+  
   unit_list_iterate_safe(unit_tile(ferry)->units, aunit) {
     if (unit_transport_get(aunit) == ferry) {
       unit_activity_handling(aunit, ACTIVITY_IDLE);
       def_ai_unit_data(aunit, ait)->done = FALSE;
-      dai_manage_unit(ait, unit_owner(aunit), aunit);
+
+      if (unit_owner(aunit) == ferry_owner) {
+        /* Move it only if it's our own. */
+        dai_manage_unit(ait, ferry_owner, aunit);
+      }
     }
   } unit_list_iterate_safe_end;
 }


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to