Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12688) move tech sprites into the tileset
Home

[Freeciv-Dev] (PR#12688) move tech sprites into the tileset

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12688) move tech sprites into the tileset
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 29 Mar 2005 00:03:14 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12688 >

This patch moves the tech sprite pointer out of the tech structure and 
into the tileset.  This should work better when loading/freeing tilesets 
or working with more than one tileset at a time.

I started out with the tech sprite because it seems easiest.  I'd like 
to move all sprites into the tileset (struct sprite shouldn't be 
referenced in the common code).  I also added a get_tech_sprite() 
accessor function even though there are no users of this sprite yet (!).

-jason

Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.280
diff -u -r1.280 tilespec.c
--- client/tilespec.c   28 Mar 2005 23:25:37 -0000      1.280
+++ client/tilespec.c   29 Mar 2005 08:01:27 -0000
@@ -128,6 +128,8 @@
       *unworked_tile;
   } mask;
 
+  struct sprite *tech[A_LAST];
+
   struct citizen_graphic {
     /* Each citizen type has up to MAX_NUM_CITIZEN_SPRITES different
      * sprites, as defined by the tileset. */
@@ -2246,7 +2248,7 @@
 void tileset_setup_tech_type(struct tileset *t, int id)
 {
   if (tech_exists(id)) {
-    advances[id].sprite
+    t->sprites.tech[id]
       = lookup_sprite_tag_alt(t, advances[id].graphic_str,
                              advances[id].graphic_alt,
                              FALSE, "tech_type",
@@ -2254,7 +2256,7 @@
 
     /* should maybe do something if NULL, eg generic default? */
   } else {
-    advances[id].sprite = NULL;
+    t->sprites.tech[id] = NULL;
   }
 }
 
@@ -4230,6 +4232,18 @@
 }
 
 /**************************************************************************
+  Return the sprite for the technology/advance.
+**************************************************************************/
+struct sprite *get_tech_sprite(struct tileset *t, Tech_Type_id tech)
+{
+  if (tech <= 0 || tech >= game.num_tech_types) {
+    assert(0);
+    return NULL;
+  }
+  return t->sprites.tech[tech];
+}
+
+/**************************************************************************
   Return a "sample" sprite for this city style.
 **************************************************************************/
 struct sprite *get_sample_city_sprite(struct tileset *t, int city_style)
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.140
diff -u -r1.140 tilespec.h
--- client/tilespec.h   28 Mar 2005 23:25:38 -0000      1.140
+++ client/tilespec.h   29 Mar 2005 08:01:27 -0000
@@ -181,6 +181,7 @@
                                  const struct city *pcity);
 struct sprite *get_nation_flag_sprite(struct tileset *t,
                                      const struct nation_type *nation);
+struct sprite *get_tech_sprite(struct tileset *t, Tech_Type_id tech);
 struct sprite *get_sample_city_sprite(struct tileset *t, int city_style);
 struct sprite *get_arrow_sprite(struct tileset *t);
 struct sprite *get_tax_sprite(struct tileset *t, Output_type_id otype);
Index: common/tech.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.h,v
retrieving revision 1.51
diff -u -r1.51 tech.h
--- common/tech.h       28 Mar 2005 16:59:15 -0000      1.51
+++ common/tech.h       29 Mar 2005 08:01:27 -0000
@@ -88,8 +88,6 @@
   unsigned int flags;
   char *helptext;
 
-  struct sprite *sprite;               /* icon of tech. */
-         
   /* 
    * Message displayed to the first player to get a bonus tech 
    */

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12688) move tech sprites into the tileset, Jason Short <=