Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#11146) move output types into city.h
Home

[Freeciv-Dev] (PR#11146) move output types into city.h

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11146) move output types into city.h
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 21 Nov 2004 21:17:25 -0800
Reply-to: rt@xxxxxxxxxxx

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

cm.h has a cm_stat enumeration containing (more or less) the types of 
output.

This patch moves that into city.h and prepares it for use everywhere.

1.  enum cm_stat is renamed as enum output_type.

2.  Output_type_id is typedef'd.

3.  Values are prefixed.  Instead of FOOD there is O_FOOD.  Naturally 
this takes lots of changes.

4.  NUM_STATS is removed; O_LAST is the last entry in the enum.

5.  Two new values are defined: O_MAX (the maximum number of output 
types) and O_COUNT (the number of output types).  Previous users of 
NUM_STATS now use O_MAX or O_COUNT.  The difference is that O_COUNT is a 
variable so it can't be used in static places (this has no benefit now 
but could come in handy a few years down the road).

The main changes are in city.h and cm.h.  Lots of other places have 
simple renaming-style changes.

jason

Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.92
diff -u -r1.92 aihand.c
--- ai/aihand.c 20 Jul 2004 16:27:07 -0000      1.92
+++ ai/aihand.c 22 Nov 2004 05:06:27 -0000
@@ -157,8 +157,8 @@
     cmp.require_happy = TRUE;    /* note this one */
     cmp.allow_disorder = FALSE;
     cmp.allow_specialists = TRUE;
-    cmp.factor[FOOD] = 20;
-    cmp.minimal_surplus[GOLD] = -FC_INFINITY;
+    cmp.factor[O_FOOD] = 20;
+    cmp.minimal_surplus[O_GOLD] = -FC_INFINITY;
 
     city_list_iterate(pplayer->cities, pcity) {
       cm_clear_cache(pcity);
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.106
diff -u -r1.106 options.c
--- client/options.c    17 Nov 2004 19:21:13 -0000      1.106
+++ client/options.c    22 Nov 2004 05:06:27 -0000
@@ -642,7 +642,7 @@
 
   name = secfile_lookup_str_default(file, "preset", 
                                    "cma.preset%d.name", inx);
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     parameter.minimal_surplus[i] =
        secfile_lookup_int_default(file, 0, "cma.preset%d.minsurp%d", inx, i);
     parameter.factor[i] =
@@ -668,7 +668,7 @@
   int i;
 
   secfile_insert_str(file, name, "cma.preset%d.name", inx);
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     secfile_insert_int(file, pparam->minimal_surplus[i],
                       "cma.preset%d.minsurp%d", inx, i);
     secfile_insert_int(file, pparam->factor[i],
Index: client/agents/cma_core.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v
retrieving revision 1.65
diff -u -r1.65 cma_core.c
--- client/agents/cma_core.c    22 Nov 2004 00:51:18 -0000      1.65
+++ client/agents/cma_core.c    22 Nov 2004 05:06:27 -0000
@@ -100,7 +100,7 @@
                             const struct cm_result *const result1,
                             const struct cm_result *const result2)
 {
-  enum cm_stat stat;
+  Output_type_id stat;
 
   T(disorder);
   T(happy);
@@ -109,7 +109,7 @@
     T(specialists[sp]);
   } specialist_type_iterate_end;
 
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     T(surplus[stat]);
   }
 
@@ -587,7 +587,7 @@
   dio_get_uint8(&din, &version);
   assert(version == 2);
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     dio_get_sint16(&din, &parameter->minimal_surplus[i]);
     dio_get_sint16(&din, &parameter->factor[i]);
   }
@@ -619,7 +619,7 @@
 
   dio_put_uint8(&dout, 2);
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     dio_put_sint16(&dout, parameter->minimal_surplus[i]);
     dio_put_sint16(&dout, parameter->factor[i]);
   }
Index: client/agents/cma_fec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_fec.c,v
retrieving revision 1.26
diff -u -r1.26 cma_fec.c
--- client/agents/cma_fec.c     6 Sep 2004 02:13:16 -0000       1.26
+++ client/agents/cma_fec.c     22 Nov 2004 05:06:27 -0000
@@ -333,7 +333,7 @@
     for (j = 0; j < RESULT_COLUMNS; j++)
       my_snprintf(buf[j], BUFFER_SIZE, "---");
   } else {
-    for (j = 0; j < NUM_STATS; j++) {
+    for (j = 0; j < O_COUNT; j++) {
       my_snprintf(buf[j], BUFFER_SIZE, "%+3d", result->surplus[j]);
     }
 
@@ -343,9 +343,9 @@
                result->happy ? _(" happy") : "");
 
     my_snprintf(buf[7], BUFFER_SIZE, "%s",
-               get_city_growth_string(pcity, result->surplus[FOOD]));
+               get_city_growth_string(pcity, result->surplus[O_FOOD]));
     my_snprintf(buf[8], BUFFER_SIZE, "%s",
-               get_prod_complete_string(pcity, result->surplus[SHIELD]));
+               get_prod_complete_string(pcity, result->surplus[O_SHIELD]));
     my_snprintf(buf[9], BUFFER_SIZE, "%s",
                cmafec_get_short_descr(parameter));
   }
@@ -359,8 +359,8 @@
                "    People (W/E/S/T): %s\n"
                "          City grows: %s\n"
                "Production completed: %s"),
-             buf[9], buf[FOOD], buf[GOLD], buf[SHIELD], buf[LUXURY],
-             buf[TRADE], buf[SCIENCE], buf[6], buf[7], buf[8]);
+             buf[9], buf[O_FOOD], buf[O_GOLD], buf[O_SHIELD], buf[O_LUXURY],
+             buf[O_TRADE], buf[O_SCIENCE], buf[6], buf[7], buf[8]);
 
   freelog(LOG_DEBUG, "\n%s", buffer);
   return buffer;
Index: client/gui-gtk/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/cma_fe.c,v
retrieving revision 1.22
diff -u -r1.22 cma_fe.c
--- client/gui-gtk/cma_fe.c     20 Jul 2004 16:27:07 -0000      1.22
+++ client/gui-gtk/cma_fe.c     22 Nov 2004 05:06:28 -0000
@@ -213,7 +213,7 @@
 
   /* Minimal Surplus and Factor */
 
-  table = gtk_table_new(NUM_STATS + 2, 3, FALSE);
+  table = gtk_table_new(O_COUNT + 2, 3, FALSE);
   gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 2);
 
   label = gtk_label_new(_("Minimal Surplus"));
@@ -223,7 +223,7 @@
   gtk_misc_set_alignment(GTK_MISC(label), 0.1, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 0, 1);
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     label = gtk_label_new(cm_get_stat_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);
@@ -256,12 +256,12 @@
 
   label = gtk_label_new(_("Celebrate"));
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1,
-                           NUM_STATS + 1, NUM_STATS + 2);
+                           O_COUNT + 1, O_COUNT + 2);
   gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 
   hbox = gtk_hbox_new(FALSE, 0);
   gtk_table_attach_defaults(GTK_TABLE(table), hbox, 1, 2,
-                           NUM_STATS + 1, NUM_STATS + 2);
+                           O_COUNT + 1, O_COUNT + 2);
 
   pdialog->happy_button = gtk_check_button_new();
   gtk_box_pack_start(GTK_BOX(hbox), pdialog->happy_button, FALSE, FALSE,
@@ -272,16 +272,16 @@
   gtk_signal_connect(GTK_OBJECT(pdialog->happy_button), "toggled",
                     GTK_SIGNAL_FUNC(hscale_changed), pdialog);
 
-  pdialog->factor[NUM_STATS] =
+  pdialog->factor[O_COUNT] =
       GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 50, 1, 0, 0));
 
-  hscale = gtk_hscale_new(GTK_ADJUSTMENT(pdialog->factor[NUM_STATS]));
+  hscale = gtk_hscale_new(GTK_ADJUSTMENT(pdialog->factor[O_COUNT]));
   gtk_table_attach_defaults(GTK_TABLE(table), hscale, 2, 3,
-                           NUM_STATS + 1, NUM_STATS + 2);
+                           O_COUNT + 1, O_COUNT + 2);
   gtk_scale_set_digits(GTK_SCALE(hscale), 0);
   gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_LEFT);
 
-  gtk_signal_connect(GTK_OBJECT(pdialog->factor[NUM_STATS]),
+  gtk_signal_connect(GTK_OBJECT(pdialog->factor[O_COUNT]),
                     "value_changed", GTK_SIGNAL_FUNC(hscale_changed),
                     pdialog);
 
@@ -643,14 +643,14 @@
   int i;
 
   allow_refreshes = 0;
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     gtk_adjustment_set_value(pdialog->minimal_surplus[i],
                             parameter->minimal_surplus[i]);
     gtk_adjustment_set_value(pdialog->factor[i], parameter->factor[i]);
   }
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pdialog->happy_button),
                               parameter->require_happy);
-  gtk_adjustment_set_value(pdialog->factor[NUM_STATS],
+  gtk_adjustment_set_value(pdialog->factor[O_COUNT],
                           parameter->happy_factor);
   allow_refreshes = 1;
 }
@@ -669,13 +669,13 @@
   }
 
   cmafec_get_fe_parameter(pdialog->pcity, &param);
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     param.minimal_surplus[i] = (int) (pdialog->minimal_surplus[i]->value);
     param.factor[i] = (int) (pdialog->factor[i]->value);
   }
   param.require_happy =
       (GTK_TOGGLE_BUTTON(pdialog->happy_button)->active ? 1 : 0);
-  param.happy_factor = (int) (pdialog->factor[NUM_STATS]->value);
+  param.happy_factor = (int) (pdialog->factor[O_COUNT]->value);
 
   /* save the change */
   cmafec_set_fe_parameter(pdialog->pcity, &param);
Index: client/gui-gtk/cma_fe.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/cma_fe.h,v
retrieving revision 1.2
diff -u -r1.2 cma_fe.h
--- client/gui-gtk/cma_fe.h     26 Feb 2002 01:33:45 -0000      1.2
+++ client/gui-gtk/cma_fe.h     22 Nov 2004 05:06:28 -0000
@@ -38,9 +38,9 @@
   GtkWidget *change_command;
   GtkWidget *perm_command;
   GtkWidget *release_command;
-  GtkAdjustment *minimal_surplus[NUM_STATS];
+  GtkAdjustment *minimal_surplus[O_COUNT];
   GtkWidget *happy_button;
-  GtkAdjustment *factor[NUM_STATS + 1];
+  GtkAdjustment *factor[O_COUNT + 1];
   int id;                      /* needed to pass a preset_index */
 };
 
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.21
diff -u -r1.21 cma_fe.c
--- client/gui-gtk-2.0/cma_fe.c 14 Nov 2004 22:08:23 -0000      1.21
+++ client/gui-gtk-2.0/cma_fe.c 22 Nov 2004 05:06:28 -0000
@@ -234,7 +234,7 @@
 
   /* Minimal Surplus and Factor */
 
-  table = gtk_table_new(NUM_STATS + 2, 3, FALSE);
+  table = gtk_table_new(O_COUNT + 2, 3, FALSE);
   gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 2);
 
   label = gtk_label_new(_("Minimal Surplus"));
@@ -244,7 +244,7 @@
   gtk_misc_set_alignment(GTK_MISC(label), 0.1, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 0, 1);
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     label = gtk_label_new(cm_get_stat_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);
@@ -277,12 +277,12 @@
 
   label = gtk_label_new(_("Celebrate"));
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1,
-                           NUM_STATS + 1, NUM_STATS + 2);
+                           O_COUNT + 1, O_COUNT + 2);
   gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 
   hbox = gtk_hbox_new(FALSE, 0);
   gtk_table_attach_defaults(GTK_TABLE(table), hbox, 1, 2,
-                           NUM_STATS + 1, NUM_STATS + 2);
+                           O_COUNT + 1, O_COUNT + 2);
 
   pdialog->happy_button = gtk_check_button_new();
   gtk_box_pack_start(GTK_BOX(hbox), pdialog->happy_button, FALSE, FALSE,
@@ -293,16 +293,16 @@
   g_signal_connect(pdialog->happy_button, "toggled",
                   G_CALLBACK(hscale_changed), pdialog);
 
-  pdialog->factor[NUM_STATS] =
+  pdialog->factor[O_COUNT] =
       GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 50, 1, 0, 0));
 
-  hscale = gtk_hscale_new(GTK_ADJUSTMENT(pdialog->factor[NUM_STATS]));
+  hscale = gtk_hscale_new(GTK_ADJUSTMENT(pdialog->factor[O_COUNT]));
   gtk_table_attach_defaults(GTK_TABLE(table), hscale, 2, 3,
-                           NUM_STATS + 1, NUM_STATS + 2);
+                           O_COUNT + 1, O_COUNT + 2);
   gtk_scale_set_digits(GTK_SCALE(hscale), 0);
   gtk_scale_set_value_pos(GTK_SCALE(hscale), GTK_POS_LEFT);
 
-  g_signal_connect(pdialog->factor[NUM_STATS],
+  g_signal_connect(pdialog->factor[O_COUNT],
                   "value_changed",
                   G_CALLBACK(hscale_changed), pdialog);
 
@@ -659,14 +659,14 @@
   int i;
 
   allow_refreshes = 0;
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     gtk_adjustment_set_value(pdialog->minimal_surplus[i],
                             parameter->minimal_surplus[i]);
     gtk_adjustment_set_value(pdialog->factor[i], parameter->factor[i]);
   }
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pdialog->happy_button),
                               parameter->require_happy);
-  gtk_adjustment_set_value(pdialog->factor[NUM_STATS],
+  gtk_adjustment_set_value(pdialog->factor[O_COUNT],
                           parameter->happy_factor);
   allow_refreshes = 1;
 }
@@ -685,13 +685,13 @@
   }
 
   cmafec_get_fe_parameter(pdialog->pcity, &param);
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     param.minimal_surplus[i] = (int) (pdialog->minimal_surplus[i]->value);
     param.factor[i] = (int) (pdialog->factor[i]->value);
   }
   param.require_happy =
       (GTK_TOGGLE_BUTTON(pdialog->happy_button)->active ? 1 : 0);
-  param.happy_factor = (int) (pdialog->factor[NUM_STATS]->value);
+  param.happy_factor = (int) (pdialog->factor[O_COUNT]->value);
 
   /* save the change */
   cmafec_set_fe_parameter(pdialog->pcity, &param);
Index: client/gui-gtk-2.0/cma_fe.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/cma_fe.h,v
retrieving revision 1.3
diff -u -r1.3 cma_fe.h
--- client/gui-gtk-2.0/cma_fe.h 16 Apr 2003 22:28:26 -0000      1.3
+++ client/gui-gtk-2.0/cma_fe.h 22 Nov 2004 05:06:28 -0000
@@ -38,9 +38,9 @@
   GtkWidget *change_command;
   GtkWidget *perm_command;
   GtkWidget *release_command;
-  GtkAdjustment *minimal_surplus[NUM_STATS];
+  GtkAdjustment *minimal_surplus[O_MAX];
   GtkWidget *happy_button;
-  GtkAdjustment *factor[NUM_STATS + 1];
+  GtkAdjustment *factor[O_MAX + 1];
   GtkTooltips *tips;
   GtkTreeSelection *selection;
   GtkListStore *store;
Index: client/gui-mui/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/citydlg.c,v
retrieving revision 1.83
diff -u -r1.83 citydlg.c
--- client/gui-mui/citydlg.c    29 Sep 2004 02:24:21 -0000      1.83
+++ client/gui-mui/citydlg.c    22 Nov 2004 05:06:28 -0000
@@ -1150,7 +1150,7 @@
   int i;
 
   cmafec_get_fe_parameter(pdialog->pcity, &param);
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     param.minimal_surplus[i] = 
(int)xget(pdialog->minimal_surplus_slider[i],MUIA_Numeric_Value);
     param.factor[i] = (int)xget(pdialog->factor_slider[i],MUIA_Numeric_Value);
   }
@@ -2154,7 +2154,7 @@
 
   
   /* if called from a hscale, we _don't_ want to do this */
-  for (i = 0; i < NUM_STATS; i++)
+  for (i = 0; i < O_COUNT; i++)
   {
     
nnset(pdialog->minimal_surplus_slider[i],MUIA_Numeric_Value,param.minimal_surplus[i]);
     nnset(pdialog->factor_slider[i],MUIA_Numeric_Value,param.factor[i]);
Index: client/gui-sdl/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/cma_fe.c,v
retrieving revision 1.13
diff -u -r1.13 cma_fe.c
--- client/gui-sdl/cma_fe.c     23 Jun 2004 23:08:55 -0000      1.13
+++ client/gui-sdl/cma_fe.c     22 Nov 2004 05:06:28 -0000
@@ -599,7 +599,7 @@
   
   /* exit button */
   pBuf = pCma->pDlg->pEndWidgetList->prev;
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     
     /* min label */
     pBuf = pBuf->prev;
@@ -796,7 +796,7 @@
 void popup_city_cma_dialog(struct city *pCity)
 {
   struct GUI *pWindow, *pBuf;
-  SDL_Surface *pLogo, *pText[NUM_STATS + 1], *pMinimal, *pFactor;
+  SDL_Surface *pLogo, *pText[O_COUNT + 1], *pMinimal, *pFactor;
   SDL_Surface *pCity_Map;
   SDL_String16 *pStr;
   char cBuf[128];
@@ -857,7 +857,7 @@
   pFactor = create_text_surf_from_str16(pStr);
     
   /* ---------- */
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     
     copy_chars_to_string16(pStr, cm_get_stat_name(i));
     pText[i] = create_text_surf_from_str16(pStr);
@@ -902,7 +902,7 @@
   }
   
   copy_chars_to_string16(pStr, _("Celebrate"));
-  pText[NUM_STATS] = create_text_surf_from_str16(pStr);
+  pText[O_COUNT] = create_text_surf_from_str16(pStr);
   FREESTRING16(pStr);
   
   /* happy factor label */
@@ -1021,7 +1021,7 @@
   area.y = dst.y - 20;
   w = area.w = 10 + text_w + 10 + pWindow->prev->prev->size.w + 5 + 70 + 5 +
                pWindow->prev->prev->size.w + 5 + 55 + 10;
-  area.h = (NUM_STATS + 1) * (pText[0]->h + 6) + 20;
+  area.h = (O_COUNT + 1) * (pText[0]->h + 6) + 20;
   SDL_FillRectAlpha(pWindow->theme, &area, &color);
   putframe(pWindow->theme, area.x, area.y,
        area.x + area.w - 1, area.y + area.h - 1, 0xff000000);
@@ -1040,7 +1040,7 @@
   FREESURFACE(pCity_Map);
   
   
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
             
     /* min label */
     pBuf = pBuf->prev;
@@ -1087,12 +1087,12 @@
   /* happy factor label */
   pBuf = pBuf->prev;
   pBuf->size.x = pBuf->next->next->size.x;
-  pBuf->size.y = pWindow->size.y + dst.y + (pText[NUM_STATS]->h - 
pBuf->size.h) / 2;
+  pBuf->size.y = pWindow->size.y + dst.y + (pText[O_COUNT]->h - pBuf->size.h) 
/ 2;
   
   /* happy factor sb */
   pBuf = pBuf->prev;
   pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 5;
-  pBuf->size.y = pWindow->size.y + dst.y + (pText[NUM_STATS]->h - 
pBuf->size.h) / 2;
+  pBuf->size.y = pWindow->size.y + dst.y + (pText[O_COUNT]->h - pBuf->size.h) 
/ 2;
   
   area.x = pBuf->size.x - pWindow->size.x - 2;
   area.y = pBuf->size.y - pWindow->size.y;
@@ -1109,9 +1109,9 @@
   
   /* celebrate static text */
   dst.x += (10 + pBuf->size.w + 5);
-  dst.y += (pBuf->size.h - pText[NUM_STATS]->h) / 2;
-  SDL_BlitSurface(pText[NUM_STATS], NULL, pWindow->theme, &dst);
-  FREESURFACE(pText[NUM_STATS]);
+  dst.y += (pBuf->size.h - pText[O_COUNT]->h) / 2;
+  SDL_BlitSurface(pText[O_COUNT], NULL, pWindow->theme, &dst);
+  FREESURFACE(pText[O_COUNT]);
   /* ------------------------ */
   
   /* save as */
Index: client/gui-win32/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/cma_fe.c,v
retrieving revision 1.2
diff -u -r1.2 cma_fe.c
--- client/gui-win32/cma_fe.c   5 May 2004 20:39:16 -0000       1.2
+++ client/gui-win32/cma_fe.c   22 Nov 2004 05:06:28 -0000
@@ -52,9 +52,9 @@
   HWND change;
   HWND perm;
   HWND release;
-  HWND minimal_surplus[NUM_STATS];
+  HWND minimal_surplus[O_COUNT];
   HWND happy;
-  HWND factor[NUM_STATS + 1];
+  HWND factor[O_COUNT + 1];
   int id;
 };
 
@@ -213,7 +213,7 @@
   fcwin_box_add_static(vbox[0], " ",0, SS_LEFT,TRUE, TRUE, 0);
   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< NUM_STATS; i++) {
+  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, TRUE, _("Celebrate"), i);
@@ -228,7 +228,7 @@
 {
   int i;
   allow_refreshes = 0;
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     handle_hscroll(pdialog->mainwin, pdialog->minimal_surplus[i],
                   SB_THUMBTRACK, parameter->minimal_surplus[i]);
     handle_hscroll(pdialog->mainwin, pdialog->factor[i],
@@ -515,13 +515,13 @@
   }
   
   cmafec_get_fe_parameter(pdialog->pcity, &param);
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     param.minimal_surplus[i] = ScrollBar_GetPos(pdialog->minimal_surplus[i]);
     param.factor[i] = ScrollBar_GetPos(pdialog->factor[i]);
   }
   
   param.require_happy = (Button_GetCheck(pdialog->happy) == BST_CHECKED) ? 1 : 
0;
-  param.happy_factor = ScrollBar_GetPos(pdialog->factor[NUM_STATS]);
+  param.happy_factor = ScrollBar_GetPos(pdialog->factor[O_COUNT]);
   
   /* save the change */
   cmafec_set_fe_parameter(pdialog->pcity, &param);
Index: client/gui-xaw/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/cma_fe.c,v
retrieving revision 1.2
diff -u -r1.2 cma_fe.c
--- client/gui-xaw/cma_fe.c     20 Jul 2004 16:27:08 -0000      1.2
+++ client/gui-xaw/cma_fe.c     22 Nov 2004 05:06:28 -0000
@@ -70,9 +70,9 @@
 Widget *stat_surplus_label, *stat_factor_label;
 Widget control_button, change_button, preset_list, cma_dialog;
 Widget celebrate_toggle, result_label, release_button;
-Widget surplus_slider[NUM_STATS], factor_slider[NUM_STATS + 1];
+Widget surplus_slider[O_COUNT], factor_slider[O_COUNT + 1];
 
-int minimal_surplus[NUM_STATS], factors[NUM_STATS + 1];
+int minimal_surplus[O_COUNT], factors[O_COUNT + 1];
 struct city *current_city;
 char *initial_preset_list[] = {
       N_("For information on:"),
@@ -133,8 +133,8 @@
   int i;
 
   current_city = pcity;
-  stat_surplus_label = fc_malloc((NUM_STATS + 1) * sizeof(Widget));
-  stat_factor_label = fc_malloc((NUM_STATS + 1) * sizeof(Widget));
+  stat_surplus_label = fc_malloc((O_COUNT + 1) * sizeof(Widget));
+  stat_factor_label = fc_malloc((O_COUNT + 1) * sizeof(Widget));
 
   cma_dialog = 
     I_T(XtCreatePopupShell("cmapopup",
@@ -172,14 +172,14 @@
 
   /* Create labels in the minimal surplus column. */
   prev = surplus_header;
-  for (i = 0; i < (NUM_STATS + 1); i++) {
+  for (i = 0; i < (O_COUNT + 1); i++) {
     I_L(stat_surplus_label[i] = 
         XtVaCreateManagedWidget("cmastatlabel",
                                 labelWidgetClass, form,
                                 XtNfromHoriz, preset_viewport,
                                 XtNfromVert, prev,
                                 XtNvertDistance, 1,
-                                XtNlabel, (i == NUM_STATS) ? 
+                                XtNlabel, (i == O_COUNT) ? 
                                   _("Celebrate") : cm_get_stat_name(i),
                                 NULL));
     prev = stat_surplus_label[i];
@@ -187,7 +187,7 @@
 
   /* Create scrollbars in the minimal surplus column. */
   prev = surplus_header;
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     surplus_slider[i] = 
       XtVaCreateManagedWidget("cmapresetscroll",
                                   scrollbarWidgetClass, form,
@@ -201,7 +201,7 @@
     I_L(XtVaCreateManagedWidget("cmapresettoggle",
                                 toggleWidgetClass,form,
                                 XtNfromHoriz, stat_surplus_label[0],
-                                XtNfromVert, stat_surplus_label[NUM_STATS - 1],
+                                XtNfromVert, stat_surplus_label[O_COUNT - 1],
                                 NULL));
 
   /* Create header label in the factor column. */
@@ -214,14 +214,14 @@
 
   /* Create stat labels in the factor column. */
   prev = factor_header;
-  for (i = 0; i < (NUM_STATS + 1); i++) {
+  for (i = 0; i < (O_COUNT + 1); i++) {
     I_L(stat_factor_label[i] =
         XtVaCreateManagedWidget("cmastatlabel",
                                 labelWidgetClass, form,
                                 XtNfromHoriz, surplus_slider[0],
                                 XtNfromVert, prev,
                                 XtNvertDistance, 1,
-                                XtNlabel, (i == NUM_STATS) ?
+                                XtNlabel, (i == O_COUNT) ?
                                   _("Celebrate") : cm_get_stat_name(i),
                                 NULL));
     prev = stat_factor_label[i];
@@ -229,7 +229,7 @@
 
   /* Create scrollbars in the factor column. */
   prev = factor_header;
-  for (i = 0; i < (NUM_STATS + 1); i++) {
+  for (i = 0; i < (O_COUNT + 1); i++) {
     factor_slider[i] =
       XtVaCreateManagedWidget("cmapresetscroll",
                                   scrollbarWidgetClass, form,
@@ -306,14 +306,14 @@
   XtAddCallback(close_button, XtNcallback,
                 close_callback, NULL);
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     XtAddCallback(surplus_slider[i], XtNscrollProc,
                   sliders_scroll_callback, NULL);
     XtAddCallback(surplus_slider[i], XtNjumpProc,
                   sliders_jump_callback, NULL);
   }
 
-  for (i = 0; i < (NUM_STATS + 1); i++) {
+  for (i = 0; i < (O_COUNT + 1); i++) {
     XtAddCallback(factor_slider[i], XtNscrollProc,
                   sliders_scroll_callback, NULL);
     XtAddCallback(factor_slider[i], XtNjumpProc,
@@ -323,7 +323,7 @@
   /* Update dialog with CMA parameters from city.  */
   cmafec_get_fe_parameter(current_city, &parameter);
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     minimal_surplus[i] = parameter.minimal_surplus[i];
   }
 
@@ -332,12 +332,12 @@
          XtNstate, parameter.require_happy, NULL);
 
   if (parameter.happy_factor > 0) {
-    factors[NUM_STATS] = parameter.happy_factor;
+    factors[O_COUNT] = parameter.happy_factor;
   } else {
-    factors[NUM_STATS] = 1;
+    factors[O_COUNT] = 1;
   }
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     factors[i] = parameter.factor[i];
   }
 
@@ -350,7 +350,7 @@
   XtVaSetValues(result_label, XtNwidth, 360, NULL);
   XtVaSetValues(result_label, XtNheight, 110, NULL);
 
-  for(i = 0; i < NUM_STATS; i++) {
+  for(i = 0; i < O_COUNT; i++) {
     XtVaSetValues(stat_surplus_label[i], XtNwidth, 90, NULL);
     XtVaSetValues(stat_factor_label[i], XtNwidth, 90, NULL);
   }
@@ -507,7 +507,7 @@
     xaw_set_label(result_label,
         (char *) cmafec_get_result_descr(current_city, &result, &parameter));
 
-    for (i = 0; i < NUM_STATS; i++) {
+    for (i = 0; i < O_COUNT; i++) {
       minimal_surplus[i] = param->minimal_surplus[i];
     }
 
@@ -515,9 +515,9 @@
             param->require_happy ? _("Yes") : _("No"),
             XtNstate, parameter.require_happy, NULL);
 
-    factors[NUM_STATS] = param->happy_factor;
+    factors[O_COUNT] = param->happy_factor;
 
-    for (i = 0; i < NUM_STATS; i++) {
+    for (i = 0; i < O_COUNT; i++) {
       factors[i] = param->factor[i];
     }
   }
@@ -541,12 +541,12 @@
 {
   int i;
   
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     XawScrollbarSetThumb(surplus_slider[i],
                      (((20 + minimal_surplus[i])))*1/41.0f, 1/41.0f);
   }
 
-  for (i = 0; i < (NUM_STATS + 1); i++) { 
+  for (i = 0; i < (O_COUNT + 1); i++) { 
     XawScrollbarSetThumb(factor_slider[i],
                      (((factors[i])))*1/25.0f, 1/25.0f);
   }
@@ -563,7 +563,7 @@
   struct cm_result result;
   int i, preset_index;
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     if (w == surplus_slider[i]) {
       if (pos > 0 ) {
         minimal_surplus[i]++;
@@ -579,7 +579,7 @@
     }
   }
 
-  for (i = 0; i < (NUM_STATS + 1); i++) {
+  for (i = 0; i < (O_COUNT + 1); i++) {
     if (w == factor_slider[i]) {
       if (pos > 0 ) {
         factors[i]++;
@@ -597,13 +597,13 @@
 
   cmafec_get_fe_parameter(current_city, &parameter);
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     parameter.minimal_surplus[i] = minimal_surplus[i];
     parameter.factor[i] = factors[i];
   }
 
   XtVaGetValues(celebrate_toggle, XtNstate, &parameter.require_happy, NULL);
-  parameter.happy_factor = factors[NUM_STATS];
+  parameter.happy_factor = factors[O_COUNT];
 
   cmafec_set_fe_parameter(current_city, &parameter);
 
@@ -639,14 +639,14 @@
   int i, preset_index;
 
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     if (w == surplus_slider[i]) {
       /* convert from percent to [-20..20] */
       minimal_surplus[i] = (int)(percent * 41) - 20;
     }
   }
 
-  for (i = 0; i < (NUM_STATS + 1); i++) {
+  for (i = 0; i < (O_COUNT + 1); i++) {
     if (w == factor_slider[i]) {
       /* convert from percent to [1..25] */
       factors[i] = (int)(percent * 25) + 1;  
@@ -655,13 +655,13 @@
 
   cmafec_get_fe_parameter(current_city, &parameter);
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     parameter.minimal_surplus[i] = minimal_surplus[i];
     parameter.factor[i] = factors[i];
   }
 
   XtVaGetValues(celebrate_toggle, XtNstate, &parameter.require_happy, NULL);
-  parameter.happy_factor = factors[NUM_STATS];
+  parameter.happy_factor = factors[O_COUNT];
 
   cmafec_set_fe_parameter(current_city, &parameter);
 
@@ -693,14 +693,14 @@
   char buf[256]; 
   int i;
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     my_snprintf(buf, sizeof(buf), "%-9s%3d",
                 cm_get_stat_name(i),
                 minimal_surplus[i]);
     xaw_set_label(stat_surplus_label[i], buf);
   }
 
-  for (i = 0; i < NUM_STATS; i++) { 
+  for (i = 0; i < O_COUNT; i++) { 
     my_snprintf(buf, sizeof(buf), "%-9s%3d",
                 cm_get_stat_name(i),
                 factors[i]);
@@ -708,8 +708,8 @@
   }
   my_snprintf(buf, sizeof(buf), "%-9s%3d",
               "Celebrate",
-              factors[NUM_STATS]);
-  xaw_set_label(stat_factor_label[NUM_STATS], buf);
+              factors[O_COUNT]);
+  xaw_set_label(stat_factor_label[O_COUNT], buf);
 
   XtSetSensitive(release_button, 
        (cma_is_city_under_agent(current_city, NULL)
@@ -743,14 +743,14 @@
     XtVaGetValues(celebrate_toggle, XtNstate, &celebrate_setting, NULL);
     cmafec_get_fe_parameter(current_city, &parameter);
 
-    for (i = 0; i < NUM_STATS; i++) {
+    for (i = 0; i < O_COUNT; i++) {
       parameter.minimal_surplus[i] = minimal_surplus[i];
     }
-    for (i = 0; i < NUM_STATS; i++) {
+    for (i = 0; i < O_COUNT; i++) {
       parameter.factor[i] = factors[i];
     }
 
-    parameter.happy_factor = factors[NUM_STATS];
+    parameter.happy_factor = factors[O_COUNT];
     parameter.require_happy = celebrate_setting;
 
     cmafec_preset_add(input_dialog_get_input(w), &parameter);
@@ -776,13 +776,13 @@
 
   /* Update parameters with new celebrate setting. */
   cmafec_get_fe_parameter(current_city, &parameter);
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     parameter.minimal_surplus[i] = minimal_surplus[i];
     parameter.factor[i] = factors[i];
   }
 
   XtVaGetValues(celebrate_toggle, XtNstate, &parameter.require_happy, NULL);
-  parameter.happy_factor = factors[NUM_STATS];
+  parameter.happy_factor = factors[O_COUNT];
 
   cmafec_set_fe_parameter(current_city, &parameter);
 
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.255
diff -u -r1.255 city.c
--- common/city.c       17 Nov 2004 19:21:14 -0000      1.255
+++ common/city.c       22 Nov 2004 05:06:29 -0000
@@ -40,6 +40,7 @@
 struct citystyle *city_styles = NULL;
 
 int city_tiles;
+Output_type_id num_output_types = O_LAST;
 
 /**************************************************************************
   Return TRUE if the given city coordinate pair is "valid"; that is, if it
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.166
diff -u -r1.166 city.h
--- common/city.h       10 Nov 2004 17:01:59 -0000      1.166
+++ common/city.h       22 Nov 2004 05:06:29 -0000
@@ -30,6 +30,12 @@
   C_TILE_EMPTY, C_TILE_WORKER, C_TILE_UNAVAILABLE
 };
 
+enum output_type {
+  O_FOOD, O_SHIELD, O_TRADE, O_GOLD, O_LUXURY, O_SCIENCE, O_LAST
+};
+#define O_COUNT num_output_types
+#define O_MAX O_LAST
+
 enum city_options {
   /* The first 4 are whether to auto-attack versus each unit move_type
    * from with auto-attack units within this city.  Note that these
@@ -335,6 +341,7 @@
 };                              /* not incl. wall and occupied tiles */
 
 extern struct citystyle *city_styles;
+extern Output_type_id num_output_types;
 
 /* get 'struct city_list' and related functions: */
 #define SPECLIST_TAG city
Index: common/fc_types.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/fc_types.h,v
retrieving revision 1.8
diff -u -r1.8 fc_types.h
--- common/fc_types.h   13 Sep 2004 15:54:51 -0000      1.8
+++ common/fc_types.h   22 Nov 2004 05:06:29 -0000
@@ -22,6 +22,7 @@
 typedef int Terrain_type_id;
 typedef enum specialist_type Specialist_type_id;
 typedef int Impr_Type_id;
+typedef enum output_type Output_type_id;
 
 struct city;
 struct government;
Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.44
diff -u -r1.44 cm.c
--- common/aicore/cm.c  19 Nov 2004 02:31:35 -0000      1.44
+++ common/aicore/cm.c  22 Nov 2004 05:06:30 -0000
@@ -171,7 +171,7 @@
  * vector is empty.  We can never run out of specialists.
        */
 struct cm_tile_type {
-  int production[NUM_STATS];
+  int production[O_MAX];
   double estimated_fitness; /* weighted sum of production */
   bool is_specialist;
   enum specialist_type spec; /* valid only if is_specialist */
@@ -193,7 +193,7 @@
   int *worker_counts;   /* number of workers on each type */
   int *prereqs_filled;  /* number of better types filled up */
 
-  int production[NUM_STATS]; /* raw production, cached for the heuristic */
+  int production[O_MAX]; /* raw production, cached for the heuristic */
   int idle;             /* number of idle workers */
 };
 
@@ -209,7 +209,7 @@
 
   /* the tile lattice */
   struct tile_type_vector lattice;
-  struct tile_type_vector lattice_by_prod[NUM_STATS];
+  struct tile_type_vector lattice_by_prod[O_MAX];
 
   /* the best known solution, and its fitness */
   struct partial_solution best;
@@ -219,7 +219,7 @@
    * this fails to satisfy the constraints, so we can stop investigating
    * this branch.  A solution with more production than this may still
    * fail (for being unhappy, for instance). */
-  int min_production[NUM_STATS];
+  int min_production[O_MAX];
 
   /* the current solution we're examining. */
   struct partial_solution current;
@@ -383,9 +383,9 @@
 static bool tile_type_equal(const struct cm_tile_type *a,
                            const struct cm_tile_type *b)
 {
-  enum cm_stat stat;
+  Output_type_id stat;
 
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     if (a->production[stat] != b->production[stat])  {
       return FALSE;
     }
@@ -407,9 +407,9 @@
 static bool tile_type_better(const struct cm_tile_type *a,
                             const struct cm_tile_type *b)
 {
-  enum cm_stat stat;
+  Output_type_id stat;
 
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     if (a->production[stat] < b->production[stat])  {
       return FALSE;
     }
@@ -534,17 +534,17 @@
   Compute the fitness of the given surplus (and disorder/happy status)
   according to the weights and minimums given in the parameter.
 ****************************************************************************/
-static struct cm_fitness compute_fitness(const int surplus[NUM_STATS],
+static struct cm_fitness compute_fitness(const int surplus[],
                                         bool disorder, bool happy,
                                        const struct cm_parameter *parameter)
 {
-  enum cm_stat stat;
+  Output_type_id stat;
   struct cm_fitness fitness;
 
   fitness.sufficient = TRUE;
   fitness.weighted = 0;
 
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     fitness.weighted += surplus[stat] * parameter->factor[stat];
     if (surplus[stat] < parameter->minimal_surplus[stat]) {
       fitness.sufficient = FALSE;
@@ -686,15 +686,15 @@
   values based on the city's data.
 ****************************************************************************/
 static void get_city_surplus(const struct city *pcity,
-                            int surplus[NUM_STATS],
+                            int surplus[],
                             bool *disorder, bool *happy)
 {
-  surplus[FOOD] = pcity->food_surplus;
-  surplus[SHIELD] = pcity->shield_surplus;
-  surplus[TRADE] = pcity->trade_prod;
-  surplus[GOLD] = city_gold_surplus(pcity, pcity->tax_total);
-  surplus[LUXURY] = pcity->luxury_total;
-  surplus[SCIENCE] = pcity->science_total;
+  surplus[O_FOOD] = pcity->food_surplus;
+  surplus[O_SHIELD] = pcity->shield_surplus;
+  surplus[O_TRADE] = pcity->trade_prod;
+  surplus[O_GOLD] = city_gold_surplus(pcity, pcity->tax_total);
+  surplus[O_LUXURY] = pcity->luxury_total;
+  surplus[O_SCIENCE] = pcity->science_total;
 
   *disorder = city_unhappy(pcity);
   *happy = city_happy(pcity);
@@ -708,7 +708,7 @@
 {
   struct city *pcity = state->pcity;
   struct city backup;
-  int surplus[NUM_STATS];
+  int surplus[O_COUNT];
   bool disorder, happy;
 
   /* make a backup, apply and evaluate the solution, and restore.  This costs
@@ -766,7 +766,7 @@
 static int compare_tile_type_by_lattice_order(const struct cm_tile_type *a,
                                              const struct cm_tile_type *b)
 {
-  enum cm_stat stat;
+  Output_type_id stat;
 
   if (a == b) {
     return 0;
@@ -778,7 +778,7 @@
   }
 
   /* With equal depth, break ties arbitrarily, more production first. */
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     if (a->production[stat] != b->production[stat]) {
       return b->production[stat] - a->production[stat];
     }
@@ -818,7 +818,7 @@
   return compare_tile_type_by_lattice_order(*a, *b);
 }
 
-static enum cm_stat compare_key;
+static Output_type_id compare_key;
 
 /****************************************************************************
   Compare by the production of type compare_key.
@@ -857,14 +857,14 @@
 {
   bool is_celebrating = base_city_celebrating(pcity);
 
-  out->production[FOOD]
+  out->production[O_FOOD]
     = base_city_get_food_tile(x, y, pcity, is_celebrating);
-  out->production[SHIELD]
+  out->production[O_SHIELD]
     = base_city_get_shields_tile(x, y, pcity, is_celebrating);
-  out->production[TRADE]
+  out->production[O_TRADE]
     = base_city_get_trade_tile(x, y, pcity, is_celebrating);
-  out->production[GOLD] = out->production[SCIENCE]
-    = out->production[LUXURY] = 0;
+  out->production[O_GOLD] = out->production[O_SCIENCE]
+    = out->production[O_LUXURY] = 0;
 }
 
 /****************************************************************************
@@ -924,12 +924,12 @@
  */
 struct spec_stat_pair {
   enum specialist_type spec;
-  enum cm_stat stat;
+  Output_type_id stat;
 };
 const static struct spec_stat_pair pairs[SP_COUNT] =  {
-  { SP_ELVIS, LUXURY },
-  { SP_SCIENTIST, SCIENCE },
-  { SP_TAXMAN, GOLD }
+  { SP_ELVIS, O_LUXURY },
+  { SP_SCIENTIST, O_SCIENCE },
+  { SP_TAXMAN, O_GOLD }
 };
 
 /****************************************************************************
@@ -1101,7 +1101,7 @@
   much of the domain-specific knowledge.
 ****************************************************************************/
 static double estimate_fitness(const struct cm_state *state,
-                              const int production[NUM_STATS]);
+                              const int production[]);
 
 static void sort_lattice_by_fitness(const struct cm_state *state,
                                    struct tile_type_vector *lattice)
@@ -1202,7 +1202,7 @@
                        int itype, int number,
                        const struct cm_state *state)
 {
-  enum cm_stat stat;
+  Output_type_id stat;
   const struct cm_tile_type *ptype = tile_type_get(state, itype);
   int newcount;
   int old_worker_count = soln->worker_counts[itype];
@@ -1241,7 +1241,7 @@
   }
 
   /* update production */
-  for (stat = 0 ; stat < NUM_STATS; stat++) {
+  for (stat = 0 ; stat < O_COUNT; stat++) {
     newcount = soln->production[stat] + number * ptype->production[stat];
     assert(newcount >= 0);
     soln->production[stat] = newcount;
@@ -1461,10 +1461,10 @@
 ****************************************************************************/
 static void compute_max_stats_heuristic(const struct cm_state *state,
                                        const struct partial_solution *soln,
-                                       int production[NUM_STATS],
+                                       int production[],
                                        int check_choice)
 {
-  enum cm_stat stat;
+  Output_type_id stat;
   struct partial_solution solnplus; /* will be soln, plus some tiles */
 
   /* Production is whatever the solution produces, plus the
@@ -1474,11 +1474,11 @@
   if (soln->idle == 1) {
     /* Then the total solution is soln + this new worker.  So we know the
        production exactly, and can shortcut the later code. */
-    enum cm_stat stat;
+    Output_type_id stat;
     const struct cm_tile_type *ptype = tile_type_get(state, check_choice);
 
     memcpy(production, soln->production, sizeof(soln->production));
-    for (stat = 0; stat < NUM_STATS; stat++) {
+    for (stat = 0; stat < O_COUNT; stat++) {
       production[stat] += ptype->production[stat];
     }
     return;
@@ -1487,7 +1487,7 @@
   /* initialize solnplus here, after the shortcut check */
   init_partial_solution(&solnplus, num_types(state), state->pcity->size);
 
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     /* compute the solution that has soln, then the check_choice,
        then complete it with the best available tiles for the stat. */
     copy_partial_solution(&solnplus, soln, state);
@@ -1508,13 +1508,13 @@
 ****************************************************************************/
 static bool choice_is_promising(struct cm_state *state, int newchoice)
 {
-  int production[NUM_STATS];
-  enum cm_stat stat;
+  int production[O_COUNT];
+  Output_type_id stat;
   bool beats_best = FALSE;
 
   compute_max_stats_heuristic(state, &state->current, production, newchoice);
 
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  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],
@@ -1541,7 +1541,7 @@
 static void init_min_production(struct cm_state *state)
 {
   int x = CITY_MAP_RADIUS, y = CITY_MAP_RADIUS;
-  int usage[NUM_STATS];
+  int usage[O_COUNT];
   struct city *pcity = state->pcity;
   bool is_celebrating = base_city_celebrating(pcity);
   struct city backup;
@@ -1557,12 +1557,12 @@
    * prod-surplus; otherwise, we know it's at least 2*size but we
    * can't easily compute the settlers. */
   if (!city_unhappy(pcity)) {
-    usage[FOOD] = pcity->food_prod - pcity->food_surplus;
+    usage[O_FOOD] = pcity->food_prod - pcity->food_surplus;
   } else {
-    usage[FOOD] = pcity->size * 2;
+    usage[O_FOOD] = pcity->size * 2;
   }
-  state->min_production[FOOD] = usage[FOOD]
-    + state->parameter.minimal_surplus[FOOD]
+  state->min_production[O_FOOD] = usage[O_FOOD]
+    + state->parameter.minimal_surplus[O_FOOD]
     - base_city_get_food_tile(x, y, pcity, is_celebrating);
 
   /* surplus = (factories-waste) * production - shield_usage, so:
@@ -1580,19 +1580,20 @@
   if (!city_unhappy(pcity)) {
     double sbonus;
 
-    usage[SHIELD] = pcity->shield_prod - pcity->shield_surplus;
+    usage[O_SHIELD] = pcity->shield_prod - pcity->shield_surplus;
 
     sbonus = ((double)pcity->shield_bonus) / 100.0;
     sbonus += .1;
-    state->min_production[SHIELD]
-      = (usage[SHIELD] + state->parameter.minimal_surplus[SHIELD]) / sbonus;
-    state->min_production[SHIELD]
+    state->min_production[O_SHIELD]
+      = ((usage[O_SHIELD] + state->parameter.minimal_surplus[O_SHIELD])
+        / sbonus);
+    state->min_production[O_SHIELD]
       -= base_city_get_shields_tile(x, y, pcity, is_celebrating);
   } else {
     /* Dunno what the usage is, so it's pointless to set the
      * min_production */
-    usage[SHIELD] = 0;
-    state->min_production[SHIELD] = 0;
+    usage[O_SHIELD] = 0;
+    state->min_production[O_SHIELD] = 0;
   }
 
   /* we should be able to get a min_production on gold and trade, too;
@@ -1611,34 +1612,37 @@
   The only fields of the state used are the city and parameter.
 ****************************************************************************/
 static double estimate_fitness(const struct cm_state *state,
-                              const int production[NUM_STATS]) {
+                              const int production[]) {
   const struct city *pcity = state->pcity;
   const struct player *pplayer = get_player(pcity->owner);
-  enum cm_stat stat;
-  double estimates[NUM_STATS];
+  Output_type_id stat;
+  double estimates[O_COUNT];
   double sum = 0;
 
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     estimates[stat] = production[stat];
   }
 
   /* sci/lux/gold get benefit from the tax rates (in percentage) */
-  estimates[SCIENCE] += pplayer->economic.science * estimates[TRADE] / 100.0;
-  estimates[LUXURY] += pplayer->economic.luxury  * estimates[TRADE] / 100.0;
-  estimates[GOLD] += pplayer->economic.tax     * estimates[TRADE] / 100.0;
+  estimates[O_SCIENCE]
+    += pplayer->economic.science * estimates[O_TRADE] / 100.0;
+  estimates[O_LUXURY]
+    += pplayer->economic.luxury * estimates[O_TRADE] / 100.0;
+  estimates[O_GOLD]
+    += pplayer->economic.tax * estimates[O_TRADE] / 100.0;
 
   /* now add in the bonuses (none for food or trade) (in percentage) */
-  estimates[SHIELD] *= pcity->shield_bonus / 100.0;
-  estimates[LUXURY] *= pcity->luxury_bonus / 100.0;
-  estimates[GOLD] *= pcity->tax_bonus / 100.0;
-  estimates[SCIENCE] *= pcity->science_bonus / 100.0;
+  estimates[O_SHIELD] *= pcity->shield_bonus / 100.0;
+  estimates[O_LUXURY] *= pcity->luxury_bonus / 100.0;
+  estimates[O_GOLD] *= pcity->tax_bonus / 100.0;
+  estimates[O_SCIENCE] *= pcity->science_bonus / 100.0;
 
   /* finally, sum it all up, weighted by the parameter, but give additional
    * weight to luxuries to take account of disorder/happy constraints */
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     sum += estimates[stat] * state->parameter.factor[stat];
   }
-  sum += estimates[LUXURY];
+  sum += estimates[O_LUXURY];
   return sum;
 }
 
@@ -1695,7 +1699,7 @@
 struct cm_state *cm_init_state(struct city *pcity)
 {
   int numtypes;
-  enum cm_stat stat;
+  Output_type_id stat;
   struct cm_state *state = fc_malloc(sizeof(*state));
 
   freelog(LOG_CM_STATE, "creating cm_state for %s (size %d)",
@@ -1710,7 +1714,7 @@
   numtypes = tile_type_vector_size(&state->lattice);
 
   /* For the heuristic, make sorted copies of the lattice */
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     tile_type_vector_init(&state->lattice_by_prod[stat]);
     tile_type_vector_copy(&state->lattice_by_prod[stat], &state->lattice);
     compare_key = stat;
@@ -1780,10 +1784,10 @@
 ****************************************************************************/
 void cm_free_state(struct cm_state *state)
 {
-  enum cm_stat stat;
+  Output_type_id stat;
 
   tile_type_vector_free_all(&state->lattice);
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     tile_type_vector_free(&state->lattice_by_prod[stat]);
   }
   destroy_partial_solution(&state->best);
@@ -1833,22 +1837,22 @@
 /****************************************************************************
   Return a translated name for the stat type.
 *****************************************************************************/
-const char *cm_get_stat_name(enum cm_stat stat)
+const char *cm_get_stat_name(Output_type_id stat)
 {
   switch (stat) {
-  case FOOD:
+  case O_FOOD:
     return _("Food");
-  case SHIELD:
+  case O_SHIELD:
     return _("Shield");
-  case TRADE:
+  case O_TRADE:
     return _("Trade");
-  case GOLD:
+  case O_GOLD:
     return _("Gold");
-  case LUXURY:
+  case O_LUXURY:
     return _("Luxury");
-  case SCIENCE:
+  case O_SCIENCE:
     return _("Science");
-  case NUM_STATS:
+  case O_LAST:
     break;
   }
   die("Unknown stat value in cm_get_stat_name: %d", stat);
@@ -1863,7 +1867,7 @@
 {
   int i;
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     if (p1->minimal_surplus[i] != p2->minimal_surplus[i]) {
       return FALSE;
     }
@@ -1901,9 +1905,9 @@
 **************************************************************************/
 void cm_init_parameter(struct cm_parameter *dest)
 {
-  enum cm_stat stat;
+  Output_type_id stat;
 
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     dest->minimal_surplus[stat] = 0;
     dest->factor[stat] = 1;
   }
@@ -1920,9 +1924,9 @@
 ***************************************************************************/
 void cm_init_emergency_parameter(struct cm_parameter *dest)
 {
-  enum cm_stat stat;
+  Output_type_id stat;
 
-  for (stat = 0; stat < NUM_STATS; stat++) {
+  for (stat = 0; stat < O_COUNT; stat++) {
     dest->minimal_surplus[stat] = -FC_INFINITY;
     dest->factor[stat] = 1;
   }
@@ -1994,14 +1998,14 @@
 ****************************************************************************/
 #ifdef CM_DEBUG
 static void snprint_production(char *buffer, size_t bufsz,
-                             const int production[NUM_STATS])
+                             const int production[])
 {
   int nout;
 
   nout = snprintf(buffer, bufsz, "[%d %d %d %d %d %d]",
-                 production[FOOD], production[SHIELD],
-                 production[TRADE], production[GOLD],
-                 production[LUXURY], production[SCIENCE]);
+                 production[O_FOOD], production[O_SHIELD],
+                 production[O_TRADE], production[O_GOLD],
+                 production[O_LUXURY], production[O_SCIENCE]);
 
   assert(nout >= 0 && nout <= bufsz);
 }
@@ -2178,7 +2182,7 @@
       "print_result:  people: (workers/specialists) %d/%s",
       worker, specialists_string(result->specialists));
 
-  for (i = 0; i < NUM_STATS; i++) {
+  for (i = 0; i < O_COUNT; i++) {
     freelog(LOG_NORMAL, "print_result:  %10s surplus=%d",
         cm_get_stat_name(i), result->surplus[i]);
   }
Index: common/aicore/cm.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.h,v
retrieving revision 1.10
diff -u -r1.10 cm.h
--- common/aicore/cm.h  22 Jul 2004 15:20:47 -0000      1.10
+++ common/aicore/cm.h  22 Nov 2004 05:06:30 -0000
@@ -29,16 +29,14 @@
 #include "city.h"              /* CITY_MAP_SIZE */
 #include "shared.h"            /* bool type */
 
-enum cm_stat { FOOD, SHIELD, TRADE, GOLD, LUXURY, SCIENCE, NUM_STATS };
-
 /* A description of the goal. */
 struct cm_parameter {
-  int minimal_surplus[NUM_STATS];
+  int minimal_surplus[O_MAX];
   bool require_happy;
   bool allow_disorder;
   bool allow_specialists;
 
-  int factor[NUM_STATS];
+  int factor[O_MAX];
   int happy_factor;
 };
 
@@ -46,7 +44,7 @@
 struct cm_result {
   bool found_a_valid, disorder, happy;
 
-  int surplus[NUM_STATS];
+  int surplus[O_MAX];
 
   bool worker_positions_used[CITY_MAP_SIZE][CITY_MAP_SIZE];
   int specialists[SP_COUNT];
@@ -76,7 +74,7 @@
 void cm_clear_cache(struct city *pcity);
 
 /***************** utility methods *************************************/
-const char *cm_get_stat_name(enum cm_stat stat);
+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,
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.273
diff -u -r1.273 cityturn.c
--- server/cityturn.c   17 Nov 2004 19:21:14 -0000      1.273
+++ server/cityturn.c   22 Nov 2004 05:06:31 -0000
@@ -213,35 +213,35 @@
    * priorities - this should be done via a separate set of variables. */
   if (pcity->size > 1) {
     if (pcity->size <= game.notradesize) {
-      cmp.factor[FOOD] = 15;
+      cmp.factor[O_FOOD] = 15;
     } else {
-      cmp.factor[FOOD] = 10;
+      cmp.factor[O_FOOD] = 10;
     }
   } else {
     /* Growing to size 2 is the highest priority. */
-    cmp.factor[FOOD] = 20;
+    cmp.factor[O_FOOD] = 20;
   }
-  cmp.factor[SHIELD] = 5;
-  cmp.factor[TRADE] = 0; /* Trade only provides gold/science. */
-  cmp.factor[GOLD] = 2;
-  cmp.factor[LUXURY] = 0; /* Luxury only influences happiness. */
-  cmp.factor[SCIENCE] = 2;
+  cmp.factor[O_SHIELD] = 5;
+  cmp.factor[O_TRADE] = 0; /* Trade only provides gold/science. */
+  cmp.factor[O_GOLD] = 2;
+  cmp.factor[O_LUXURY] = 0; /* Luxury only influences happiness. */
+  cmp.factor[O_SCIENCE] = 2;
   cmp.happy_factor = 0;
 
-  cmp.minimal_surplus[FOOD] = 1;
-  cmp.minimal_surplus[SHIELD] = 1;
-  cmp.minimal_surplus[TRADE] = 0;
-  cmp.minimal_surplus[GOLD] = -FC_INFINITY;
-  cmp.minimal_surplus[LUXURY] = 0;
-  cmp.minimal_surplus[SCIENCE] = 0;
+  cmp.minimal_surplus[O_FOOD] = 1;
+  cmp.minimal_surplus[O_SHIELD] = 1;
+  cmp.minimal_surplus[O_TRADE] = 0;
+  cmp.minimal_surplus[O_GOLD] = -FC_INFINITY;
+  cmp.minimal_surplus[O_LUXURY] = 0;
+  cmp.minimal_surplus[O_SCIENCE] = 0;
 
   cm_query_result(pcity, &cmp, &cmr);
 
   if (!cmr.found_a_valid) {
     if (!pplayer->ai.control) {
       /* Drop surpluses and try again. */
-      cmp.minimal_surplus[FOOD] = 0;
-      cmp.minimal_surplus[SHIELD] = 0;
+      cmp.minimal_surplus[O_FOOD] = 0;
+      cmp.minimal_surplus[O_SHIELD] = 0;
       cm_query_result(pcity, &cmp, &cmr);
 
       if (!cmr.found_a_valid) {
@@ -250,14 +250,14 @@
        cm_query_result(pcity, &cmp, &cmr);
       }
     } else {
-      cmp.minimal_surplus[FOOD] = 0;
-      cmp.minimal_surplus[SHIELD] = 0;
-      cmp.minimal_surplus[GOLD] = -FC_INFINITY;
+      cmp.minimal_surplus[O_FOOD] = 0;
+      cmp.minimal_surplus[O_SHIELD] = 0;
+      cmp.minimal_surplus[O_GOLD] = -FC_INFINITY;
       cm_query_result(pcity, &cmp, &cmr);
 
       if (!cmr.found_a_valid) {
-       cmp.minimal_surplus[FOOD] = -(pcity->food_stock);
-       cmp.minimal_surplus[TRADE] = -FC_INFINITY;
+       cmp.minimal_surplus[O_FOOD] = -(pcity->food_stock);
+       cmp.minimal_surplus[O_TRADE] = -FC_INFINITY;
        cm_query_result(pcity, &cmp, &cmr);
       }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11146) move output types into city.h, Jason Short <=