[Tux4kids-commits] r890 - in tuxmath/trunk: . doc src

dbruce-guest at alioth.debian.org dbruce-guest at alioth.debian.org
Mon Feb 16 22:06:54 UTC 2009


Author: dbruce-guest
Date: 2009-02-16 22:06:54 +0000 (Mon, 16 Feb 2009)
New Revision: 890

Modified:
   tuxmath/trunk/Makefile.am
   tuxmath/trunk/Makefile.in
   tuxmath/trunk/doc/changelog
   tuxmath/trunk/src/credits.c
   tuxmath/trunk/src/globals.h
   tuxmath/trunk/src/highscore.c
   tuxmath/trunk/src/linewrap.c
   tuxmath/trunk/src/loaders.c
   tuxmath/trunk/src/multiplayer.c
   tuxmath/trunk/src/setup.c
   tuxmath/trunk/src/titlescreen.c
   tuxmath/trunk/src/tuxmath.c
Log:
code cleanup



Modified: tuxmath/trunk/Makefile.am
===================================================================
--- tuxmath/trunk/Makefile.am	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/Makefile.am	2009-02-16 22:06:54 UTC (rev 890)
@@ -9,7 +9,12 @@
 
 ACLOCAL_AMFLAGS = -I m4
 
-EXTRA_DIST = tuxmath.spec tuxmath.desktop config.rpath m4/ChangeLog
+EXTRA_DIST = tuxmath.spec \
+	tuxmath.desktop \
+	config.rpath \
+	m4/ChangeLog \
+	CMakeLists.txt
+
 datadir = @datadir@
 localedir = $(datadir)/locale
 

Modified: tuxmath/trunk/Makefile.in
===================================================================
--- tuxmath/trunk/Makefile.in	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/Makefile.in	2009-02-16 22:06:54 UTC (rev 890)
@@ -253,7 +253,12 @@
 	src
 
 ACLOCAL_AMFLAGS = -I m4
-EXTRA_DIST = tuxmath.spec tuxmath.desktop config.rpath m4/ChangeLog
+EXTRA_DIST = tuxmath.spec \
+	tuxmath.desktop \
+	config.rpath \
+	m4/ChangeLog \
+	CMakeLists.txt
+
 MAKENSIS = @NSIS@
 NSIS_FOUND = @NSIS_FOUND@
 NSI_TEMP_INSTALL_DIR = $(abs_top_builddir)/_instw32

Modified: tuxmath/trunk/doc/changelog
===================================================================
--- tuxmath/trunk/doc/changelog	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/doc/changelog	2009-02-16 22:06:54 UTC (rev 890)
@@ -1,4 +1,4 @@
-2009.Feb.15 
+2009.Feb.15 (svn.debian.org/tux4kids - revision 889)
         build - moved linebreak-related code back to /linebreak, adjusted 
         autotools files. The code in /linebreak is now built as a static 
         library when using the autotools build.

Modified: tuxmath/trunk/src/credits.c
===================================================================
--- tuxmath/trunk/src/credits.c	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/src/credits.c	2009-02-16 22:06:54 UTC (rev 890)
@@ -449,14 +449,14 @@
           dest.y = subscreen.y + (subscreen.h - scroll * speed);
           dest.w = 1;
           dest.h = 1;
-#ifdef LINEBREAK
+//#ifdef LINEBREAK
 	  draw_text(text[line], dest);  // translation should have already occurred
-#else
-	  if (strlen(text[line]) > 0)
-	    draw_text(gettext(text[line]), dest);
-	  else
-	    draw_text(text[line], dest);
-#endif
+//#else
+//	  if (strlen(text[line]) > 0)
+//	    draw_text(gettext(text[line]), dest);
+//	  else
+//	    draw_text(text[line], dest);
+//#endif
 
           if (scroll * speed >= TTF_FontHeight(default_font) )
             {

Modified: tuxmath/trunk/src/globals.h
===================================================================
--- tuxmath/trunk/src/globals.h	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/src/globals.h	2009-02-16 22:06:54 UTC (rev 890)
@@ -27,10 +27,10 @@
 
 #include "config.h"
 /* for conditional compilation of debugging output */
-//#define TUXMATH_DEBUG
+#define TUXMATH_DEBUG
 /* for Tim's feedback speed control code           */
 //#define FEEDBACK_DEBUG
-#define LINEBREAK
+//#define LINEBREAK
 /* nice inline debugging macro */
 #ifdef TUXMATH_DEBUG
 #define tmdprintf(...) printf(__VA_ARGS__)

Modified: tuxmath/trunk/src/highscore.c
===================================================================
--- tuxmath/trunk/src/highscore.c	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/src/highscore.c	2009-02-16 22:06:54 UTC (rev 890)
@@ -18,6 +18,7 @@
 #include "setup.h"
 #include "options.h"
 #include "SDL_extras.h"
+#include "convert_utf.h"
 
 
 typedef struct high_score_entry {
@@ -490,7 +491,7 @@
         case SDL_KEYDOWN:
         {
 #ifdef TUXMATH_DEBUG
-          fprintf(stderr, "Before keypress, string is %s\tlength = %d\n",
+          fprintf(stderr, "Before keypress, string is %S\tlength = %d\n",
                   wchar_buf, (int)wcslen(wchar_buf));
 #endif
           switch (event.key.keysym.sym)
@@ -525,7 +526,7 @@
           }  /* end  'switch (event.key.keysym.sym)'  */
 
 #ifdef TUXMATH_DEBUG
-          fprintf(stderr, "After keypress, string is %s\tlength = %d\n",
+          fprintf(stderr, "After keypress, string is %S\tlength = %d\n",
                     wchar_buf, (int)wcslen(wchar_buf));
 #endif
             /* Now draw name, if needed: */

Modified: tuxmath/trunk/src/linewrap.c
===================================================================
--- tuxmath/trunk/src/linewrap.c	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/src/linewrap.c	2009-02-16 22:06:54 UTC (rev 890)
@@ -27,8 +27,8 @@
 #include "../linebreak/linebreak.h"
 #include "linewrap.h"
 
-static char *wrapped_lines0[MAX_LINES];  // for internal storage
-char *wrapped_lines[MAX_LINES];  // publicly available!
+static char *wrapped_lines0[MAX_LINES] = {NULL};  // for internal storage
+char *wrapped_lines[MAX_LINES] = {NULL}; // publicly available!
 
 void linewrap_initialize()
 {
@@ -43,14 +43,27 @@
 void linewrap_cleanup()
 {
   int i;
+  fprintf(stderr, "enter linewrap_cleanup()\n");
 
   for (i = 0; i < MAX_LINES; i++) {
-    free(wrapped_lines[i]);
-    free(wrapped_lines0[i]);
+
+    if (wrapped_lines[i] != NULL) {
+    fprintf(stderr, "about to try to free wrapped_lines[%d]: %s\n", i, wrapped_lines[i]);
+      free(wrapped_lines[i]);
+      wrapped_lines[i] = NULL;
+    }
+
+    if(wrapped_lines0[i] != NULL) {
+      fprintf(stderr, "about to try to free wrapped_lines0[%d]: %s\n", i, wrapped_lines0[i]);
+      free(wrapped_lines0[i]);
+      wrapped_lines0[i] = NULL;
+    }
   }
-}  
 
+  fprintf(stderr, "done linewrap_cleanup()\n");
+}
 
+
 int linewrap(const char *input,char *str_list[],int width,int max_lines,int max_width)
 {
   int length = strlen (input);
@@ -67,7 +80,7 @@
   // values at the first character of the next line, not at the space
   // between words.
   listIndex = 0;
-  for (strIndex = 0, i = 0; i < length; strIndex++,i++) {
+  for (strIndex = 0, i = 0; i < length; strIndex++, i++) {
     if (breaks[i] == UC_BREAK_POSSIBLE || breaks[i] == UC_BREAK_MANDATORY) {
       str_list[listIndex][strIndex] = '\0';  // terminate the previous string
       strIndex = 0;                          // start the next line
@@ -107,11 +120,11 @@
     }
     /* Handle real strings */
     printf("Not blank. Translated: %s\n",gettext(input[inputIndex]));
-    n_lines = linewrap(gettext(input[inputIndex]),wrapped_lines0,width,max_lines,max_width);
-    printf("Wrapped to %d lines.\n",n_lines);
+    n_lines = linewrap(gettext(input[inputIndex]), wrapped_lines0, width,max_lines, max_width);
+    printf("Wrapped to %d lines.\n", n_lines);
     for (intermedIndex = 0; intermedIndex < n_lines && outputIndex < max_lines-1; intermedIndex++, outputIndex++) {
-      printf("intermedIndex %d, outputIndex %d, string %s\n",intermedIndex,outputIndex,wrapped_lines0[intermedIndex]);
-      strncpy(str_list[outputIndex],wrapped_lines0[intermedIndex],max_width);
+      printf("intermedIndex %d, outputIndex %d, string %s\n",intermedIndex,outputIndex, wrapped_lines0[intermedIndex]);
+      strncpy(str_list[outputIndex], wrapped_lines0[intermedIndex], max_width);
     }
   }
   printf("All done (outputIndex = %d)\n",outputIndex);

Modified: tuxmath/trunk/src/loaders.c
===================================================================
--- tuxmath/trunk/src/loaders.c	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/src/loaders.c	2009-02-16 22:06:54 UTC (rev 890)
@@ -346,19 +346,30 @@
 
 
 
-void FreeSprite( sprite *gfx ) {
+void FreeSprite(sprite* gfx )
+{
   int x;
   if (!gfx)
     return;
-  printf("Freeing image");
-  tmdprintf(" at %p", gfx);
+
+  tmdprintf("Freeing image at %p", gfx);
   for (x = 0; x < gfx->num_frames; x++)
   {
-    printf(".");
-    SDL_FreeSurface( gfx->frame[x] );
-  }              
-  SDL_FreeSurface( gfx->default_img );
-  printf("done\n");
+    tmdprintf(".");
+    if (gfx->frame[x])
+    {
+      SDL_FreeSurface(gfx->frame[x]);
+      gfx->frame[x] = NULL;
+    }
+  }
+
+  if (gfx->default_img)
+  {
+    SDL_FreeSurface(gfx->default_img);
+    gfx->default_img = NULL;
+  }
+
+  tmdprintf("FreeSprite() - done\n");
   free(gfx);
 }
 

Modified: tuxmath/trunk/src/multiplayer.c
===================================================================
--- tuxmath/trunk/src/multiplayer.c	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/src/multiplayer.c	2009-02-16 22:06:54 UTC (rev 890)
@@ -170,7 +170,7 @@
   SDL_Rect center = box;
   SDL_Event evt;
 
-//  const char* winnername = (winners[0] == -1 ? "Nobody" : pnames[winners[0]] );
+  const char* winnername = (winners[0] == -1 ? "Nobody" : pnames[winners[0]] );
   
   tmdprintf(pnames[winners[0]] );
   tmdprintf("%d\n", snprintf(text, HIGH_SCORE_NAME_LENGTH + strlen(" wins!"),

Modified: tuxmath/trunk/src/setup.c
===================================================================
--- tuxmath/trunk/src/setup.c	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/src/setup.c	2009-02-16 22:06:54 UTC (rev 890)
@@ -50,9 +50,9 @@
 #include "highscore.h"
 #include "SDL_extras.h"
 
-#ifdef LINEBREAK
+//#ifdef LINEBREAK
 #include "linewrap.h"
-#endif
+//#endif
 
 /* Global data used in setup.c:              */
 /* (These are now 'extern'd in "tuxmath.h") */
@@ -113,9 +113,9 @@
   /* Command-line code now in own function: */
   handle_command_args(argc, argv);
   /* Allocate memory for line wrapping */
-#ifdef LINEBREAK
+//#ifdef LINEBREAK
   linewrap_initialize();
-#endif
+//#endif
   /* SDL setup in own function:*/
   initialize_SDL();
   /* Read image and sound files: */
@@ -643,7 +643,7 @@
   /* want to save settings from certain types of games. */
   //write_user_config_file();
   cleanup_memory();
-  exit(0);
+//  exit(0);
 }
 
 
@@ -672,9 +672,9 @@
   Uint16 format;
 
   /* Free memory used for line breaking */
-#ifdef LINEBREAK
+//#ifdef LINEBREAK
   linewrap_cleanup();
-#endif
+//#endif
 
   /* Free all images and sounds used by SDL: */
   if(default_font)

Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/src/titlescreen.c	2009-02-16 22:06:54 UTC (rev 890)
@@ -455,8 +455,9 @@
 
   for (i = 0; i < N_SPRITES; i++)
   {
-    tmdprintf("Freeing image #%d: ", i);
+    tmdprintf("Freeing image %d: ", i);
     FreeSprite(sprite_list[i]);
+    sprite_list[i] = NULL;
   }
   free(sprite_list);
   tmdprintf("Images freed\n");

Modified: tuxmath/trunk/src/tuxmath.c
===================================================================
--- tuxmath/trunk/src/tuxmath.c	2009-02-15 17:00:03 UTC (rev 889)
+++ tuxmath/trunk/src/tuxmath.c	2009-02-16 22:06:54 UTC (rev 890)
@@ -33,10 +33,9 @@
 #define TUXLOCALE LOCALEDIR
 #endif
 
-#ifdef LINEBREAK
-//#include "../linebreak/linebreak.h"
+//#ifdef LINEBREAK
 #include "linewrap.h"
-#endif
+//#endif
 
 int main(int argc, char * argv[])
 {
@@ -58,24 +57,6 @@
   fprintf(stderr, "After gettext() call\n");
 #endif
 
-  /*
-  const char* brief[5] = {
-    N_("I'm so glad you've come!"),
-    " ",
-    N_("The penguins need your help! Comets are falling from the sky, and are melting the penguins' igloos. To save their homes, we need you to find the secret code that will zap each comet."),
-    ""
-  };
-  linewrap_initialize();
-  linewrap_list(brief, wrapped_lines, 40, MAX_LINES, MAX_LINEWIDTH);
-
-  int i;
-  i = 0;
-  while (strlen(wrapped_lines[i]) > 0)
-    printf("%s\n",wrapped_lines[i++]);
-  linewrap_cleanup();
-  return 0;
-  */
-
   setup(argc, argv);
   TitleScreen();  /* Run the game! */
   cleanup();




More information about the Tux4kids-commits mailing list