~ubuntu-branches/ubuntu/lucid/tuxtype/lucid-proposed

« back to all changes in this revision

Viewing changes to debian/patches/120_fix-null-pointer.patch

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-08-27 22:11:15 UTC
  • Revision ID: james.westby@ubuntu.com-20080827221115-mj64qs9tm0akmbeb
Tags: 1.5.17.dfsg1-3ubuntu1
* Merge from debian unstable. (LP: #261991) remaining changes:
  - merge conflicting greek and malayalam translations
+ debian/tuxtype.desktop:
  - add X-Ubuntu-Gettext-Domain=tuxtype
  * add missing semicolon in the Categories section

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -Nurwd orig/tuxtype-1.5.17.dfsg1/tuxtype/funcs.h tuxtype-1.5.17.dfsg1/tuxtype/funcs.h
 
2
--- orig/tuxtype-1.5.17.dfsg1/tuxtype/funcs.h   2008-07-05 14:19:19.000000000 +0200
 
3
+++ tuxtype-1.5.17.dfsg1/tuxtype/funcs.h        2008-07-05 14:19:30.000000000 +0200
 
4
@@ -119,4 +119,5 @@
 
5
 /* In titlescreen.c: */
 
6
 void SwitchScreenMode(void);
 
7
 void TitleScreen(void);
 
8
+void error_occured(void);
 
9
 
 
10
diff -Nurwd orig/tuxtype-1.5.17.dfsg1/tuxtype/laser.c tuxtype-1.5.17.dfsg1/tuxtype/laser.c
 
11
--- orig/tuxtype-1.5.17.dfsg1/tuxtype/laser.c   2008-07-05 14:19:19.000000000 +0200
 
12
+++ tuxtype-1.5.17.dfsg1/tuxtype/laser.c        2008-07-05 14:19:30.000000000 +0200
 
13
@@ -829,6 +829,11 @@
 
14
           int i = 0;
 
15
           comet_type* prev_comet = NULL;
 
16
 
 
17
+          /* Do nothing if word is a NULL pointer. This could happen for example if a char  *
 
18
+             in a word is not listed keyboard.lst of this specific language. It would imho  *
 
19
+             be nicer to get here a warning or a error and not a tux waiting for nothing.   *
 
20
+             This have to be fixed later.                                                   */
 
21
+          if (word != NULL) {
 
22
           DEBUGCODE {fprintf(stderr, "word is: %S\tlength is: %d\n", word, (int)wcslen(word));}
 
23
           do
 
24
           { 
 
25
@@ -865,11 +870,14 @@
 
26
                                DEBUGCODE {fprintf(stderr, "Assigning letter to comet: %C\n", word[i]);}
 
27
                        }
 
28
                }
 
29
+               } else {
 
30
+                       DEBUGCODE {fprintf(stderr, "word was pointer to NULL, showing error dialog\n");}
 
31
+                       error_occured();
 
32
+               }
 
33
        }
 
34
        LOG ("Leaving laser_add_comet()\n");
 
35
 }
 
36
 
 
37
-
 
38
 /* Draw numbers/symbols over the attacker: */
 
39
 
 
40
 static void laser_draw_let(wchar_t c, int x, int y)
 
41
diff -Nurwd orig/tuxtype-1.5.17.dfsg1/tuxtype/titlescreen.c tuxtype-1.5.17.dfsg1/tuxtype/titlescreen.c
 
42
--- orig/tuxtype-1.5.17.dfsg1/tuxtype/titlescreen.c     2008-07-05 14:19:19.000000000 +0200
 
43
+++ tuxtype-1.5.17.dfsg1/tuxtype/titlescreen.c  2008-07-05 14:19:30.000000000 +0200
 
44
@@ -867,6 +867,109 @@
 
45
   settings.fullscreen = !settings.fullscreen;
 
46
 }
 
47
 
 
48
+/*Derived from not_implemented: should only be shown if an error occurs somewhere */
 
49
+void error_occured(void)
 
50
+{
 
51
+       SDL_Surface* bk = NULL;
 
52
+       SDL_Surface *s1 = NULL, *s2 = NULL, *s3 = NULL, *s4 = NULL;
 
53
+       sprite* tux = NULL;
 
54
+       SDL_Rect loc;
 
55
+       int finished = 0, i;
 
56
+
 
57
+       LOG( "ErrorOccured() - creating text\n" );
 
58
+       /* if no font is set, use default ones */
 
59
+       if (!font) 
 
60
+               font = LoadFont(DEFAULT_MENU_FONT, MENU_FONT_SIZE);
 
61
+
 
62
+       s1 = BlackOutline( _("An error occured"), font, &white);
 
63
+       s2 = BlackOutline( _("This shouldn't happen, you'll found a bug"), font, &white);
 
64
+       s3 = BlackOutline( _("Please report this problem to"), font, &white);
 
65
+
 
66
+       /* we always want the URL in english */
 
67
+       /* NOTE: all fonts are almost certain to include glyphs for ASCII, */
 
68
+       /* so the following "english_font" hackery is probably unnecessary: */
 
69
+       if (!settings.use_english)
 
70
+       {
 
71
+               TTF_Font *english_font;
 
72
+               settings.use_english = 1;
 
73
+               english_font = LoadFont(DEFAULT_MENU_FONT, MENU_FONT_SIZE);
 
74
+               s4 = BlackOutline( "tux4kids-tuxtype-dev@lists.alioth.debian.org", english_font, &white);
 
75
+               TTF_CloseFont(english_font);
 
76
+               settings.use_english = 0;
 
77
+       }
 
78
+       else 
 
79
+               s4 = BlackOutline( "tux4kids-tuxtype-dev@lists.alioth.debian.org", font, &white);
 
80
+
 
81
+       tux = LoadSprite("tux/tux-egypt", IMG_ALPHA);
 
82
+       bk = LoadImage("main_bkg.png", IMG_REGULAR);
 
83
+
 
84
+       if (s1 && s2 && s3 && s4 && tux && bk)
 
85
+       {
 
86
+               LOG( "ErrorOccured() - drawing screen\n" );
 
87
+
 
88
+               SDL_BlitSurface(bk, NULL, screen, NULL);
 
89
+               loc.x = 320-(s1->w/2); loc.y = 10;
 
90
+               SDL_BlitSurface( s1, NULL, screen, &loc);
 
91
+               loc.x = 320-(s2->w/2); loc.y = 60;
 
92
+               SDL_BlitSurface( s2, NULL, screen, &loc);
 
93
+               loc.x = 320-(s3->w/2); loc.y = 400;
 
94
+               SDL_BlitSurface( s3, NULL, screen, &loc);
 
95
+               loc.x = 320-(s4->w/2); loc.y = 440;
 
96
+               SDL_BlitSurface( s4, NULL, screen, &loc);
 
97
+
 
98
+               loc.x = 320-(tux->frame[0]->w/2);
 
99
+               loc.y = 200;
 
100
+               loc.w = tux->frame[0]->w;
 
101
+               loc.h = tux->frame[0]->h;
 
102
+               SDL_BlitSurface( tux->frame[tux->cur], NULL, screen, &loc);
 
103
+
 
104
+               SDL_UpdateRect(screen, 0, 0, 0, 0);
 
105
+
 
106
+               i = 0;
 
107
+
 
108
+               while (!finished)
 
109
+               {
 
110
+                       while (SDL_PollEvent(&event)) 
 
111
+                       {
 
112
+                               switch (event.type)
 
113
+                               {
 
114
+                                       case SDL_QUIT:
 
115
+                                               exit(0);
 
116
+                                       case SDL_MOUSEBUTTONDOWN:
 
117
+                                       case SDL_KEYDOWN:
 
118
+                                               TitleScreen();
 
119
+                                               exit(0);
 
120
+                               }
 
121
+                       }
 
122
+
 
123
+                       i++;
 
124
+
 
125
+                       if (i %5 == 0)
 
126
+                       {
 
127
+                               NEXT_FRAME(tux);
 
128
+                               SDL_BlitSurface(bk, &loc, screen, &loc);
 
129
+                               SDL_BlitSurface(tux->frame[tux->cur], NULL, screen, &loc);
 
130
+                               SDL_UpdateRect(screen, loc.x, loc.y, loc.w, loc.h);
 
131
+                       }
 
132
+
 
133
+                       SDL_Delay(40);
 
134
+               }
 
135
+       }
 
136
+       else
 
137
+               fprintf(stderr, "ErrorOccured() - could not load needed graphic\n");
 
138
+
 
139
+       SDL_FreeSurface(s1);
 
140
+       SDL_FreeSurface(s2);
 
141
+       SDL_FreeSurface(s3);
 
142
+       SDL_FreeSurface(s4);
 
143
+       SDL_FreeSurface(bk);
 
144
+       s1 = s2 = s3 = s4 = bk = NULL;
 
145
+       FreeSprite(tux);
 
146
+       tux = NULL;
 
147
+}
 
148
+
 
149
+
 
150
+
 
151
 
 
152
 /************************************************************************/
 
153
 /*                                                                      */