Author: sveinung Date: Wed Aug 19 16:44:15 2015 New Revision: 29587 URL: http://svn.gna.org/viewcvs/freeciv?rev=29587&view=rev Log: Handle ACTION_ANY in move frags may act code
Handle the special value ACTION_ANY, meaning any action, in utype_may_act_move_frags(). This is the code responsible for figuring out if a unit will be able to perform an action if it has a certain amount of move fragments left. Stop handling it in its users. See patch #6253 Modified: trunk/common/unittype.c trunk/server/unithand.c Modified: trunk/common/unittype.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/unittype.c?rev=29587&r1=29586&r2=29587&view=diff ============================================================================== --- trunk/common/unittype.c (original) +++ trunk/common/unittype.c Wed Aug 19 16:44:15 2015 @@ -623,8 +623,24 @@ { struct range *ml_range; + fc_assert(action_id_is_valid(action_id) || action_id == ACTION_ANY); + if (!is_actor_unit_type(punit_type)) { /* Not an actor unit. */ + return FALSE; + } + + if (action_id == ACTION_ANY) { + /* Any action is OK. */ + action_iterate(alt_act) { + if (utype_may_act_move_frags(punit_type, alt_act, + move_fragments)) { + /* It only has to be true for one action. */ + return TRUE; + } + } action_iterate_end; + + /* No action enabled. */ return FALSE; } Modified: trunk/server/unithand.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=29587&r1=29586&r2=29587&view=diff ============================================================================== --- trunk/server/unithand.c (original) +++ trunk/server/unithand.c Wed Aug 19 16:44:15 2015 @@ -684,26 +684,15 @@ **************************************************************************/ static bool need_full_mp(const struct unit *actor, const int action_id) { - if (action_id == ACTION_ANY) { - /* Any action at all will do. */ - action_iterate(act) { - if (need_full_mp(actor, act)) { - /* Full movement points may enable this action. */ - return TRUE; - } - } action_iterate_end; - - /* No action at all may be enabled by full MP. */ - return FALSE; - } else { - /* Check if full movement points may enable the specified action. */ - return !utype_may_act_move_frags(unit_type(actor), - action_id, - actor->moves_left) - && utype_may_act_move_frags(unit_type(actor), - action_id, - unit_move_rate(actor)); - } + fc_assert(action_id_is_valid(action_id) || action_id == ACTION_ANY); + + /* Check if full movement points may enable the specified action. */ + return !utype_may_act_move_frags(unit_type(actor), + action_id, + actor->moves_left) + && utype_may_act_move_frags(unit_type(actor), + action_id, + unit_move_rate(actor)); } /************************************************************************** _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits