[Tux4kids-commits] r1409 - in branches/commonification: tux4kids-common/trunk/src tuxmath/trunk/src tuxtype/trunk/src

Bolesław Kulbabiński bolekk-guest at alioth.debian.org
Tue Aug 11 00:03:45 UTC 2009


Author: bolekk-guest
Date: 2009-08-11 00:03:45 +0000 (Tue, 11 Aug 2009)
New Revision: 1409

Modified:
   branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c
   branches/commonification/tuxmath/trunk/src/loaders.c
   branches/commonification/tuxtype/trunk/src/loaders.c
Log:
fixed small issue in sprite loader

Modified: branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c	2009-08-11 00:01:33 UTC (rev 1408)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-loaders.c	2009-08-11 00:03:45 UTC (rev 1409)
@@ -512,6 +512,7 @@
       DEBUGMSG(debug_loaders, "load_sprite(): failed to load default image for %s\n", name);
 
     new_sprite->cur = 0;
+    new_sprite->num_frames = 0;
     for(i = 0; i < MAX_SPRITE_FRAMES; i++)
     {
       sprintf(fn, "%s%d.png", name, i);
@@ -521,9 +522,7 @@
         new_sprite->frame[i] = LoadScaledImage(fn, mode | IMG_NOT_REQUIRED, w, h);
 
       if(new_sprite->frame[i] == NULL)
-      {
         break;
-      }
       else
       {
         DEBUGMSG(debug_loaders, "load_sprite(): loaded frame %d of %s\n", i, name);
@@ -532,6 +531,13 @@
     }
   }
 
+  if(0 == new_sprite->num_frames)
+  {
+    DEBUGMSG(debug_loaders, "load_sprite(): failed to load %s\n", name);
+    free(new_sprite);
+    return NULL;
+  }
+
   return new_sprite;
 }
 

Modified: branches/commonification/tuxmath/trunk/src/loaders.c
===================================================================
--- branches/commonification/tuxmath/trunk/src/loaders.c	2009-08-11 00:01:33 UTC (rev 1408)
+++ branches/commonification/tuxmath/trunk/src/loaders.c	2009-08-11 00:03:45 UTC (rev 1409)
@@ -515,6 +515,7 @@
       DEBUGMSG(debug_loaders, "load_sprite(): failed to load default image for %s\n", name);
 
     new_sprite->cur = 0;
+    new_sprite->num_frames = 0;
     for(i = 0; i < MAX_SPRITE_FRAMES; i++)
     {
       sprintf(fn, "%s%d.png", name, i);
@@ -524,9 +525,7 @@
         new_sprite->frame[i] = LoadScaledImage(fn, mode | IMG_NOT_REQUIRED, w, h);
 
       if(new_sprite->frame[i] == NULL)
-      {
         break;
-      }
       else
       {
         DEBUGMSG(debug_loaders, "load_sprite(): loaded frame %d of %s\n", i, name);
@@ -535,6 +534,13 @@
     }
   }
 
+  if(0 == new_sprite->num_frames)
+  {
+    DEBUGMSG(debug_loaders, "load_sprite(): failed to load %s\n", name);
+    free(new_sprite);
+    return NULL;
+  }
+
   return new_sprite;
 }
 

Modified: branches/commonification/tuxtype/trunk/src/loaders.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/loaders.c	2009-08-11 00:01:33 UTC (rev 1408)
+++ branches/commonification/tuxtype/trunk/src/loaders.c	2009-08-11 00:03:45 UTC (rev 1409)
@@ -659,6 +659,7 @@
       DEBUGMSG(debug_loaders, "load_sprite(): failed to load default image for %s\n", name);
 
     new_sprite->cur = 0;
+    new_sprite->num_frames = 0;
     for(i = 0; i < MAX_SPRITE_FRAMES; i++)
     {
       sprintf(fn, "%s%d.png", name, i);
@@ -668,9 +669,7 @@
         new_sprite->frame[i] = LoadScaledImage(fn, mode | IMG_NOT_REQUIRED, w, h);
 
       if(new_sprite->frame[i] == NULL)
-      {
         break;
-      }
       else
       {
         DEBUGMSG(debug_loaders, "load_sprite(): loaded frame %d of %s\n", i, name);
@@ -679,6 +678,13 @@
     }
   }
 
+  if(0 == new_sprite->num_frames)
+  {
+    DEBUGMSG(debug_loaders, "load_sprite(): failed to load %s\n", name);
+    free(new_sprite);
+    return NULL;
+  }
+
   return new_sprite;
 }
 




More information about the Tux4kids-commits mailing list