Author: cazfi
Date: Tue Aug 11 17:43:17 2015
New Revision: 29459

URL: http://svn.gna.org/viewcvs/freeciv?rev=29459&view=rev
Log:
Added "Topology" requirement type.

See patch #6193

Modified:
    trunk/ai/default/daieffects.c
    trunk/client/helpdata.c
    trunk/common/fc_types.h
    trunk/common/map.h
    trunk/common/requirements.c
    trunk/doc/README.effects
    trunk/fc_version
    trunk/server/cityturn.c
    trunk/server/rssanity.c

Modified: trunk/ai/default/daieffects.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/daieffects.c?rev=29459&r1=29458&r2=29459&view=diff
==============================================================================
--- trunk/ai/default/daieffects.c       (original)
+++ trunk/ai/default/daieffects.c       Tue Aug 11 17:43:17 2015
@@ -698,6 +698,7 @@
   case VUT_ADVANCE:
   case VUT_MINSIZE:
   case VUT_MINYEAR:
+  case VUT_TOPO:
   case VUT_AGE:
   case VUT_TECHFLAG:
   case VUT_ACHIEVEMENT:

Modified: trunk/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/helpdata.c?rev=29459&r1=29458&r2=29459&view=diff
==============================================================================
--- trunk/client/helpdata.c     (original)
+++ trunk/client/helpdata.c     Tue Aug 11 17:43:17 2015
@@ -2502,6 +2502,21 @@
                    _("Requires that the game has not yet reached the "
                      "year %s.\n"),
                    textyear(preq->source.value.minyear));
+    }
+    return TRUE;
+
+  case VUT_TOPO:
+    if (preq->range != REQ_RANGE_WORLD) {
+      break;
+    }
+    if (preq->present) {
+      cat_snprintf(buf, bufsz,
+                   _("Requires %s map.\n"),
+                   _(topo_flag_name(preq->source.value.topo_property)));
+    } else {
+      cat_snprintf(buf, bufsz,
+                   _("Prevented on %s map.\n"),
+                   _(topo_flag_name(preq->source.value.topo_property)));
     }
     return TRUE;
 

Modified: trunk/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=29459&r1=29458&r2=29459&view=diff
==============================================================================
--- trunk/common/fc_types.h     (original)
+++ trunk/common/fc_types.h     Tue Aug 11 17:43:17 2015
@@ -294,6 +294,19 @@
 #define SPECENUM_COUNT USP_COUNT
 #include "specenum_gen.h"
 
+/* Changing these values will break map_init_topology. */
+#define SPECENUM_NAME topo_flag
+#define SPECENUM_BITWISE
+#define SPECENUM_VALUE0 TF_WRAPX
+#define SPECENUM_VALUE0NAME N_("WrapX")
+#define SPECENUM_VALUE1 TF_WRAPY
+#define SPECENUM_VALUE1NAME N_("WrapY")
+#define SPECENUM_VALUE2 TF_ISO
+#define SPECENUM_VALUE2NAME N_("ISO")
+#define SPECENUM_VALUE3 TF_HEX
+#define SPECENUM_VALUE3NAME N_("Hex")
+#include "specenum_gen.h"
+
 /* Sometimes we don't know (or don't care) if some requirements for effect
  * are currently fulfilled or not. This enum tells lower level functions
  * how to handle uncertain requirements.
@@ -348,6 +361,8 @@
   int minveteran;
   int min_hit_points;
   int age;
+
+  enum topo_flag topo_property;
 } universals_u;
 
 /* The kind of universals_u (value_union_type was req_source_type).
@@ -430,8 +445,10 @@
 #define SPECENUM_VALUE34NAME "Age"
 #define SPECENUM_VALUE35 VUT_NATIONGROUP
 #define SPECENUM_VALUE35NAME "NationGroup"
-#define SPECENUM_VALUE36 VUT_ACTION
-#define SPECENUM_VALUE36NAME "Action"
+#define SPECENUM_VALUE36 VUT_TOPO
+#define SPECENUM_VALUE36NAME "Topology"
+#define SPECENUM_VALUE37 VUT_ACTION
+#define SPECENUM_VALUE37NAME "Action"
 /* Keep this last. */
 #define SPECENUM_COUNT VUT_COUNT
 #include "specenum_gen.h"

Modified: trunk/common/map.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/map.h?rev=29459&r1=29458&r2=29459&view=diff
==============================================================================
--- trunk/common/map.h  (original)
+++ trunk/common/map.h  Tue Aug 11 17:43:17 2015
@@ -110,15 +110,6 @@
 
     /* Add client side when needed */
   };
-};
-
-enum topo_flag {
-  /* Bit-values. */
-  /* Changing these values will break map_init_topology. */
-  TF_WRAPX = 1,
-  TF_WRAPY = 2,
-  TF_ISO = 4,
-  TF_HEX = 8
 };
 
 /* Parameters for terrain counting functions. */

Modified: trunk/common/requirements.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/requirements.c?rev=29459&r1=29458&r2=29459&view=diff
==============================================================================
--- trunk/common/requirements.c (original)
+++ trunk/common/requirements.c Tue Aug 11 17:43:17 2015
@@ -273,6 +273,12 @@
   case VUT_MINYEAR:
     source.value.minyear = atoi(value);
     return source;
+  case VUT_TOPO:
+    source.value.topo_property = topo_flag_by_name(value, fc_strcasecmp);
+    if (topo_flag_is_valid(source.value.topo_property)) {
+      return source;
+    }
+    break;
   case VUT_TERRAINALTER:
     source.value.terrainalter
       = terrain_alteration_by_name(value, fc_strcasecmp);
@@ -456,6 +462,9 @@
     return source;
   case VUT_MINYEAR:
     source.value.minyear = value;
+    return source;
+  case VUT_TOPO:
+    source.value.topo_property = value;
     return source;
   case VUT_TERRAINALTER:
     source.value.terrainalter = value;
@@ -562,6 +571,8 @@
     return source->value.roadflag;
   case VUT_MINYEAR:
     return source->value.minyear;
+  case VUT_TOPO:
+    return source->value.topo_property;
   case VUT_TERRAINALTER:
     return source->value.terrainalter;
   case VUT_CITYTILE:
@@ -662,6 +673,7 @@
       req.range = REQ_RANGE_PLAYER;
       break;
     case VUT_MINYEAR:
+    case VUT_TOPO:
       req.range = REQ_RANGE_WORLD;
       break;
     }
@@ -750,6 +762,7 @@
                && req.range != REQ_RANGE_ADJACENT);
     break;
   case VUT_MINYEAR:
+  case VUT_TOPO:
     invalid = (req.range != REQ_RANGE_WORLD);
     break;
   case VUT_AGE:
@@ -802,6 +815,7 @@
     case VUT_AI_LEVEL:
     case VUT_TERRAINCLASS:
     case VUT_MINYEAR:
+    case VUT_TOPO:
     case VUT_TERRAINALTER:
     case VUT_CITYTILE:
     case VUT_RESOURCE:
@@ -2746,6 +2760,9 @@
   case VUT_MINYEAR:
     eval = BOOL_TO_TRISTATE(game.info.year >= req->source.value.minyear);
     break;
+  case VUT_TOPO:
+    eval = 
BOOL_TO_TRISTATE(current_topo_has_flag(req->source.value.topo_property));
+    break;
   case VUT_TERRAINALTER:
     if (target_tile == NULL) {
       eval = TRI_MAYBE;
@@ -2841,6 +2858,7 @@
   case VUT_AI_LEVEL:
   case VUT_CITYTILE:
   case VUT_STYLE:
+  case VUT_TOPO:
     return TRUE;
   case VUT_NATION:
   case VUT_NATIONGROUP:
@@ -2986,6 +3004,8 @@
     return psource1->value.roadflag == psource2->value.roadflag;
   case VUT_MINYEAR:
     return psource1->value.minyear == psource2->value.minyear;
+  case VUT_TOPO:
+    return psource1->value.topo_property == psource2->value.topo_property;
   case VUT_TERRAINALTER:
     return psource1->value.terrainalter == psource2->value.terrainalter;
   case VUT_CITYTILE:
@@ -3015,6 +3035,8 @@
     fc_snprintf(buffer, sizeof(buffer), "%d", psource->value.minyear);
 
     return buffer;
+  case VUT_TOPO:
+    return topo_flag_name(psource->value.topo_property);
   case VUT_ADVANCE:
     return advance_rule_name(psource->value.advance);
   case VUT_TECHFLAG:
@@ -3290,6 +3312,10 @@
     cat_snprintf(buf, bufsz, _("After %s"),
                  textyear(psource->value.minyear));
     return buf;
+  case VUT_TOPO:
+    cat_snprintf(buf, bufsz, _("%s map"),
+                 _(topo_flag_name(psource->value.topo_property)));
+    return buf;
   case VUT_TERRAINALTER:
     /* TRANS: "Irrigation possible" */
     cat_snprintf(buf, bufsz, _("%s possible"),

Modified: trunk/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.effects?rev=29459&r1=29458&r2=29459&view=diff
==============================================================================
--- trunk/doc/README.effects    (original)
+++ trunk/doc/README.effects    Tue Aug 11 17:43:17 2015
@@ -66,6 +66,7 @@
 OutputType:    Local
 Specialist:    Local
 MinYear:       World
+Topology:      World
 Age:           Local, City
 MinSize:       Traderoute, City
 MinCulture:    World, Alliance, Team, Player, Traderoute, City

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=29459&r1=29458&r2=29459&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Tue Aug 11 17:43:17 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-3.0-2015.Aug.11"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Aug.11b"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/cityturn.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/cityturn.c?rev=29459&r1=29458&r2=29459&view=diff
==============================================================================
--- trunk/server/cityturn.c     (original)
+++ trunk/server/cityturn.c     Tue Aug 11 17:43:17 2015
@@ -1727,6 +1727,22 @@
                 success = FALSE;
               }
               break;
+            case VUT_TOPO:
+              if (preq->present) {
+                notify_player(pplayer, city_tile(pcity),
+                              E_CITY_CANTBUILD, ftc_server,
+                              _("%s can't build %s from the workist; "
+                                "only available in worlds with %s map."),
+                              city_link(pcity),
+                              city_improvement_name_translation(pcity, 
ptarget),
+                              
_(topo_flag_name(preq->source.value.topo_property)));
+                script_server_signal_emit("building_cant_be_built", 3,
+                                          API_TYPE_BUILDING_TYPE, ptarget,
+                                          API_TYPE_CITY, pcity,
+                                          API_TYPE_STRING, "need_topo");
+              }
+              success = FALSE;
+              break;
             case VUT_AGE:
               if (preq->present) {
                 notify_player(pplayer, city_tile(pcity),

Modified: trunk/server/rssanity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/rssanity.c?rev=29459&r1=29458&r2=29459&view=diff
==============================================================================
--- trunk/server/rssanity.c     (original)
+++ trunk/server/rssanity.c     Tue Aug 11 17:43:17 2015
@@ -205,6 +205,8 @@
       }
       break;
 
+     case VUT_TOPO:
+       /* Can have multiple, since it's flag based (iso & wrapx & wrapy & hex) 
*/
      case VUT_EXTRA:
        /* Note that there can be more than 1 extra / tile. */
      case VUT_MAXTILEUNITS:


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

Reply via email to