Author: cazfi
Date: Sun Aug  2 00:40:55 2015
New Revision: 29288

URL: http://svn.gna.org/viewcvs/freeciv?rev=29288&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:
    trunk/ai/default/aidata.c
    trunk/server/unittools.c

Modified: trunk/ai/default/aidata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aidata.c?rev=29288&r1=29287&r2=29288&view=diff
==============================================================================
--- trunk/ai/default/aidata.c   (original)
+++ trunk/ai/default/aidata.c   Sun Aug  2 00:40:55 2015
@@ -218,14 +218,16 @@
          || unit_can_do_action(punit, ACTION_STEAL_MAPS)
          || unit_can_do_action(punit, ACTION_SPY_NUKE))
         && 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: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=29288&r1=29287&r2=29288&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Sun Aug  2 00:40:55 2015
@@ -465,6 +465,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