Author: cazfi
Date: Mon Jun 20 18:25:33 2016
New Revision: 32932

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

See patch #7269

Modified:
    trunk/ai/default/aicity.c
    trunk/server/citytools.c
    trunk/server/cityturn.c

Modified: trunk/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aicity.c?rev=32932&r1=32931&r2=32932&view=diff
==============================================================================
--- trunk/ai/default/aicity.c   (original)
+++ trunk/ai/default/aicity.c   Mon Jun 20 18:25:33 2016
@@ -308,56 +308,34 @@
   }
 
   if (city_data->choice.want != 0) {
+    struct universal build_new;
+
     ADV_CHOICE_ASSERT(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));
-    }
 
     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: trunk/server/citytools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/citytools.c?rev=32932&r1=32931&r2=32932&view=diff
==============================================================================
--- trunk/server/citytools.c    (original)
+++ trunk/server/citytools.c    Mon Jun 20 18:25:33 2016
@@ -79,6 +79,9 @@
 
 /* server/scripting */
 #include "script_server.h"
+
+/* ai */
+#include "handicaps.h"
 
 /* ai */
 #include "handicaps.h"

Modified: trunk/server/cityturn.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/cityturn.c?rev=32932&r1=32931&r2=32932&view=diff
==============================================================================
--- trunk/server/cityturn.c     (original)
+++ trunk/server/cityturn.c     Mon Jun 20 18:25:33 2016
@@ -2026,12 +2026,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