Author: cazfi Date: Sun Aug 2 00:41:03 2015 New Revision: 29289 URL: http://svn.gna.org/viewcvs/freeciv?rev=29289&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_6/ai/default/aidata.c branches/S2_6/server/unittools.c Modified: branches/S2_6/ai/default/aidata.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aidata.c?rev=29289&r1=29288&r2=29289&view=diff ============================================================================== --- branches/S2_6/ai/default/aidata.c (original) +++ branches/S2_6/ai/default/aidata.c Sun Aug 2 00:41:03 2015 @@ -216,14 +216,16 @@ || unit_can_do_action(punit, ACTION_SPY_INVESTIGATE_CITY) || unit_can_do_action(punit, ACTION_SPY_STEAL_GOLD)) && 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_6/server/unittools.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unittools.c?rev=29289&r1=29288&r2=29289&view=diff ============================================================================== --- branches/S2_6/server/unittools.c (original) +++ branches/S2_6/server/unittools.c Sun Aug 2 00:41:03 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