Author: sveinung
Date: Wed Dec 23 15:57:19 2015
New Revision: 31163

URL: http://svn.gna.org/viewcvs/freeciv?rev=31163&view=rev
Log:
Plug "Found City" max 1 city info leak.

Check if the target tile of "Found City" is seen by the actor player before
checking if it has a city when asked if founding a city on it is legal.

The leak is probably not exploitable. A unit can currently only build a
city at the tile where it is located.

See patch #6714

Modified:
    trunk/common/actions.c

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=31163&r1=31162&r2=31163&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Wed Dec 23 15:57:19 2015
@@ -1010,6 +1010,7 @@
                    const bool omniscient)
 {
   bool can_see_tgt_unit;
+  bool can_see_tgt_tile;
 
   fc_assert_msg((action_get_target_kind(wanted_action) == ATK_CITY
                  && target_city != NULL)
@@ -1029,6 +1030,14 @@
   can_see_tgt_unit = (omniscient || (target_unit
                                      && can_player_see_unit(actor_player,
                                                             target_unit)));
+
+  /* Only check requirement against the target tile if the actor can see it
+   * or if the evaluator is omniscient. The game checking the rules is
+   * omniscient. The player asking about his odds isn't. */
+  can_see_tgt_tile = (omniscient
+                      || (target_tile
+                          && (tile_get_known(target_tile, actor_player)
+                              == TILE_KNOWN_SEEN)));
 
   if (!action_actor_utype_hard_reqs_ok(wanted_action, actor_unittype)) {
     /* Info leak: The actor player knows the type of his unit. */
@@ -1191,6 +1200,16 @@
   }
 
   if (wanted_action == ACTION_FOUND_CITY) {
+    if (!can_see_tgt_tile) {
+      /* Need to know if target tile already has a city. */
+      return TRI_MAYBE;
+    }
+
+    if (tile_city(target_tile)) {
+      /* Reason: a tile can have 0 or 1 cities. */
+      return TRI_NO;
+    }
+
     /* TODO: Move more individual requirements to the action enabler. */
     if (!unit_can_build_city(actor_unit)) {
       return TRI_NO;


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

Reply via email to