Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#11186) get_output_name
Home

[Freeciv-Dev] (PR#11186) get_output_name

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11186) get_output_name
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Nov 2004 23:28:56 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Wed Nov 24 19:37:19 2004]:
> 
> This patch moves cm_stat_get_name into city.c and renames it as 
> get_output_name.
> 
> A new function get_output_identifier is added at the same time.  This 
> holds the "identifier" for the output as seen in the rulesets.

Updated patch.

-jason

Index: client/gui-gtk/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/cma_fe.c,v
retrieving revision 1.23
diff -u -r1.23 cma_fe.c
--- client/gui-gtk/cma_fe.c     24 Nov 2004 03:34:56 -0000      1.23
+++ client/gui-gtk/cma_fe.c     24 Nov 2004 19:32:20 -0000
@@ -224,7 +224,7 @@
   gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 0, 1);
 
   for (i = 0; i < O_COUNT; i++) {
-    label = gtk_label_new(cm_get_stat_name(i));
+    label = gtk_label_new(get_output_name(i));
     gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, i + 1, i + 2);
     gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 
Index: client/gui-gtk-2.0/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/cma_fe.c,v
retrieving revision 1.22
diff -u -r1.22 cma_fe.c
--- client/gui-gtk-2.0/cma_fe.c 24 Nov 2004 03:34:56 -0000      1.22
+++ client/gui-gtk-2.0/cma_fe.c 24 Nov 2004 19:32:20 -0000
@@ -245,7 +245,7 @@
   gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 0, 1);
 
   for (i = 0; i < O_COUNT; i++) {
-    label = gtk_label_new(cm_get_stat_name(i));
+    label = gtk_label_new(get_output_name(i));
     gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, i + 1, i + 2);
     gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 
Index: client/gui-sdl/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/cma_fe.c,v
retrieving revision 1.14
diff -u -r1.14 cma_fe.c
--- client/gui-sdl/cma_fe.c     24 Nov 2004 03:34:56 -0000      1.14
+++ client/gui-sdl/cma_fe.c     24 Nov 2004 19:32:20 -0000
@@ -859,7 +859,7 @@
   /* ---------- */
   for (i = 0; i < O_COUNT; i++) {
     
-    copy_chars_to_string16(pStr, cm_get_stat_name(i));
+    copy_chars_to_string16(pStr, get_output_name(i));
     pText[i] = create_text_surf_from_str16(pStr);
     text_w = MAX(text_w, pText[i]->w);
     
Index: client/gui-win32/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/cma_fe.c,v
retrieving revision 1.4
diff -u -r1.4 cma_fe.c
--- client/gui-win32/cma_fe.c   24 Nov 2004 09:59:06 -0000      1.4
+++ client/gui-win32/cma_fe.c   24 Nov 2004 19:32:21 -0000
@@ -214,7 +214,7 @@
   fcwin_box_add_static(vbox[1], _("Minimal Surplus"), 0, SS_LEFT, TRUE, TRUE, 
0);
   fcwin_box_add_static(vbox[2], _("Factor"), 0, SS_LEFT, TRUE, TRUE, 0);
   for (i = 0; i< O_COUNT; i++) {
-    cmagui_add_slider(pdialog, win, vbox, FALSE, cm_get_stat_name(i), i);
+    cmagui_add_slider(pdialog, win, vbox, FALSE, get_output_name(i), i);
   } 
   cmagui_add_slider(pdialog, win, vbox, TRUE, _("Celebrate"), i);
 }
Index: client/gui-xaw/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/cma_fe.c,v
retrieving revision 1.4
diff -u -r1.4 cma_fe.c
--- client/gui-xaw/cma_fe.c     24 Nov 2004 09:59:06 -0000      1.4
+++ client/gui-xaw/cma_fe.c     24 Nov 2004 19:32:21 -0000
@@ -180,7 +180,7 @@
                                 XtNfromVert, prev,
                                 XtNvertDistance, 1,
                                 XtNlabel, (i == O_COUNT) ? 
-                                  _("Celebrate") : cm_get_stat_name(i),
+                                  _("Celebrate") : get_output_name(i),
                                 NULL));
     prev = stat_surplus_label[i];
   }
@@ -222,7 +222,7 @@
                                 XtNfromVert, prev,
                                 XtNvertDistance, 1,
                                 XtNlabel, (i == O_COUNT) ?
-                                  _("Celebrate") : cm_get_stat_name(i),
+                                  _("Celebrate") : get_output_name(i),
                                 NULL));
     prev = stat_factor_label[i];
   }
@@ -695,14 +695,14 @@
 
   for (i = 0; i < O_COUNT; i++) {
     my_snprintf(buf, sizeof(buf), "%-9s%3d",
-                cm_get_stat_name(i),
+                get_output_name(i),
                 minimal_surplus[i]);
     xaw_set_label(stat_surplus_label[i], buf);
   }
 
   for (i = 0; i < O_COUNT; i++) { 
     my_snprintf(buf, sizeof(buf), "%-9s%3d",
-                cm_get_stat_name(i),
+                get_output_name(i),
                 factors[i]);
     xaw_set_label(stat_factor_label[i], buf);
   }
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.256
diff -u -r1.256 city.c
--- common/city.c       24 Nov 2004 03:34:57 -0000      1.256
+++ common/city.c       24 Nov 2004 19:32:21 -0000
@@ -206,6 +206,60 @@
   cm_init_citymap();
 }
 
+
+/****************************************************************************
+  Return an id string for the output type.  This string can be used
+  internally by rulesets and tilesets and should not be changed or
+  translated.
+*****************************************************************************/
+const char *get_output_identifier(Output_type_id output)
+{
+  switch (output) {
+  case O_FOOD:
+    return "food";
+  case O_SHIELD:
+    return "shield";
+  case O_TRADE:
+    return "trade";
+  case O_GOLD:
+    return "gold";
+  case O_LUXURY:
+    return "luxury";
+  case O_SCIENCE:
+    return "science";
+  case O_LAST:
+    break;
+  }
+  die("Unknown output type in get_output_id: %d", output);
+  return NULL;
+}
+
+/****************************************************************************
+  Return a translated name for the output type.  This name should only be
+  used for user display.
+*****************************************************************************/
+const char *get_output_name(Output_type_id output)
+{
+  switch (output) {
+  case O_FOOD:
+    return _("Food");
+  case O_SHIELD:
+    return _("Shield");
+  case O_TRADE:
+    return _("Trade");
+  case O_GOLD:
+    return _("Gold");
+  case O_LUXURY:
+    return _("Luxury");
+  case O_SCIENCE:
+    return _("Science");
+  case O_LAST:
+    break;
+  }
+  die("Unknown output type in get_output_name: %d", output);
+  return NULL;
+}
+
 /**************************************************************************
   Set the worker on the citymap.  Also sets the worked field in the map.
 **************************************************************************/
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.167
diff -u -r1.167 city.h
--- common/city.h       24 Nov 2004 03:34:57 -0000      1.167
+++ common/city.h       24 Nov 2004 19:32:21 -0000
@@ -363,6 +363,11 @@
 }
 
 
+/* output type functions */
+
+const char *get_output_identifier(Output_type_id output);
+const char *get_output_name(Output_type_id output);
+
 /* properties */
 
 struct player *city_owner(const struct city *pcity);
Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.45
diff -u -r1.45 cm.c
--- common/aicore/cm.c  24 Nov 2004 03:34:57 -0000      1.45
+++ common/aicore/cm.c  24 Nov 2004 19:32:22 -0000
@@ -1517,7 +1517,7 @@
   for (stat = 0; stat < O_COUNT; stat++) {
     if (production[stat] < state->min_production[stat]) {
       freelog(LOG_PRUNE_BRANCH, "--- pruning: insufficient %s (%d < %d)",
-             cm_get_stat_name(stat), production[stat],
+             get_output_name(stat), production[stat],
              state->min_production[stat]);
       return FALSE;
     }
@@ -1833,32 +1833,6 @@
   cm_free_state(state);
 }
 
-
-/****************************************************************************
-  Return a translated name for the stat type.
-*****************************************************************************/
-const char *cm_get_stat_name(Output_type_id stat)
-{
-  switch (stat) {
-  case O_FOOD:
-    return _("Food");
-  case O_SHIELD:
-    return _("Shield");
-  case O_TRADE:
-    return _("Trade");
-  case O_GOLD:
-    return _("Gold");
-  case O_LUXURY:
-    return _("Luxury");
-  case O_SCIENCE:
-    return _("Science");
-  case O_LAST:
-    break;
-  }
-  die("Unknown stat value in cm_get_stat_name: %d", stat);
-  return NULL;
-}
-
 /**************************************************************************
   Returns true if the two cm_parameters are equal.
 **************************************************************************/
@@ -2184,6 +2158,6 @@
 
   for (i = 0; i < O_COUNT; i++) {
     freelog(LOG_NORMAL, "print_result:  %10s surplus=%d",
-        cm_get_stat_name(i), result->surplus[i]);
+        get_output_name(i), result->surplus[i]);
   }
 }
Index: common/aicore/cm.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.h,v
retrieving revision 1.11
diff -u -r1.11 cm.h
--- common/aicore/cm.h  24 Nov 2004 03:34:57 -0000      1.11
+++ common/aicore/cm.h  24 Nov 2004 19:32:22 -0000
@@ -74,7 +74,6 @@
 void cm_clear_cache(struct city *pcity);
 
 /***************** utility methods *************************************/
-const char *cm_get_stat_name(Output_type_id stat);
 bool cm_are_parameter_equal(const struct cm_parameter *const p1,
                            const struct cm_parameter *const p2);
 void cm_copy_parameter(struct cm_parameter *dest,

[Prev in Thread] Current Thread [Next in Thread]