Author: sveinung
Date: Sun Mar  6 16:16:00 2016
New Revision: 32191

URL: http://svn.gna.org/viewcvs/freeciv?rev=32191&view=rev
Log:
Evaluate actor_reqs against actor's tile city.

Make City range action enabler actor requirements about the city the actor
unit is located inside. The alternative is to make it about the actor unit's
home city.

This allows action enablers to depend on city walls, oil depots, airports
and turrets. The cost is that they won't be able to depend on smuggler's
dens, special secret munition factories and public schools.

Picking the tile city is consistent with depending on the actor unit's
current tile. Home city properties can be supported later via other
mechanisms.

See patch #7039

Modified:
    trunk/common/actions.c
    trunk/fc_version

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=32191&r1=32190&r2=32191&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Sun Mar  6 16:16:00 2016
@@ -1591,6 +1591,7 @@
                                     const struct unit *actor_unit,
                                     const struct city *target_city)
 {
+  struct tile *actor_tile = unit_tile(actor_unit);
   struct impr_type *target_building;
   struct unit_type *target_utype;
 
@@ -1617,8 +1618,8 @@
   target_utype = tgt_city_local_utype(target_city);
 
   return is_action_enabled(wanted_action,
-                           unit_owner(actor_unit), NULL, NULL,
-                           unit_tile(actor_unit),
+                           unit_owner(actor_unit), tile_city(actor_tile),
+                           NULL, actor_tile,
                            actor_unit, unit_type_get(actor_unit),
                            NULL, NULL,
                            city_owner(target_city), target_city,
@@ -1636,6 +1637,8 @@
                                     const struct unit *actor_unit,
                                     const struct unit *target_unit)
 {
+  struct tile *actor_tile = unit_tile(actor_unit);
+
   if (actor_unit == NULL || target_unit == NULL) {
     /* Can't do an action when actor or target are missing. */
     return FALSE;
@@ -1656,8 +1659,8 @@
                         action_target_kind_name(ATK_UNIT));
 
   return is_action_enabled(wanted_action,
-                           unit_owner(actor_unit), NULL, NULL,
-                           unit_tile(actor_unit),
+                           unit_owner(actor_unit), tile_city(actor_tile),
+                           NULL, actor_tile,
                            actor_unit, unit_type_get(actor_unit),
                            NULL, NULL,
                            unit_owner(target_unit),
@@ -1677,6 +1680,8 @@
                                      const struct unit *actor_unit,
                                      const struct tile *target_tile)
 {
+  struct tile *actor_tile = unit_tile(actor_unit);
+
   if (actor_unit == NULL || target_tile == NULL
       || unit_list_size(target_tile->units) == 0) {
     /* Can't do an action when actor or target are missing. */
@@ -1699,8 +1704,8 @@
 
   unit_list_iterate(target_tile->units, target_unit) {
     if (!is_action_enabled(wanted_action,
-                           unit_owner(actor_unit), NULL, NULL,
-                           unit_tile(actor_unit),
+                           unit_owner(actor_unit), tile_city(actor_tile),
+                           NULL, actor_tile,
                            actor_unit, unit_type_get(actor_unit),
                            NULL, NULL,
                            unit_owner(target_unit),
@@ -1727,6 +1732,8 @@
                                     const struct unit *actor_unit,
                                     const struct tile *target_tile)
 {
+  struct tile *actor_tile = unit_tile(actor_unit);
+
   if (actor_unit == NULL || target_tile == NULL) {
     /* Can't do an action when actor or target are missing. */
     return FALSE;
@@ -1747,8 +1754,8 @@
                         action_target_kind_name(ATK_TILE));
 
   return is_action_enabled(wanted_action,
-                           unit_owner(actor_unit), NULL, NULL,
-                           unit_tile(actor_unit),
+                           unit_owner(actor_unit), tile_city(actor_tile),
+                           NULL, actor_tile,
                            actor_unit, unit_type_get(actor_unit),
                            NULL, NULL,
                            tile_owner(target_tile), NULL, NULL,
@@ -1765,6 +1772,8 @@
 bool is_action_enabled_unit_on_self(const enum gen_action wanted_action,
                                     const struct unit *actor_unit)
 {
+  struct tile *actor_tile = unit_tile(actor_unit);
+
   if (actor_unit == NULL) {
     /* Can't do an action when the actor is missing. */
     return FALSE;
@@ -1785,8 +1794,8 @@
                         action_target_kind_name(ATK_SELF));
 
   return is_action_enabled(wanted_action,
-                           unit_owner(actor_unit), NULL, NULL,
-                           unit_tile(actor_unit),
+                           unit_owner(actor_unit), tile_city(actor_tile),
+                           NULL, actor_tile,
                            actor_unit, unit_type_get(actor_unit),
                            NULL, NULL,
                            NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
@@ -2243,6 +2252,7 @@
                                        const int action_id,
                                        const struct city* target_city)
 {
+  struct tile *actor_tile = unit_tile(actor_unit);
   struct impr_type *target_building;
   struct unit_type *target_utype;
 
@@ -2269,8 +2279,8 @@
   target_utype = tgt_city_local_utype(target_city);
 
   return action_prob(action_id,
-                     unit_owner(actor_unit), NULL, NULL,
-                     unit_tile(actor_unit), actor_unit, NULL,
+                     unit_owner(actor_unit), tile_city(actor_tile),
+                     NULL, actor_tile, actor_unit, NULL,
                      NULL, NULL,
                      city_owner(target_city), target_city,
                      target_building, city_tile(target_city),
@@ -2285,6 +2295,8 @@
                                        const int action_id,
                                        const struct unit* target_unit)
 {
+  struct tile *actor_tile = unit_tile(actor_unit);
+
   if (actor_unit == NULL || target_unit == NULL) {
     /* Can't do an action when actor or target are missing. */
     return ACTPROB_IMPOSSIBLE;
@@ -2305,8 +2317,8 @@
                         action_target_kind_name(ATK_UNIT));
 
   return action_prob(action_id,
-                     unit_owner(actor_unit), NULL, NULL,
-                     unit_tile(actor_unit), actor_unit, NULL,
+                     unit_owner(actor_unit), tile_city(actor_tile),
+                     NULL, actor_tile, actor_unit, NULL,
                      NULL, NULL,
                      unit_owner(target_unit),
                      tile_city(unit_tile(target_unit)), NULL,
@@ -2323,6 +2335,7 @@
                                         const struct tile* target_tile)
 {
   int prob_all;
+  struct tile *actor_tile = unit_tile(actor_unit);
 
   if (actor_unit == NULL || target_tile == NULL
       || unit_list_size(target_tile->units) == 0) {
@@ -2347,9 +2360,9 @@
   prob_all = 200;
   unit_list_iterate(target_tile->units, target_unit) {
     int prob_unit = action_prob(action_id,
-                                unit_owner(actor_unit), NULL, NULL,
-                                unit_tile(actor_unit),
-                                actor_unit, NULL,
+                                unit_owner(actor_unit),
+                                tile_city(actor_tile),
+                                NULL, actor_tile, actor_unit, NULL,
                                 NULL, NULL,
                                 unit_owner(target_unit),
                                 tile_city(unit_tile(target_unit)), NULL,
@@ -2399,6 +2412,8 @@
                                        const int action_id,
                                        const struct tile* target_tile)
 {
+  struct tile *actor_tile = unit_tile(actor_unit);
+
   if (actor_unit == NULL || target_tile == NULL) {
     /* Can't do an action when actor or target are missing. */
     return ACTPROB_IMPOSSIBLE;
@@ -2419,9 +2434,8 @@
                         action_target_kind_name(ATK_TILE));
 
   return action_prob(action_id,
-                     unit_owner(actor_unit), NULL, NULL,
-                     unit_tile(actor_unit),
-                     actor_unit, NULL,
+                     unit_owner(actor_unit), tile_city(actor_tile),
+                     NULL, actor_tile, actor_unit, NULL,
                      NULL, NULL,
                      tile_owner(target_tile), NULL, NULL,
                      target_tile, NULL, NULL, NULL, NULL);
@@ -2434,6 +2448,8 @@
 action_probability action_prob_self(const struct unit* actor_unit,
                                     const int action_id)
 {
+  struct tile *actor_tile = unit_tile(actor_unit);
+
   if (actor_unit == NULL) {
     /* Can't do the action when the actor is missing. */
     return ACTPROB_IMPOSSIBLE;
@@ -2454,8 +2470,8 @@
                         action_target_kind_name(ATK_SELF));
 
   return action_prob(action_id,
-                     unit_owner(actor_unit), NULL, NULL,
-                     unit_tile(actor_unit), actor_unit, NULL,
+                     unit_owner(actor_unit), tile_city(actor_tile),
+                     NULL, actor_tile, actor_unit, NULL,
                      NULL, NULL,
                      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 }

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=32191&r1=32190&r2=32191&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Sun Mar  6 16:16:00 2016
@@ -55,7 +55,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Mar.02"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Mar.06"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""


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

Reply via email to