Author: cazfi
Date: Thu Aug 11 05:43:28 2016
New Revision: 33565

URL: http://svn.gna.org/viewcvs/freeciv?rev=33565&view=rev
Log:
Made AI caravans able to plan trade routes over longer distances than one tile.

See bug #24947

Modified:
    branches/S2_6/common/actions.c
    branches/S2_6/common/actions.h
    branches/S2_6/common/aicore/caravan.c

Modified: branches/S2_6/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.c?rev=33565&r1=33564&r2=33565&view=diff
==============================================================================
--- branches/S2_6/common/actions.c      (original)
+++ branches/S2_6/common/actions.c      Thu Aug 11 05:43:28 2016
@@ -492,7 +492,8 @@
                               const struct output_type *target_output,
                                const struct specialist *target_specialist,
                                const bool omniscient,
-                               const struct city *homecity)
+                               const struct city *homecity,
+                               bool ignore_dist)
 {
   fc_assert_msg((action_get_target_kind(wanted_action) == ATK_CITY
                  && target_city != NULL)
@@ -500,7 +501,7 @@
                     && target_unit != NULL),
                 "Missing target!");
 
-  if (action_get_actor_kind(wanted_action) == AAK_UNIT) {
+  if (!ignore_dist && action_get_actor_kind(wanted_action) == AAK_UNIT) {
     /* The Freeciv code for all actions controlled by enablers assumes that
      * an acting unit is on the same tile as its target or on the tile next
      * to it. */
@@ -718,7 +719,7 @@
                              const struct unit_type *target_unittype,
                              const struct output_type *target_output,
                              const struct specialist *target_specialist,
-                              const struct city *homecity)
+                              const struct city *homecity, bool ignore_dist)
 {
   if (!is_action_possible(wanted_action,
                           actor_player, actor_city,
@@ -729,7 +730,7 @@
                           target_building, target_tile,
                           target_unit, target_unittype,
                           target_output, target_specialist,
-                          TRUE, homecity)) {
+                          TRUE, homecity, ignore_dist)) {
     /* The action enablers are irrelevant since the action it self is
      * impossible. */
     return FALSE;
@@ -764,7 +765,8 @@
 {
   return is_action_enabled_unit_on_city_full(wanted_action, actor_unit,
                                              target_city,
-                                             
game_city_by_number(actor_unit->homecity));
+                                             
game_city_by_number(actor_unit->homecity),
+                                             FALSE);
 }
 
 /**************************************************************************
@@ -776,7 +778,8 @@
 bool is_action_enabled_unit_on_city_full(const enum gen_action wanted_action,
                                          const struct unit *actor_unit,
                                          const struct city *target_city,
-                                         const struct city *homecity)
+                                         const struct city *homecity,
+                                         bool ignore_dist)
 {
   struct tile *actor_tile = unit_tile(actor_unit);
 
@@ -811,7 +814,7 @@
                            NULL, NULL,
                            city_owner(target_city), target_city, NULL,
                            city_tile(target_city), NULL, NULL, NULL, NULL,
-                           homecity);
+                           homecity, ignore_dist);
 }
 
 /**************************************************************************
@@ -861,7 +864,8 @@
                            unit_tile(target_unit),
                            target_unit, unit_type_get(target_unit),
                            NULL, NULL,
-                           game_city_by_number(actor_unit->homecity));
+                           game_city_by_number(actor_unit->homecity),
+                           FALSE);
 }
 
 /**************************************************************************
@@ -1160,7 +1164,7 @@
                           target_building, target_tile,
                           target_unit, target_unittype,
                           target_output, target_specialist,
-                          FALSE, homecity)) {
+                          FALSE, homecity, FALSE)) {
     /* The action enablers are irrelevant since the action it self is
      * impossible. */
     return ACTPROB_IMPOSSIBLE;

Modified: branches/S2_6/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.h?rev=33565&r1=33564&r2=33565&view=diff
==============================================================================
--- branches/S2_6/common/actions.h      (original)
+++ branches/S2_6/common/actions.h      Thu Aug 11 05:43:28 2016
@@ -173,7 +173,8 @@
 bool is_action_enabled_unit_on_city_full(const enum gen_action wanted_action,
                                          const struct unit *actor_unit,
                                          const struct city *target_city,
-                                         const struct city *homecity);
+                                         const struct city *homecity,
+                                         bool ignore_dist);
 
 bool is_action_enabled_unit_on_unit(const enum gen_action wanted_action,
                                     const struct unit *actor_unit,

Modified: branches/S2_6/common/aicore/caravan.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/aicore/caravan.c?rev=33565&r1=33564&r2=33565&view=diff
==============================================================================
--- branches/S2_6/common/aicore/caravan.c       (original)
+++ branches/S2_6/common/aicore/caravan.c       Thu Aug 11 05:43:28 2016
@@ -477,13 +477,13 @@
 
   consider_wonder = parameter->consider_wonders
     && is_action_enabled_unit_on_city_full(ACTION_HELP_WONDER,
-                                           caravan, dest, src);
+                                           caravan, dest, src, TRUE);
   consider_trade = parameter->consider_trade
     && is_action_enabled_unit_on_city_full(ACTION_TRADE_ROUTE,
-                                           caravan, dest, src);
+                                           caravan, dest, src, TRUE);
   consider_windfall = parameter->consider_windfall
     && is_action_enabled_unit_on_city_full(ACTION_MARKETPLACE,
-                                           caravan, dest, src);
+                                           caravan, dest, src, TRUE);
 
   if (!consider_wonder && !consider_trade && !consider_windfall) {
     /* No caravan action is possible against this target. */


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

Reply via email to