Author: cazfi Date: Wed May 10 17:38:47 2017 New Revision: 35492 URL: http://svn.gna.org/viewcvs/freeciv?rev=35492&view=rev Log: Avoid double map_move_cost_unit()
See hrm Feature #658612 Modified: trunk/ai/default/aitools.c trunk/server/advisors/advgoto.c Modified: trunk/ai/default/aitools.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aitools.c?rev=35492&r1=35491&r2=35492&view=diff ============================================================================== --- trunk/ai/default/aitools.c (original) +++ trunk/ai/default/aitools.c Wed May 10 17:38:47 2017 @@ -916,6 +916,7 @@ int sanity = punit->id; struct player *pplayer = unit_owner(punit); const bool is_plr_ai = is_ai(pplayer); + int mcost; CHECK_UNIT(punit); fc_assert_ret_val_msg(is_tiles_adjacent(unit_tile(punit), ptile), FALSE, @@ -948,8 +949,9 @@ } /* Try not to end move next to an enemy if we can avoid it by waiting */ - if (punit->moves_left <= map_move_cost_unit(punit, ptile) - && unit_move_rate(punit) > map_move_cost_unit(punit, ptile) + mcost = map_move_cost_unit(punit, ptile); + if (punit->moves_left <= mcost + && unit_move_rate(punit) > mcost && adv_danger_at(punit, ptile) && !adv_danger_at(punit, unit_tile(punit))) { UNIT_LOG(LOG_DEBUG, punit, "ending move early to stay out of trouble"); Modified: trunk/server/advisors/advgoto.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/advgoto.c?rev=35492&r1=35491&r2=35492&view=diff ============================================================================== --- trunk/server/advisors/advgoto.c (original) +++ trunk/server/advisors/advgoto.c Wed May 10 17:38:47 2017 @@ -129,6 +129,7 @@ static bool adv_unit_move(struct unit *punit, struct tile *ptile) { struct player *pplayer = unit_owner(punit); + int mcost; /* if enemy, stop and give a chance for the human player to handle this case */ @@ -139,8 +140,9 @@ } /* Try not to end move next to an enemy if we can avoid it by waiting */ - if (punit->moves_left <= map_move_cost_unit(punit, ptile) - && unit_move_rate(punit) > map_move_cost_unit(punit, ptile) + mcost = map_move_cost_unit(punit, ptile); + if (punit->moves_left <= mcost + && unit_move_rate(punit) > mcost && adv_danger_at(punit, ptile) && !adv_danger_at(punit, unit_tile(punit))) { UNIT_LOG(LOG_DEBUG, punit, "ending move early to stay out of trouble"); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits