Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2004:
[Freeciv-Dev] (PR#9317) specialist graphics
Home

[Freeciv-Dev] (PR#9317) specialist graphics

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9317) specialist graphics
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 8 Jul 2004 11:06:08 -0700
Reply-to: rt@xxxxxxxxxxx

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

Currently the types of specialist are hard-coded in the client's citizen 
enumeration.  This makes it impossible to change the number or ordering 
of the specialists.

This patch changes that.  Now the citizen enumeration has a 
CITIZEN_SPECIALIST type along with another field that holds the type of 
the specialist.  A second array of sprites holds the specialist 
graphics.  These graphics are not loaded until the ruleset is sent to 
the client.

A number of changes are needed just because of the enum -> struct 
change.  This makes the patch fairly large.  A lot of small GUI changes 
are needed.

It is tested under gui-gtk and gui-gtk-2.0.  All other GUIs are also 
updated.  However gui-xaw won't work without more adjustments because it 
hard-codes the specialists internally.  gui-win32 should work but I 
haven't compiled it.

jason

? diff
? data/tridenthex
? data/tridenthex.tilespec
Index: client/citydlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.c,v
retrieving revision 1.39
diff -u -r1.39 citydlg_common.c
--- client/citydlg_common.c     25 Jun 2004 23:35:55 -0000      1.39
+++ client/citydlg_common.c     8 Jul 2004 18:02:35 -0000
@@ -387,32 +387,29 @@
   citizens (use MAX_CITY_SIZE to be on the safe side).
 **************************************************************************/
 void get_city_citizen_types(struct city *pcity, int index,
-                           enum citizen_type *citizens)
+                           struct citizen_type *citizens)
 {
-  int i = 0, n;
+  int i = 0, n, sp;
   assert(index >= 0 && index < 5);
 
   for (n = 0; n < pcity->ppl_happy[index]; n++, i++) {
-    citizens[i] = CITIZEN_HAPPY;
+    citizens[i].type = CITIZEN_HAPPY;
   }
   for (n = 0; n < pcity->ppl_content[index]; n++, i++) {
-    citizens[i] = CITIZEN_CONTENT;
+    citizens[i].type = CITIZEN_CONTENT;
   }
   for (n = 0; n < pcity->ppl_unhappy[index]; n++, i++) {
-    citizens[i] = CITIZEN_UNHAPPY;
+    citizens[i].type = CITIZEN_UNHAPPY;
   }
   for (n = 0; n < pcity->ppl_angry[index]; n++, i++) {
-    citizens[i] = CITIZEN_ANGRY;
+    citizens[i].type = CITIZEN_ANGRY;
   }
 
-  for (n = 0; n < pcity->specialists[SP_ELVIS]; n++, i++) {
-    citizens[i] = CITIZEN_ELVIS;
-  }
-  for (n = 0; n < pcity->specialists[SP_SCIENTIST]; n++, i++) {
-    citizens[i] = CITIZEN_SCIENTIST;
-  }
-  for (n = 0; n < pcity->specialists[SP_TAXMAN]; n++, i++) {
-    citizens[i] = CITIZEN_TAXMAN;
+  for (sp = 0; sp < SP_COUNT; sp++) {
+    for (n = 0; n < pcity->specialists[sp]; n++, i++) {
+      citizens[i].type = CITIZEN_SPECIALIST;
+      citizens[i].spec_type = sp;
+    }
   }
 
   assert(i == pcity->size);
@@ -423,7 +420,7 @@
 **************************************************************************/
 void city_rotate_specialist(struct city *pcity, int citizen_index)
 {
-  enum citizen_type citizens[MAX_CITY_SIZE];
+  struct citizen_type citizens[MAX_CITY_SIZE];
   enum specialist_type from, to;
 
   if (citizen_index < 0 || citizen_index >= pcity->size) {
@@ -432,19 +429,10 @@
 
   get_city_citizen_types(pcity, 4, citizens);
 
-  switch (citizens[citizen_index]) {
-  case CITIZEN_ELVIS:
-    from = SP_ELVIS;
-    break;
-  case CITIZEN_SCIENTIST:
-    from = SP_SCIENTIST;
-    break;
-  case CITIZEN_TAXMAN:
-    from = SP_TAXMAN;
-    break;
-  default:
+  if (citizens[citizen_index].type != CITIZEN_SPECIALIST) {
     return;
   }
+  from = citizens[citizen_index].spec_type;
 
   /* Loop through all specialists in order until we find a usable one
    * (or run out of choices). */
Index: client/citydlg_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.h,v
retrieving revision 1.21
diff -u -r1.21 citydlg_common.h
--- client/citydlg_common.h     16 Jun 2004 22:45:39 -0000      1.21
+++ client/citydlg_common.h     8 Jul 2004 18:02:35 -0000
@@ -23,15 +23,16 @@
 struct city;
 struct canvas;
 
-enum citizen_type {
-  CITIZEN_ELVIS,
-  CITIZEN_SCIENTIST,
-  CITIZEN_TAXMAN,
-  CITIZEN_CONTENT,
-  CITIZEN_HAPPY,
-  CITIZEN_UNHAPPY,
-  CITIZEN_ANGRY,
-  CITIZEN_LAST
+struct citizen_type {
+  enum {
+    CITIZEN_SPECIALIST,
+    CITIZEN_CONTENT,
+    CITIZEN_HAPPY,
+    CITIZEN_UNHAPPY,
+    CITIZEN_ANGRY,
+    CITIZEN_LAST
+  } type;
+  enum specialist_type spec_type;
 };
 
 int get_citydlg_canvas_width(void);
@@ -54,7 +55,7 @@
                                    bool is_unit, struct city *pcity);
 
 void get_city_citizen_types(struct city *pcity, int index,
-                           enum citizen_type *citizens);
+                           struct citizen_type *citizens);
 void city_rotate_specialist(struct city *pcity, int citizen_index);
 
 void activate_all_units(int map_x, int map_y);
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.383
diff -u -r1.383 packhand.c
--- client/packhand.c   7 Jul 2004 16:02:50 -0000       1.383
+++ client/packhand.c   8 Jul 2004 18:02:36 -0000
@@ -2708,6 +2708,8 @@
     game.rgame.specialists[i].min_size = packet->specialist_min_size[i];
     game.rgame.specialists[i].bonus = packet->specialist_bonus[i];
   }
+  tilespec_setup_specialist_types();
+
   game.rgame.changable_tax = packet->changable_tax;
   game.rgame.forced_science = packet->forced_science;
   game.rgame.forced_luxury = packet->forced_luxury;
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.181
diff -u -r1.181 tilespec.c
--- client/tilespec.c   29 Jun 2004 17:05:07 -0000      1.181
+++ client/tilespec.c   8 Jul 2004 18:02:37 -0000
@@ -970,17 +970,13 @@
 /**********************************************************************
   Returns a text name for the citizen, as used in the tileset.
 ***********************************************************************/
-static const char *get_citizen_name(enum citizen_type citizen)
+static const char *get_citizen_name(struct citizen_type citizen)
 {
   /* These strings are used in reading the tileset.  Do not
    * translate. */
-  switch (citizen) {
-  case CITIZEN_ELVIS:
-    return "entertainer";
-  case CITIZEN_SCIENTIST:
-    return "scientist";
-  case CITIZEN_TAXMAN:
-    return "tax_collector";
+  switch (citizen.type) {
+  case CITIZEN_SPECIALIST:
+    return game.rgame.specialists[citizen.spec_type].name;
   case CITIZEN_HAPPY:
     return "happy";
   case CITIZEN_CONTENT:
@@ -989,9 +985,10 @@
     return "unhappy";
   case CITIZEN_ANGRY:
     return "angry";
-  default:
-    die("unknown citizen type %d", (int) citizen);
+  case CITIZEN_LAST:
+    break;
   }
+  die("unknown citizen type %d", (int) citizen.type);
   return NULL;
 }
 
@@ -1053,6 +1050,66 @@
                                            "sprite", #field); \
     } while (FALSE)
 
+/****************************************************************************
+  Setup the graphics for specialist types.
+****************************************************************************/
+void tilespec_setup_specialist_types(void)
+{
+  int i, j;
+  char buffer[512];
+
+  /* Load the specialist sprite graphics. */
+  for (i = 0; i < SP_COUNT; i++) {
+    struct citizen_type c = {.type = CITIZEN_SPECIALIST, .spec_type = i};
+    const char *name = get_citizen_name(c);
+
+    for (j = 0; j < NUM_TILES_CITIZEN; j++) {
+      my_snprintf(buffer, sizeof(buffer), "specialist.%s_%d", name, j);
+      sprites.specialist[i].sprite[j] = load_sprite(buffer);
+      if (!sprites.specialist[i].sprite[j]) {
+       break;
+      }
+    }
+    sprites.specialist[i].count = j;
+    if (j == 0) {
+      freelog(LOG_NORMAL, _("No graphics for specialist %s."), name);
+      exit(EXIT_FAILURE);
+    }
+  }
+}
+
+/****************************************************************************
+  Setup the graphics for (non-specialist) citizen types.
+****************************************************************************/
+static void tilespec_setup_citizen_types(void)
+{
+  int i, j;
+  char buffer[512];
+
+  /* Load the citizen sprite graphics. */
+  for (i = 0; i < NUM_TILES_CITIZEN; i++) {
+    struct citizen_type c = {.type = i};
+    const char *name = get_citizen_name(c);
+
+    if (i == CITIZEN_SPECIALIST) {
+      continue; /* Handled separately. */
+    }
+
+    for (j = 0; j < NUM_TILES_CITIZEN; j++) {
+      my_snprintf(buffer, sizeof(buffer), "citizen.%s_%d", name, j);
+      sprites.citizen[i].sprite[j] = load_sprite(buffer);
+      if (!sprites.citizen[i].sprite[j]) {
+       break;
+      }
+    }
+    sprites.citizen[i].count = j;
+    if (j == 0) {
+      freelog(LOG_NORMAL, _("No graphics for citizen %s."), name);
+      exit(EXIT_FAILURE);
+    }
+  }
+}
+
 /**********************************************************************
   Initialize 'sprites' structure based on hardwired tags which
   freeciv always requires. 
@@ -1061,7 +1118,7 @@
 {
   char buffer[512];
   const char dir_char[] = "nsew";
-  int i, j;
+  int i;
   
   assert(sprite_hash != NULL);
 
@@ -1087,31 +1144,7 @@
   SET_SPRITE(tax_science, "s.tax_science");
   SET_SPRITE(tax_gold, "s.tax_gold");
 
-  /* 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] = load_sprite(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] = load_sprite(buffer);
-      if (!sprites.citizen[i].sprite[j]) {
-       break;
-      }
-    }
-    sprites.citizen[i].count = j;
-    assert(j > 0);
-  }
+  tilespec_setup_citizen_types();
 
   SET_SPRITE(spaceship.solar_panels, "spaceship.solar_panels");
   SET_SPRITE(spaceship.life_support, "spaceship.life_support");
@@ -2915,12 +2948,19 @@
   value indicates there is no city; i.e., the sprite is just being
   used as a picture).
 **************************************************************************/
-struct Sprite *get_citizen_sprite(enum citizen_type type, int citizen_index,
-                                 struct city *pcity)
+struct Sprite *get_citizen_sprite(struct citizen_type type,
+                                 int citizen_index,
+                                 const struct city *pcity)
 {
-  assert(type >= 0 && type < NUM_TILES_CITIZEN);
-  citizen_index %= sprites.citizen[type].count;
-  return sprites.citizen[type].sprite[citizen_index];
+  struct citizen_graphic *graphic;
+
+  if (type.type == CITIZEN_SPECIALIST) {
+    graphic = &sprites.specialist[type.spec_type];
+  } else {
+    graphic = &sprites.citizen[type.type];
+  }
+
+  return graphic->sprite[citizen_index % graphic->count];
 }
 
 /**************************************************************************
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.74
diff -u -r1.74 tilespec.h
--- client/tilespec.h   29 Jun 2004 17:05:07 -0000      1.74
+++ client/tilespec.h   8 Jul 2004 18:02:37 -0000
@@ -54,6 +54,7 @@
 void tilespec_reread(const char *tileset_name);
 void tilespec_reread_callback(struct client_option *option);
 
+void tilespec_setup_specialist_types(void);
 void tilespec_setup_unit_type(int id);
 void tilespec_setup_impr_type(int id);
 void tilespec_setup_tech_type(int id);
@@ -173,12 +174,12 @@
     *black_tile,      /* only used for isometric view */
     *dither_tile;     /* only used for isometric view */
 
-  struct {
+  struct citizen_graphic {
     /* 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];
+  } citizen[NUM_TILES_CITIZEN], specialist[SP_COUNT];
   struct {
     struct Sprite
       *solar_panels,
@@ -280,8 +281,9 @@
 
 extern struct named_sprites sprites;
 
-struct Sprite *get_citizen_sprite(enum citizen_type type, int citizen_index,
-                                 struct city *pcity);
+struct Sprite *get_citizen_sprite(struct citizen_type type,
+                                 int citizen_index,
+                                 const struct city *pcity);
 
 /* full pathnames: */
 extern char *main_intro_filename;
Index: client/gui-gtk/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v
retrieving revision 1.183
diff -u -r1.183 citydlg.c
--- client/gui-gtk/citydlg.c    5 May 2004 20:39:15 -0000       1.183
+++ client/gui-gtk/citydlg.c    8 Jul 2004 18:02:37 -0000
@@ -1643,7 +1643,7 @@
   int i;
   struct city *pcity = pdialog->pcity;
   int width;
-  enum citizen_type citizens[MAX_CITY_SIZE];
+  struct citizen_type citizens[MAX_CITY_SIZE];
 
   /* If there is not enough space we stack the icons. We draw from left to */
   /* right. width is how far we go to the right for each drawn pixmap. The */
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.149
diff -u -r1.149 gui_main.c
--- client/gui-gtk/gui_main.c   6 Jun 2004 06:00:08 -0000       1.149
+++ client/gui-gtk/gui_main.c   8 Jul 2004 18:02:38 -0000
@@ -638,9 +638,14 @@
   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(get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL)->pixmap,
-                    NULL);
+  {
+    /* HACK: the UNHAPPY citizen is used for the government
+     * when we don't know any better. */
+    struct citizen_type c = {.type = CITIZEN_UNHAPPY};
+    struct Sprite *sprite = get_citizen_sprite(c, 0, NULL);
+
+    government_label = gtk_pixmap_new(sprite->pixmap, 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.15
diff -u -r1.15 happiness.c
--- client/gui-gtk/happiness.c  8 May 2004 04:47:56 -0000       1.15
+++ client/gui-gtk/happiness.c  8 Jul 2004 18:02:38 -0000
@@ -155,7 +155,7 @@
 static GdkPixmap *create_happiness_pixmap(struct city *pcity, int index)
 {
   int i;
-  enum citizen_type citizens[MAX_CITY_SIZE];
+  struct citizen_type citizens[MAX_CITY_SIZE];
   int num_citizens = pcity->size;
   int pix_width = HAPPINESS_PIX_WIDTH * SMALL_TILE_WIDTH;
   int offset = MIN(SMALL_TILE_WIDTH, pix_width / num_citizens);
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.224
diff -u -r1.224 mapview.c
--- client/gui-gtk/mapview.c    23 Jun 2004 14:50:43 -0000      1.224
+++ client/gui-gtk/mapview.c    8 Jul 2004 18:02:38 -0000
@@ -253,8 +253,11 @@
   gtk_pixmap_set(GTK_PIXMAP(flake_label), sprites.cooling[flake]->pixmap, 
NULL);
 
   if (game.government_count==0) {
-    /* not sure what to do here */
-    gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL); 
+    /* HACK: the UNHAPPY citizen is used for the government
+     * when we don't know any better. */
+    struct citizen_type c = {.type = CITIZEN_UNHAPPY};
+
+    gov_sprite = get_citizen_sprite(c, 0, NULL);
   } else {
     gov_sprite = get_government(gov)->sprite;
   }
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.88
diff -u -r1.88 citydlg.c
--- client/gui-gtk-2.0/citydlg.c        24 May 2004 13:00:51 -0000      1.88
+++ client/gui-gtk-2.0/citydlg.c        8 Jul 2004 18:02:39 -0000
@@ -1262,7 +1262,7 @@
 {
   int i, width;
   struct city *pcity = pdialog->pcity;
-  enum citizen_type citizens[MAX_CITY_SIZE];
+  struct citizen_type citizens[MAX_CITY_SIZE];
 
   /* If there is not enough space we stack the icons. We draw from left to */
   /* right. width is how far we go to the right for each drawn pixmap. The */
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.73
diff -u -r1.73 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       6 Jun 2004 06:00:08 -0000       1.73
+++ client/gui-gtk-2.0/gui_main.c       8 Jul 2004 18:02:39 -0000
@@ -820,7 +820,13 @@
   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);
-  sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
+  {
+    /* HACK: the UNHAPPY citizen is used for the government
+     * when we don't know any better. */
+    struct citizen_type c = {.type = CITIZEN_UNHAPPY};
+
+    sprite = get_citizen_sprite(c, 0, NULL);
+  }
   government_label = gtk_image_new_from_pixmap(sprite->pixmap, sprite->mask);
 
   for (i = 0; i < 4; i++) {
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.12
diff -u -r1.12 happiness.c
--- client/gui-gtk-2.0/happiness.c      5 May 2004 20:39:15 -0000       1.12
+++ client/gui-gtk-2.0/happiness.c      8 Jul 2004 18:02:39 -0000
@@ -153,7 +153,7 @@
 static void refresh_pixcomm(GtkPixcomm *dst, struct city *pcity, int index)
 {
   int i;
-  enum citizen_type citizens[MAX_CITY_SIZE];
+  struct citizen_type citizens[MAX_CITY_SIZE];
   int num_citizens = pcity->size;
   int offset = MIN(SMALL_TILE_WIDTH, PIXCOMM_WIDTH / num_citizens);
 
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.130
diff -u -r1.130 mapview.c
--- client/gui-gtk-2.0/mapview.c        23 Jun 2004 14:50:43 -0000      1.130
+++ client/gui-gtk-2.0/mapview.c        8 Jul 2004 18:02:39 -0000
@@ -246,8 +246,11 @@
                            sprites.cooling[flake]->pixmap, NULL);
 
   if (game.government_count==0) {
-    /* not sure what to do here */
-    gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
+    /* HACK: the UNHAPPY citizen is used for the government
+     * when we don't know any better. */
+    struct citizen_type c = {.type = CITIZEN_UNHAPPY};
+
+    gov_sprite = get_citizen_sprite(c, 0, NULL);
   } else {
     gov_sprite = get_government(gov)->sprite;
   }
Index: client/gui-mui/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/citydlg.c,v
retrieving revision 1.75
diff -u -r1.75 citydlg.c
--- client/gui-mui/citydlg.c    5 May 2004 20:39:15 -0000       1.75
+++ client/gui-mui/citydlg.c    8 Jul 2004 18:02:40 -0000
@@ -1861,7 +1861,7 @@
 {
   int i;
   struct city *pcity = pdialog->pcity;
-  enum citizen_type citizens[MAX_CITY_SIZE];
+  struct citizen_type citizens[MAX_CITY_SIZE];
 
   DoMethod(pdialog->citizen_group, MUIM_Group_InitChange);
   if (pdialog->citizen2_group)
@@ -2379,7 +2379,7 @@
   {
     int j;
     int num_citizens = pcity->size;
-    enum citizen_type citizens[MAX_CITY_SIZE];
+    struct citizen_type citizens[MAX_CITY_SIZE];
 
     DoMethod(pdialog->happiness_citizen_group[i],MUIM_Group_InitChange);
     DisposeAllChilds(pdialog->happiness_citizen_group[i]);
Index: client/gui-mui/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/gui_main.c,v
retrieving revision 1.82
diff -u -r1.82 gui_main.c
--- client/gui-mui/gui_main.c   1 Apr 2004 23:46:25 -0000       1.82
+++ client/gui-mui/gui_main.c   8 Jul 2004 18:02:40 -0000
@@ -1387,8 +1387,14 @@
       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(get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL));
+      {
+       /* HACK: the UNHAPPY citizen is used for the government
+        * when we don't know any better. */
+       struct citizen_type c = {.type = CITIZEN_UNHAPPY};
+       struct Sprite *sprite = get_citizen_sprite(c, 0, NULL);
+
+       main_government_sprite = MakeBorderSprite(sprite);
+      }
       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.67
diff -u -r1.67 mapview.c
--- client/gui-mui/mapview.c    6 Jun 2004 06:00:09 -0000       1.67
+++ client/gui-mui/mapview.c    8 Jul 2004 18:02:40 -0000
@@ -333,7 +333,11 @@
   if (game.government_count == 0)
   {
     /* not sure what to do here */
-    gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
+    /* HACK: the UNHAPPY citizen is used for the government
+     * when we don't know any better. */
+    struct citizen_type c = {.type = CITIZEN_UNHAPPY};
+
+    gov_sprite = get_citizen_sprite(c, 0, NULL);
   }
   else
   {
Index: client/gui-sdl/gui_tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/gui_tilespec.c,v
retrieving revision 1.18
diff -u -r1.18 gui_tilespec.c
--- client/gui-sdl/gui_tilespec.c       5 Jan 2004 00:18:30 -0000       1.18
+++ client/gui-sdl/gui_tilespec.c       8 Jul 2004 18:02:40 -0000
@@ -80,7 +80,7 @@
 /**********************************************************************
   Returns a text name for the citizen, as used in the tileset.
 ***********************************************************************/
-static const char *get_citizen_name(enum citizen_type citizen)
+static const char *get_citizen_name(struct citizen_type citizen)
 {
   /* These strings are used in reading the tileset.  Do not
    * translate. */
@@ -778,7 +778,8 @@
   Return a surface for the given citizen.  The citizen's type is given,
   as well as their index (in the range [0..pcity->size)).
 **************************************************************************/
-SDL_Surface * get_citizen_surface(enum citizen_type type, int citizen_index)
+SDL_Surface * get_citizen_surface(struct citizen_type type,
+                                 int citizen_index)
 {
   assert(type >= 0 && type < NUM_TILES_CITIZEN);
   citizen_index %= sprites.citizen[type].count;
Index: client/gui-sdl/gui_tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/gui_tilespec.h,v
retrieving revision 1.11
diff -u -r1.11 gui_tilespec.h
--- client/gui-sdl/gui_tilespec.h       5 Jan 2004 00:18:30 -0000       1.11
+++ client/gui-sdl/gui_tilespec.h       8 Jul 2004 18:02:41 -0000
@@ -22,7 +22,7 @@
 #ifndef FC__GUI_TILESPEC_H
 #define FC__GUI_TILESPEC_H
 
-#include "citydlg_common.h"    /* enum citizen_type */
+#include "citydlg_common.h"    /* struct citizen_type */
   
 struct Theme {
        SDL_Surface *Button;
@@ -205,7 +205,8 @@
 void tilespec_setup_city_icons(void);
 void tilespec_free_city_icons(void);
 void reload_citizens_icons(int style);
-SDL_Surface * get_citizen_surface(enum citizen_type type, int citizen_index);
+SDL_Surface * get_citizen_surface(struct citizen_type type,
+                                 int citizen_index);
 void unload_unused_graphics(void);
 
 #endif  /* FC__GUI_TILESPEC_H */
Index: client/gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.69
diff -u -r1.69 mapview.c
--- client/gui-sdl/mapview.c    17 May 2004 07:16:43 -0000      1.69
+++ client/gui-sdl/mapview.c    8 Jul 2004 18:02:42 -0000
@@ -418,8 +418,11 @@
   if (SDL_Client_Flags & CF_REVOLUTION) {
     struct Sprite *sprite = NULL;
     if (game.government_count == 0) {
-      /* not sure what to do here */
-      sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
+      /* HACK: the UNHAPPY citizen is used for the government
+       * when we don't know any better. */
+      struct citizen_type c = {.type = CITIZEN_UNHAPPY};
+
+      sprite = get_citizen_sprite(c, 0, NULL);
     } 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.77
diff -u -r1.77 citydlg.c
--- client/gui-win32/citydlg.c  23 Jun 2004 04:33:13 -0000      1.77
+++ client/gui-win32/citydlg.c  8 Jul 2004 18:02:42 -0000
@@ -97,7 +97,7 @@
   int present_y;
   Impr_Type_id sell_id;
   
-  enum citizen_type citizen_type[NUM_CITIZENS_SHOWN];
+  struct 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];
@@ -531,7 +531,7 @@
   struct city *pcity=pdialog->pcity;
   RECT rc;
   HBITMAP oldbit;
-  enum citizen_type citizens[MAX_CITY_SIZE];
+  struct citizen_type citizens[MAX_CITY_SIZE];
   oldbit=SelectObject(citydlgdc,pdialog->citizen_bmp);
 
   get_city_citizen_types(pcity, 4, citizens);
Index: client/gui-win32/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/happiness.c,v
retrieving revision 1.5
diff -u -r1.5 happiness.c
--- client/gui-win32/happiness.c        15 Dec 2002 22:43:47 -0000      1.5
+++ client/gui-win32/happiness.c        8 Jul 2004 18:02:42 -0000
@@ -392,7 +392,7 @@
   HBITMAP old;
   RECT rc;
   int i;
-  enum citizen_type citizens[MAX_CITY_SIZE];
+  struct citizen_type citizens[MAX_CITY_SIZE];
   int num_citizens = pcity->size;
   int pix_width = HAPPINESS_PIX_WIDTH * SMALL_TILE_WIDTH;
   int offset = MIN(SMALL_TILE_WIDTH, pix_width / num_citizens);
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.122
diff -u -r1.122 mapview.c
--- client/gui-win32/mapview.c  23 Jun 2004 14:50:43 -0000      1.122
+++ client/gui-win32/mapview.c  8 Jul 2004 18:02:42 -0000
@@ -324,8 +324,11 @@
   indicator_sprite[1]=sprites.warming[sol];
   indicator_sprite[2]=sprites.cooling[flake];
   if (game.government_count==0) {
-    /* not sure what to do here */
-    indicator_sprite[3] = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
+    /* HACK: the UNHAPPY citizen is used for the government
+     * when we don't know any better. */
+    struct citizen_type c = {.type = CITIZEN_UNHAPPY};
+
+    gov_sprite = get_citizen_sprite(c, 0, NULL);
   } 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.115
diff -u -r1.115 citydlg.c
--- client/gui-xaw/citydlg.c    5 May 2004 20:39:16 -0000       1.115
+++ client/gui-xaw/citydlg.c    8 Jul 2004 18:02:44 -0000
@@ -1526,7 +1526,7 @@
 {
   int i;
   struct city *pcity=pdialog->pcity;
-  enum citizen_type citizens[MAX_CITY_SIZE];
+  struct citizen_type citizens[MAX_CITY_SIZE];
 
   get_city_citizen_types(pcity, 4, citizens);
 
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.176
diff -u -r1.176 mapview.c
--- client/gui-xaw/mapview.c    23 Jun 2004 14:50:43 -0000      1.176
+++ client/gui-xaw/mapview.c    8 Jul 2004 18:02:44 -0000
@@ -253,7 +253,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-Pixmap get_citizen_pixmap(enum citizen_type type, int cnum,
+Pixmap get_citizen_pixmap(struct citizen_type type, int cnum,
                          struct city *pcity)
 {
   return get_citizen_sprite(type, cnum, pcity)->pixmap;
@@ -276,8 +276,11 @@
   xaw_set_bitmap(flake_label, sprites.cooling[flake]->pixmap);
 
   if (game.government_count==0) {
-    /* not sure what to do here */
-    gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
+    /* HACK: the UNHAPPY citizen is used for the government
+     * when we don't know any better. */
+    struct citizen_type c = {.type = CITIZEN_UNHAPPY};
+
+    gov_sprite = get_citizen_sprite(c, 0, NULL);
   } 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.23
diff -u -r1.23 mapview.h
--- client/gui-xaw/mapview.h    15 Mar 2004 05:35:28 -0000      1.23
+++ client/gui-xaw/mapview.h    8 Jul 2004 18:02:44 -0000
@@ -25,7 +25,7 @@
 struct city;
 
 Pixmap get_thumb_pixmap(int onoff);
-Pixmap get_citizen_pixmap(enum citizen_type type, int cnum,
+Pixmap get_citizen_pixmap(struct citizen_type type, int cnum,
                          struct city *pcity);
 
 void put_unit_pixmap_city_overlays(struct unit *punit, Pixmap pm);
Index: data/misc/small.spec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/misc/small.spec,v
retrieving revision 1.6
diff -u -r1.6 small.spec
--- data/misc/small.spec        11 Jun 2004 16:59:18 -0000      1.6
+++ data/misc/small.spec        8 Jul 2004 18:02:44 -0000
@@ -76,9 +76,10 @@
 
 ; Citizen icons:
 
-  0, 23, "citizen.entertainer"
-  0, 24, "citizen.scientist"
-  0, 25, "citizen.tax_collector"
+  0, 23, "specialist.elvis_0"
+  0, 24, "specialist.scientist_0"
+  0, 25, "specialist.taxman_0"
+
   0, 26, "citizen.content_0"
   0, 27, "citizen.content_1"
   0, 28, "citizen.happy_0"
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.176
diff -u -r1.176 ruleset.c
--- server/ruleset.c    7 Jul 2004 16:02:50 -0000       1.176
+++ server/ruleset.c    8 Jul 2004 18:02:45 -0000
@@ -3116,6 +3116,7 @@
   struct packet_ruleset_game misc_p;
 
   for (i = 0; i < SP_COUNT; i++) {
+    sz_strlcpy(misc_p.specialist_name[i], game.rgame.specialists[i].name);
     misc_p.specialist_min_size[i] = game.rgame.specialists[i].min_size;
     misc_p.specialist_bonus[i] = game.rgame.specialists[i].bonus;
   }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9317) specialist graphics, Jason Short <=