From e10d6c0b95e2f4fe7acd75733370dae71bb3b73f Mon Sep 17 00:00:00 2001 From: Joshua Grams Date: Sun, 2 Jan 2005 21:45:35 +0000 Subject: [PATCH] hmm...apparently you can't strdup a NULL pointer :) renamed load_file to add_path, changed all callers --- file.c | 5 +++-- file.h | 2 +- main.c | 22 +++++++++++----------- score.c | 34 ++++++++++++++++++++++++++-------- sound.c | 8 ++++---- 5 files changed, 45 insertions(+), 26 deletions(-) diff --git a/file.c b/file.c index a8f9ff4..57cfc56 100644 --- a/file.c +++ b/file.c @@ -31,7 +31,7 @@ char *g_score_file; mode_t g_score_mode; char * -load_file(char *filename) +add_path(char *filename) { static char r[MAX_PATH_LEN]; snprintf(r, MAX_PATH_LEN, "%s/%s", g_data_dir, filename); @@ -65,6 +65,7 @@ find_data_dir(void) }; for(i=0; i<3; i++) { + if(!data_options[i]) continue; g_data_dir = strdup(data_options[i]); if(is_dir(g_data_dir)) return true; } @@ -79,7 +80,7 @@ find_data_dir(void) int find_score_file(void) { - g_score_file = load_file("scores"); + g_score_file = add_path("scores"); g_score_mode = 0111; if(is_file(g_score_file)) return true; diff --git a/file.h b/file.h index 806772c..14092ce 100644 --- a/file.h +++ b/file.h @@ -26,7 +26,7 @@ extern char *g_data_dir; extern char *g_score_file; extern mode_t g_score_mode; -char *load_file(char *filename); +char *add_path(char *filename); int is_dir(char *dirname); int is_file(char *filename); int find_data_dir(void); diff --git a/main.c b/main.c index be5444b..4942aa2 100644 --- a/main.c +++ b/main.c @@ -111,7 +111,7 @@ char *initerror = ""; float xship,yship = 240.0; // X position, 0..XSIZE float xvel,yvel; // Change in X position per tick. float rockrate,rockspeed; -float movementrate; +float movementrate; // this controls the speed of everything that moves. float yscroll; float scrollvel; @@ -517,30 +517,30 @@ init(int fullscreen) { } // Load the banners - NULLERROR(temp = IMG_Load(load_file("banners/variations.png"))); + NULLERROR(temp = IMG_Load(add_path("banners/variations.png"))); NULLERROR(surf_b_variations = SDL_DisplayFormat(temp)); - NULLERROR(temp = IMG_Load(load_file("banners/on.png"))); + NULLERROR(temp = IMG_Load(add_path("banners/on.png"))); NULLERROR(surf_b_on = SDL_DisplayFormat(temp)); - NULLERROR(temp = IMG_Load(load_file("banners/rockdodger.png"))); + NULLERROR(temp = IMG_Load(add_path("banners/rockdodger.png"))); NULLERROR(surf_b_rockdodger = SDL_DisplayFormat(temp)); - NULLERROR(temp = IMG_Load(load_file("banners/game.png"))); + NULLERROR(temp = IMG_Load(add_path("banners/game.png"))); NULLERROR(surf_b_game = SDL_DisplayFormat(temp)); - NULLERROR(temp = IMG_Load(load_file("banners/over.png"))); + NULLERROR(temp = IMG_Load(add_path("banners/over.png"))); NULLERROR(surf_b_over = SDL_DisplayFormat(temp)); - surf_font_big = IMG_Load(load_file(BIG_FONT_FILE)); + surf_font_big = IMG_Load(add_path(BIG_FONT_FILE)); g_font = SFont_InitFont(surf_font_big); // Load the spaceship graphic. - NULLERROR(temp = IMG_Load(load_file("sprites/ship.png"))); + NULLERROR(temp = IMG_Load(add_path("sprites/ship.png"))); NULLERROR(surf_ship = SDL_DisplayFormat(temp)); // Load the life indicator (small ship) graphic. - NULLERROR(temp = IMG_Load(load_file("indicators/life.png"))); + NULLERROR(temp = IMG_Load(add_path("indicators/life.png"))); NULLERROR(surf_life = SDL_DisplayFormat(temp)); // Create the array of black points; @@ -565,11 +565,11 @@ init(int fullscreen) { for(i = 0; i + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include "config.h" #include "SFont.h" @@ -13,14 +31,14 @@ // High score table struct highscore g_scores[N_SCORES] = { - {13000,"Pad"}, - {12500,"Pad"}, - {6500,"Pad"}, - {5000,"Pad"}, - {3000,"Pad"}, - {2500,"Pad"}, - {2000,"Pad"}, - {1500,"Pad"} + {1*60*1000,"-"}, + {45*1000,"-"}, + {30*1000,"-"}, + {20*1000,"-"}, + {10*1000,"-"}, + {7*1000,"-"}, + {5*1000,"-"}, + {3*1000,"-"} }; extern SFont_Font *g_font; diff --git a/sound.c b/sound.c index aafff76..3f13e0e 100644 --- a/sound.c +++ b/sound.c @@ -21,7 +21,7 @@ int audio_rate; Uint16 audio_format; int audio_channels; -char *load_file(char *); +char *add_path(char *); char *wav_file[] = { "sounds/booom.wav", "sounds/cboom.wav", @@ -61,14 +61,14 @@ init_sound() { // Preload all the tunes into memory for (i=0; i