Author: sveinung
Date: Fri Sep  2 16:11:37 2016
New Revision: 33742

URL: http://svn.gna.org/viewcvs/freeciv?rev=33742&view=rev
Log:
Act prob: stop leaking invisible units.

An invisible unit at a tile can allow or forbid an action with the units
target. An unseen enemy can make the "Bombard" action legal. An invisible
unit belonging to someone the player has peace with can forbid bombard. Stop
leaking this information by making action probability calculation against
unit stack targeted actions consider this.

See bug #25010

Modified:
    trunk/common/actions.c

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=33742&r1=33741&r2=33742&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Fri Sep  2 16:11:37 2016
@@ -2616,8 +2616,7 @@
   struct act_prob prob_all;
   struct tile *actor_tile = unit_tile(actor_unit);
 
-  if (actor_unit == NULL || target_tile == NULL
-      || unit_list_size(target_tile->units) == 0) {
+  if (actor_unit == NULL || target_tile == NULL) {
     /* Can't do an action when actor or target are missing. */
     return ACTPROB_IMPOSSIBLE;
   }
@@ -2640,6 +2639,18 @@
 
   if (!unit_can_do_action(actor_unit, action_id)) {
     /* No point in continuing. */
+    return ACTPROB_IMPOSSIBLE;
+  }
+
+  /* Do 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 ACTPROB_NOT_KNOWN;
+  } 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

Reply via email to