Author: sveinung Date: Sun Nov 13 19:29:46 2016 New Revision: 34497 URL: http://svn.gna.org/viewcvs/freeciv?rev=34497&view=rev Log: An unknown target can't make an action possible.
An action can be known to be impossible because of the actor unit. When this is true it doesn't matter what the target is. Example: It doesn't matter if the unseen distant tile the unit wants to bombard has units or not when it is out of moves and the rules requires a bombarding unit to have a move fragment left. Have the action probability calculation for unit stack targeted actions return impossible rather than unknown when the actor unit is known to make the action impossible. See bug #25281 Modified: trunk/common/actions.c Modified: trunk/common/actions.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=34497&r1=34496&r2=34497&view=diff ============================================================================== --- trunk/common/actions.c (original) +++ trunk/common/actions.c Sun Nov 13 19:29:46 2016 @@ -2740,6 +2740,21 @@ return ACTPROB_CERTAIN; } +/*************************************************************************** + Returns the action probability for when a target is unseen. +***************************************************************************/ +static struct act_prob act_prob_unseen_target(int action_id, + const struct unit *actor_unit) +{ + if (action_maybe_possible_actor_unit(action_id, actor_unit)) { + /* Unknown because the target is unseen. */ + return ACTPROB_NOT_KNOWN; + } else { + /* The actor it self can't do this. */ + return ACTPROB_IMPOSSIBLE; + } +} + /************************************************************************** An action's probability of success. @@ -3133,7 +3148,7 @@ target_tile)) { /* Invisible units at this tile can make the action legal or * illegal. */ - return ACTPROB_NOT_KNOWN; + return act_prob_unseen_target(action_id, actor_unit); } else if (unit_list_size(target_tile->units) == 0) { /* Known empty tile. */ return ACTPROB_IMPOSSIBLE; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits