Author: sveinung
Date: Mon Dec 29 12:46:22 2014
New Revision: 27441

URL: http://svn.gna.org/viewcvs/freeciv?rev=27441&view=rev
Log:
AI: A transport assigned to war isn't on a spy mission (yet).

When a transport unit is seen as a better military unit than transport unit
the AI transport code will notice and forward it to the code that handles
military units.

While forwarding it would set the unit's task to AIUNIT_ATTACK. If the unit
also could do spy actions against cities the statistics code in
dai_data_phase_begin() would later understand the unit as being on a spy
mission against a city and crash when no target city was found.

Make the transport code set the unit's task to AIUNIT_NONE in stead of
AIUNIT_ATTACK when forwarding a unit to the military unit handling code. The
other consequence of this change is that the unit will release any transport
or body guard it may have before being passed to the military unit handling
code.

Reported by Marko Lindqvist <cazfi>

See bug #23107

Modified:
    trunk/ai/default/aidata.c
    trunk/ai/default/aiferry.c

Modified: trunk/ai/default/aidata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aidata.c?rev=27441&r1=27440&r2=27441&view=diff
==============================================================================
--- trunk/ai/default/aidata.c   (original)
+++ trunk/ai/default/aidata.c   Mon Dec 29 12:46:22 2014
@@ -217,6 +217,9 @@
          || 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) {

Modified: trunk/ai/default/aiferry.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aiferry.c?rev=27441&r1=27440&r2=27441&view=diff
==============================================================================
--- trunk/ai/default/aiferry.c  (original)
+++ trunk/ai/default/aiferry.c  Mon Dec 29 12:46:22 2014
@@ -1177,7 +1177,7 @@
   if (IS_ATTACKER(punit) && punit->moves_left > 0) {
      /* AI used to build frigates to attack and then use them as ferries 
       * -- Syela */
-    dai_unit_new_task(ait, punit, AIUNIT_ATTACK, NULL);
+    dai_unit_new_task(ait, punit, AIUNIT_NONE, NULL);
     UNIT_LOG(LOGLEVEL_FERRY, punit, "passing ferry over to attack code");
     dai_manage_military(ait, pplayer, punit);
     return;


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

Reply via email to