Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[Freeciv-Dev] (PR#3746) explosion sprites are loaded twice
Home

[Freeciv-Dev] (PR#3746) explosion sprites are loaded twice

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3746) explosion sprites are loaded twice
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 21 Mar 2003 00:17:17 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[jdorje - Tue Mar 18 06:32:36 2003]:

> One thing I just noticed about the new sprite loading code is that the
> unit explosion sprites are loaded twice - once when counting how many
> explosion sprites there are, and a second time when putting them into an
> array.  This just means there is an extra reference to the sprite, which
> means if unload_sprite were ever called (outside of free_all_sprites) on
> these sprites we probably wouldn't end up releasing the pixmap
immediately.
> 
> The attached patch is a poor solution to this problem.

The attached patch is a better solution.

jason

? client/annotate
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.112
diff -u -r1.112 tilespec.c
--- client/tilespec.c   2003/03/18 06:24:18     1.112
+++ client/tilespec.c   2003/03/21 08:16:16
@@ -856,7 +856,7 @@
   do {
     my_snprintf(buffer, sizeof(buffer), "explode.unit_%d",
                num_tiles_explode_unit++);
-  } while (load_sprite(buffer));
+  } while (check_sprite(buffer));
   num_tiles_explode_unit--;
     
   if (num_tiles_explode_unit==0) {
@@ -2518,6 +2518,18 @@
     free_sprite(ss->sprite);
     ss->sprite = NULL;
   }
+}
+
+/**************************************************************************
+  Return TRUE iff the specified sprite exists in the tileset (whether or
+  not it is currently loaded).
+**************************************************************************/
+bool check_sprite(const char *tag_name)
+{
+  /* Lookup information about where the sprite is found. */
+  struct small_sprite *ss = hash_lookup_data(sprite_hash, tag_name);
+
+  return (ss != NULL);
 }
 
 /**************************************************************************
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.39
diff -u -r1.39 tilespec.h
--- client/tilespec.h   2003/03/18 06:24:18     1.39
+++ client/tilespec.h   2003/03/21 08:16:16
@@ -263,6 +263,7 @@
 
 struct Sprite *load_sprite(const char *tag_name);
 void unload_sprite(const char *tag_name);
+bool check_sprite(const char *tag_name);
 void finish_loading_sprites(void);
 
 #endif  /* FC__TILESPEC_H */

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