[Super-tux-commit] supertux/src Makefile.am,1.10,1.11 globals.h,1.18,1.19 high_scores.cpp,1.5,1.6 hi
Brought to you by:
wkendrick
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8467 Modified Files: Makefile.am globals.h high_scores.cpp high_scores.h setup.cpp setup.h sound.cpp sound.h supertux.cpp worldmap.cpp Log Message: - commited Michael George's config-file patch Index: high_scores.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/high_scores.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- high_scores.cpp 24 Mar 2004 13:52:34 -0000 1.5 +++ high_scores.cpp 24 Mar 2004 14:35:11 -0000 1.6 @@ -15,47 +15,16 @@ #include "menu.h" #include "screen.h" #include "texture.h" +#include "setup.h" -int hs_score; -char hs_name[62]; /* highscores global variables*/ - -FILE * opendata(char * mode) -{ - char * filename = NULL; - FILE * fi; - - - filename = (char *) malloc(sizeof(char) * (strlen(st_dir) + - strlen("/st_highscore.dat") + 1)); - - strcpy(filename, st_dir); - /* Open the high score file: */ - -#ifndef WIN32 - strcat(filename, "/highscore"); +#ifdef WIN32 +const char * highscore_filename = "/st_highscore.dat"; #else - strcat(filename, "/st_highscore.dat"); +const char * highscore_filename = "/highscore"; #endif - - /* Try opening the file: */ - - fi = fopen(filename, mode); - free( filename ); - - if (fi == NULL) - { - fprintf(stderr, "Warning: Unable to open the high score file "); - - if (strcmp(mode, "r") == 0) - fprintf(stderr, "for read!!!\n"); - else if (strcmp(mode, "w") == 0) - fprintf(stderr, "for write!!!\n"); - - } - - return(fi); -} +int hs_score; +char hs_name[62]; /* highscores global variables*/ /* Load data from high score file: */ @@ -72,7 +41,7 @@ /* Try to open file: */ - fi = opendata("r"); + fi = opendata(highscore_filename, "r"); if (fi != NULL) { do @@ -162,7 +131,7 @@ /* Try to open file: */ - fi = opendata("w"); + fi = opendata(highscore_filename, "w"); if (fi != NULL) { fprintf(fi, "# Supertux highscore file\n\n"); Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/src/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Makefile.am 21 Mar 2004 22:13:04 -0000 1.10 +++ Makefile.am 24 Mar 2004 14:35:10 -0000 1.11 @@ -7,6 +7,8 @@ bitmask.h \ button.cpp \ button.h \ + configfile.h \ + configfile.cpp \ collision.cpp \ collision.h \ defines.h \ Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- setup.cpp 24 Mar 2004 13:52:34 -0000 1.15 +++ setup.cpp 24 Mar 2004 14:35:11 -0000 1.16 @@ -37,6 +37,7 @@ #include "texture.h" #include "menu.h" #include "gameloop.h" +#include "configfile.h" #ifdef WIN32 #define mkdir(dir, mode) mkdir(dir) @@ -102,6 +103,36 @@ } } +FILE * opendata(const char * rel_filename, const char * mode) +{ + char * filename = NULL; + FILE * fi; + + filename = (char *) malloc(sizeof(char) * (strlen(st_dir) + + strlen(rel_filename) + 1)); + + strcpy(filename, st_dir); + /* Open the high score file: */ + + strcat(filename, rel_filename); + + /* Try opening the file: */ + fi = fopen(filename, mode); + + if (fi == NULL) + { + fprintf(stderr, "Warning: Unable to open the file \"%s\" ", filename); + + if (strcmp(mode, "r") == 0) + fprintf(stderr, "for read!!!\n"); + else if (strcmp(mode, "w") == 0) + fprintf(stderr, "for write!!!\n"); + } + free( filename ); + + return(fi); +} + /* Get all names of sub-directories in a certain directory. */ /* Returns the number of sub-directories found. */ /* Note: The user has to free the allocated space. */ @@ -310,7 +341,7 @@ } } #else - datadir = DATA_PREFIX; + datadir = DATA_PREFIX; #endif } printf("Datadir: %s\n", datadir.c_str()); @@ -781,16 +812,16 @@ { close_audio(); SDL_Quit(); + saveconfig(); } - /* --- ABORT! --- */ void st_abort(const std::string& reason, const std::string& details) { fprintf(stderr, "\nError: %s\n%s\n\n", reason.c_str(), details.c_str()); st_shutdown(); - exit(1); + abort(); } @@ -841,17 +872,7 @@ { int i; - /* Set defaults: */ - - - debug_mode = false; - use_fullscreen = false; - show_fps = false; - use_gl = false; - - use_sound = true; - use_music = true; - audio_device = true; + loadconfig(); /* Parse arguments: */ @@ -927,7 +948,7 @@ } else if (strcmp(argv[i], "--help") == 0) - { /* Show help: */ + { /* Show help: */ puts("Super Tux " VERSION "\n" " Please see the file \"README.txt\" for more details.\n"); printf("Usage: %s [OPTIONS] FILENAME\n\n", argv[0]); Index: setup.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- setup.h 24 Mar 2004 13:52:34 -0000 1.13 +++ setup.h 24 Mar 2004 14:35:11 -0000 1.14 @@ -20,6 +20,7 @@ int faccessible(const char *filename); int fcreatedir(const char* relative_dir); int fwriteable(const char *filename); +FILE * opendata(const char * filename, const char * mode); string_list_type dsubdirs(const char *rel_path, const char* expected_file); string_list_type dfiles(const char *rel_path, const char* glob, const char* exception_str); void free_strings(char **strings, int num); Index: globals.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- globals.h 23 Mar 2004 01:30:16 -0000 1.18 +++ globals.h 24 Mar 2004 14:35:11 -0000 1.19 @@ -36,7 +36,8 @@ extern bool launch_worldmap_mode; /* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */ -extern char *st_dir, *st_save_dir; +extern char* st_dir; +extern char* st_save_dir; extern SDL_Joystick * js; Index: sound.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sound.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- sound.cpp 22 Mar 2004 15:47:31 -0000 1.6 +++ sound.cpp 24 Mar 2004 14:35:11 -0000 1.7 @@ -16,9 +16,9 @@ #include "setup.h" /*global variable*/ -int use_sound; /* handle sound on/off menu and command-line option */ -int use_music; /* handle music on/off menu and command-line option */ -int audio_device; /* != 0: available and initialized */ +bool use_sound; /* handle sound on/off menu and command-line option */ +bool use_music; /* handle music on/off menu and command-line option */ +bool audio_device; /* != 0: available and initialized */ int current_music; char * soundfilenames[NUM_SOUNDS] = { Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- worldmap.cpp 23 Mar 2004 01:30:16 -0000 1.13 +++ worldmap.cpp 24 Mar 2004 14:35:11 -0000 1.14 @@ -1,7 +1,7 @@ // $Id$ // -// Pingus - A free Lemmings clone -// Copyright (C) 2002 Ingo Ruhnke <gr...@gm...> +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Ingo Ruhnke <gr...@gm...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License Index: sound.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sound.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- sound.h 22 Mar 2004 10:33:16 -0000 1.20 +++ sound.h 24 Mar 2004 14:35:11 -0000 1.21 @@ -22,9 +22,9 @@ #define SOUND_RESERVED_CHANNELS 2 /*global variable*/ -extern int use_sound; /* handle sound on/off menu and command-line option */ -extern int use_music; /* handle music on/off menu and command-line option */ -extern int audio_device; /* != 0: available and initialized */ +extern bool use_sound; /* handle sound on/off menu and command-line option */ +extern bool use_music; /* handle music on/off menu and command-line option */ +extern bool audio_device; /* != 0: available and initialized */ /* enum of different internal music types */ enum Music_Type { Index: supertux.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/supertux.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- supertux.cpp 22 Mar 2004 10:33:16 -0000 1.3 +++ supertux.cpp 24 Mar 2004 14:35:11 -0000 1.4 @@ -19,9 +19,9 @@ { int done; + st_directory_setup(); parseargs(argc, argv); - st_directory_setup(); st_audio_setup(); st_video_setup(); st_joystick_setup(); Index: high_scores.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/high_scores.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- high_scores.h 24 Feb 2004 14:43:27 -0000 1.4 +++ high_scores.h 24 Mar 2004 14:35:11 -0000 1.5 @@ -5,6 +5,9 @@ */ +#ifndef SUPERTUX_HIGH_SCORES_H +#define SUPERTUX_HIGH_SCORES_H + #include <stdio.h> extern int hs_score; @@ -12,4 +15,5 @@ void save_hs(int score); void load_hs(); -FILE * opendata(char * mode); + +#endif |