Author: cazfi
Date: Sun Aug  2 00:41:10 2015
New Revision: 29290

URL: http://svn.gna.org/viewcvs/freeciv?rev=29290&view=rev
Log:
Clear advisor and default AI task of a unit when goto_tile gets cleared as part 
of rescuing planes.
Avoid crash if diplomat unit has attack-task, but no target selected.

See bug #23728

Modified:
    branches/S2_5/ai/default/aidata.c
    branches/S2_5/server/unittools.c

Modified: branches/S2_5/ai/default/aidata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/ai/default/aidata.c?rev=29290&r1=29289&r2=29290&view=diff
==============================================================================
--- branches/S2_5/ai/default/aidata.c   (original)
+++ branches/S2_5/ai/default/aidata.c   Sun Aug  2 00:41:10 2015
@@ -247,14 +247,16 @@
   unit_list_iterate(pplayer->units, punit) {
     if (unit_has_type_flag(punit, UTYF_DIPLOMAT)
         && def_ai_unit_data(punit, ait)->task == AIUNIT_ATTACK) {
-      /* Heading somewhere on a mission, reserve target. */
-
-      fc_assert_msg(punit->goto_tile, "No target city for spy action");
-
-      struct city *pcity = tile_city(punit->goto_tile);
-
-      if (pcity) {
-        BV_SET(ai->stats.diplomat_reservations, pcity->id);
+
+      fc_assert_msg(punit->goto_tile != NULL, "No target city for spy action");
+
+      if (punit->goto_tile != NULL) {
+        struct city *pcity = tile_city(punit->goto_tile);
+
+        if (pcity != NULL) {
+          /* Heading somewhere on a mission, reserve target. */
+          BV_SET(ai->stats.diplomat_reservations, pcity->id);
+        }
       }
     }
   } unit_list_iterate_end;

Modified: branches/S2_5/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/unittools.c?rev=29290&r1=29289&r2=29290&view=diff
==============================================================================
--- branches/S2_5/server/unittools.c    (original)
+++ branches/S2_5/server/unittools.c    Sun Aug  2 00:41:10 2015
@@ -457,6 +457,7 @@
                 /* Clear activity. Unit info will be sent in the end of
                 * the function. */
                 unit_activity_handling(punit, ACTIVITY_IDLE);
+                adv_unit_new_task(punit, AUT_NONE, NULL);
                 punit->goto_tile = NULL;
 
                 if (!is_unit_being_refueled(punit)) {


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

Reply via email to