[Tux4kids-commits] r255 - in tuxtype/trunk: . tuxtype tuxtype/data/themes/deutsch

dbruce-guest at alioth.debian.org dbruce-guest at alioth.debian.org
Mon Sep 17 03:18:09 UTC 2007


Author: dbruce-guest
Date: 2007-09-17 03:18:09 +0000 (Mon, 17 Sep 2007)
New Revision: 255

Modified:
   tuxtype/trunk/ChangeLog
   tuxtype/trunk/configure.ac
   tuxtype/trunk/tuxtype/alphabet.c
   tuxtype/trunk/tuxtype/data/themes/deutsch/keyboard.lst
   tuxtype/trunk/tuxtype/funcs.h
   tuxtype/trunk/tuxtype/globals.h
   tuxtype/trunk/tuxtype/laser.c
   tuxtype/trunk/tuxtype/pause.c
   tuxtype/trunk/tuxtype/playgame.c
Log:
Corrected Malayalam Makefile.am, fixed bug in BlackOutline_SDLPango(), revised word list generation, partially corrected German keyboard.lst


Modified: tuxtype/trunk/ChangeLog
===================================================================
--- tuxtype/trunk/ChangeLog	2007-09-16 18:18:21 UTC (rev 254)
+++ tuxtype/trunk/ChangeLog	2007-09-17 03:18:09 UTC (rev 255)
@@ -1,5 +1,18 @@
+v 1.5.15 - svn revision 255
+15 Sep 2007
+[ David Bruce <dbruce at tampabay.rr.com> ]
+       - alphabet.c - fixed crash occurring in BlackOutline_SDLPango() when 
+         passed empty string (see Debian Bug #439071)
+       - alphabet.c - added code to check words in list to see if they have
+         chars not in keyboard.lst, and just leave out these words rather
+         than aborting the game.
+       - Corrected Makefile.am for Malayalam theme so that settings.txt
+         gets installed (needed for font selection to work).
+       - Added numerals and punctuation to German keyboard.lst (likely
+         needs to be done for many other themes).
+
 [ Holger Levsen ]
-	- added updated spanish translation by Amaya Rodrigo 
+	- added updated Spanish translation by Amaya Rodrigo 
 
 v 1.5.14 - svn revision 240
 15 Sep 2007

Modified: tuxtype/trunk/configure.ac
===================================================================
--- tuxtype/trunk/configure.ac	2007-09-16 18:18:21 UTC (rev 254)
+++ tuxtype/trunk/configure.ac	2007-09-17 03:18:09 UTC (rev 255)
@@ -1,9 +1,9 @@
 # Process this file with autoconf to produce a configure script.
-AC_INIT(tuxtype, 1.5.14, tuxmath-devel at lists.sourceforge.net)
+AC_INIT(tuxtype, 1.5.15, tuxmath-devel at lists.sourceforge.net)
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(tuxtype, 1.5.14)
+AM_INIT_AUTOMAKE(tuxtype, 1.5.15)
 
 AC_CONFIG_SRCDIR([tuxtype/funcs.h])
 

Modified: tuxtype/trunk/tuxtype/alphabet.c
===================================================================
--- tuxtype/trunk/tuxtype/alphabet.c	2007-09-16 18:18:21 UTC (rev 254)
+++ tuxtype/trunk/tuxtype/alphabet.c	2007-09-17 03:18:09 UTC (rev 255)
@@ -81,8 +81,8 @@
 static void show_letters(void);
 static void clear_keyboard(void);
 static int unicode_in_key_list(wchar_t uni_char);
+int check_needed_unicodes_str(const wchar_t* s);
 
-
 #ifndef WIN32
 static SDLPango_Matrix* SDL_Colour_to_SDLPango_Matrix(const SDL_Color* cl);
 #endif
@@ -236,7 +236,7 @@
   {
     i++;
   }
-  if (i = MAX_UNICODES)
+  if (i == MAX_UNICODES)
     return 0;
   else
     return 1;
@@ -254,6 +254,8 @@
   SDL_Rect dstrect;
   Uint32 color_key;
 
+  LOG("Entering BlackOutline()\n");
+
 /* Simply passthrough to SDLPango version if available (i.e. not under Windows):*/
 #ifndef WIN32
 return BlackOutline_SDLPango(t, font, c);
@@ -307,6 +309,8 @@
   out = SDL_DisplayFormatAlpha(bg);
   SDL_FreeSurface(bg);
 
+  LOG("Leaving BlackOutline()\n");
+
   return out;
 }
 
@@ -345,20 +349,28 @@
   SDL_Surface* bg = NULL;
   SDL_Rect dstrect;
   Uint32 color_key;
-
   /* To covert SDL_Colour to SDLPango_Matrix */
-  SDLPango_Matrix* colour;
+  SDLPango_Matrix* colour = NULL;
   /* Create a context which contains Pango objects.*/
-  SDLPango_Context* context;
+  SDLPango_Context* context = NULL;
 
+  LOG("\nEntering BlackOutline_SDLPango()\n");
+  DEBUGCODE{ fprintf(stderr, "will attempt to render: %s\n", t); }
 
   if (!t || !font || !c)
   {
-    fprintf(stderr, "BlackOutline(): invalid ptr parameter, returning.");
+    fprintf(stderr, "BlackOutline_SDLPango(): invalid ptr parameter, returning.");
     return NULL;
   }
 
-  colour=SDL_Colour_to_SDLPango_Matrix(c);
+  /* SDLPango crashes on 64 bit machines if passed empty string - Debian Bug#439071 */
+  if (*t == '\0')
+  {
+    fprintf(stderr, "BlackOutline_SDLPango(): empty string arg - must return to avoid segfault.");
+    return NULL;
+  }
+
+  colour = SDL_Colour_to_SDLPango_Matrix(c);
   
   /* Create the context */
   context = SDLPango_CreateContext();	
@@ -367,14 +379,19 @@
   SDLPango_SetDefaultColor(context, MATRIX_TRANSPARENT_BACK_BLACK_LETTER );
   SDLPango_SetBaseDirection(context, SDLPANGO_DIRECTION_LTR);
   /* Set text to context */ 
-  SDLPango_SetMarkup(context,t, -1);  
+  SDLPango_SetMarkup(context, t, -1); 
 
+  if (!context)
+  {
+    fprintf (stderr, "In BlackOutline_SDLPango(), could not create context for %s", t);
+    return NULL;
+  }
 
   black_letters = SDLPango_CreateSurfaceDraw(context);
 
   if (!black_letters)
   {
-    fprintf (stderr, "Warning - BlackOutline() could not create image for %s\n", t);
+    fprintf (stderr, "Warning - BlackOutline_SDLPango() could not create image for %s\n", t);
     return NULL;
   }
 
@@ -383,10 +400,16 @@
                             (black_letters->h) + 5,
                              32,
                              RMASK, GMASK, BMASK, AMASK);
+  if (!bg)
+  {
+    fprintf (stderr, "Warning - BlackOutline()_SDLPango - bg creation failed\n");
+    SDL_FreeSurface(black_letters);
+    return NULL;
+  }
 
   /* Draw text on a existing surface */
   SDLPango_Draw(context, bg, 0, 0);
-  
+
   /* Use color key for eventual transparency: */
   color_key = SDL_MapRGB(bg->format, 10, 10, 10);
   SDL_FillRect(bg, NULL, color_key);
@@ -416,6 +439,8 @@
   out = SDL_DisplayFormatAlpha(bg);
   SDL_FreeSurface(bg);
 
+  LOG("Leaving BlackOutline_SDLPango()\n\n");
+
   return out;
 }
 
@@ -742,7 +767,7 @@
               temp_word, MAX_WORD_SIZE);
       continue;
     }
-;
+
     if (num_words >= MAX_NUM_WORDS)
     {
       fprintf(stderr, "Word '%s' not added - list has reached max of %d characters\n",
@@ -750,10 +775,16 @@
       continue;
     }
 
+    if (!check_needed_unicodes_str(temp_wide_word))
+    {
+      fprintf(stderr, "Word '%S' not added - contains Unicode chars not in keyboard list\n",
+              temp_wide_word);
+      continue;
+    }
+
     /* If we make it to here, OK to add word: */
     /* NOTE we have to add one to the length argument */
     /* to include the terminating null.  */
-    //mbstowcs(word_list[num_words], temp_word, strlen(temp_word) + 1);
     DEBUGCODE
     {
       fprintf(stderr, "Adding word: %ls\n", temp_wide_word);
@@ -917,7 +948,24 @@
   return 1;
 }
 
+int check_needed_unicodes_str(const wchar_t* s)
+{
+  int i = 0;
 
+  while ((i < MAX_WORD_SIZE)
+      && (s[i] != '\0'))
+  {
+    if (!unicode_in_key_list(s[i]))
+    {
+      fprintf(stderr, "\ncheck_needed_unicodes_str() - needed char '%C' (Unicode value = %d) not found.\n",
+              s[i], s[i]);
+      return 0;
+    }
+    i++;
+  }
+  return 1;
+}
+
 /****************************************************/
 /*                                                  */
 /*       Local ("private") functions:               */

Modified: tuxtype/trunk/tuxtype/data/themes/deutsch/keyboard.lst
===================================================================
--- tuxtype/trunk/tuxtype/data/themes/deutsch/keyboard.lst	2007-09-16 18:18:21 UTC (rev 254)
+++ tuxtype/trunk/tuxtype/data/themes/deutsch/keyboard.lst	2007-09-17 03:18:09 UTC (rev 255)
@@ -51,10 +51,20 @@
 0|y
 6|Z
 6|z
-9|�
-9|�
-9|�
-9|�
-9|�
-9|�
-9|�
+5| 
+0|!
+0|@
+0|#
+0|1
+0|2
+0|3
+0|4
+0|5
+0|6
+0|7
+0|8
+0|9
+0|0
+7|,
+8|.
+9|;

Modified: tuxtype/trunk/tuxtype/funcs.h
===================================================================
--- tuxtype/trunk/tuxtype/funcs.h	2007-09-16 18:18:21 UTC (rev 254)
+++ tuxtype/trunk/tuxtype/funcs.h	2007-09-17 03:18:09 UTC (rev 255)
@@ -84,8 +84,6 @@
 
 /* In pause.c: */
 int  Pause(void);
-void PauseLoadMedia(void);
-void PauseUnloadMedia(void);
 int  inRect(SDL_Rect r, int x, int y);
 
 

Modified: tuxtype/trunk/tuxtype/globals.h
===================================================================
--- tuxtype/trunk/tuxtype/globals.h	2007-09-16 18:18:21 UTC (rev 254)
+++ tuxtype/trunk/tuxtype/globals.h	2007-09-17 03:18:09 UTC (rev 255)
@@ -154,7 +154,7 @@
 /* Limits on word list size, word length, and on the number of distinct characters */
 /* that can be present within a word list: */
 #define MAX_NUM_WORDS   500
-#define MAX_WORD_SIZE   12
+#define MAX_WORD_SIZE   8
 #define MAX_UNICODES    1024
 
 #define WAIT_MS		2500

Modified: tuxtype/trunk/tuxtype/laser.c
===================================================================
--- tuxtype/trunk/tuxtype/laser.c	2007-09-16 18:18:21 UTC (rev 254)
+++ tuxtype/trunk/tuxtype/laser.c	2007-09-17 03:18:09 UTC (rev 255)
@@ -675,7 +675,7 @@
 			musics[i] = LoadMusic(music_filenames[i]);
 	}
 
-	PauseLoadMedia();
+//	PauseLoadMedia();
 }
 
 
@@ -698,7 +698,7 @@
 	FreeSprite(shield);
         shield = NULL;
 
-	PauseUnloadMedia();
+//	PauseUnloadMedia();
 
 	TTF_CloseFont(font);
         font = NULL;
@@ -829,7 +829,7 @@
           int i = 0;
           comet_type* prev_comet = NULL;
 
-          DEBUGCODE {fprintf(stderr, "word is: %s\n", word);}
+          DEBUGCODE {fprintf(stderr, "word is: %S\tlength is: %d\n", word, (int)wcslen(word));}
           do
           { 
   	    target = rand() % (NUM_CITIES - wcslen(word) + 1);
@@ -862,7 +862,7 @@
 				/* Save pointer for next time through: */
                                 prev_comet = &comets[location];
 
-				DEBUGCODE {fprintf(stderr, "Assigning letter to comet: %c\n", word[i]);}
+				DEBUGCODE {fprintf(stderr, "Assigning letter to comet: %C\n", word[i]);}
 			}
 		}
 	}

Modified: tuxtype/trunk/tuxtype/pause.c
===================================================================
--- tuxtype/trunk/tuxtype/pause.c	2007-09-16 18:18:21 UTC (rev 254)
+++ tuxtype/trunk/tuxtype/pause.c	2007-09-17 03:18:09 UTC (rev 255)
@@ -19,17 +19,18 @@
 #include "globals.h"
 #include "funcs.h"
 
-static Mix_Chunk *pause_sfx;
-static SDL_Surface *up, *down, *left, *right;
+static Mix_Chunk *pause_sfx = NULL;
+static SDL_Surface *up = NULL, *down = NULL, *left = NULL, *right = NULL;
 static SDL_Rect rectUp, rectDown, rectLeft, rectRight;
-static TTF_Font *f1, *f2;
+static TTF_Font *f1 = NULL, *f2 = NULL;
 
 /* Local function prototypes: */
 static void darkenscreen(void);
 static void draw_vols(int sfx, int mus);
-static void pause_draw_info(void);
+static void pause_draw(void);
+static void pause_load_media(void);
+static void pause_unload_media(void);
 
-
 // QUESTION: For usability sake, should escape return to the game
 //           and the user have to choose to quit the game, or ???
 /**********************
@@ -47,8 +48,9 @@
 	int tocks=0;  // used for keeping track of when a tock has happened
 	SDL_Event event;
 
-	LOG( "---GAME PAUSED---\n" );
+	LOG( "Entering Pause()\n" );
 
+	pause_load_media();
 	/* --- stop all sounds, play pause noise --- */
 
 	if (settings.sys_sound) {
@@ -65,7 +67,7 @@
 	// Darken the screen...
 	darkenscreen(); 
 
-	pause_draw_info();
+	pause_draw();
 
 	if (settings.sys_sound) {
 		draw_vols(sfx_volume, mus_volume);
@@ -194,13 +196,15 @@
 		Mix_Resume(-1);
 	}
 
-	LOG( "---GAME RESUMED---\n" );
+	pause_unload_media();
 
+	LOG( "Leaving Pause()\n" );
+
 	return (quit);
 }
 
 
-void PauseLoadMedia(void) {
+static void pause_load_media(void) {
 	if (settings.sys_sound) 
 		pause_sfx = LoadSound( "tock.wav" );
 
@@ -220,7 +224,7 @@
 	f2 = LoadFont(settings.theme_font_name, 36);
 }
 
-void PauseUnloadMedia(void) {
+static void pause_unload_media(void) {
 	if (settings.sys_sound)
         {
 	  Mix_FreeChunk(pause_sfx);
@@ -254,93 +258,119 @@
 
 
 
-static void pause_draw_info(void) {
-	SDL_Rect s;
-	SDL_Surface *t;
+static void pause_draw(void)
+{
+  SDL_Rect s;
+  SDL_Surface* t = NULL;
 
-	rectLeft.y = rectRight.y = 200;
-	rectDown.y = rectUp.y = 300;
+  LOG("Entering pause_draw()\n");
 
-	rectLeft.x = rectDown.x = 320 - (7*16) - rectLeft.w - 4;
-	rectRight.x = rectUp.x  = 320 + (7*16) + 4;
+  rectLeft.y = rectRight.y = 200;
+  rectDown.y = rectUp.y = 300;
 
-	if (settings.sys_sound) {
+  rectLeft.x = rectDown.x = 320 - (7*16) - rectLeft.w - 4;
+  rectRight.x = rectUp.x  = 320 + (7*16) + 4;
 
-		SDL_BlitSurface(left, NULL, screen, &rectLeft);
-		SDL_BlitSurface(right, NULL, screen, &rectRight);
+  /* Avoid segfault if any needed SDL_Surfaces missing: */
+  if (settings.sys_sound
+    && left && right && down && up)
+  {
+    SDL_BlitSurface(left, NULL, screen, &rectLeft);
+    SDL_BlitSurface(right, NULL, screen, &rectRight);
+    SDL_BlitSurface(down, NULL, screen, &rectDown);
+    SDL_BlitSurface(up, NULL, screen, &rectUp);
+  }
 
-		SDL_BlitSurface(down, NULL, screen, &rectDown);
-		SDL_BlitSurface(up, NULL, screen, &rectUp);
-	}
+  if (settings.sys_sound)
+  {
+    t = BlackOutline(_("Sound Effects Volume"), f1, &white);
+    if (t)
+    {	
+      s.y = 160;
+      s.x = 320 - t->w/2;
+      SDL_BlitSurface(t, NULL, screen, &s);
+      SDL_FreeSurface(t);
+    }
 
-	if (settings.sys_sound) {
+    t = BlackOutline(_("Music Volume"), f1, &white);
+    if (t)
+    {
+      s.y = 260;
+      s.x = 320 - t->w/2;
+      SDL_BlitSurface(t, NULL, screen, &s);
+      SDL_FreeSurface(t);
+    }
+  }
+  else  /* No sound: */
+  {
+    t = BlackOutline(_("Sound & Music Disabled"), f1, &white);
+    if (t)
+    {
+      s.y = 160;
+      s.x = 320 - t->w/2;
+      SDL_BlitSurface(t, NULL, screen, &s);
+      SDL_FreeSurface(t);
+    }
+  }
 
-		t = BlackOutline(_("Sound Effects Volume"), f1, &white);
-		s.y = 160;
-		s.x = 320 - t->w/2;
-		SDL_BlitSurface(t, NULL, screen, &s);
-		SDL_FreeSurface(t);
-
-		t = BlackOutline(_("Music Volume"), f1, &white);
-		s.y = 260;
-		s.x = 320 - t->w/2;
-		SDL_BlitSurface(t, NULL, screen, &s);
-		SDL_FreeSurface(t);
-
-	} else {
-
-		t = BlackOutline(_("Sound & Music Disabled"), f1, &white);
-		s.y = 160;
-		s.x = 320 - t->w/2;
-		SDL_BlitSurface(t, NULL, screen, &s);
-		SDL_FreeSurface(t);
-	}
-
-	t = BlackOutline(_("Paused!"), f2, &white);
+  t = BlackOutline(_("Paused!"), f2, &white);
+  if (t)
+  {
 	s.y = 60;
 	s.x = 320 - t->w/2;
 	SDL_BlitSurface(t, NULL, screen, &s);
 	SDL_FreeSurface(t);
+  }
 
-	t = BlackOutline(_("Press escape again to return to menu"), f1, &white);
-	s.y = 400;
-	s.x = 320 - t->w/2;
-	SDL_BlitSurface(t, NULL, screen, &s);
-	SDL_FreeSurface(t);
+  t = BlackOutline(_("Press escape again to return to menu"), f1, &white);
+  if (t)
+  {
+    s.y = 400;
+    s.x = 320 - t->w/2;
+    SDL_BlitSurface(t, NULL, screen, &s);
+    SDL_FreeSurface(t);
+  }
 
-	t = BlackOutline(_("Press space bar to return to game"), f1, &white);
-	s.y = 440;
-	s.x = 320 - t->w/2;
-	SDL_BlitSurface(t, NULL, screen, &s);
-	SDL_FreeSurface(t);
+  t = BlackOutline(_("Press space bar to return to game"), f1, &white);
+  if (t)
+  {
+    s.y = 440;
+    s.x = 320 - t->w/2;
+    SDL_BlitSurface(t, NULL, screen, &s);
+    SDL_FreeSurface(t);
+  }
+
+  LOG("Leaving pause_draw()\n");
 }
 
 
+/* FIXME what if rectLeft and rectDown not initialized? - should be args */
+static void draw_vols(int sfx, int mus)
+{
+  SDL_Rect s,m;
+  int i;
 
-static void draw_vols(int sfx, int mus) {
-	SDL_Rect s,m;
-	int i;
+  s.y = rectLeft.y; 
+  m.y = rectDown.y;
+  m.w = s.w = 5;
+  s.x = rectLeft.x + rectLeft.w + 5;
+  m.x = rectDown.x + rectDown.w + 5;
+  m.h = s.h = 40;
 
-	s.y = rectLeft.y; 
-	m.y = rectDown.y;
-	m.w = s.w = 5;
-	s.x = rectLeft.x + rectLeft.w + 5;
-	m.x = rectDown.x + rectDown.w + 5;
-	m.h = s.h = 40;
+  for (i = 1; i<=32; i++)
+  {
+    if (sfx >= i * 4)
+      SDL_FillRect(screen, &s, SDL_MapRGB(screen->format, 0, 0, 127 + sfx));
+    else
+      SDL_FillRect(screen, &s, SDL_MapRGB(screen->format, 0, 0, 0));
 
-	for (i = 1; i<=32; i++){
-		if (sfx >= i*4)
-			SDL_FillRect(screen, &s, SDL_MapRGB(screen->format, 0, 0, 127+sfx));
-		else
-			SDL_FillRect(screen, &s, SDL_MapRGB(screen->format, 0, 0, 0));
+    if (mus >= i * 4)
+      SDL_FillRect(screen, &m, SDL_MapRGB(screen->format, 0, 0, 127 + mus));
+    else
+      SDL_FillRect(screen, &m, SDL_MapRGB(screen->format, 0, 0, 0));
 
-		if (mus >= i*4)
-			SDL_FillRect(screen, &m, SDL_MapRGB(screen->format, 0, 0, 127+mus));
-		else
-			SDL_FillRect(screen, &m, SDL_MapRGB(screen->format, 0, 0, 0));
-
-		m.x = s.x += 7;
-	}
+    m.x = s.x += 7;
+  }
 }
 
 /* ==== fillscreen ====

Modified: tuxtype/trunk/tuxtype/playgame.c
===================================================================
--- tuxtype/trunk/tuxtype/playgame.c	2007-09-16 18:18:21 UTC (rev 254)
+++ tuxtype/trunk/tuxtype/playgame.c	2007-09-17 03:18:09 UTC (rev 255)
@@ -249,7 +249,8 @@
 					if (event.key.keysym.sym == SDLK_F12) 
 						SNOW_toggle();
 					if (event.key.keysym.sym == SDLK_ESCAPE) {
-
+						/* Pause() returns 1 if quitting, */
+						/* 0 if returning to game:        */
 						if (Pause() == 1) {
 							playing_level = 0;
 							still_playing = 0;
@@ -979,7 +980,7 @@
 	} else 
 		LOG( "=NO SOUND FX LOADED (not selected)\n" );
 
-	PauseLoadMedia();
+//	PauseLoadMedia();
 
 	LOG( "=Setting NULL fish & splat & word\n" );
 
@@ -1187,7 +1188,7 @@
 	  }
 	}
 
-	PauseUnloadMedia();
+//	PauseUnloadMedia();
 
 
 	LOG( "FreeGame(): END\n" );




More information about the Tux4kids-commits mailing list