Author: sveinung
Date: Wed Dec 28 17:29:59 2016
New Revision: 34744

URL: http://svn.gna.org/viewcvs/freeciv?rev=34744&view=rev
Log:
Explicit action target city is known assumption.

Make the assumption that a city targeted action's target city is know
explicit.

See patch #7974

Modified:
    branches/S2_6/common/actions.c
    branches/S2_6/doc/README.actions

Modified: branches/S2_6/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.c?rev=34744&r1=34743&r2=34744&view=diff
==============================================================================
--- branches/S2_6/common/actions.c      (original)
+++ branches/S2_6/common/actions.c      Wed Dec 28 17:29:59 2016
@@ -511,6 +511,16 @@
 }
 
 /**************************************************************************
+  Returns TRUE iff the specified player knows (has seen) the specified
+  tile.
+**************************************************************************/
+static bool plr_knows_tile(const struct player *plr,
+                           const struct tile *ttile)
+{
+  return plr && ttile && (tile_get_known(ttile, plr) != TILE_UNKNOWN);
+}
+
+/**************************************************************************
   Returns TRUE if the wanted action is possible given that an action
   enabler later will enable it.
 
@@ -562,13 +572,26 @@
     }
   }
 
-  if (action_id_get_target_kind(wanted_action) == ATK_UNIT) {
-    /* The Freeciv code for all actions with a unit target that is
-     * controlled by action enablers assumes that the acting player can see
-     * the target unit. */
+  switch (action_id_get_target_kind(wanted_action)) {
+  case ATK_UNIT:
+    /* The Freeciv code for all actions that is controlled by action
+     * enablers and targets a unit assumes that the acting
+     * player can see the target unit. */
     if (!can_player_see_unit(actor_player, target_unit)) {
       return FALSE;
     }
+    break;
+  case ATK_CITY:
+    /* The Freeciv code assumes that the player is aware of the target
+     * city's existence. (How can you order an airlift to a city when you
+     * don't know its city ID?) */
+    if (!(plr_knows_tile(actor_player, city_tile(target_city)))) {
+      return TRI_NO;
+    }
+    break;
+  case ATK_COUNT:
+    fc_assert(action_id_get_target_kind(wanted_action) != ATK_COUNT);
+    break;
   }
 
   if (wanted_action == ACTION_ESTABLISH_EMBASSY

Modified: branches/S2_6/doc/README.actions
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/doc/README.actions?rev=34744&r1=34743&r2=34744&view=diff
==============================================================================
--- branches/S2_6/doc/README.actions    (original)
+++ branches/S2_6/doc/README.actions    Wed Dec 28 17:29:59 2016
@@ -152,50 +152,60 @@
 =====================================
 "Establish Embassy" - Establish a real embassy to the target player
  * UI name can be set using ui_name_establish_embassy
+ * actor must be aware that the target exists
  * actor can't have a real embassy to the target player
  * actor must be on the same tile as the target or on the tile next to it.
  * target must be foreign.
 
 "Investigate City" - Look at the city dialog of a foreign city
  * UI name can be set using ui_name_investigate_city
+ * actor must be aware that the target exists
  * actor must be on the same tile as the target or on the tile next to it.
  * target must be foreign.
 
 "Sabotage City" - Destroy a building or the production in the target city.
  * UI name can be set using ui_name_sabotage_city
+ * actor must be aware that the target exists
  * actor must be on the same tile as the target or on the tile next to it.
 
 "Targeted Sabotage City" - Targeted version of the above.
  * UI name can be set using ui_name_targeted_sabotage_city
+ * actor must be aware that the target exists
  * actor must be on the same tile as the target or on the tile next to it.
 
 "Poison City" - Kill a citizen in the target city.
  * UI name can be set using ui_name_poison_city
+ * actor must be aware that the target exists
  * actor must be on the same tile as the target or on the tile next to it.
 
 "Steal Tech" - Steal a random tech from the targets owner.
  * UI name can be set using ui_name_steal_tech
+ * actor must be aware that the target exists
  * actor must be on the same tile as the target or on the tile next to it.
  * target must be foreign.
 
 "Targeted Steal Tech" - Targeted version of the above.
  * UI name can be set using ui_name_targeted_steal_tech
+ * actor must be aware that the target exists
  * actor must be on the same tile as the target or on the tile next to it.
  * target must be foreign.
 
 "Incite City" - Pay the target city to join the actors owners side.
  * UI name can be set using ui_name_incite_city
+ * actor must be aware that the target exists
  * actor must be on the same tile as the target or on the tile next to it.
  * target must be foreign.
 
 "Steal Gold" - Steal some gold from the owner of the target city.
  * UI name can be set using ui_name_steal_gold
+ * actor must be aware that the target exists
  * the targets owner must have more than 0 gold.
  * actor must be on the same tile as the target or on the tile next to it.
  * target must be foreign.
 
 "Establish Trade Route" - Establish a trade route to the target city.
  * UI name can be set using ui_name_establish_trade_route
+ * actor must be aware that the target exists
  * actor must be on the same tile as the target or on the tile next to it.
  * actor must have a home city.
  * target must be foreign or trademindist tiles away from that home city.
@@ -207,6 +217,7 @@
 
 "Enter Marketplace" - Get a one time bounus without creating a trade route.
  * UI name can be set using ui_name_enter_marketplace
+ * actor must be aware that the target exists
  * if force_trade_route is true "Establish Trade Route" must be impossible
  * actor must be on the same tile as the target or on the tile next to it.
  * actor must have a home city.
@@ -215,6 +226,7 @@
 
 "Help Wonder" - Add the shields used to build the actor to the target city.
  * UI name can be set using ui_name_help_wonder
+ * actor must be aware that the target exists
  * actor must be on the same tile as the target or on the tile next to it.
  * target must be building a wonder.
  * target city must still need the extra sheilds to build the wonder.


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

Reply via email to