Author: cazfi
Date: Mon Aug 10 18:41:17 2015
New Revision: 29445

URL: http://svn.gna.org/viewcvs/freeciv?rev=29445&view=rev
Log:
Added requirement property 'quiet' that can be used to suppress automatic help 
generation
from adding information about them.

Requested by Jacob Nevins <jtn>

See patch #4723

Modified:
    branches/S2_6/client/helpdata.c
    branches/S2_6/common/dataio.c
    branches/S2_6/common/requirements.c
    branches/S2_6/common/requirements.h
    branches/S2_6/doc/README.effects
    branches/S2_6/fc_version
    branches/S2_6/server/ruleset.c
    branches/S2_6/tools/ruledit/rulesave.c

Modified: branches/S2_6/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/helpdata.c?rev=29445&r1=29444&r2=29445&view=diff
==============================================================================
--- branches/S2_6/client/helpdata.c     (original)
+++ branches/S2_6/client/helpdata.c     Mon Aug 10 18:41:17 2015
@@ -379,6 +379,10 @@
                                struct player *pplayer,
                                const struct requirement *preq)
 {
+  if (preq->quiet) {
+    return FALSE;
+  }
+
   switch (preq->source.kind) {
   case VUT_NONE:
     return FALSE;
@@ -2623,12 +2627,12 @@
   /* FIXME: show other data like range and survives. */
 
   requirement_vector_iterate(psubjreqs, req) {
-    if (are_universals_equal(psource, &req->source)) {
+    if (!req->quiet && are_universals_equal(psource, &req->source)) {
       if (req->present) {
         /* psource enables the subject, but other sources may
          * also be required (or required to be absent). */
         requirement_vector_iterate(psubjreqs, coreq) {
-          if (!are_universals_equal(psource, &coreq->source)) {
+          if (!coreq->quiet && !are_universals_equal(psource, &coreq->source)) 
{
             universal_name_translation(&coreq->source, buf2, sizeof(buf2));
             strvec_append(coreq->present ? coreqs : conoreqs, buf2);
           }

Modified: branches/S2_6/common/dataio.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/dataio.c?rev=29445&r1=29444&r2=29445&view=diff
==============================================================================
--- branches/S2_6/common/dataio.c       (original)
+++ branches/S2_6/common/dataio.c       Mon Aug 10 18:41:17 2015
@@ -993,13 +993,14 @@
 bool dio_get_requirement(struct data_in *din, struct requirement *preq)
 {
   int type, range, value;
-  bool survives, present;
+  bool survives, present, quiet;
 
   if (!dio_get_uint8(din, &type)
       || !dio_get_sint32(din, &value)
       || !dio_get_uint8(din, &range)
       || !dio_get_bool8(din, &survives)
-      || !dio_get_bool8(din, &present)) {
+      || !dio_get_bool8(din, &present)
+      || !dio_get_bool8(din, &quiet)) {
     log_packet("Got a bad requirement");
     return FALSE;
   }
@@ -1007,7 +1008,7 @@
   /*
    * FIXME: the value returned by req_from_values() should be checked!
    */
-  *preq = req_from_values(type, range, survives, present, value);
+  *preq = req_from_values(type, range, survives, present, quiet, value);
 
   return TRUE;
 }
@@ -1018,13 +1019,14 @@
 void dio_put_requirement(struct data_out *dout, const struct requirement *preq)
 {
   int type, range, value;
-  bool survives, present;
-
-  req_get_values(preq, &type, &range, &survives, &present, &value);
+  bool survives, present, quiet;
+
+  req_get_values(preq, &type, &range, &survives, &present, &quiet, &value);
 
   dio_put_uint8(dout, type);
   dio_put_sint32(dout, value);
   dio_put_uint8(dout, range);
   dio_put_bool8(dout, survives);
   dio_put_bool8(dout, present);
-}
+  dio_put_bool8(dout, quiet);
+}

Modified: branches/S2_6/common/requirements.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/requirements.c?rev=29445&r1=29444&r2=29445&view=diff
==============================================================================
--- branches/S2_6/common/requirements.c (original)
+++ branches/S2_6/common/requirements.c Mon Aug 10 18:41:17 2015
@@ -564,7 +564,8 @@
 
 
 /****************************************************************************
-  Returns the given requirement as a formated string ready for printing.
+  Returns the given requirement as a formatted string ready for printing.
+  Does not care about the 'quiet' property.
 ****************************************************************************/
 const char *req_to_fstring(const struct requirement *req)
 {
@@ -588,7 +589,7 @@
   Pass this some values like "Building", "Factory".
 ****************************************************************************/
 struct requirement req_from_str(const char *type, const char *range,
-                               bool survives, bool present,
+                               bool survives, bool present, bool quiet,
                                const char *value)
 {
   struct requirement req;
@@ -653,6 +654,7 @@
 
   req.survives = survives;
   req.present = present;
+  req.quiet = quiet;
 
   /* These checks match what combinations are supported inside
    * is_req_active(). However, it's only possible to do basic checks,
@@ -824,7 +826,7 @@
   of req_get_values.
 ****************************************************************************/
 struct requirement req_from_values(int type, int range,
-                                  bool survives, bool present,
+                                  bool survives, bool present, bool quiet,
                                   int value)
 {
   struct requirement req;
@@ -833,6 +835,8 @@
   req.range = range;
   req.survives = survives;
   req.present = present;
+  req.quiet = quiet;
+
   return req;
 }
 
@@ -842,17 +846,19 @@
 ****************************************************************************/
 void req_get_values(const struct requirement *req,
                    int *type, int *range,
-                   bool *survives, bool *present,
+                   bool *survives, bool *present, bool *quiet,
                    int *value)
 {
   universal_extraction(&req->source, type, value);
   *range = req->range;
   *survives = req->survives;
   *present = req->present;
+  *quiet = req->quiet;
 }
 
 /****************************************************************************
   Returns TRUE if req1 and req2 are equal.
+  Does not care if one is quiet and the other not.
 ****************************************************************************/
 bool are_requirements_equal(const struct requirement *req1,
                            const struct requirement *req2)

Modified: branches/S2_6/common/requirements.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/requirements.h?rev=29445&r1=29444&r2=29445&view=diff
==============================================================================
--- branches/S2_6/common/requirements.h (original)
+++ branches/S2_6/common/requirements.h Mon Aug 10 18:41:17 2015
@@ -66,6 +66,7 @@
   enum req_range range;                        /* requirement range */
   bool survives; /* set if destroyed sources satisfy the req*/
   bool present;         /* set if the requirement is to be present */
+  bool quiet;    /* do not list this in helptext */
 };
 
 #define SPECVEC_TAG requirement
@@ -77,15 +78,16 @@
 
 /* General requirement functions. */
 struct requirement req_from_str(const char *type, const char *range,
-                               bool survives, bool present,
+                               bool survives, bool present, bool quiet,
                                const char *value);
 const char *req_to_fstring(const struct requirement *req);
 
 void req_get_values(const struct requirement *req, int *type,
-                   int *range, bool *survives, bool *present,
+                   int *range, bool *survives, bool *present, bool *quiet,
                    int *value);
 struct requirement req_from_values(int type, int range,
-                                  bool survives, bool present, int value);
+                                  bool survives, bool present, bool quiet,
+                                   int value);
 
 bool are_requirements_equal(const struct requirement *req1,
                            const struct requirement *req2);

Modified: branches/S2_6/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/doc/README.effects?rev=29445&r1=29444&r2=29445&view=diff
==============================================================================
--- branches/S2_6/doc/README.effects    (original)
+++ branches/S2_6/doc/README.effects    Mon Aug 10 18:41:17 2015
@@ -6,12 +6,12 @@
 name  = "Output_Bonus"
 value = 25
 reqs  =
-    { "type", "name", "range", "present"
-      "Building", "Factory", "City", TRUE
-      "Building", "Hydro Plant", "City", TRUE
-      "OutputType", "Shield", "Local", TRUE
-      "Building", "Hoover Dam", "Player", FALSE
-      "Building", "Nuclear Plant", "City", FALSE
+    { "type", "name", "range", "present", "quiet"
+      "Building", "Factory", "City", TRUE, FALSE
+      "Building", "Hydro Plant", "City", TRUE, FALSE
+      "OutputType", "Shield", "Local", TRUE, TRUE
+      "Building", "Hoover Dam", "Player", FALSE, FALSE
+      "Building", "Nuclear Plant", "City", FALSE, FALSE
     }
 
 The text in the brackets is the entry name, which just has to be unique, but 

Modified: branches/S2_6/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=29445&r1=29444&r2=29445&view=diff
==============================================================================
--- branches/S2_6/fc_version    (original)
+++ branches/S2_6/fc_version    Mon Aug 10 18:41: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-2.6-2015.Aug.04"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Aug.10"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: branches/S2_6/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/ruleset.c?rev=29445&r1=29444&r2=29445&view=diff
==============================================================================
--- branches/S2_6/server/ruleset.c      (original)
+++ branches/S2_6/server/ruleset.c      Mon Aug 10 18:41:17 2015
@@ -360,7 +360,7 @@
                                                  sec, sub, j)); j++) {
     char buf[MAX_LEN_NAME];
     const char *range;
-    bool survives, present;
+    bool survives, present, quiet;
     struct entry *pentry;
     struct requirement req;
 
@@ -426,8 +426,16 @@
                     "\"%s\": invalid boolean value for present for "
                     "'%s.%s%d'.", filename, sec, sub, j);
     }
-
-    req = req_from_str(type, range, survives, present, name);
+    quiet = TRUE;
+    if ((pentry = secfile_entry_lookup(file, "%s.%s%d.quiet",
+                                        sec, sub, j))
+        && !entry_bool_get(pentry, &quiet)) {
+      ruleset_error(LOG_ERROR,
+                    "\"%s\": invalid boolean value for quiet for "
+                    "'%s.%s%d'.", filename, sec, sub, j);
+    }
+
+    req = req_from_str(type, range, survives, present, quiet, name);
     if (req.source.kind == universals_n_invalid()) {
       ruleset_error(LOG_ERROR, "\"%s\" [%s] has invalid or unknown req: "
                                "\"%s\" \"%s\".",

Modified: branches/S2_6/tools/ruledit/rulesave.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/ruledit/rulesave.c?rev=29445&r1=29444&r2=29445&view=diff
==============================================================================
--- branches/S2_6/tools/ruledit/rulesave.c      (original)
+++ branches/S2_6/tools/ruledit/rulesave.c      Mon Aug 10 18:41:17 2015
@@ -132,6 +132,7 @@
   int i;
   bool includes_negated = FALSE;
   bool includes_surviving = FALSE;
+  bool includes_quiet = FALSE;
 
   requirement_vector_iterate(reqs, preq) {
     if (!preq->present) {
@@ -139,6 +140,9 @@
     }
     if (preq->survives) {
       includes_surviving = TRUE;
+    }
+    if (preq->quiet) {
+      includes_quiet = TRUE;
     }
   } requirement_vector_iterate_end;
 
@@ -164,6 +168,12 @@
       secfile_insert_bool(sfile,
                           preq->present,
                           "%s.%s%d.present", path, entry, i);
+    }
+
+    if (includes_quiet) {
+      secfile_insert_bool(sfile,
+                          preq->quiet,
+                          "%s.%s%d.quiet", path, entry, i);
     }
 
     i++;


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

Reply via email to