Author: sveinung
Date: Fri Mar 13 14:00:49 2015
New Revision: 28513

URL: http://svn.gna.org/viewcvs/freeciv?rev=28513&view=rev
Log:
Give the requirement system the ability the check if a tile is claimed.

(I think this was) requested by Marko Lindqvist <cazfi>

See patch #5929

Modified:
    branches/S2_6/client/helpdata.c
    branches/S2_6/common/fc_types.h
    branches/S2_6/common/requirements.c
    branches/S2_6/doc/README.effects
    branches/S2_6/fc_version

Modified: branches/S2_6/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/helpdata.c?rev=28513&r1=28512&r2=28513&view=diff
==============================================================================
--- branches/S2_6/client/helpdata.c     (original)
+++ branches/S2_6/client/helpdata.c     Fri Mar 13 14:00:49 2015
@@ -2528,45 +2528,64 @@
     break;
 
   case VUT_CITYTILE:
-    if (preq->source.value.citytile != CITYT_CENTER) {
+    if (preq->source.value.citytile == CITYT_LAST) {
       break;
-    }
-    switch (preq->range) {
-    case REQ_RANGE_LOCAL:
-      if (preq->present) {
-        cat_snprintf(buf, bufsz, _("Applies only to city centers.\n"));
-      } else {
-        cat_snprintf(buf, bufsz, _("Does not apply to city centers.\n"));
-      }
-      return TRUE;
-    case REQ_RANGE_CADJACENT:
-      if (preq->present) {
-        cat_snprintf(buf, bufsz, _("Applies only to city centers and "
-                                   "cardinally adjacent tiles.\n"));
-      } else {
-        cat_snprintf(buf, bufsz, _("Does not apply to city centers or "
-                                   "cardinally adjacent tiles.\n"));
-      }
-      return TRUE;
-    case REQ_RANGE_ADJACENT:
-      if (preq->present) {
-        cat_snprintf(buf, bufsz, _("Applies only to city centers and "
-                                   "adjacent tiles.\n"));
-      } else {
-        cat_snprintf(buf, bufsz, _("Does not apply to city centers or "
-                                   "adjacent tiles.\n"));
-      }
-      return TRUE;
-    case REQ_RANGE_CITY:
-    case REQ_RANGE_TRADEROUTE:
-    case REQ_RANGE_CONTINENT:
-    case REQ_RANGE_PLAYER:
-    case REQ_RANGE_TEAM:
-    case REQ_RANGE_ALLIANCE:
-    case REQ_RANGE_WORLD:
-    case REQ_RANGE_COUNT:
-      /* Not supported. */
-      break;
+    } else {
+      static char *tile_property = NULL;
+
+      switch (preq->source.value.citytile) {
+      case CITYT_CENTER:
+        tile_property = "city centers";
+        break;
+      case CITYT_CLAIMED:
+        tile_property = "claimed tiles";
+        break;
+      case CITYT_LAST:
+        fc_assert(preq->source.value.citytile != CITYT_LAST);
+        break;
+      }
+
+      switch (preq->range) {
+      case REQ_RANGE_LOCAL:
+        if (preq->present) {
+          cat_snprintf(buf, bufsz,
+                       _("Applies only to %s.\n"), tile_property);
+        } else {
+          cat_snprintf(buf, bufsz,
+                       _("Does not apply to %s.\n"), tile_property);
+        }
+        return TRUE;
+      case REQ_RANGE_CADJACENT:
+        if (preq->present) {
+          cat_snprintf(buf, bufsz, _("Applies only to %s and "
+                                     "cardinally adjacent tiles.\n"),
+                       tile_property);
+        } else {
+          cat_snprintf(buf, bufsz, _("Does not apply to %s or "
+                                     "cardinally adjacent tiles.\n"),
+                       tile_property);
+        }
+        return TRUE;
+      case REQ_RANGE_ADJACENT:
+        if (preq->present) {
+          cat_snprintf(buf, bufsz, _("Applies only to %s and "
+                                     "adjacent tiles.\n"), tile_property);
+        } else {
+          cat_snprintf(buf, bufsz, _("Does not apply to %s or "
+                                     "adjacent tiles.\n"), tile_property);
+        }
+        return TRUE;
+      case REQ_RANGE_CITY:
+      case REQ_RANGE_TRADEROUTE:
+      case REQ_RANGE_CONTINENT:
+      case REQ_RANGE_PLAYER:
+      case REQ_RANGE_TEAM:
+      case REQ_RANGE_ALLIANCE:
+      case REQ_RANGE_WORLD:
+      case REQ_RANGE_COUNT:
+        /* Not supported. */
+        break;
+      }
     }
 
   case VUT_COUNT:

Modified: branches/S2_6/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/fc_types.h?rev=28513&r1=28512&r2=28513&view=diff
==============================================================================
--- branches/S2_6/common/fc_types.h     (original)
+++ branches/S2_6/common/fc_types.h     Fri Mar 13 14:00:49 2015
@@ -269,6 +269,8 @@
 #define SPECENUM_NAME citytile_type
 #define SPECENUM_VALUE0 CITYT_CENTER
 #define SPECENUM_VALUE0NAME "Center"
+#define SPECENUM_VALUE1 CITYT_CLAIMED
+#define SPECENUM_VALUE1NAME "Claimed"
 #define SPECENUM_COUNT CITYT_LAST
 #include "specenum_gen.h"
 

Modified: branches/S2_6/common/requirements.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/requirements.c?rev=28513&r1=28512&r2=28513&view=diff
==============================================================================
--- branches/S2_6/common/requirements.c (original)
+++ branches/S2_6/common/requirements.c Fri Mar 13 14:00:49 2015
@@ -2329,6 +2329,46 @@
       case REQ_RANGE_WORLD:
       case REQ_RANGE_COUNT:
        break;
+      }
+
+      fc_assert_msg(FALSE, "Invalid range %d for citytile.", range);
+
+      return TRI_MAYBE;
+    } else if (citytile == CITYT_CLAIMED) {
+      switch (range) {
+      case REQ_RANGE_LOCAL:
+        return BOOL_TO_TRISTATE(target_tile->owner != NULL);
+      case REQ_RANGE_CADJACENT:
+        if (target_tile->owner != NULL) {
+          return TRI_YES;
+        }
+        cardinal_adjc_iterate(target_tile, adjc_tile) {
+          if (adjc_tile->owner != NULL) {
+            return TRI_YES;
+          }
+        } cardinal_adjc_iterate_end;
+
+        return TRI_NO;
+      case REQ_RANGE_ADJACENT:
+        if (target_tile->owner != NULL) {
+          return TRI_YES;
+        }
+        adjc_iterate(target_tile, adjc_tile) {
+          if (adjc_tile->owner != NULL) {
+            return TRI_YES;
+          }
+        } adjc_iterate_end;
+
+        return TRI_NO;
+      case REQ_RANGE_CITY:
+      case REQ_RANGE_TRADEROUTE:
+      case REQ_RANGE_CONTINENT:
+      case REQ_RANGE_PLAYER:
+      case REQ_RANGE_TEAM:
+      case REQ_RANGE_ALLIANCE:
+      case REQ_RANGE_WORLD:
+      case REQ_RANGE_COUNT:
+        break;
       }
 
       fc_assert_msg(FALSE, "Invalid range %d for citytile.", range);

Modified: branches/S2_6/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/doc/README.effects?rev=28513&r1=28512&r2=28513&view=diff
==============================================================================
--- branches/S2_6/doc/README.effects    (original)
+++ branches/S2_6/doc/README.effects    Fri Mar 13 14:00:49 2015
@@ -84,7 +84,7 @@
 MinSize is the minimum size of a city required.
 AI is ai player difficulty level.
 TerrainClass is either "Land" or "Oceanic".
-Only "Center" is supported as CityTile type.
+CityTile is either "Center" (city center) or "Claimed" (owned).
 DiplRel is a diplomatic relationship.
 MaxUnitsOnTile is about the number of units present on a tile.
 UnitState is "Transported" or "TransportDependent".

Modified: branches/S2_6/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=28513&r1=28512&r2=28513&view=diff
==============================================================================
--- branches/S2_6/fc_version    (original)
+++ branches/S2_6/fc_version    Fri Mar 13 14:00:49 2015
@@ -54,7 +54,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-2.6-2015.Mar.03"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Mar.13"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""


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

Reply via email to