[Tux4kids-commits] r881 - tuxtype/trunk/src
dbruce-guest at alioth.debian.org
dbruce-guest at alioth.debian.org
Thu Feb 12 23:09:38 UTC 2009
Author: dbruce-guest
Date: 2009-02-12 23:09:37 +0000 (Thu, 12 Feb 2009)
New Revision: 881
Modified:
tuxtype/trunk/src/laser.c
tuxtype/trunk/src/laser.h
tuxtype/trunk/src/loaders.c
tuxtype/trunk/src/playgame.c
tuxtype/trunk/src/playgame.h
tuxtype/trunk/src/setup.c
tuxtype/trunk/src/titlescreen.c
Log:
more code cleanup to fix compiler warnings
Modified: tuxtype/trunk/src/laser.c
===================================================================
--- tuxtype/trunk/src/laser.c 2009-02-10 22:58:31 UTC (rev 880)
+++ tuxtype/trunk/src/laser.c 2009-02-12 23:09:37 UTC (rev 881)
@@ -19,6 +19,7 @@
#include "globals.h"
#include "funcs.h"
+#include "SDL_extras.h"
#include "laser.h"
@@ -53,7 +54,7 @@
static void laser_draw_console_image(int i);
static void laser_draw_let(wchar_t c, int x, int y);
static void laser_draw_line(int x1, int y1, int x2, int y2, int r, int g, int b);
-static void laser_draw_numbers(const unsigned char* str, int x);
+static void laser_draw_numbers(const char* str, int x);
static void laser_load_data(void);
static void laser_reset_level(int diff_level);
static void laser_putpixel(SDL_Surface* surface, int x, int y, Uint32 pixel);
@@ -76,11 +77,12 @@
Uint16 key_unicode;
SDL_Event event;
- Uint32 last_time, now_time;
+ Uint32 last_time = 0;
+ Uint32 now_time = 0;
SDLKey key;
SDL_Rect src, dest;
/* str[] is a buffer to draw the scores, waves, etc. (don't need wchar_t) */
- unsigned char str[64];
+ char str[64];
LOG( "starting Comet Zap game\n" );
DOUT( diff_level );
@@ -317,7 +319,7 @@
while (tux_img == old_tux_img)
tux_img = IMG_TUX_CONSOLE1 + (rand() % 3);
- playsound(sounds[SND_CLICK]);
+ PlaySound(sounds[SND_CLICK]);
}
@@ -754,7 +756,7 @@
static void laser_reset_level(int diff_level)
{
- unsigned char fname[1024];
+ char fname[1024];
static int last_bkgd = -1;
int i;
@@ -778,8 +780,7 @@
sprintf(fname, "backgrounds/%d.jpg", i);
- LOG("Will try to load file:");
- LOG(fname);
+ DEBUGCODE { fprintf(stderr, "Will try to load file:\t%s", fname); }
FreeBothBkgds(); // LoadBothBkgds() actually does this just in case
@@ -934,12 +935,11 @@
/* Draw status numbers: */
-static void laser_draw_numbers(const unsigned char* str, int x)
+static void laser_draw_numbers(const char* str, int x)
{
int i, cur_x, c;
SDL_Rect src, dest;
-
cur_x = x;
@@ -949,7 +949,6 @@
{
c = -1;
-
/* Determine which character to display: */
if (str[i] >= '0' && str[i] <= '9')
Modified: tuxtype/trunk/src/laser.h
===================================================================
--- tuxtype/trunk/src/laser.h 2009-02-10 22:58:31 UTC (rev 880)
+++ tuxtype/trunk/src/laser.h 2009-02-12 23:09:37 UTC (rev 881)
@@ -90,7 +90,7 @@
};
-static unsigned char * image_filenames[NUM_IMAGES] = {
+static char* image_filenames[NUM_IMAGES] = {
"status/tux_helmet1.png",
"status/tux_helmet2.png",
"status/tux_helmet3.png",
@@ -161,7 +161,7 @@
};
-static unsigned char * sound_filenames[NUM_SOUNDS] = {
+static char* sound_filenames[NUM_SOUNDS] = {
"pop.wav",
"laser.wav",
"buzz.wav",
@@ -179,7 +179,7 @@
NUM_MUSICS
};
-static unsigned char * music_filenames[NUM_MUSICS] = {
+static char * music_filenames[NUM_MUSICS] = {
"game.mod",
"game2.mod",
"game3.mod"
Modified: tuxtype/trunk/src/loaders.c
===================================================================
--- tuxtype/trunk/src/loaders.c 2009-02-10 22:58:31 UTC (rev 880)
+++ tuxtype/trunk/src/loaders.c 2009-02-12 23:09:37 UTC (rev 881)
@@ -121,7 +121,6 @@
{
TTF_Font* loaded_font = NULL;
char fn[FNLEN];
- int i;
/* try to find font in default data dir: */
sprintf(fn, "%s/fonts/%s", settings.default_data_path, font_name );
@@ -187,7 +186,6 @@
************************/
SDL_Surface* LoadImage(const char* datafile, int mode)
{
- int oldDebug; //so we can turn off debug output for this func only
SDL_Surface* tmp_pic = NULL, *final_pic = NULL;
char fn[FNLEN];
@@ -215,12 +213,12 @@
DEBUGCODE { fprintf(stderr, "Warning: graphics file %s could not be loaded\n", fn);}
}
- /* NOTE changed this so we just return NULL instead of exiting - DSB
+ /* NOTE changed this so we just return NULL instead of exiting - DSB */
/* Couldn't load image - action depends on whether image is essential: */
if (!tmp_pic)
{
{
- DEBUGCODE { (stderr, "Warning - could not load graphics file %s\n", datafile);}
+ DEBUGCODE { fprintf(stderr, "Warning - could not load graphics file %s\n", datafile);}
return NULL;
}
Modified: tuxtype/trunk/src/playgame.c
===================================================================
--- tuxtype/trunk/src/playgame.c 2009-02-10 22:58:31 UTC (rev 880)
+++ tuxtype/trunk/src/playgame.c 2009-02-12 23:09:37 UTC (rev 881)
@@ -69,7 +69,7 @@
static void CheckCollision(int fishies, int* fish_left, int frame );
static void CheckFishies(int* fishies, int* splats);
static int check_word(int f);
-static void display_msg(const unsigned char* msg, int x, int y);
+static void display_msg(const char* msg, int x, int y);
static void DrawBackground(void);
static void draw_bar(int curlevel, int diflevel, int curlives,
int oldlives, int fish_left, int oldfish_left);
@@ -108,7 +108,7 @@
*************************************************************************/
int PlayCascade(int diflevel)
{
- unsigned char filename[FNLEN];
+ char filename[FNLEN];
int still_playing = 1;
int playing_level = 1;
int setup_new_level = 1;
@@ -119,7 +119,7 @@
int curlives;
int oldlives = 0;
int oldfish_left = 0;
- int fish_left;
+ int fish_left = 0;
int fishies = 0;
int local_max_fishies = 1;
int frame = 0;
@@ -1096,7 +1096,7 @@
static void LoadOthers(void)
{
int i;
- unsigned char filename[FNLEN];
+ char filename[FNLEN];
LOG( "=LoadOthers()\n" );
DEBUGCODE
@@ -1170,7 +1170,7 @@
LOG( "=LoadOthers() END\n" );
}
-static void display_msg(const unsigned char* msg, int x, int y)
+static void display_msg(const char* msg, int x, int y)
{
if (msg == NULL || msg[0] == '\0')
return;
@@ -1244,7 +1244,7 @@
// number = 5 and places = 2, would draw "05")
// if places = 0, then will simply display as
// many as necessary
- unsigned char numnuts[FNLEN];
+ char numnuts[FNLEN];
int needed_places, i;
int uddernumber;
@@ -1288,7 +1288,7 @@
// number = 5 and places = 2, would draw "05")
// if places = 0, then will simply display as
// many as necessary
- unsigned char numnuts[FNLEN];
+ char numnuts[FNLEN];
int needed_places, i;
int uddernumber;
Modified: tuxtype/trunk/src/playgame.h
===================================================================
--- tuxtype/trunk/src/playgame.h 2009-02-10 22:58:31 UTC (rev 880)
+++ tuxtype/trunk/src/playgame.h 2009-02-12 23:09:37 UTC (rev 881)
@@ -112,7 +112,7 @@
TUX_NUM_STATES
};
-static unsigned char* tux_sprite_fns[TUX_NUM_STATES] = {
+static char* tux_sprite_fns[TUX_NUM_STATES] = {
"tux/walk",
"tux/stand",
"tux/run",
Modified: tuxtype/trunk/src/setup.c
===================================================================
--- tuxtype/trunk/src/setup.c 2009-02-10 22:58:31 UTC (rev 880)
+++ tuxtype/trunk/src/setup.c 2009-02-12 23:09:37 UTC (rev 881)
@@ -271,7 +271,8 @@
/* we load all the settings here */
while (!feof(fp))
{
- fscanf(fp, "%[^=]=%[^\n]\n", setting, value );
+ if (EOF == fscanf(fp, "%[^=]=%[^\n]\n", setting, value))
+ break;
DEBUGCODE {fprintf(stderr, "%s = %s", setting, value );}
//For now we are not reading or saving the language selection:
@@ -405,7 +406,6 @@
int SetupPaths(const char* theme_dir)
{
- int i;
settings.use_english = 1; // default is to use English if we cannot find theme
if (CheckFile(DATA_PREFIX))
@@ -416,7 +416,7 @@
else
{
fprintf(stderr, "Error - DATA_PREFIX = '%s' not found!\n", DATA_PREFIX);
- return;
+ return 0;
}
/* Now look for theme directory: */
Modified: tuxtype/trunk/src/titlescreen.c
===================================================================
--- tuxtype/trunk/src/titlescreen.c 2009-02-10 22:58:31 UTC (rev 880)
+++ tuxtype/trunk/src/titlescreen.c 2009-02-12 23:09:37 UTC (rev 881)
@@ -27,14 +27,10 @@
/* images of regular and selected text of menu items: */
static SDL_Surface* reg_text[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {{NULL}};
-static SDL_Surface* sel_text[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {NULL};
+static SDL_Surface* sel_text[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {{NULL}};
/* this will contain pointers to all of the menu 'icons' */
-static sprite* menu_gfx[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {NULL};
+static sprite* menu_gfx[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {{NULL}};
-/* Background images for windowed and fullscreen modes: */
-static SDL_Surface* win_bkgd = NULL; //640x480 background (windowed)
-static SDL_Surface* fullscr_bkgd = NULL; //native resolution (fullscreen)
-
/* --- other media --- */
static SDL_Surface* title = NULL;
static SDL_Surface* speaker = NULL;
@@ -63,7 +59,7 @@
static void load_menu(void);
static void recalc_rects(void);
static int chooseWordlist(void);
-static void ChooseWord(char *words_file);
+static void ChooseWord(char* words_file);
static void ChooseFile(void);
static void unload_media(void);
static void unload_menu(void);
@@ -73,7 +69,7 @@
/* --- define menu structure --- */
/* (these values are all in the Game_Type enum in globals.h) */
-const int menu_item[][6]= {{0, 0, 0, 0, 0},
+const int menu_item[][6] = {{0, 0, 0, 0, 0},
{0, CASCADE, LEVEL1, LEVEL1, EDIT_WORDLIST },
{0, LASER, LEVEL2, LEVEL2, PHRASE_TYPING },
{0, LESSONS, LEVEL3, LEVEL3, PROJECT_INFO },
@@ -81,7 +77,7 @@
{0, QUIT_GAME, MAIN, MAIN, MAIN }};
/* --- menu icons --- */
-const unsigned char *menu_icon[][6]=
+const char* menu_icon[][6] =
{{"", "", "", "", ""},
{"", "cascade", "easy", "grade1_", "list" },
{"", "comet", "medium", "grade2_", "practice" },
@@ -90,7 +86,7 @@
{"", "quit", "main", "main", "main" }};
-static const char *menu_text[]=
+static const char* menu_text[] =
{"", "", "", "", "" ,
"",gettext_noop("Fish Cascade"),gettext_noop("Easy"),gettext_noop("Space Cadet"),gettext_noop("Edit Word Lists"),
"",gettext_noop("Comet Zap"),gettext_noop("Medium"),gettext_noop("Pilot"),gettext_noop("Phrase Typing"),
@@ -132,11 +128,6 @@
int redraw = 0;
int key_menu = 1;
int old_key_menu = 5;
-// wchar_t phrase[128];
-// FILE *fp;
-// unsigned char fn[FNLEN];
-// int found = 0;
- unsigned char str[1000];
if (settings.sys_sound)
@@ -145,12 +136,6 @@
settings.menu_music = 1;
}
-
- /* FIXME phrase(s) should come from file */
-
-// ConvertFromUTF8(phrase, "The quick brown fox jumps over the lazy dog.");
-
-// wcscpy(phrase, "Now is the time for all good men to come to the aid of their country.");
start = SDL_GetTicks();
@@ -904,7 +889,7 @@
/* animated sprites, if any. */
static void load_menu(void)
{
- unsigned char fn[FNLEN];
+ char fn[FNLEN];
int max, i, j;
SDL_ShowCursor(1);
@@ -919,12 +904,12 @@
DEBUGCODE
{
fprintf(stderr, "i = '%d'\tj = '%d'\ttext = '%s'\n",
- i, j, gettext((unsigned char*)menu_text[j+5*i]));
+ i, j, gettext(menu_text[j + 5 * i]));
}
/* --- create text surfaces --- */
- reg_text[i][j] = BlackOutline( gettext((unsigned char*)menu_text[j+5*i]), font, &white);
- sel_text[i][j] = BlackOutline( gettext((unsigned char*)menu_text[j+5*i]), font, &yellow);
+ reg_text[i][j] = BlackOutline( gettext(menu_text[j + 5 * i]), font, &white);
+ sel_text[i][j] = BlackOutline( gettext(menu_text[j + 5 * i]), font, &yellow);
/* (first make sure ptr valid to avoid segfault) */
if (sel_text[i][j] && sel_text[i][j]->w > max)
@@ -1253,9 +1238,10 @@
int old_loc = 1;
int lists = 0;
int i;
- unsigned char wordPath[FNLEN];
- unsigned char wordlistFile[MAX_WORD_LISTS][200];
- unsigned char wordlistName[MAX_WORD_LISTS][200];
+ int result = 0;;
+ char wordPath[FNLEN];
+ char wordlistFile[MAX_WORD_LISTS][200];
+ char wordlistName[MAX_WORD_LISTS][200];
DIR* wordsDir = NULL;
struct dirent* wordsFile = NULL;
@@ -1316,7 +1302,9 @@
if (!tempFile)
continue;
- fscanf(tempFile, "%[^\n]\n", wordlistName[lists]);
+ result = fscanf(tempFile, "%[^\n]\n", wordlistName[lists]);
+ if (result == EOF)
+ continue;
/* check to see if it has a \r at the end of it (dos format!) */
if (wordlistName[lists][strlen(wordlistName[lists]) - 1] == '\r')
@@ -1543,7 +1531,6 @@
{
SDL_Surface* titles[MAX_WORD_LISTS] = {NULL};
SDL_Surface* select[MAX_WORD_LISTS] = {NULL};
- SDL_Surface *photo = NULL;
SDL_Surface* bkg = NULL;
TTF_Font* font = NULL;
SDL_Rect titleRects[8];
@@ -1553,14 +1540,14 @@
int themes = 0;
int i;
- unsigned char fn[FNLEN];
- unsigned char wordTypes[MAX_WORD_LISTS][FNLEN];
- unsigned char fileNames[MAX_WORD_LISTS][FNLEN];
+ char fn[FNLEN];
+ char wordTypes[MAX_WORD_LISTS][FNLEN];
+ char fileNames[MAX_WORD_LISTS][FNLEN];
int old_use_english;
char old_theme_path[FNLEN];
- FILE *fp;
+ FILE* fp;
DIR* themesDir = NULL;
struct dirent* themesFile = NULL;
@@ -1617,7 +1604,8 @@
/* We know it opens safely because CheckFile() returned 1 */
fp = fopen(fn,"r");
/* HACK: we should get the names from file :) */
- fscanf(fp, "%[^\n]\n", wordTypes[themes]);
+ if (EOF ==fscanf(fp, "%[^\n]\n", wordTypes[themes]))
+ continue;
/* Make sure theme name is capitalized: */
wordTypes[themes][0] = toupper(wordTypes[themes][0]);
fclose(fp);
@@ -1774,23 +1762,22 @@
SDL_Surface* select[MAX_WORD_LISTS] = {NULL};
SDL_Surface* left = NULL, *right = NULL;
SDL_Rect leftRect, rightRect;
- SDL_Surface* photo = NULL;
SDL_Surface* bkg = NULL;
TTF_Font* font = NULL;
- SDL_Rect worldRect, photoRect;
SDL_Rect titleRects[8];
int stop = 0;
int loc = 0;
int old_loc = 1;
+ int result = 0;
- FILE *fp;
+ FILE* fp = NULL;
int start,themes,themest = 0;
int i,len;
- unsigned char fn[FNLEN];
- unsigned char str[FNLEN];
- unsigned char editWordW[MAX_WORD_LISTS][FNLEN];
- unsigned char editWordY[MAX_WORD_LISTS][FNLEN];
+ char fn[FNLEN];
+ char str[FNLEN];
+ char editWordW[MAX_WORD_LISTS][FNLEN];
+ char editWordY[MAX_WORD_LISTS][FNLEN];
wchar_t temp[FNLEN];
@@ -1810,13 +1797,14 @@
sprintf(fn , "%s/words/%s", settings.theme_data_path,words_file);
}
- fp=fopen(fn,"r");
- fscanf(fp, "%[^\n]\n", str);
+ fp = fopen(fn,"r");
+ result = fscanf(fp, "%[^\n]\n", str);
while(!feof(fp))
{
/* HACK: we should get the strings from file :) */
- fscanf(fp, "%[^\n]\n", editWordW[themes]);
+ if (EOF ==fscanf(fp, "%[^\n]\n", editWordW[themes]))
+ continue;
themest=themes;
strcpy(editWordY[themes++],editWordW[themest]);
}
More information about the Tux4kids-commits
mailing list