Author: cazfi Date: Thu Aug 11 05:43:22 2016 New Revision: 33564 URL: http://svn.gna.org/viewcvs/freeciv?rev=33564&view=rev Log: Made AI caravans able to plan trade routes over longer distances than one tile.
See bug #24947 Modified: trunk/common/actions.c trunk/common/actions.h trunk/common/aicore/caravan.c Modified: trunk/common/actions.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=33564&r1=33563&r2=33564&view=diff ============================================================================== --- trunk/common/actions.c (original) +++ trunk/common/actions.c Thu Aug 11 05:43:22 2016 @@ -1251,7 +1251,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) { bool can_see_tgt_unit; bool can_see_tgt_tile; @@ -1283,14 +1284,13 @@ || plr_sees_tile(actor_player, target_tile)); /* Info leak: The player knows where his unit is. */ - if (action_get_target_kind(wanted_action) != ATK_SELF) { - if (!action_id_distance_accepted(wanted_action, - real_map_distance(actor_tile, - target_tile))) { - /* The distance between the actor and the target isn't inside the - * action's accepted range. */ - return TRI_NO; - } + if (!ignore_dist && action_get_target_kind(wanted_action) != ATK_SELF + && !action_id_distance_accepted(wanted_action, + real_map_distance(actor_tile, + target_tile))) { + /* The distance between the actor and the target isn't inside the + * action's accepted range. */ + return TRI_NO; } if (action_get_target_kind(wanted_action) == ATK_UNIT) { @@ -1717,7 +1717,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) { enum fc_tristate possible; @@ -1730,7 +1730,7 @@ target_building, target_tile, target_unit, target_unittype, target_output, target_specialist, - TRUE, homecity); + TRUE, homecity, ignore_dist); if (possible != TRI_YES) { /* This context is omniscient. Should be yes or no. */ @@ -1771,7 +1771,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); } /************************************************************************** @@ -1783,7 +1784,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); struct impr_type *target_building; @@ -1823,7 +1825,8 @@ NULL, NULL, city_owner(target_city), target_city, target_building, city_tile(target_city), - NULL, target_utype, NULL, NULL, homecity); + NULL, target_utype, NULL, NULL, homecity, + ignore_dist); } /************************************************************************** @@ -1872,7 +1875,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); } /************************************************************************** @@ -1925,7 +1929,7 @@ tile_city(unit_tile(target_unit)), NULL, unit_tile(target_unit), target_unit, unit_type_get(target_unit), - NULL, NULL, homecity)) { + NULL, NULL, homecity, FALSE)) { /* One unit makes it impossible for all units. */ return FALSE; } @@ -1978,7 +1982,8 @@ NULL, NULL, tile_owner(target_tile), NULL, NULL, target_tile, NULL, NULL, NULL, NULL, - game_city_by_number(actor_unit->homecity)); + game_city_by_number(actor_unit->homecity), + FALSE); } /************************************************************************** @@ -2023,7 +2028,7 @@ actor_unit, unit_type_get(actor_unit), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - game_city_by_number(actor_unit->homecity)); + game_city_by_number(actor_unit->homecity), FALSE); } /************************************************************************** @@ -2323,7 +2328,7 @@ target_building, target_tile, target_unit, target_unittype, target_output, target_specialist, - FALSE, homecity); + FALSE, homecity, FALSE); if (known == TRI_NO) { /* The action enablers are irrelevant since the action it self is Modified: trunk/common/actions.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=33564&r1=33563&r2=33564&view=diff ============================================================================== --- trunk/common/actions.h (original) +++ trunk/common/actions.h Thu Aug 11 05:43:22 2016 @@ -342,7 +342,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: trunk/common/aicore/caravan.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/aicore/caravan.c?rev=33564&r1=33563&r2=33564&view=diff ============================================================================== --- trunk/common/aicore/caravan.c (original) +++ trunk/common/aicore/caravan.c Thu Aug 11 05:43:22 2016 @@ -483,13 +483,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