Author: sveinung
Date: Wed Apr 12 11:57:22 2017
New Revision: 35226

URL: http://svn.gna.org/viewcvs/freeciv?rev=35226&view=rev
Log:
A visible unit may forbid a stack tgt action.

A unit the player is able to see may make a unit stack targeted action
illegal. Make action_prob_vs_units() use this fact to eliminate false
positives.

See hrm Feature #651396

Modified:
    branches/S3_0/common/actions.c

Modified: branches/S3_0/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/actions.c?rev=35226&r1=35225&r2=35226&view=diff
==============================================================================
--- branches/S3_0/common/actions.c      (original)
+++ branches/S3_0/common/actions.c      Wed Apr 12 11:57:22 2017
@@ -3206,21 +3206,36 @@
     return ACTPROB_IMPOSSIBLE;
   }
 
-  /* Does the player know if there are units at the tile? Must be done here
-   * since an empthy unseen tile will result in false. */
-  if (!can_player_see_hypotetic_units_at(unit_owner(actor_unit),
-                                         target_tile)) {
-    /* Invisible units at this tile can make the action legal or
-     * illegal. */
-    return act_prob_unseen_target(action_id, actor_unit);
-  } else if (unit_list_size(target_tile->units) == 0) {
-    /* Known empty tile. */
-    return ACTPROB_IMPOSSIBLE;
-  }
-
-  prob_all = ACTPROB_CERTAIN;
+  /* Must be done here since an empty unseen tile will result in
+   * ACTPROB_IMPOSSIBLE. */
+  if (unit_list_size(target_tile->units) == 0) {
+    /* Can't act against an empty tile. */
+
+    if (player_can_trust_tile_has_no_units(unit_owner(actor_unit),
+                                           target_tile)) {
+      /* Known empty tile. */
+      return ACTPROB_IMPOSSIBLE;
+    } else {
+      /* The player doesn't know that the tile is empty. */
+      return act_prob_unseen_target(action_id, actor_unit);
+    }
+  }
+
+  /* Invisible units at this tile can make the action legal or illegal.
+   * Invisible units can be stacked with visible units. The possible
+   * existence of invisible units therefore makes the result uncertain. */
+  prob_all = (can_player_see_hypotetic_units_at(unit_owner(actor_unit),
+                                                target_tile)
+              ? ACTPROB_CERTAIN : ACTPROB_NOT_KNOWN);
+
   unit_list_iterate(target_tile->units, target_unit) {
     struct act_prob prob_unit;
+
+    if (!can_player_see_unit(unit_owner(actor_unit), target_unit)) {
+      /* Only visible units are considered. The invisible units contributed
+       * their uncertainty to prob_all above. */
+      continue;
+    }
 
     prob_unit = action_prob(action_id,
                             unit_owner(actor_unit),


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to