JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
hmm...apparently you can't strdup a NULL pointer :)
authorJoshua Grams <josh@qualdan.com>
Sun, 2 Jan 2005 21:45:35 +0000 (21:45 +0000)
committerJoshua Grams <josh@qualdan.com>
Sun, 2 Jan 2005 21:45:35 +0000 (21:45 +0000)
renamed load_file to add_path, changed all callers

file.c
file.h
main.c
score.c
sound.c

diff --git a/file.c b/file.c
index a8f9ff4..57cfc56 100644 (file)
--- 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 (file)
--- 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 (file)
--- 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<NROCKS; i++) {
                char a[100];
 
-               sprintf(a,load_file("sprites/rock%d.png"),i);
+               sprintf(a,add_path("sprites/rock%d.png"),i);
                NULLERROR(temp = IMG_Load(a));
                NULLERROR(surf_rock[i] = SDL_DisplayFormat(temp));
 
-               sprintf(a,load_file("sprites/deadrock%d.png"),i);
+               sprintf(a,add_path("sprites/deadrock%d.png"),i);
                NULLERROR(temp = IMG_Load(a));
                NULLERROR(surf_deadrock[i] = SDL_DisplayFormat(temp));
        }
diff --git a/score.c b/score.c
index ac619dd..e49e956 100644 (file)
--- a/score.c
+++ b/score.c
@@ -1,3 +1,21 @@
+/* Variations on RockDodger
+ * Copyright (C) 2004 Joshua Grams <josh@qualdan.com>
+ *
+ * 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"
 
 // 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 (file)
--- 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<NUM_TUNES; i++) {
-       if (!(music[i] = Mix_LoadMUS(load_file(tune_file[i])))) {
-           printf ("Failed to load %s\n",load_file(tune_file[i]));
+       if (!(music[i] = Mix_LoadMUS(add_path(tune_file[i])))) {
+           printf ("Failed to load %s\n",add_path(tune_file[i]));
        }
     }
 
     // Preload all the wav files into memory
     for (i=0; i<NUM_SOUNDS; i++) {
-       wav[i] = Mix_LoadWAV(load_file(wav_file[i]));
+       wav[i] = Mix_LoadWAV(add_path(wav_file[i]));
     }
 
     return 1;