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

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

See patch #6193

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

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

Modified: branches/S2_6/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/helpdata.c?rev=29460&r1=29459&r2=29460&view=diff
==============================================================================
--- branches/S2_6/client/helpdata.c     (original)
+++ branches/S2_6/client/helpdata.c     Tue Aug 11 17:43:43 2015
@@ -2484,6 +2484,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: branches/S2_6/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/fc_types.h?rev=29460&r1=29459&r2=29460&view=diff
==============================================================================
--- branches/S2_6/common/fc_types.h     (original)
+++ branches/S2_6/common/fc_types.h     Tue Aug 11 17:43:43 2015
@@ -289,6 +289,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.
@@ -342,6 +355,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).
@@ -424,6 +439,8 @@
 #define SPECENUM_VALUE34NAME "Age"
 #define SPECENUM_VALUE35 VUT_NATIONGROUP
 #define SPECENUM_VALUE35NAME "NationGroup"
+#define SPECENUM_VALUE36 VUT_TOPO
+#define SPECENUM_VALUE36NAME "Topology"
 /* Keep this last. */
 #define SPECENUM_COUNT VUT_COUNT
 #include "specenum_gen.h"

Modified: branches/S2_6/common/map.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/map.h?rev=29460&r1=29459&r2=29460&view=diff
==============================================================================
--- branches/S2_6/common/map.h  (original)
+++ branches/S2_6/common/map.h  Tue Aug 11 17:43:43 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: branches/S2_6/common/requirements.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/requirements.c?rev=29460&r1=29459&r2=29460&view=diff
==============================================================================
--- branches/S2_6/common/requirements.c (original)
+++ branches/S2_6/common/requirements.c Tue Aug 11 17:43:43 2015
@@ -267,6 +267,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);
@@ -444,6 +450,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;
@@ -548,6 +557,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:
@@ -647,6 +658,7 @@
       req.range = REQ_RANGE_PLAYER;
       break;
     case VUT_MINYEAR:
+    case VUT_TOPO:
       req.range = REQ_RANGE_WORLD;
       break;
     }
@@ -734,6 +746,7 @@
                && req.range != REQ_RANGE_ADJACENT);
     break;
   case VUT_MINYEAR:
+  case VUT_TOPO:
     invalid = (req.range != REQ_RANGE_WORLD);
     break;
   case VUT_AGE:
@@ -785,6 +798,7 @@
     case VUT_AI_LEVEL:
     case VUT_TERRAINCLASS:
     case VUT_MINYEAR:
+    case VUT_TOPO:
     case VUT_TERRAINALTER:
     case VUT_CITYTILE:
     case VUT_RESOURCE:
@@ -2723,6 +2737,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;
@@ -2816,6 +2833,7 @@
   case VUT_AI_LEVEL:
   case VUT_CITYTILE:
   case VUT_STYLE:
+  case VUT_TOPO:
     return TRUE;
   case VUT_NATION:
   case VUT_NATIONGROUP:
@@ -2958,6 +2976,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:
@@ -2987,6 +3007,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:
@@ -3256,6 +3278,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: branches/S2_6/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/doc/README.effects?rev=29460&r1=29459&r2=29460&view=diff
==============================================================================
--- branches/S2_6/doc/README.effects    (original)
+++ branches/S2_6/doc/README.effects    Tue Aug 11 17:43:43 2015
@@ -65,6 +65,7 @@
 OutputType:    Local
 Specialist:    Local
 MinYear:       World
+Topology:      World
 Age:           Local, City
 MinSize:       Traderoute, City
 MinCulture:    World, Alliance, Team, Player, Traderoute, City

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

Modified: branches/S2_6/server/cityturn.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/cityturn.c?rev=29460&r1=29459&r2=29460&view=diff
==============================================================================
--- branches/S2_6/server/cityturn.c     (original)
+++ branches/S2_6/server/cityturn.c     Tue Aug 11 17:43:43 2015
@@ -1723,6 +1723,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: branches/S2_6/server/rssanity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/rssanity.c?rev=29460&r1=29459&r2=29460&view=diff
==============================================================================
--- branches/S2_6/server/rssanity.c     (original)
+++ branches/S2_6/server/rssanity.c     Tue Aug 11 17:43:43 2015
@@ -204,6 +204,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