Author: cazfi
Date: Mon Jun 20 18:25:39 2016
New Revision: 32933

URL: http://svn.gna.org/viewcvs/freeciv?rev=32933&view=rev
Log:
Made default AI to use change_build_target()

See patch #7269

Modified:
    branches/S2_6/ai/default/aicity.c
    branches/S2_6/server/citytools.c
    branches/S2_6/server/cityturn.c

Modified: branches/S2_6/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aicity.c?rev=32933&r1=32932&r2=32933&view=diff
==============================================================================
--- branches/S2_6/ai/default/aicity.c   (original)
+++ branches/S2_6/ai/default/aicity.c   Mon Jun 20 18:25:39 2016
@@ -322,56 +322,34 @@
   }
 
   if (city_data->choice.want != 0) {
+    struct universal build_new;
+
     ASSERT_CHOICE(city_data->choice);
 
     CITY_LOG(LOG_DEBUG, pcity, "wants %s with desire " ADV_WANT_PRINTF ".",
-            dai_choice_rule_name(&city_data->choice),
-            city_data->choice.want);
-    
-    /* FIXME: parallel to citytools change_build_target() */
-    if (VUT_IMPROVEMENT == pcity->production.kind
-     && is_great_wonder(pcity->production.value.building)
-     && (CT_BUILDING != city_data->choice.type
-         || city_data->choice.value.building
-            != pcity->production.value.building)) {
-      notify_player(NULL, pcity->tile, E_WONDER_STOPPED, ftc_server,
-                   _("The %s have stopped building The %s in %s."),
-                   nation_plural_for_player(pplayer),
-                   city_production_name_translation(pcity),
-                    city_link(pcity));
-    }
-    if (CT_BUILDING == city_data->choice.type
-      && is_great_wonder(city_data->choice.value.building)
-      && (VUT_IMPROVEMENT != pcity->production.kind
-          || pcity->production.value.building
-             != city_data->choice.value.building)) {
-      notify_player(NULL, pcity->tile, E_WONDER_STARTED, ftc_server,
-                   _("The %s have started building The %s in %s."),
-                   nation_plural_for_player(city_owner(pcity)),
-                   city_improvement_name_translation(pcity,
-                      city_data->choice.value.building),
-                    city_link(pcity));
-    }
+             dai_choice_rule_name(&city_data->choice),
+             city_data->choice.want);
 
     switch (city_data->choice.type) {
     case CT_CIVILIAN:
     case CT_ATTACKER:
     case CT_DEFENDER:
-      pcity->production.kind = VUT_UTYPE;
-      pcity->production.value.utype = city_data->choice.value.utype;
+      build_new.kind = VUT_UTYPE;
+      build_new.value.utype = city_data->choice.value.utype;
       break;
     case CT_BUILDING:
-      pcity->production.kind = VUT_IMPROVEMENT;
-      pcity->production.value.building 
-        = city_data->choice.value.building;
+      build_new.kind = VUT_IMPROVEMENT;
+      build_new.value.building = city_data->choice.value.building;
       break;
     case CT_NONE:
-      pcity->production.kind = VUT_NONE;
+      build_new.kind = VUT_NONE;
       break;
     case CT_LAST:
-      pcity->production.kind = universals_n_invalid();
+      build_new.kind = universals_n_invalid();
       break;
     };
+
+    change_build_target(pplayer, pcity, &build_new, E_CITY_PRODUCTION_CHANGED);
   }
 }
 

Modified: branches/S2_6/server/citytools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/citytools.c?rev=32933&r1=32932&r2=32933&view=diff
==============================================================================
--- branches/S2_6/server/citytools.c    (original)
+++ branches/S2_6/server/citytools.c    Mon Jun 20 18:25:39 2016
@@ -79,6 +79,9 @@
 
 /* server/scripting */
 #include "script_server.h"
+
+/* ai */
+#include "handicaps.h"
 
 /* ai */
 #include "handicaps.h"

Modified: branches/S2_6/server/cityturn.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/cityturn.c?rev=32933&r1=32932&r2=32933&view=diff
==============================================================================
--- branches/S2_6/server/cityturn.c     (original)
+++ branches/S2_6/server/cityturn.c     Mon Jun 20 18:25:39 2016
@@ -1934,12 +1934,16 @@
     /* We can build a unit again unless it's unique or we have lost the tech. 
*/
     if (!utype_has_flag(pcity->production.value.utype, UTYF_UNIQUE)
         && can_city_build_unit_now(pcity, pcity->production.value.utype)) {
+      log_debug("%s repeats building %s", city_name_get(pcity),
+                utype_rule_name(pcity->production.value.utype));
       return;
     }
     break;
   case VUT_IMPROVEMENT:
     if (can_city_build_improvement_now(pcity, 
pcity->production.value.building)) {
       /* We can build space and coinage again, and possibly others. */
+      log_debug("%s repeats building %s", city_name_get(pcity),
+                improvement_rule_name(pcity->production.value.building));
       return;
     }
     break;


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

Reply via email to