bitmask.h \
button.cpp \
button.h \
+ configfile.h \
+ configfile.cpp \
collision.cpp \
collision.h \
defines.h \
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;
#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: */
/* Try to open file: */
- fi = opendata("r");
+ fi = opendata(highscore_filename, "r");
if (fi != NULL)
{
do
/* Try to open file: */
- fi = opendata("w");
+ fi = opendata(highscore_filename, "w");
if (fi != NULL)
{
fprintf(fi, "# Supertux highscore file\n\n");
*/
+#ifndef SUPERTUX_HIGH_SCORES_H
+#define SUPERTUX_HIGH_SCORES_H
+
#include <stdio.h>
extern int hs_score;
void save_hs(int score);
void load_hs();
-FILE * opendata(char * mode);
+
+#endif
#include "texture.h"
#include "menu.h"
#include "gameloop.h"
+#include "configfile.h"
#ifdef WIN32
#define mkdir(dir, mode) mkdir(dir)
}
}
+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. */
}
}
#else
- datadir = DATA_PREFIX;
+ datadir = DATA_PREFIX;
#endif
}
printf("Datadir: %s\n", datadir.c_str());
{
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();
}
{
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: */
}
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]);
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);
#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] = {
#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 {
{
int done;
+ st_directory_setup();
parseargs(argc, argv);
- st_directory_setup();
st_audio_setup();
st_video_setup();
st_joystick_setup();
// $Id$
//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
+// SuperTux - A Jump'n Run
+// Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License