Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9814) rewrite helptext_improvement
Home

[Freeciv-Dev] (PR#9814) rewrite helptext_improvement

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9814) rewrite helptext_improvement
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 25 Aug 2004 18:12:41 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9814 >

This patch rewrites helptext_improvement.  These changes should be 
sufficient to work with gen-eff.

- Aqueduct and sewer texts are no longer assembled automatically.  They 
are included in the ruleset's helptext.  This could probably eventually 
be done automatically but this should suffice for now.

- Obsoletion is handled in a general way rather than special-casing 
B_BARRACKS and B_BARRAKCS_2.

- Extra whitespace is removed from the translated strings.  Translators 
shouldn't have to worry about preserving it.

- If user_text is NULL it's just ignored.

- The prototype is change to accept an Impr_Type_id instead of an int.

jason

? diff
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.71
diff -u -r1.71 helpdata.c
--- client/helpdata.c   18 Aug 2004 04:23:20 -0000      1.71
+++ client/helpdata.c   26 Aug 2004 01:12:03 -0000
@@ -492,52 +492,31 @@
   have been built (or are being built and by who/where?)
 *****************************************************************/
 
-/****************************************************************
-  Write misc dynamic text for improvements (not wonders).
-  user_text is written after some extra, and before others.
-*****************************************************************/
-void helptext_improvement(char *buf, int which, const char *user_text)
+/**************************************************************************
+  Write dynamic text for improvements (not wonders).  This includes
+  the ruleset helptext as well as any automatically generated text.
+
+  user_text, if non-NULL, will be appended to the text.
+**************************************************************************/
+void helptext_improvement(char *buf, Impr_Type_id which,
+                         const char *user_text)
 {
   struct impr_type *imp = &improvement_types[which];
   
-  assert(buf&&user_text);
+  assert(buf);
   buf[0] = '\0';
-  if(which==B_AQUEDUCT) {
-    sprintf(buf+strlen(buf), _("Allows a city to grow larger than size %d.  "),
-           game.aqueduct_size);
-    if(improvement_exists(B_SEWER)) {
-      char *s = improvement_types[B_SEWER].name;
-      sprintf(buf+strlen(buf),
-             _("(The %s improvement is also required for a city to grow"
-               " larger than size %d.)  "), s, game.sewer_size);
-    }
-    strcat(buf,"\n");
-  }
-  if(which==B_SEWER) {
-    sprintf(buf+strlen(buf), _("Allows a city to grow larger than size %d.  "),
-          game.sewer_size);
-  }
   if (imp->helptext[0] != '\0') {
     sprintf(buf + strlen(buf), "%s  ", _(imp->helptext));
   }
-  if(which==B_BARRACKS
-     && tech_exists(improvement_types[B_BARRACKS].obsolete_by)
-     && tech_exists(improvement_types[B_BARRACKS2].obsolete_by)) {
-    sprintf(buf+strlen(buf),
-          _("\n\nNote that discovering %s or %s will obsolete"
-          " any existing %s.  "),
-          advances[improvement_types[B_BARRACKS].obsolete_by].name,
-          advances[improvement_types[B_BARRACKS2].obsolete_by].name,
-          improvement_types[B_BARRACKS].name);
-  }
-  if(which==B_BARRACKS2
-     && tech_exists(improvement_types[B_BARRACKS2].obsolete_by)) {
-    sprintf(buf+strlen(buf),
-          _("\n\nThe discovery of %s will make %s obsolete.  "),
-          advances[improvement_types[B_BARRACKS2].obsolete_by].name,
-          improvement_types[B_BARRACKS2].name);
+  if (tech_exists(improvement_types[which].obsolete_by)) {
+    sprintf(buf + strlen(buf), "\n\n");
+    sprintf(buf + strlen(buf),
+           _("The discovery of %s will make %s obsolete."),
+           advances[improvement_types[which].obsolete_by].name,
+           improvement_types[which].name);
+    sprintf(buf + strlen(buf), "  ");
   }
-  if (strcmp(user_text, "")!=0) {
+  if (user_text && user_text[0] != '\0') {
     sprintf(buf+strlen(buf), "\n\n%s", user_text);
   }
   wordwrap_string(buf, 68);
Index: client/helpdata.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.h,v
retrieving revision 1.8
diff -u -r1.8 helpdata.h
--- client/helpdata.h   18 Aug 2004 04:23:20 -0000      1.8
+++ client/helpdata.h   26 Aug 2004 01:12:03 -0000
@@ -31,7 +31,7 @@
 void help_iter_start(void);
 const struct help_item *help_iter_next(void);
 
-void helptext_improvement(char *buf, int which, const char *user_text);
+void helptext_improvement(char *buf, Impr_Type_id id, const char *user_text);
 void helptext_wonder(char *buf, int which, const char *user_text);
 void helptext_unit(char *buf, int i, const char *user_text);
 void helptext_tech(char *buf, int i, const char *user_text);
Index: data/civ1/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/buildings.ruleset,v
retrieving revision 1.34
diff -u -r1.34 buildings.ruleset
--- data/civ1/buildings.ruleset 13 Jul 2004 22:52:17 -0000      1.34
+++ data/civ1/buildings.ruleset 26 Aug 2004 01:12:04 -0000
@@ -81,12 +81,9 @@
     }
 sound          = "b_aqueduct"
 sound_alt      = "b_generic"
-; FIXME: use this help text when gen-impr implemented...
-; /* (ignore for gettext until fixed)
-; helptext     = _("\
-; Allows a city to grow larger than size 10.\
-; ")
-; */
+helptext       = _("\
+Allows a city to grow larger than size 10.\
+")
 
 [building_bank]
 name           = _("Bank")
@@ -945,10 +942,7 @@
     }
 sound          = "b_sewer_system"
 sound_alt      = "b_generic"
-helptext       = _("\
-Allows a city to grow larger than size 12.  An Aqueduct is first\
- required for a city to grow larger than size 8.\
-")
+; helptext     = ""
 
 [building_solar_plant]
 name           = _("Solar Plant")
Index: data/civ2/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/buildings.ruleset,v
retrieving revision 1.37
diff -u -r1.37 buildings.ruleset
--- data/civ2/buildings.ruleset 13 Jul 2004 22:52:17 -0000      1.37
+++ data/civ2/buildings.ruleset 26 Aug 2004 01:12:04 -0000
@@ -81,13 +81,10 @@
     }
 sound          = "b_aqueduct"
 sound_alt      = "b_generic"
-; FIXME: use this help text when gen-impr implemented...
-; /* (ignore for gettext until fixed)
-; helptext     = _("\
-; Allows a city to grow larger than size 8.  A Sewer System is also\
-;  required for a city to grow larger than size 12.\
-; ")
-; */
+helptext       = _("\
+Allows a city to grow larger than size 8.  A Sewer System is also\
+ required for a city to grow larger than size 12.\
+")
 
 [building_bank]
 name           = _("Bank")
@@ -933,13 +930,10 @@
     }
 sound          = "b_sewer_system"
 sound_alt      = "b_generic"
-; FIXME: use this help text when gen-impr implemented...
-; /* (ignore for gettext until fixed)
-; helptext     = _("\
-; Allows a city to grow larger than size 12.  An Aqueduct is first\
-;  required for a city to grow larger than size 8.\
-; ")
-; */
+helptext       = _("\
+Allows a city to grow larger than size 12.  An Aqueduct is first\
+ required for a city to grow larger than size 8.\
+")
 
 [building_solar_plant]
 name           = _("Solar Plant")
Index: data/default/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/buildings.ruleset,v
retrieving revision 1.49
diff -u -r1.49 buildings.ruleset
--- data/default/buildings.ruleset      14 Jul 2004 16:40:57 -0000      1.49
+++ data/default/buildings.ruleset      26 Aug 2004 01:12:04 -0000
@@ -128,13 +128,10 @@
     }
 sound          = "b_aqueduct"
 sound_alt      = "b_generic"
-; FIXME: use this help text when gen-impr implemented...
-; /* (ignore for gettext until fixed)
-; helptext     = _("\
-; Allows a city to grow larger than size 8.  A Sewer System is also\
-;  required for a city to grow larger than size 12.\
-; ")
-; */
+helptext       = _("\
+Allows a city to grow larger than size 8.  A Sewer System is also\
+ required for a city to grow larger than size 12.\
+")
 
 [building_bank]
 name           = _("Bank")
@@ -996,13 +993,10 @@
     }
 sound          = "b_sewer_system"
 sound_alt      = "b_generic"
-; FIXME: use this help text when gen-impr implemented...
-; /* (ignore for gettext until fixed)
-; helptext     = _("\
-; Allows a city to grow larger than size 12.  An Aqueduct is first\
-;  required for a city to grow larger than size 8.\
-; ")
-; */
+helptext       = _("\
+Allows a city to grow larger than size 12.  An Aqueduct is first\
+ required for a city to grow larger than size 8.\
+")
 
 [building_solar_plant]
 name           = _("Solar Plant")
Index: data/history/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/buildings.ruleset,v
retrieving revision 1.9
diff -u -r1.9 buildings.ruleset
--- data/history/buildings.ruleset      14 Jul 2004 17:12:21 -0000      1.9
+++ data/history/buildings.ruleset      26 Aug 2004 01:12:05 -0000
@@ -81,13 +81,10 @@
     }
 sound          = "b_aqueduct"
 sound_alt      = "b_generic"
-; FIXME: use this help text when gen-impr implemented...
-; /* (ignore for gettext until fixed)
-; helptext     = _("\
-; Allows a city to grow larger than size 8.  A Sewer System is also\
-;  required for a city to grow larger than size 12.\
-; ")
-; */
+helptext       = _("\
+Allows a city to grow larger than size 8.  A Sewer System is also\
+ required for a city to grow larger than size 12.\
+")
 
 [building_bank]
 name           = _("Bank")
@@ -949,13 +946,10 @@
     }
 sound          = "b_sewer_system"
 sound_alt      = "b_generic"
-; FIXME: use this help text when gen-impr implemented...
-; /* (ignore for gettext until fixed)
-; helptext     = _("\
-; Allows a city to grow larger than size 12.  An Aqueduct is first\
-;  required for a city to grow larger than size 8.\
-; ")
-; */
+helptext       = _("\
+Allows a city to grow larger than size 12.  An Aqueduct is first\
+ required for a city to grow larger than size 8.\
+")
 
 [building_solar_plant]
 name           = _("Solar Plant")

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9814) rewrite helptext_improvement, Jason Short <=