Author: cazfi
Date: Fri Sep  9 07:58:59 2016
New Revision: 33767

URL: http://svn.gna.org/viewcvs/freeciv?rev=33767&view=rev
Log:
Support two different verbosity modes in req_text_insert() to better support 
its usage in ruledit.

See patch #7672

Modified:
    trunk/client/helpdata.c
    trunk/common/reqtext.c
    trunk/common/reqtext.h
    trunk/tools/ruledit/req_edit.cpp

Modified: trunk/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/helpdata.c?rev=33767&r1=33766&r2=33767&view=diff
==============================================================================
--- trunk/client/helpdata.c     (original)
+++ trunk/client/helpdata.c     Fri Sep  9 07:58:59 2016
@@ -1119,7 +1119,7 @@
 
   /* Add requirement text for improvement itself */
   requirement_vector_iterate(&pimprove->reqs, preq) {
-    if (req_text_insert(buf, bufsz, pplayer, preq)) {
+    if (req_text_insert(buf, bufsz, pplayer, preq, VERB_DEFAULT)) {
       reqs = TRUE;
     }
   } requirement_vector_iterate_end;
@@ -2273,7 +2273,7 @@
   if (requirement_vector_size(&vap->research_reqs) > 0) {
     CATLSTR(buf, bufsz, _("Requirements to research:\n"));
     requirement_vector_iterate(&vap->research_reqs, preq) {
-      (void) req_text_insert(buf, bufsz, pplayer, preq);
+      (void) req_text_insert(buf, bufsz, pplayer, preq, VERB_DEFAULT);
     } requirement_vector_iterate_end;
     CATLSTR(buf, bufsz, "\n");
   }
@@ -2600,7 +2600,7 @@
       CATLSTR(buf, bufsz, _("Requirements to build:\n"));
     }
     requirement_vector_iterate(&pextra->reqs, preq) {
-      (void) req_text_insert(buf, bufsz, pplayer, preq);
+      (void) req_text_insert(buf, bufsz, pplayer, preq, VERB_DEFAULT);
     } requirement_vector_iterate_end;
     CATLSTR(buf, bufsz, "\n");
   }
@@ -2816,7 +2816,7 @@
 
   /* Requirements for this specialist. */
   requirement_vector_iterate(&pspec->reqs, preq) {
-    if (req_text_insert(buf, bufsz, pplayer, preq)) {
+    if (req_text_insert(buf, bufsz, pplayer, preq, VERB_DEFAULT)) {
       reqs = TRUE;
     }
   } requirement_vector_iterate_end;
@@ -2855,7 +2855,7 @@
 
   /* Add requirement text for government itself */
   requirement_vector_iterate(&gov->reqs, preq) {
-    if (req_text_insert(buf, bufsz, pplayer, preq)) {
+    if (req_text_insert(buf, bufsz, pplayer, preq, VERB_DEFAULT)) {
       reqs = TRUE;
     }
   } requirement_vector_iterate_end;

Modified: trunk/common/reqtext.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/reqtext.c?rev=33767&r1=33766&r2=33767&view=diff
==============================================================================
--- trunk/common/reqtext.c      (original)
+++ trunk/common/reqtext.c      Fri Sep  9 07:58:59 2016
@@ -33,17 +33,18 @@
 #include "reqtext.h"
 
 /****************************************************************
-  Append text for the requirement.  Something like
+  Append text for the requirement. Something like
 
     "Requires knowledge of the technology Communism.\n"
 
-  pplayer may be NULL.  Note that it must be updated everytime
+  pplayer may be NULL. Note that it must be updated everytime
   a new requirement type or range is defined.
 *****************************************************************/
 bool req_text_insert(char *buf, size_t bufsz, struct player *pplayer,
-                     const struct requirement *preq)
+                     const struct requirement *preq,
+                     enum rt_verbosity verb)
 {
-  if (preq->quiet) {
+  if (preq->quiet && verb != VERB_ACTUAL) {
     return FALSE;
   }
 
@@ -2442,10 +2443,10 @@
     break;
   }
 
-  {
+  if (verb == VERB_DEFAULT) {
     char text[256];
 
-    log_error("%s requirement %s in range %d is not supported in helpdata.c.",
+    log_error("%s requirement %s in range %d is not supported in reqtext.c.",
               preq->present ? "Present" : "Absent",
               universal_name_translation(&preq->source, text, sizeof(text)),
               preq->range);

Modified: trunk/common/reqtext.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/reqtext.h?rev=33767&r1=33766&r2=33767&view=diff
==============================================================================
--- trunk/common/reqtext.h      (original)
+++ trunk/common/reqtext.h      Fri Sep  9 07:58:59 2016
@@ -17,8 +17,11 @@
 extern "C" {
 #endif /* __cplusplus */
 
+enum rt_verbosity { VERB_DEFAULT, VERB_ACTUAL };
+
 bool req_text_insert(char *buf, size_t bufsz, struct player *pplayer,
-                     const struct requirement *preq);
+                     const struct requirement *preq,
+                     enum rt_verbosity verb);
 
 #ifdef __cplusplus
 }

Modified: trunk/tools/ruledit/req_edit.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/req_edit.cpp?rev=33767&r1=33766&r2=33767&view=diff
==============================================================================
--- trunk/tools/ruledit/req_edit.cpp    (original)
+++ trunk/tools/ruledit/req_edit.cpp    Fri Sep  9 07:58:59 2016
@@ -145,7 +145,7 @@
       QListWidgetItem *item;
 
       buf[0] = '\0';
-      if (!req_text_insert(buf, sizeof(buf), NULL, preq)) {
+      if (!req_text_insert(buf, sizeof(buf), NULL, preq, VERB_ACTUAL)) {
         universal_name_translation(&preq->source, buf, sizeof(buf));
       }
       item = new QListWidgetItem(QString::fromUtf8(buf));


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

Reply via email to