Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] (PR#2516) introducing an enum citizen_type
Home

[Freeciv-Dev] (PR#2516) introducing an enum citizen_type

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2516) introducing an enum citizen_type
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Sat, 7 Dec 2002 20:43:46 -0800
Reply-to: rt@xxxxxxxxxxxxxx

The current client code tracks 11 different types of citizens: 2 each
for happy, content, unhappy, angry citizens, plus elvises, scientists,
and taxmen.  The order of these 11 is hard-coded in several places.  The
sprites for all 11 are loaded manually, and the accesses to them are
often also hard-coded.

This is inelegant and inextensible; see PR#2495.

The attached patch rewrites a lot of this code.  Now there are 7 types
of citizens: happy, content, unhappy, angry, elvis, scientist, taxman. 
Each type may have one or more sprites, as defined by the tileset. 
Accessing the sprite is done through the get_citizen_sprite function. 
This means a future change to the sprite system (such as PR#2495) can be
done without any GUI changes.

The patch itself is pretty lengthy and touches every GUI.

A lot of the happiness code could be removed with some common
functions.  This would be easier to do _after_ the enum citizen_type is
put into place, but could be done before to make the patches slightly
smaller.  I would prefer that this patch go in first.

jason


Index: client/citydlg_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.h,v
retrieving revision 1.5
diff -u -r1.5 citydlg_common.h
--- client/citydlg_common.h     2002/04/12 13:50:55     1.5
+++ client/citydlg_common.h     2002/12/08 04:21:06
@@ -20,6 +20,17 @@
 
 struct city;
 
+enum citizen_type {
+  CITIZEN_ELVIS,
+  CITIZEN_SCIENTIST,
+  CITIZEN_TAXMAN,
+  CITIZEN_CONTENT,
+  CITIZEN_HAPPY,
+  CITIZEN_UNHAPPY,
+  CITIZEN_ANGRY,
+  T_LAST_CITIZEN
+};
+
 void city_pos_to_canvas_pos(int city_x, int city_y, int *canvas_x, int 
*canvas_y);
 void canvas_pos_to_city_pos(int canvas_x, int canvas_y, int *map_x, int 
*map_y);
 
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.92
diff -u -r1.92 tilespec.c
--- client/tilespec.c   2002/12/07 09:59:18     1.92
+++ client/tilespec.c   2002/12/08 04:21:06
@@ -554,6 +554,33 @@
 }
 
 /**********************************************************************
+  Returns a text name for the citizen, as used in the tileset.
+***********************************************************************/
+static char *get_citizen_name(enum citizen_type citizen)
+{
+  switch (citizen) {
+  case CITIZEN_ELVIS:
+    return "entertainer";
+  case CITIZEN_SCIENTIST:
+    return "scientist";
+  case CITIZEN_TAXMAN:
+    return "tax_collector";
+  case CITIZEN_HAPPY:
+    return "happy";
+  case CITIZEN_CONTENT:
+    return "content";
+  case CITIZEN_UNHAPPY:
+    return "unhappy";
+  case CITIZEN_ANGRY:
+    return "angry";
+  case T_LAST_CITIZEN:
+    break;
+  }
+  assert(0);
+  return "";
+}
+
+/**********************************************************************
   Return string n0s0e0w0 such that INDEX_NSEW(n,s,e,w) = idx
   The returned string is pointer to static memory.
 ***********************************************************************/
@@ -612,18 +639,28 @@
     SET_SPRITE(coast_color, "t.coast_color");
   }
 
-  /* This uses internal code for citizens array/index: */
-  SET_SPRITE(citizen[0], "citizen.entertainer");
-  SET_SPRITE(citizen[1], "citizen.scientist");
-  SET_SPRITE(citizen[2], "citizen.tax_collector");
-  SET_SPRITE(citizen[3], "citizen.content_0");
-  SET_SPRITE(citizen[4], "citizen.content_1");
-  SET_SPRITE(citizen[5], "citizen.happy_0");
-  SET_SPRITE(citizen[6], "citizen.happy_1");
-  SET_SPRITE(citizen[7], "citizen.unhappy_0");
-  SET_SPRITE(citizen[8], "citizen.unhappy_1");
-  SET_SPRITE(citizen[9], "citizen.angry_0");
-  SET_SPRITE(citizen[10], "citizen.angry_1");
+  /* Load the citizen sprite graphics. */
+  for (i = 0; i < NUM_TILES_CITIZEN; i++) {
+    my_snprintf(buffer, sizeof(buffer), "citizen.%s", get_citizen_name(i));
+    sprites.citizen[i].sprite[0] = hash_lookup_data(sprite_hash, buffer);
+    if (sprites.citizen[i].sprite[0]) {
+      /* If this form exists, use it as the only sprite.  This allows
+       * backwards compatability with tilesets that use e.g.,
+       * citizen.entertainer. */
+      sprites.citizen[i].count = 1;
+      continue;
+    }
+    for (j = 0; j < NUM_TILES_CITIZEN; j++) {
+      my_snprintf(buffer, sizeof(buffer), "citizen.%s_%d",
+                 get_citizen_name(i), j);
+      sprites.citizen[i].sprite[j] = hash_lookup_data(sprite_hash, buffer);
+      if (!sprites.citizen[i].sprite[j]) {
+       break;
+      }
+    }
+    sprites.citizen[i].count = j;
+    assert(j > 0);
+  }
 
   SET_SPRITE(spaceship.solar_panels, "spaceship.solar_panels");
   SET_SPRITE(spaceship.life_support, "spaceship.life_support");
@@ -2044,10 +2081,12 @@
 }
 
 /**************************************************************************
-  Return a sprite for the given citizen.
+  Return a sprite for the given citizen.  The citizen's type is given,
+  as well as their number (in the range [0..pcity->size)).
 **************************************************************************/
-struct Sprite *get_citizen_sprite(int citizen)
+struct Sprite *get_citizen_sprite(enum citizen_type citizen, int cnum)
 {
-  citizen = CLIP(0, citizen, NUM_TILES_CITIZEN - 1);
-  return sprites.citizen[citizen];
+  assert(citizen >= 0 && citizen < NUM_TILES_CITIZEN);
+  cnum %= sprites.citizen[citizen].count;
+  return sprites.citizen[citizen].sprite[cnum];
 }
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.33
diff -u -r1.33 tilespec.h
--- client/tilespec.h   2002/12/07 09:59:18     1.33
+++ client/tilespec.h   2002/12/08 04:21:07
@@ -21,6 +21,8 @@
 #include "map.h"               /* NUM_DIRECTION_NSEW */
 
 #include "colors_g.h"
+
+#include "citydlg_common.h"    /* enum citizen_type */
 #include "options.h"
 
 struct Sprite;                 /* opaque; gui-dep */
@@ -75,9 +77,10 @@
                              ((w) ? BIT_WEST  : 0))
 
 #define NUM_TILES_PROGRESS 8
-#define NUM_TILES_CITIZEN 11
+#define NUM_TILES_CITIZEN T_LAST_CITIZEN
 #define NUM_TILES_HP_BAR 11
 #define NUM_TILES_DIGITS 10
+#define MAX_NUM_CITIZEN_SPRITES 6
 
 /* This could be moved to common/map.h if there's more use for it. */
 enum direction4 {
@@ -89,13 +92,19 @@
     *bulb[NUM_TILES_PROGRESS],
     *warming[NUM_TILES_PROGRESS],
     *cooling[NUM_TILES_PROGRESS],
-    *citizen[NUM_TILES_CITIZEN],   /* internal code... */
     *treaty_thumb[2],     /* 0=disagree, 1=agree */
     *right_arrow,
 
     *black_tile,      /* only used for isometric view */
     *dither_tile,     /* only used for isometric view */
     *coast_color;     /* only used for isometric view */
+
+  struct {
+    /* Each citizen type has up to MAX_NUM_CITIZEN_SPRITES different
+     * sprites, as defined by the tileset. */
+    int count;
+    struct Sprite *sprite[MAX_NUM_CITIZEN_SPRITES];
+  } citizen[NUM_TILES_CITIZEN];
   struct {
     struct Sprite
       *solar_panels,
@@ -192,7 +201,7 @@
 
 extern struct named_sprites sprites;
 
-struct Sprite *get_citizen_sprite(int citizen);
+struct Sprite *get_citizen_sprite(enum citizen_type citizen, int cnum);
 
 extern char current_tile_set_name[512];
 
Index: client/gui-gtk/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v
retrieving revision 1.147
diff -u -r1.147 citydlg.c
--- client/gui-gtk/citydlg.c    2002/12/05 22:22:34     1.147
+++ client/gui-gtk/citydlg.c    2002/12/08 04:21:07
@@ -1671,40 +1671,47 @@
   i = 0;       /* tracks the # of the citizen we are currently placing. */
   for (n = 0; n < pcity->ppl_happy[4]; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(5 + i % 2), i * width, 0, TRUE);
+                      get_citizen_sprite(CITIZEN_HAPPY, i),
+                      i * width, 0, TRUE);
   }
 
   for (n = 0; n < pcity->ppl_content[4]; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(3 + i % 2), i * width, 0, TRUE);
+                      get_citizen_sprite(CITIZEN_CONTENT, i),
+                      i * width, 0, TRUE);
   }
 
   for (n = 0; n < pcity->ppl_unhappy[4]; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(7 + i % 2), i * width, 0, TRUE);
+                      get_citizen_sprite(CITIZEN_UNHAPPY, i),
+                      i * width, 0, TRUE);
   }
 
   for (n = 0; n < pcity->ppl_angry[4]; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(9 + i % 2), i * width, 0, TRUE);
+                      get_citizen_sprite(CITIZEN_ANGRY, i),
+                      i * width, 0, TRUE);
   }
 
   pdialog->first_elvis = i;
   for (n = 0; n < pcity->ppl_elvis; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(0), i * width, 0, TRUE);
+                      get_citizen_sprite(CITIZEN_ELVIS, i),
+                      i * width, 0, TRUE);
   }
 
   pdialog->first_scientist = i;
   for (n = 0; n < pcity->ppl_scientist; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(1), i * width, 0, TRUE);
+                      get_citizen_sprite(CITIZEN_SCIENTIST, i),
+                      i * width, 0, TRUE);
   }
 
   pdialog->first_taxman = i;
   for (n = 0; n < pcity->ppl_taxman; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(2), i * width, 0, TRUE);
+                      get_citizen_sprite(CITIZEN_TAXMAN, i),
+                      i * width, 0, TRUE);
   }
 /*  gtk_widget_set_sensitive(pdialog->citizen_pixmap,*/
 /*                           !cma_is_city_under_agent(pcity, NULL));*/
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.121
diff -u -r1.121 gui_main.c
--- client/gui-gtk/gui_main.c   2002/11/30 20:04:19     1.121
+++ client/gui-gtk/gui_main.c   2002/12/08 04:21:07
@@ -641,6 +641,7 @@
 
   /* citizens for taxrates */
   for (i = 0; i < 10; i++) {
+    enum citizen_type c = i < 5 ? CITIZEN_SCIENTIST : CITIZEN_TAXMAN;
     ebox = gtk_event_box_new();
     gtk_widget_set_events(ebox, GDK_BUTTON_PRESS_MASK);
 
@@ -649,7 +650,7 @@
     gtk_signal_connect(GTK_OBJECT(ebox), "button_press_event",
                        GTK_SIGNAL_FUNC(taxrates_callback), GINT_TO_POINTER(i));
 
-    econ_label[i] = gtk_pixmap_new(get_citizen_pixmap(i < 5 ? 1 : 2), NULL);
+    econ_label[i] = gtk_pixmap_new(get_citizen_pixmap(c, i), NULL);
     gtk_pixmap_set_build_insensitive(GTK_PIXMAP(econ_label[i]), FALSE);
     gtk_container_add(GTK_CONTAINER(ebox), econ_label[i]);
   }
@@ -664,7 +665,8 @@
   flake_label = gtk_pixmap_new(sprites.cooling[0]->pixmap, NULL);
   gtk_pixmap_set_build_insensitive(GTK_PIXMAP(flake_label), FALSE);
 
-  government_label= gtk_pixmap_new(sprites.citizen[7]->pixmap, NULL);
+  government_label
+    = gtk_pixmap_new(get_citizen_pixmap(CITIZEN_UNHAPPY, 0), NULL);
   gtk_pixmap_set_build_insensitive(GTK_PIXMAP(government_label), FALSE);
 
   timeout_label = gtk_label_new("");
Index: client/gui-gtk/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/happiness.c,v
retrieving revision 1.9
diff -u -r1.9 happiness.c
--- client/gui-gtk/happiness.c  2002/11/15 21:24:28     1.9
+++ client/gui-gtk/happiness.c  2002/12/08 04:21:07
@@ -28,6 +28,7 @@
 #include "gui_main.h"
 #include "gui_stuff.h"
 #include "happiness.h"
+#include "mapview.h"
 #include "tilespec.h"
 
 /* semi-arbitrary number that controls the width of the happiness widget */
@@ -158,7 +159,7 @@
 static GdkPixmap *create_happiness_pixmap(struct city *pcity, int index)
 {
   int i;
-  int citizen_type;
+  enum citizen_type citizen_type;
   int n1 = pcity->ppl_happy[index];
   int n2 = n1 + pcity->ppl_content[index];
   int n3 = n2 + pcity->ppl_unhappy[index];
@@ -175,22 +176,22 @@
 
   for (i = 0; i < num_citizens; i++) {
     if (i < n1)
-      citizen_type = 5 + i % 2;
+      citizen_type = CITIZEN_HAPPY;
     else if (i < n2)
-      citizen_type = 3 + i % 2;
+      citizen_type = CITIZEN_CONTENT;
     else if (i < n3)
-      citizen_type = 7 + i % 2;
+      citizen_type = CITIZEN_UNHAPPY;
     else if (i < n4)
-      citizen_type = 9 + i % 2;
+      citizen_type = CITIZEN_ANGRY;
     else if (i < n5)
-      citizen_type = 0;
+      citizen_type = CITIZEN_ELVIS;
     else if (i < n6)
-      citizen_type = 1;
+      citizen_type = CITIZEN_SCIENTIST;
     else
-      citizen_type = 2;
+      citizen_type = CITIZEN_TAXMAN;
 
     gdk_draw_pixmap(happiness_pixmap, civ_gc,
-                   sprites.citizen[citizen_type]->pixmap,
+                   get_citizen_pixmap(citizen_type, i),
                    0, 0, i * offset, 0, SMALL_TILE_WIDTH,
                    SMALL_TILE_HEIGHT);
   }
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.142
diff -u -r1.142 mapview.c
--- client/gui-gtk/mapview.c    2002/12/07 09:59:18     1.142
+++ client/gui-gtk/mapview.c    2002/12/08 04:21:08
@@ -357,15 +357,15 @@
   d=0;
   for(;d<(game.player_ptr->economic.luxury)/10;d++)
     gtk_pixmap_set(GTK_PIXMAP(econ_label[d]),
-    get_citizen_pixmap(0), NULL ); /* elvis tile */
+                  get_citizen_pixmap(CITIZEN_ELVIS, d), NULL );
  
   
for(;d<(game.player_ptr->economic.science+game.player_ptr->economic.luxury)/10;d++)
     gtk_pixmap_set(GTK_PIXMAP(econ_label[d]),
-    get_citizen_pixmap(1), NULL ); /* scientist tile */
+                  get_citizen_pixmap(CITIZEN_SCIENTIST, d), NULL );
  
    for(;d<10;d++)
     gtk_pixmap_set(GTK_PIXMAP(econ_label[d]),
-    get_citizen_pixmap(2), NULL ); /* taxman tile */
+                  get_citizen_pixmap(CITIZEN_TAXMAN, d), NULL );
  
   update_timeout_label();
 }
@@ -445,10 +445,9 @@
 /**************************************************************************
 ...
 **************************************************************************/
-GdkPixmap *get_citizen_pixmap(int frame)
+GdkPixmap *get_citizen_pixmap(enum citizen_type type, int cnum)
 {
-  frame = CLIP(0, frame, NUM_TILES_CITIZEN-1);
-  return sprites.citizen[frame]->pixmap;
+  return get_citizen_sprite(type, cnum)->pixmap;
 }
 
 /**************************************************************************
@@ -468,7 +467,7 @@
 
   if (game.government_count==0) {
     /* not sure what to do here */
-    gov_sprite = sprites.citizen[7]; 
+    gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0); 
   } else {
     gov_sprite = get_government(gov)->sprite;
   }
Index: client/gui-gtk/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.h,v
retrieving revision 1.14
diff -u -r1.14 mapview.h
--- client/gui-gtk/mapview.h    2002/12/07 09:59:18     1.14
+++ client/gui-gtk/mapview.h    2002/12/08 04:21:08
@@ -17,6 +17,7 @@
 
 #include "gtkpixcomm.h"
 
+#include "citydlg_common.h"
 #include "mapview_g.h"
 #include "mapview_common.h"
 
@@ -26,7 +27,7 @@
 struct city;
 
 GdkPixmap *get_thumb_pixmap(int onoff);
-GdkPixmap *get_citizen_pixmap(int frame);
+GdkPixmap *get_citizen_pixmap(enum citizen_type type, int cnum);
 
 gint overview_canvas_expose(GtkWidget *w, GdkEventExpose *ev);
 gint map_canvas_expose(GtkWidget *w, GdkEventExpose *ev);
Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.16
diff -u -r1.16 citydlg.c
--- client/gui-gtk-2.0/citydlg.c        2002/12/05 22:22:34     1.16
+++ client/gui-gtk-2.0/citydlg.c        2002/12/08 04:21:08
@@ -1657,40 +1657,47 @@
   i = 0;       /* tracks the # of the citizen we are currently placing. */
   for (n = 0; n < pcity->ppl_happy[4]; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(5 + i % 2), i * width, 0);
+                      get_citizen_sprite(CITIZEN_HAPPY, i),
+                      i * width, 0);
   }
 
   for (n = 0; n < pcity->ppl_content[4]; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(3 + i % 2), i * width, 0);
+                      get_citizen_sprite(CITIZEN_CONTENT, i),
+                      i * width, 0);
   }
 
   for (n = 0; n < pcity->ppl_unhappy[4]; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(7 + i % 2), i * width, 0);
+                      get_citizen_sprite(CITIZEN_UNHAPPY, i),
+                      i * width, 0);
   }
 
   for (n = 0; n < pcity->ppl_angry[4]; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(9 + i % 2), i * width, 0);
+                      get_citizen_sprite(CITIZEN_ANGRY, i),
+                      i * width, 0);
   }
 
   pdialog->first_elvis = i;
   for (n = 0; n < pcity->ppl_elvis; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(0), i * width, 0);
+                      get_citizen_sprite(CITIZEN_ELVIS, i),
+                      i * width, 0);
   }
 
   pdialog->first_scientist = i;
   for (n = 0; n < pcity->ppl_scientist; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(1), i * width, 0);
+                      get_citizen_sprite(CITIZEN_SCIENTIST, i),
+                      i * width, 0);
   }
 
   pdialog->first_taxman = i;
   for (n = 0; n < pcity->ppl_taxman; n++, i++) {
     gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
-                      get_citizen_sprite(2), i * width, 0);
+                      get_citizen_sprite(CITIZEN_TAXMAN, i),
+                      i * width, 0);
   }
   gtk_pixcomm_thaw(GTK_PIXCOMM(pdialog->citizen_pixmap));
 
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.33
diff -u -r1.33 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       2002/11/30 20:06:49     1.33
+++ client/gui-gtk-2.0/gui_main.c       2002/12/08 04:21:09
@@ -727,6 +727,7 @@
 
   /* citizens for taxrates */
   for (i = 0; i < 10; i++) {
+    enum citizen_type c = i < 5 ? CITIZEN_SCIENTIST : CITIZEN_TAXMAN;
     ebox = gtk_event_box_new();
     gtk_widget_add_events(ebox, GDK_BUTTON_PRESS_MASK);
 
@@ -735,7 +736,7 @@
     g_signal_connect(ebox, "button_press_event",
                      G_CALLBACK(taxrates_callback), GINT_TO_POINTER(i));
 
-    econ_label[i] = gtk_image_new_from_pixmap(get_citizen_pixmap(i < 5 ? 1 : 
2),
+    econ_label[i] = gtk_image_new_from_pixmap(get_citizen_pixmap(c, i),
                                              NULL);
     gtk_container_add(GTK_CONTAINER(ebox), econ_label[i]);
   }
@@ -744,8 +745,9 @@
   bulb_label = gtk_image_new_from_pixmap(sprites.bulb[0]->pixmap, NULL);
   sun_label = gtk_image_new_from_pixmap(sprites.warming[0]->pixmap, NULL);
   flake_label = gtk_image_new_from_pixmap(sprites.cooling[0]->pixmap, NULL);
-  government_label = gtk_image_new_from_pixmap(sprites.citizen[7]->pixmap,
-                                              NULL);
+  government_label
+    = gtk_image_new_from_pixmap(get_citizen_pixmap(CITIZEN_UNHAPPY, 0),
+                               NULL);
 
   for (i = 0; i < 4; i++) {
     GtkWidget *w;
Index: client/gui-gtk-2.0/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/happiness.c,v
retrieving revision 1.4
diff -u -r1.4 happiness.c
--- client/gui-gtk-2.0/happiness.c      2002/11/14 09:14:55     1.4
+++ client/gui-gtk-2.0/happiness.c      2002/12/08 04:21:09
@@ -28,6 +28,7 @@
 #include "gui_main.h"
 #include "gui_stuff.h"
 #include "happiness.h"
+#include "mapview.h"
 #include "tilespec.h"
 
 /* semi-arbitrary number that controls the width of the happiness widget */
@@ -145,7 +146,7 @@
 static GdkPixmap *create_happiness_pixmap(struct city *pcity, int index)
 {
   int i;
-  int citizen_type;
+  enum citizen_type citizen_type;
   int n1 = pcity->ppl_happy[index];
   int n2 = n1 + pcity->ppl_content[index];
   int n3 = n2 + pcity->ppl_unhappy[index];
@@ -162,22 +163,22 @@
 
   for (i = 0; i < num_citizens; i++) {
     if (i < n1)
-      citizen_type = 5 + i % 2;
+      citizen_type = CITIZEN_HAPPY;
     else if (i < n2)
-      citizen_type = 3 + i % 2;
+      citizen_type = CITIZEN_CONTENT;
     else if (i < n3)
-      citizen_type = 7 + i % 2;
+      citizen_type = CITIZEN_UNHAPPY;
     else if (i < n4)
-      citizen_type = 9 + i % 2;
+      citizen_type = CITIZEN_ANGRY;
     else if (i < n5)
-      citizen_type = 0;
+      citizen_type = CITIZEN_ELVIS;
     else if (i < n6)
-      citizen_type = 1;
+      citizen_type = CITIZEN_SCIENTIST;
     else
-      citizen_type = 2;
+      citizen_type = CITIZEN_TAXMAN;
 
     gdk_draw_pixmap(happiness_pixmap, civ_gc,
-                   sprites.citizen[citizen_type]->pixmap,
+                   get_citizen_pixmap(citizen_type, i),
                    0, 0, i * offset, 0, SMALL_TILE_WIDTH,
                    SMALL_TILE_HEIGHT);
   }
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.30
diff -u -r1.30 mapview.c
--- client/gui-gtk-2.0/mapview.c        2002/12/07 09:59:18     1.30
+++ client/gui-gtk-2.0/mapview.c        2002/12/08 04:21:09
@@ -356,15 +356,15 @@
   d=0;
   for(;d<(game.player_ptr->economic.luxury)/10;d++)
     gtk_image_set_from_pixmap(GTK_IMAGE(econ_label[d]),
-       get_citizen_pixmap(0), NULL); /* elvis tile */
+       get_citizen_pixmap(CITIZEN_ELVIS, d), NULL);
  
   
for(;d<(game.player_ptr->economic.science+game.player_ptr->economic.luxury)/10;d++)
     gtk_image_set_from_pixmap(GTK_IMAGE(econ_label[d]),
-       get_citizen_pixmap(1), NULL); /* scientist tile */
+       get_citizen_pixmap(CITIZEN_SCIENTIST, d), NULL);
  
    for(;d<10;d++)
     gtk_image_set_from_pixmap(GTK_IMAGE(econ_label[d]),
-       get_citizen_pixmap(2), NULL); /* taxman tile */
+       get_citizen_pixmap(CITIZEN_TAXMAN, d), NULL);
  
   update_timeout_label();
 }
@@ -444,10 +444,9 @@
 /**************************************************************************
 ...
 **************************************************************************/
-GdkPixmap *get_citizen_pixmap(int frame)
+GdkPixmap *get_citizen_pixmap(enum citizen_type type, int cnum)
 {
-  frame = CLIP(0, frame, NUM_TILES_CITIZEN-1);
-  return sprites.citizen[frame]->pixmap;
+  return get_citizen_sprite(type, cnum)->pixmap;
 }
 
 /**************************************************************************
@@ -470,7 +469,7 @@
 
   if (game.government_count==0) {
     /* not sure what to do here */
-    gov_sprite = sprites.citizen[7]; 
+    gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0);
   } else {
     gov_sprite = get_government(gov)->sprite;
   }
Index: client/gui-gtk-2.0/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.h,v
retrieving revision 1.5
diff -u -r1.5 mapview.h
--- client/gui-gtk-2.0/mapview.h        2002/12/07 09:59:18     1.5
+++ client/gui-gtk-2.0/mapview.h        2002/12/08 04:21:09
@@ -17,6 +17,7 @@
 
 #include "gtkpixcomm.h"
 
+#include "citydlg_common.h"
 #include "mapview_g.h"
 #include "mapview_common.h"
 
@@ -26,7 +27,7 @@
 struct city;
 
 GdkPixmap *get_thumb_pixmap(int onoff);
-GdkPixmap *get_citizen_pixmap(int frame);
+GdkPixmap *get_citizen_pixmap(enum citizen_type type, int cnum);
 
 gboolean overview_canvas_expose(GtkWidget *w, GdkEventExpose *ev, gpointer 
data);
 gboolean map_canvas_expose(GtkWidget *w, GdkEventExpose *ev, gpointer data);
Index: client/gui-mui/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/citydlg.c,v
retrieving revision 1.58
diff -u -r1.58 citydlg.c
--- client/gui-mui/citydlg.c    2002/11/14 09:14:56     1.58
+++ client/gui-mui/citydlg.c    2002/12/08 04:21:09
@@ -1950,14 +1950,14 @@
 
   for (n = 0; n < pcity->ppl_happy[4]; n++)
   {
-    Object *o = MakeSprite(get_citizen_sprite(5 + n % 2));
+    Object *o = MakeSprite(get_citizen_sprite(CITIZEN_HAPPY, n));
     if (o)
       DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
   }
 
   for (n = 0; n < pcity->ppl_content[4]; n++)
   {
-    Object *o = MakeSprite(get_citizen_sprite(3 + n % 2));
+    Object *o = MakeSprite(get_citizen_sprite(CITIZEN_CONTENT, n));
     if (o)
       DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
   }
@@ -1965,20 +1965,20 @@
 
   for (n = 0; n < pcity->ppl_unhappy[4]; n++)
   {
-    Object *o = MakeSprite(get_citizen_sprite(7 + n % 2));
+    Object *o = MakeSprite(get_citizen_sprite(CITIZEN_UNHAPPY, n));
     if (o)
       DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
   }
 
   for (n = 0; n < pcity->ppl_angry[4]; n++) {
-    Object *o = MakeSprite(get_citizen_sprite(9 + n % 2));
+    Object *o = MakeSprite(get_citizen_sprite(CITIZEN_ANGRY, n));
     if (o)
       DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
   }
 
   for (n = 0; n < pcity->ppl_elvis; n++)
   {
-    Object *o = MakeSprite(get_citizen_sprite(0));
+    Object *o = MakeSprite(get_citizen_sprite(CITIZEN_ELVIS, n));
     if (o)
     {
       DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
@@ -1988,7 +1988,7 @@
 
   for (n = 0; n < pcity->ppl_scientist; n++)
   {
-    Object *o = MakeSprite(get_citizen_sprite(1));
+    Object *o = MakeSprite(get_citizen_sprite(CITIZEN_SCIENTIST, n));
     if (o)
     {
       DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
@@ -1998,7 +1998,7 @@
 
   for (n = 0; n < pcity->ppl_taxman; n++)
   {
-    Object *o = MakeSprite(get_citizen_sprite(2));
+    Object *o = MakeSprite(get_citizen_sprite(CITIZEN_TAXMAN, n));
 
     if (o)
     {
@@ -2493,8 +2493,9 @@
     int n1 = pcity->ppl_happy[i];
     int n2 = n1 + pcity->ppl_content[i];
     int n3 = n2 + pcity->ppl_unhappy[i];
-    int n4 = n3 + pcity->ppl_elvis;
-    int n5 = n4 + pcity->ppl_scientist;
+    int n4 = n3 + pcity->ppl_angry[i];
+    int n5 = n4 + pcity->ppl_elvis;
+    int n6 = n5 + pcity->ppl_scientist;
     int num_citizens = pcity->size;
 
     DoMethod(pdialog->happiness_citizen_group[i],MUIM_Group_InitChange);
@@ -2504,19 +2505,22 @@
       int citizen_type;
       Object *obj;
       if (j < n1)
-        citizen_type = 5 + j % 2;
+        citizen_type = CITIZEN_HAPPY;
       else if (j < n2)
-        citizen_type = 3 + j % 2;
+        citizen_type = CITIZEN_CONTENT;
       else if (j < n3)
-        citizen_type = 7 + j % 2;
-      else if (j < n4)
-        citizen_type = 0;
-      else if (j < n5)
-        citizen_type = 1;
-      else
-        citizen_type = 2;
+        citizen_type = CITIZEN_UNHAPPY;
+      else if (j < n4) {
+       citizen_type = CITIZEN_ANGRY;
+      }  else if (j < n5) {
+        citizen_type = CITIZEN_ELVIS;
+      } else if (j < n6) {
+        citizen_type = CITIZEN_SCIENTIST;
+      } else {
+        citizen_type = CITIZEN_TAXMAN;
+      }
 
-      if ((obj = MakeSprite(get_citizen_sprite(citizen_type))))
+      if ((obj = MakeSprite(get_citizen_sprite(citizen_type, j))))
       {
        DoMethod(pdialog->happiness_citizen_group[i], OM_ADDMEMBER, obj);
       }
Index: client/gui-mui/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/gui_main.c,v
retrieving revision 1.67
diff -u -r1.67 gui_main.c
--- client/gui-mui/gui_main.c   2002/11/14 09:22:09     1.67
+++ client/gui-mui/gui_main.c   2002/12/08 04:21:10
@@ -1380,7 +1380,8 @@
       main_bulb_sprite = MakeBorderSprite(sprites.bulb[0]);
       main_sun_sprite = MakeBorderSprite(sprites.warming[0]);
       main_flake_sprite = MakeBorderSprite(sprites.cooling[0]);
-      main_government_sprite = MakeBorderSprite(sprites.citizen[7]);
+      main_government_sprite
+       = MakeBorderSprite(get_citizen_sprite(CITIZEN_UNHAPPY, 0));
       main_timeout_text = TextObject, End;
 
       econ_group = HGroup, GroupSpacing(0), End;
Index: client/gui-mui/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/mapview.c,v
retrieving revision 1.51
diff -u -r1.51 mapview.c
--- client/gui-mui/mapview.c    2002/11/29 10:01:58     1.51
+++ client/gui-mui/mapview.c    2002/12/08 04:21:10
@@ -223,13 +223,16 @@
 
   d = 0;
   for (; d < (game.player_ptr->economic.luxury) / 10; d++)
-    set(main_econ_sprite[d], MUIA_Sprite_Sprite, get_citizen_sprite(0));
+    set(main_econ_sprite[d], MUIA_Sprite_Sprite,
+       get_citizen_sprite(CITIZEN_ELVIS, d));
 
   for (; d < (game.player_ptr->economic.science + 
game.player_ptr->economic.luxury) / 10; d++)
-    set(main_econ_sprite[d], MUIA_Sprite_Sprite, get_citizen_sprite(1));
+    set(main_econ_sprite[d], MUIA_Sprite_Sprite,
+       get_citizen_sprite(CITIZEN_SCIENTIST, d));
 
   for (; d < 10; d++)
-    set(main_econ_sprite[d], MUIA_Sprite_Sprite, get_citizen_sprite(2));
+    set(main_econ_sprite[d], MUIA_Sprite_Sprite,
+       get_citizen_sprite(CITIZEN_TAXMAN, d));
 
   update_timeout_label();
 }
@@ -353,7 +356,7 @@
   if (game.government_count == 0)
   {
     /* not sure what to do here */
-    gov_sprite = sprites.citizen[7];
+    gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0);
   }
   else
   {
Index: client/gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.1
diff -u -r1.1 mapview.c
--- client/gui-sdl/mapview.c    2002/12/02 08:47:03     1.1
+++ client/gui-sdl/mapview.c    2002/12/08 04:21:10
@@ -762,7 +762,7 @@
     struct Sprite *sprite = NULL;
     if (game.government_count == 0) {
       /* not sure what to do here */
-      sprite = sprites.citizen[7];
+      sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0);
     } else {
       sprite = get_government(gov)->sprite;
     }
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.39
diff -u -r1.39 citydlg.c
--- client/gui-win32/citydlg.c  2002/11/14 09:14:59     1.39
+++ client/gui-win32/citydlg.c  2002/12/08 04:21:10
@@ -94,7 +94,7 @@
   int present_y;
   Impr_Type_id sell_id;
   
-  int citizen_type[NUM_CITIZENS_SHOWN];
+  enum citizen_type citizen_type[NUM_CITIZENS_SHOWN];
   int support_unit_ids[NUM_UNITS_SHOWN];
   int present_unit_ids[NUM_UNITS_SHOWN];
   int change_list_ids[B_LAST+1+U_LAST+1];
@@ -614,46 +614,46 @@
 
 
   for(i=0, n=0; n<pcity->ppl_happy[4] && i<NUM_CITIZENS_SHOWN; n++, i++)
-    if(pdialog->citizen_type[i]!=5 && pdialog->citizen_type[i]!=6) {
-      pdialog->citizen_type[i]=5+i%2;
-      draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+    if (pdialog->citizen_type[i] != CITIZEN_HAPPY) {
+      pdialog->citizen_type[i] = CITIZEN_HAPPY;
+      draw_sprite(get_citizen_sprite(CITIZEN_HAPPY, i), citydlgdc,
                  SMALL_TILE_WIDTH*i,0);
     }
   for(n=0; n<pcity->ppl_content[4] && i<NUM_CITIZENS_SHOWN; n++, i++)
-    if(pdialog->citizen_type[i]!=3 && pdialog->citizen_type[i]!=4) {
-      pdialog->citizen_type[i]=3+i%2;
-      draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+    if (pdialog->citizen_type[i] != CITIZEN_CONTENT) {
+      pdialog->citizen_type[i] = CITIZEN_CONTENT;
+      draw_sprite(get_citizen_sprite(CITIZEN_CONTENT, i), citydlgdc,
                  SMALL_TILE_WIDTH*i,0);  
     }
   for(n=0; n<pcity->ppl_unhappy[4] && i<NUM_CITIZENS_SHOWN; n++, i++)
-    if(pdialog->citizen_type[i]!=7 && pdialog->citizen_type[i]!=8) {
-      pdialog->citizen_type[i]=7+i%2;
-      draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+    if (pdialog->citizen_type[i] != CITIZEN_UNHAPPY) {
+      pdialog->citizen_type[i] = CITIZEN_UNHAPPY;
+      draw_sprite(get_citizen_sprite(CITIZEN_UNHAPPY, i), citydlgdc,
                  SMALL_TILE_WIDTH*i,0);
     }
   for (n = 0; n < pcity->ppl_angry[4] && i < NUM_CITIZENS_SHOWN; n++, i++)
-    if (pdialog->citizen_type[i] != 9 && pdialog->citizen_type[i] != 10) {
-      pdialog->citizen_type[i] = 9 + i % 2;
-      draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]), citydlgdc,
+    if (pdialog->citizen_type[i] != CITIZEN_ANGRY) {
+      pdialog->citizen_type[i] = CITIZEN_ANGRY;
+      draw_sprite(get_citizen_sprite(CITIZEN_ANGRY, i), citydlgdc,
                  SMALL_TILE_WIDTH * i, 0);
     }
   for(n=0; n<pcity->ppl_elvis && i<NUM_CITIZENS_SHOWN; n++, i++)
-    if(pdialog->citizen_type[i]!=0) {
-      pdialog->citizen_type[i]=0;
-      draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+    if (pdialog->citizen_type[i] != CITIZEN_ELVIS) {
+      pdialog->citizen_type[i] = CITIZEN_ELVIS;
+      draw_sprite(get_citizen_sprite(CITIZEN_ELVIS, i), citydlgdc,
                  SMALL_TILE_WIDTH*i,0);
       
      }
   for(n=0; n<pcity->ppl_scientist && i<NUM_CITIZENS_SHOWN; n++, i++)
-    if(pdialog->citizen_type[i]!=1) {
-      pdialog->citizen_type[i]=1;
-      draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+    if (pdialog->citizen_type[i] != CITIZEN_SCIENTIST) {
+      pdialog->citizen_type[i] = CITIZEN_SCIENTIST;
+      draw_sprite(get_citizen_sprite(CITIZEN_SCIENTIST, i), citydlgdc,
                  SMALL_TILE_WIDTH*i,0);
     }
   for(n=0; n<pcity->ppl_taxman && i<NUM_CITIZENS_SHOWN; n++, i++)
-    if(pdialog->citizen_type[i]!=2) {
-      pdialog->citizen_type[i]=2;
-      draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+    if (pdialog->citizen_type[i] != CITIZEN_TAXMAN) {
+      pdialog->citizen_type[i] = CITIZEN_TAXMAN;
+      draw_sprite(get_citizen_sprite(CITIZEN_TAXMAN, i), citydlgdc,
                  SMALL_TILE_WIDTH*i,0);
     }
   
Index: client/gui-win32/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/happiness.c,v
retrieving revision 1.3
diff -u -r1.3 happiness.c
--- client/gui-win32/happiness.c        2002/11/14 09:14:59     1.3
+++ client/gui-win32/happiness.c        2002/12/08 04:21:11
@@ -392,7 +392,7 @@
   HBITMAP old;
   RECT rc;
   int i;
-  int citizen_type;
+  enum citizen_type citizen_type;
   int n1 = pcity->ppl_happy[index];
   int n2 = n1 + pcity->ppl_content[index];
   int n3 = n2 + pcity->ppl_unhappy[index];
@@ -412,21 +412,20 @@
   FillRect(hdc,&rc,(HBRUSH)GetClassLong(root_window,GCL_HBRBACKGROUND));
   for (i = 0; i < num_citizens; i++) {
     if (i < n1)
-      citizen_type = 5 + i % 2;
+      citizen_type = CITIZEN_HAPPY;
     else if (i < n2)
-      citizen_type = 3 + i % 2;
+      citizen_type = CITIZEN_CONTENT;
     else if (i < n3)
-      citizen_type = 7 + i % 2;
+      citizen_type = CITIZEN_UNHAPPY;
     else if (i < n4)
-      citizen_type = 9 + i % 2;
+      citizen_type = CITIZEN_ANGRY;
     else if (i < n5)
-      citizen_type = 0;
+      citizen_type = CITIZEN_ELVIS;
     else if (i < n6)
-      citizen_type = 1;
+      citizen_type = CITIZEN_SCIENTIST;
     else
-      citizen_type = 2;
-    draw_sprite(sprites.citizen[citizen_type],hdc,
-               i*offset,0);
+      citizen_type = CITIZEN_TAXMAN;
+    draw_sprite(get_citizen_sprite(citizen_type, i), hdc, i * offset, 0);
   }
   SelectObject(hdc,old);
   DeleteDC(hdc);
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.43
diff -u -r1.43 mapview.c
--- client/gui-win32/mapview.c  2002/12/07 09:59:18     1.43
+++ client/gui-win32/mapview.c  2002/12/08 04:21:11
@@ -430,13 +430,13 @@
   int d;
   d=0;
   for(;d<(game.player_ptr->economic.luxury)/10;d++)
-    draw_sprite(get_citizen_sprite(0), hdc,
+    draw_sprite(get_citizen_sprite(CITIZEN_ELVIS, d), hdc,
                SMALL_TILE_WIDTH*d,taxinfoline_y);/* elvis tile */
   
for(;d<(game.player_ptr->economic.science+game.player_ptr->economic.luxury)/10;d++)
-    draw_sprite(get_citizen_sprite(1), hdc,
+    draw_sprite(get_citizen_sprite(CITIZEN_SCIENTIST, d), hdc,
                SMALL_TILE_WIDTH*d,taxinfoline_y); /* scientist tile */    
   for(;d<10;d++)
-    draw_sprite(get_citizen_sprite(2), hdc,
+    draw_sprite(get_citizen_sprite(CITIZEN_TAXMAN, d), hdc,
                SMALL_TILE_WIDTH*d,taxinfoline_y); /* taxman tile */  
 }
 
@@ -556,7 +556,7 @@
   indicator_sprite[2]=sprites.cooling[flake];
   if (game.government_count==0) {
     /* not sure what to do here */
-    indicator_sprite[3] = sprites.citizen[7];
+    indicator_sprite[3] = get_citizen_sprite(CITIZEN_UNHAPPY, 0);
   } else {
     indicator_sprite[3] = get_government(gov)->sprite;    
   }
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.83
diff -u -r1.83 citydlg.c
--- client/gui-xaw/citydlg.c    2002/11/15 21:24:29     1.83
+++ client/gui-xaw/citydlg.c    2002/12/08 04:21:11
@@ -114,7 +114,7 @@
   
   Impr_Type_id sell_id;
   
-  int *citizen_type;
+  enum citizen_type *citizen_type;
   int support_unit_base;
   int present_unit_base;
   char improvlist_names[B_LAST+1][64];
@@ -544,7 +544,7 @@
                            pdialog->main_form,
                            XtNfromVert, 
                            pdialog->cityname_label,
-                           XtNbitmap, get_citizen_pixmap(2),
+                           XtNbitmap, get_citizen_pixmap(CITIZEN_TAXMAN, 0),
                            NULL);
 
 
@@ -931,7 +931,7 @@
   pdialog->citizen_labels=
     fc_malloc(pdialog->num_citizens_shown * sizeof(Widget));
   pdialog->citizen_type=
-    fc_malloc(pdialog->num_citizens_shown * sizeof(int));
+    fc_malloc(pdialog->num_citizens_shown * sizeof(*pdialog->citizen_type));
 
   pdialog->support_unit_pixcomms=
     fc_malloc(pdialog->num_units_shown * sizeof(Widget));
@@ -948,7 +948,7 @@
                            XtNfromVert, pdialog->cityname_label,
                            XtNfromHoriz, 
                              (XtArgVal)pdialog->citizen_labels[i-1],
-                           XtNbitmap, get_citizen_pixmap(2),
+                           XtNbitmap, get_citizen_pixmap(CITIZEN_TAXMAN, 0),
                            NULL);
 
 
@@ -1048,9 +1048,10 @@
   for(i=0; i<B_LAST+1; i++)
     pdialog->improvlist_names_ptrs[i]=0;
 
-  for(i=0; i<pdialog->num_citizens_shown; i++)
-    pdialog->citizen_type[i]=-1;
-
+  for (i = 0; i < pdialog->num_citizens_shown; i++) {
+    /* Initialize to an invalid value to trigger an assert if it's used */
+    pdialog->citizen_type[i] = T_LAST_CITIZEN;
+  }
   
   XtRealizeWidget(pdialog->shell);
 
@@ -1581,30 +1582,30 @@
   i=0;
 
   for(n=0; n<pcity->ppl_happy[4] && i<pdialog->num_citizens_shown; n++, i++)
-    if(pdialog->citizen_type[i]!=5 &&  pdialog->citizen_type[i]!=6) {
-      pdialog->citizen_type[i]=5+i%2;
+    if (pdialog->citizen_type[i] != CITIZEN_HAPPY) {
+      pdialog->citizen_type[i] = CITIZEN_HAPPY;
       xaw_set_bitmap(pdialog->citizen_labels[i], 
-                    get_citizen_pixmap(pdialog->citizen_type[i]));
+                    get_citizen_pixmap(pdialog->citizen_type[i], i));
       XtSetSensitive(pdialog->citizen_labels[i], FALSE);
       XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
     }
   if(n<pcity->ppl_happy[4]) goto city_dialog_update_citizens_overflow;
 
   for(n=0; n<pcity->ppl_content[4] && i<pdialog->num_citizens_shown; n++, i++)
-    if(pdialog->citizen_type[i]!=3 && pdialog->citizen_type[i]!=4) {
-      pdialog->citizen_type[i]=3+i%2;
+    if (pdialog->citizen_type[i] != CITIZEN_CONTENT) {
+      pdialog->citizen_type[i] = CITIZEN_CONTENT;
       xaw_set_bitmap(pdialog->citizen_labels[i], 
-                    get_citizen_pixmap(pdialog->citizen_type[i]));
+                    get_citizen_pixmap(pdialog->citizen_type[i], i));
       XtSetSensitive(pdialog->citizen_labels[i], FALSE);
       XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
     }
   if(n<pcity->ppl_content[4]) goto city_dialog_update_citizens_overflow;
 
   for(n=0; n<pcity->ppl_unhappy[4] && i<pdialog->num_citizens_shown; n++, i++)
-    if(pdialog->citizen_type[i]!=7 && pdialog->citizen_type[i]!=8) {
-      pdialog->citizen_type[i]=7+i%2;
+    if (pdialog->citizen_type[i] != CITIZEN_UNHAPPY) {
+      pdialog->citizen_type[i] = CITIZEN_UNHAPPY;
       xaw_set_bitmap(pdialog->citizen_labels[i],
-                    get_citizen_pixmap(pdialog->citizen_type[i]));
+                    get_citizen_pixmap(pdialog->citizen_type[i], i));
       XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
       XtSetSensitive(pdialog->citizen_labels[i], FALSE);
     }
@@ -1612,10 +1613,10 @@
 
   for (n = 0; n < pcity->ppl_angry[4] && i < pdialog->num_citizens_shown;
        n++, i++)
-    if (pdialog->citizen_type[i] != 9 && pdialog->citizen_type[i] != 10) {
-      pdialog->citizen_type[i] = 9 + i % 2;
+    if (pdialog->citizen_type[i] != CITIZEN_ANGRY) {
+      pdialog->citizen_type[i] = CITIZEN_ANGRY;
       xaw_set_bitmap(pdialog->citizen_labels[i],
-                    get_citizen_pixmap(pdialog->citizen_type[i]));
+                    get_citizen_pixmap(pdialog->citizen_type[i], i));
       XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
       XtSetSensitive(pdialog->citizen_labels[i], FALSE);
     }
@@ -1623,9 +1624,10 @@
     goto city_dialog_update_citizens_overflow;
 
   for(n=0; n<pcity->ppl_elvis && i<pdialog->num_citizens_shown; n++, i++)
-    if(pdialog->citizen_type[i]!=0) {
-      xaw_set_bitmap(pdialog->citizen_labels[i], get_citizen_pixmap(0));
-      pdialog->citizen_type[i]=0;
+    if (pdialog->citizen_type[i] != CITIZEN_ELVIS) {
+      xaw_set_bitmap(pdialog->citizen_labels[i],
+                    get_citizen_pixmap(CITIZEN_ELVIS, i));
+      pdialog->citizen_type[i] = CITIZEN_ELVIS;
       XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
       XtAddCallback(pdialog->citizen_labels[i], XtNcallback, elvis_callback,
                    (XtPointer)pdialog);
@@ -1634,9 +1636,10 @@
   if(n<pcity->ppl_elvis) goto city_dialog_update_citizens_overflow;
 
   for(n=0; n<pcity->ppl_scientist && i<pdialog->num_citizens_shown; n++, i++)
-    if(pdialog->citizen_type[i]!=1) {
-      xaw_set_bitmap(pdialog->citizen_labels[i], get_citizen_pixmap(1));
-      pdialog->citizen_type[i]=1;
+    if (pdialog->citizen_type[i] != CITIZEN_SCIENTIST) {
+      xaw_set_bitmap(pdialog->citizen_labels[i],
+                    get_citizen_pixmap(CITIZEN_SCIENTIST, i));
+      pdialog->citizen_type[i] = CITIZEN_SCIENTIST;
       XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
       XtAddCallback(pdialog->citizen_labels[i], XtNcallback, 
scientist_callback,
                    (XtPointer)pdialog);
@@ -1645,9 +1648,10 @@
   if(n<pcity->ppl_scientist) goto city_dialog_update_citizens_overflow;
 
   for(n=0; n<pcity->ppl_taxman && i<pdialog->num_citizens_shown; n++, i++)
-    if(pdialog->citizen_type[i]!=2) {
-      xaw_set_bitmap(pdialog->citizen_labels[i], get_citizen_pixmap(2));
-      pdialog->citizen_type[i]=2;
+    if (pdialog->citizen_type[i] != CITIZEN_TAXMAN) {
+      xaw_set_bitmap(pdialog->citizen_labels[i],
+                    get_citizen_pixmap(CITIZEN_TAXMAN, i));
+      pdialog->citizen_type[i] = CITIZEN_TAXMAN;
       XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
       XtAddCallback(pdialog->citizen_labels[i], XtNcallback, taxman_callback,
                    (XtPointer)pdialog);
Index: client/gui-xaw/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.c,v
retrieving revision 1.73
diff -u -r1.73 gui_main.c
--- client/gui-xaw/gui_main.c   2002/11/14 09:15:00     1.73
+++ client/gui-xaw/gui_main.c   2002/12/08 04:21:11
@@ -411,8 +411,9 @@
 
   /* Do this outside setup_widgets() so after tiles are loaded */
   for(i=0;i<10;i++)  {
+    enum citizen_type c = i < 5 ? CITIZEN_SCIENTIST : CITIZEN_TAXMAN;
     XtVaSetValues(econ_label[i], XtNbitmap,
-                 get_citizen_pixmap(i<5?1:2), NULL);
+                 get_citizen_pixmap(c, i), NULL);
     XtAddCallback(econ_label[i], XtNcallback, taxrates_callback,
                  INT_TO_XTPOINTER(i));
   }
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.112
diff -u -r1.112 mapview.c
--- client/gui-xaw/mapview.c    2002/12/06 22:25:12     1.112
+++ client/gui-xaw/mapview.c    2002/12/08 04:21:12
@@ -234,13 +234,13 @@
 
   d=0;
   for(;d<(game.player_ptr->economic.luxury)/10;d++)
-    xaw_set_bitmap(econ_label[d], get_citizen_pixmap(0) ); /* elvis tile */
+    xaw_set_bitmap(econ_label[d], get_citizen_pixmap(CITIZEN_ELVIS, d));
  
   
for(;d<(game.player_ptr->economic.science+game.player_ptr->economic.luxury)/10;d++)
-    xaw_set_bitmap(econ_label[d], get_citizen_pixmap(1) ); /* scientist tile */
+    xaw_set_bitmap(econ_label[d], get_citizen_pixmap(CITIZEN_SCIENTIST, d));
  
    for(;d<10;d++)
-    xaw_set_bitmap(econ_label[d], get_citizen_pixmap(2) ); /* taxman tile */
+    xaw_set_bitmap(econ_label[d], get_citizen_pixmap(CITIZEN_TAXMAN, d));
  
   update_timeout_label();
 }
@@ -311,10 +311,9 @@
 /**************************************************************************
 ...
 **************************************************************************/
-Pixmap get_citizen_pixmap(int frame)
+Pixmap get_citizen_pixmap(enum citizen_type type, int cnum)
 {
-  frame = CLIP(0, frame, NUM_TILES_CITIZEN-1);
-  return sprites.citizen[frame]->pixmap;
+  return get_citizen_sprite(type, cnum)->pixmap;
 }
 
 
@@ -335,7 +334,7 @@
 
   if (game.government_count==0) {
     /* not sure what to do here */
-    gov_sprite = sprites.citizen[7]; 
+    gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0);
   } else {
     gov_sprite = get_government(gov)->sprite;
   }
Index: client/gui-xaw/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.h,v
retrieving revision 1.11
diff -u -r1.11 mapview.h
--- client/gui-xaw/mapview.h    2002/11/15 09:24:52     1.11
+++ client/gui-xaw/mapview.h    2002/12/08 04:21:12
@@ -17,13 +17,15 @@
 
 #include "mapview_g.h"
 
+#include "citydlg_common.h"
+
 #include "graphics.h"
 
 struct unit;
 struct city;
 
 Pixmap get_thumb_pixmap(int onoff);
-Pixmap get_citizen_pixmap(int frame);
+Pixmap get_citizen_pixmap(enum citizen_type type, int cnum);
 
 void put_unit_pixmap(struct unit *punit, Pixmap pm,
                     int canvas_x, int canvas_y);

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