Hey Holger, Hey tuxtype-dev list :)

I've modified the patchset I've attached to this bugreport and added a new 
function called "error_occured()". This will show up basically the same 
screen as "not_implemented()" does, but will exit to the mainmenu 
afterwards. So if the pointer word is a NULL-pointer, you won't get a 
segfault, but you get this error screen.
 To have the fix also complete on the tuxtype-dev list I'll attach again 
the not modified patch for the german keyboard.lst.

Greetings
Winnie

-- 
 .''`.   Patrick Winnertz <[EMAIL PROTECTED]>
:  :' :  GNU/Linux Debian Developer
`. `'`   http://www.der-winnie.de http://people.skolelinux.org/~winnie
  `-  Debian - when you have better things to do than fixing systems
      Spamtrap: [EMAIL PROTECTED]
Index: titlescreen.c
===================================================================
--- titlescreen.c	(Revision 456)
+++ titlescreen.c	(Arbeitskopie)
@@ -867,7 +874,110 @@
   settings.fullscreen = !settings.fullscreen;
 }
 
+/*Derived from not_implemented: should only be shown if an error occurs somewhere */
+void error_occured(void)
+{
+	SDL_Surface* bk = NULL;
+	SDL_Surface *s1 = NULL, *s2 = NULL, *s3 = NULL, *s4 = NULL;
+	sprite* tux = NULL;
+	SDL_Rect loc;
+	int finished = 0, i;
 
+	LOG( "ErrorOccured() - creating text\n" );
+	/* if no font is set, use default ones */
+	if (!font) 
+		font = LoadFont(DEFAULT_MENU_FONT, MENU_FONT_SIZE);
+
+	s1 = BlackOutline( _("An error occured"), font, &white);
+	s2 = BlackOutline( _("This shouldn't happen, you'll found a bug"), font, &white);
+	s3 = BlackOutline( _("Please report this problem to"), font, &white);
+
+	/* we always want the URL in english */
+	/* NOTE: all fonts are almost certain to include glyphs for ASCII, */
+	/* so the following "english_font" hackery is probably unnecessary: */
+	if (!settings.use_english)
+	{
+		TTF_Font *english_font;
+		settings.use_english = 1;
+		english_font = LoadFont(DEFAULT_MENU_FONT, MENU_FONT_SIZE);
+		s4 = BlackOutline( "[EMAIL PROTECTED]", english_font, &white);
+		TTF_CloseFont(english_font);
+		settings.use_english = 0;
+	}
+	else 
+		s4 = BlackOutline( "[EMAIL PROTECTED]", font, &white);
+
+	tux = LoadSprite("tux/tux-egypt", IMG_ALPHA);
+	bk = LoadImage("main_bkg.png", IMG_REGULAR);
+
+	if (s1 && s2 && s3 && s4 && tux && bk)
+	{
+		LOG( "ErrorOccured() - drawing screen\n" );
+
+		SDL_BlitSurface(bk, NULL, screen, NULL);
+		loc.x = 320-(s1->w/2); loc.y = 10;
+		SDL_BlitSurface( s1, NULL, screen, &loc);
+		loc.x = 320-(s2->w/2); loc.y = 60;
+		SDL_BlitSurface( s2, NULL, screen, &loc);
+		loc.x = 320-(s3->w/2); loc.y = 400;
+		SDL_BlitSurface( s3, NULL, screen, &loc);
+		loc.x = 320-(s4->w/2); loc.y = 440;
+		SDL_BlitSurface( s4, NULL, screen, &loc);
+
+		loc.x = 320-(tux->frame[0]->w/2);
+		loc.y = 200;
+		loc.w = tux->frame[0]->w;
+		loc.h = tux->frame[0]->h;
+		SDL_BlitSurface( tux->frame[tux->cur], NULL, screen, &loc);
+
+		SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+		i = 0;
+
+		while (!finished)
+		{
+			while (SDL_PollEvent(&event)) 
+			{
+				switch (event.type)
+				{
+					case SDL_QUIT:
+						exit(0);
+					case SDL_MOUSEBUTTONDOWN:
+					case SDL_KEYDOWN:
+						TitleScreen();
+						exit(0);
+				}
+			}
+
+			i++;
+
+			if (i %5 == 0)
+			{
+				NEXT_FRAME(tux);
+				SDL_BlitSurface(bk, &loc, screen, &loc);
+				SDL_BlitSurface(tux->frame[tux->cur], NULL, screen, &loc);
+				SDL_UpdateRect(screen, loc.x, loc.y, loc.w, loc.h);
+			}
+
+			SDL_Delay(40);
+		}
+	}
+	else
+		fprintf(stderr, "ErrorOccured() - could not load needed graphic\n");
+
+	SDL_FreeSurface(s1);
+	SDL_FreeSurface(s2);
+	SDL_FreeSurface(s3);
+	SDL_FreeSurface(s4);
+	SDL_FreeSurface(bk);
+	s1 = s2 = s3 = s4 = bk = NULL;
+	FreeSprite(tux);
+	tux = NULL;
+}
+
+
+
+
 /************************************************************************/
 /*                                                                      */ 
 /*       "Private" functions (local to titlescreen.c)                   */
Index: laser.c
===================================================================
--- laser.c	(Revision 456)
+++ laser.c	(Arbeitskopie)
@@ -830,6 +830,11 @@
           int i = 0;
           comet_type* prev_comet = NULL;
 
+          /* Do nothing if word is a NULL pointer. This could happen for example if a char  *
+             in a word is not listed keyboard.lst of this specific language. It would imho  *
+             be nicer to get here a warning or a error and not a tux waiting for nothing.   *
+             This have to be fixed later.                                                   */
+          if (word != NULL) {
           DEBUGCODE {fprintf(stderr, "word is: %S\tlength is: %d\n", word, (int)wcslen(word));}
           do
           { 
@@ -866,11 +871,14 @@
 				DEBUGCODE {fprintf(stderr, "Assigning letter to comet: %C\n", word[i]);}
 			}
 		}
+		} else {
+			DEBUGCODE {fprintf(stderr, "word was pointer to NULL, showing error dialog\n");}
+			error_occured();
+		}
 	}
 	LOG ("Leaving laser_add_comet()\n");
 }
 
-
 /* Draw numbers/symbols over the attacker: */
 
 static void laser_draw_let(wchar_t c, int x, int y)
Index: funcs.h
===================================================================
--- funcs.h	(Revision 456)
+++ funcs.h	(Arbeitskopie)
@@ -119,4 +119,5 @@
 /* In titlescreen.c: */
 void SwitchScreenMode(void);
 void TitleScreen(void);
+void error_occured(void);
 
Index: keyboard.lst
===================================================================
--- keyboard.lst	(Revision 456)
+++ keyboard.lst	(Arbeitskopie)
@@ -54,7 +54,7 @@
 5| 
 0|!
 0|@
-0|#
+9|#
 0|1
 0|2
 0|3
@@ -67,4 +67,14 @@
 0|0
 7|,
 8|.
-9|;
+7|;
+8|:
+9|-
+9|_
+9|ö
+9|Ö
+9|ü
+9|Ü
+9|ö
+9|Ö
+9|ß

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to