Author: sveinung
Date: Tue Dec 16 17:55:23 2014
New Revision: 27318

URL: http://svn.gna.org/viewcvs/freeciv?rev=27318&view=rev
Log:
Clean up: Only select the target city if acting against it is possible.

This makes tgt_city() behave consistent with tgt_unit()

See patch #5553

Modified:
    trunk/server/unithand.c

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=27318&r1=27317&r2=27318&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Tue Dec 16 17:55:23 2014
@@ -276,7 +276,14 @@
 **************************************************************************/
 static struct city *tgt_city(struct unit *actor, struct tile *target_tile)
 {
-  return tile_city(target_tile);
+  struct city *target = tile_city(target_tile);
+
+  if (target && may_unit_act_vs_city(actor, target)) {
+    /* It may be possible to act against this city. */
+    return target;
+  }
+
+  return NULL;
 }
 
 /**************************************************************************
@@ -1785,17 +1792,17 @@
     struct unit *tunit = tgt_unit(punit, pdesttile);
     struct city *tcity = tgt_city(punit, pdesttile);
 
-    if ((0 < unit_list_size(pdesttile->units) || tcity)
+    if ((0 < unit_list_size(pdesttile->units) || pcity)
         && !(move_diplomat_city
              && unit_can_move_to_tile(punit, pdesttile, igzoc))) {
       /* A target (unit or city) exists at the tile. If a target is an ally
        * it still looks like a target since move_diplomat_city isn't set.
        * Assume that the intention is to do an action. */
 
-      if (may_unit_act_vs_city(punit, tcity)
-          /* It must be possible to act against tunit since tgt_unit()
-           * wouldn't have targeted it otherwise. */
-          || tunit != NULL) {
+      /* If a tcity or a tunit exists it must be possible to act against it
+       * since tgt_city() or tgt_unit() wouldn't have targeted it
+       * otherwise. */
+      if (tcity || tunit) {
         if (pplayer->ai_controlled) {
           return FALSE;
         }


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

Reply via email to