Author: sveinung
Date: Wed Dec 31 12:25:36 2014
New Revision: 27459

URL: http://svn.gna.org/viewcvs/freeciv?rev=27459&view=rev
Log:
AI: Request a unit that can help wonder when considering to build a unit.

Ask directly for a unit that can help build a wonder in stead of asking for
a unit with the HelpWonder unit type flag and then checking if it can help
build a wonder.

See patch #5626

Modified:
    trunk/ai/default/advdomestic.c

Modified: trunk/ai/default/advdomestic.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advdomestic.c?rev=27459&r1=27458&r2=27459&view=diff
==============================================================================
--- trunk/ai/default/advdomestic.c      (original)
+++ trunk/ai/default/advdomestic.c      Wed Dec 31 12:25:36 2014
@@ -85,7 +85,7 @@
   struct unit_type *unit_type;
   struct city *wonder_city = game_city_by_number(ai->wonder_city);
 
-  if (num_role_units(UTYF_HELP_WONDER) == 0) {
+  if (num_role_units(action_get_role(ACTION_HELP_WONDER)) == 0) {
     /* No such units available in the ruleset */
     return;
   }
@@ -117,18 +117,16 @@
     }
   } city_list_iterate_end;
 
-  unit_type = best_role_unit(pcity, UTYF_HELP_WONDER);
+  unit_type = best_role_unit(pcity, action_get_role(ACTION_HELP_WONDER));
 
   if (!unit_type) {
     /* We cannot build such units yet
      * but we will consider it to stimulate science */
-    unit_type = get_role_unit(UTYF_HELP_WONDER, 0);
-  }
-
-  if (!utype_can_do_action(unit_type, ACTION_HELP_WONDER)) {
-    /* This unit type isn't suitable for wonder building help. */
-    return;
-  }
+    unit_type = get_role_unit(action_get_role(ACTION_HELP_WONDER), 0);
+  }
+
+  fc_assert_msg(utype_can_do_action(unit_type, ACTION_HELP_WONDER),
+                "Non existence of wonder helper unit not caught");
 
   /* Check if wonder needs a little help. */
   if (build_points_left(wonder_city) 
@@ -148,14 +146,17 @@
     if (want > choice->want) {
       /* This sets our tech want in cases where we cannot actually build
        * the unit. */
-      unit_type = dai_wants_role_unit(ait, pplayer, pcity, UTYF_HELP_WONDER, 
want);
+      unit_type = dai_wants_role_unit(ait, pplayer, pcity,
+                                      action_get_role(ACTION_HELP_WONDER),
+                                      want);
       if (unit_type != NULL) {
         choice->want = want;
         choice->type = CT_CIVILIAN;
         choice->value.utype = unit_type;
       } else {
         CITY_LOG(LOG_DEBUG, pcity,
-                 "would but could not build UTYF_HELP_WONDER unit, bumped 
reqs");
+                 "would but could not build ACTION_HELP_WONDER unit, "
+                 "bumped reqs");
       }
     }
   }


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

Reply via email to