Author: sveinung Date: Sun Sep 25 18:01:28 2016 New Revision: 33889 URL: http://svn.gna.org/viewcvs/freeciv?rev=33889&view=rev Log: does_terrain_block_action: kill false negatives.
Eliminate some cases where the action not enabled explanation detection failed to find out that a tile's terrain blocks an action. * if the terrain doesn't block an action the unit can't do the terrain still blocks the unit from performing any action. * if an action enabler allows some action to be performed but not by the unit seeking an explanation the terrain still blocks the unit from performing the action. See patch #7722 Modified: branches/S2_6/server/unithand.c Modified: branches/S2_6/server/unithand.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unithand.c?rev=33889&r1=33888&r2=33889&view=diff ============================================================================== --- branches/S2_6/server/unithand.c (original) +++ branches/S2_6/server/unithand.c Sun Sep 25 18:01:28 2016 @@ -588,12 +588,15 @@ **************************************************************************/ static bool does_terrain_block_action(const int action_id, bool is_target, + struct unit *actor_unit, struct terrain *pterrain) { if (action_id == ACTION_ANY) { /* Any action is OK. */ action_iterate(alt_act) { - if (!does_terrain_block_action(alt_act, is_target, pterrain)) { + if (utype_can_do_action(unit_type_get(actor_unit), alt_act) + && !does_terrain_block_action(alt_act, is_target, + actor_unit, pterrain)) { /* Only one action has to be possible. */ return FALSE; } @@ -609,7 +612,9 @@ action_enabler_list_iterate(action_enablers_for_action(action_id), enabler) { if (requirement_fulfilled_by_terrain(pterrain, - (is_target ? &enabler->target_reqs : &enabler->actor_reqs))) { + (is_target ? &enabler->target_reqs : &enabler->actor_reqs)) + && requirement_fulfilled_by_unit_type(unit_type_get(actor_unit), + &enabler->actor_reqs)) { /* This terrain kind doesn't block this action enabler. */ return FALSE; } @@ -642,13 +647,13 @@ explnat->no_act_terrain = tile_terrain(unit_tile(punit)); } else if (punit && does_terrain_block_action(action_id, FALSE, - tile_terrain(unit_tile(punit)))) { + punit, tile_terrain(unit_tile(punit)))) { /* No action enabler allows acting against this terrain kind. */ explnat->kind = ANEK_BAD_TERRAIN_ACT; explnat->no_act_terrain = tile_terrain(unit_tile(punit)); } else if (target_tile && does_terrain_block_action(action_id, TRUE, - tile_terrain(target_tile))) { + punit, tile_terrain(target_tile))) { /* No action enabler allows acting against this terrain kind. */ explnat->kind = ANEK_BAD_TERRAIN_TGT; explnat->no_act_terrain = tile_terrain(target_tile); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits