Send a mail to me: neoneurone@users.sf.net, if you have another opinion. :)
*/
for (i = 0; i < NUM_SOUNDS; i++)
- sounds[i] = load_sound(soundfilenames[i]);
+ sounds[i] = load_sound(datadir + soundfilenames[i]);
/* Herring song */
herring_song = load_song(datadir + "/music/SALCON.MOD");
FILE * fi;
- texture_load(&bkgd, DATA_PREFIX "/images/highscore/highscore.png", IGNORE_ALPHA);
+ texture_load(&bkgd, datadir + "/images/highscore/highscore.png", IGNORE_ALPHA);
hs_score = score;
snprintf(filename, 1024, "%s/levels/%s/info", st_dir, subset);
if(!faccessible(filename))
- snprintf(filename, 1024, "%s/levels/%s/info", DATA_PREFIX, subset);
+ snprintf(filename, 1024, "%s/levels/%s/info", datadir.c_str(), subset);
if(faccessible(filename))
{
fi = fopen(filename, "r");
}
else
{
- snprintf(filename, 1024, "%s/images/status/level-subset-info.png", DATA_PREFIX);
+ snprintf(filename, 1024, "%s/images/status/level-subset-info.png", datadir.c_str());
texture_load(&image,filename,IGNORE_ALPHA);
}
}
snprintf(filename, 1024, "%s/levels/%s/level%d.stl", st_dir, subset,i);
if(!faccessible(filename))
{
- snprintf(filename, 1024, "%s/levels/%s/level%d.stl", DATA_PREFIX, subset,i);
+ snprintf(filename, 1024, "%s/levels/%s/level%d.stl", datadir.c_str(), subset,i);
if(!faccessible(filename))
break;
}
fcreatedir(filename.c_str());
filename = string(st_dir) + "/levels/" + name + "/info";
if(!fwriteable(filename.c_str()))
- filename = string(DATA_PREFIX) + "/levels/" + name + "/info";
+ filename = datadir + "/levels/" + name + "/info";
if(fwriteable(filename.c_str()))
{
fi = fopen(filename.c_str(), "w");
snprintf(filename, 1024, "%s/levels/%s/level%d.stl", st_dir, subset, level);
if(!faccessible(filename))
- snprintf(filename, 1024, "%s/levels/%s/level%d.stl", DATA_PREFIX, subset, level);
+ snprintf(filename, 1024, "%s/levels/%s/level%d.stl", datadir.c_str(), subset, level);
return level_load(plevel, filename);
}
fcreatedir(str);
snprintf(filename, 1024, "%s/levels/%s/level%d.stl", st_dir, subset, level);
if(!fwriteable(filename))
- snprintf(filename, 1024, "%s/levels/%s/level%d.stl", DATA_PREFIX, subset, level);
+ snprintf(filename, 1024, "%s/levels/%s/level%d.stl", datadir.c_str(), subset, level);
fi = fopen(filename, "w");
if (fi == NULL)
char fname[1024];
snprintf(fname, 1024, "%s/background/%s", st_dir, plevel->bkgd_image.c_str());
if(!faccessible(fname))
- snprintf(fname, 1024, "%s/images/background/%s", DATA_PREFIX, plevel->bkgd_image.c_str());
+ snprintf(fname, 1024, "%s/images/background/%s", datadir.c_str(), plevel->bkgd_image.c_str());
texture_load(&img_bkgd, fname, IGNORE_ALPHA);
}
else
snprintf(fname, 1024, "%s/themes/%s/%s", st_dir, theme.c_str(), file);
if(!faccessible(fname))
- snprintf(fname, 1024, "%s/images/themes/%s/%s", DATA_PREFIX, theme.c_str(), file);
+ snprintf(fname, 1024, "%s/images/themes/%s/%s", datadir.c_str(), theme.c_str(), file);
texture_load(ptexture, fname, use_alpha);
}
char * song_path;
char * song_subtitle;
- song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
- strlen(plevel->song_title.c_str()) + 8));
- sprintf(song_path, "%s/music/%s", DATA_PREFIX, plevel->song_title.c_str());
- level_song = load_song(song_path);
- free(song_path);
-
+ level_song = load_song(datadir + "/music/" + plevel->song_title);
- song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
- strlen(plevel->song_title.c_str()) + 8 + 5));
+ song_path = (char *) malloc(sizeof(char) * datadir.length() +
+ strlen(plevel->song_title.c_str()) + 8 + 5);
song_subtitle = strdup(plevel->song_title.c_str());
strcpy(strstr(song_subtitle, "."), "\0");
- sprintf(song_path, "%s/music/%s-fast%s", DATA_PREFIX, song_subtitle, strstr(plevel->song_title.c_str(), "."));
+ sprintf(song_path, "%s/music/%s-fast%s", datadir.c_str(), song_subtitle, strstr(plevel->song_title.c_str(), "."));
level_song_fast = load_song(song_path);
free(song_subtitle);
free(song_path);
le_mouse_pressed[LEFT] = NO;
le_mouse_pressed[RIGHT] = NO;
- texture_load(&le_selection,DATA_PREFIX "/images/leveleditor/select.png", USE_ALPHA);
+ texture_load(&le_selection, datadir + "/images/leveleditor/select.png", USE_ALPHA);
/* Load buttons */
button_load(&le_save_level_bt,"/images/icons/save.png","Save level", SDLK_F6,screen->w-64,32);
}
}
-lisp_object_t* lisp_read_from_file(const char* filename)
+lisp_object_t* lisp_read_from_file(const std::string& filename)
{
lisp_stream_t stream;
- if (has_suffix(filename, ".gz"))
+ if (has_suffix(filename.c_str(), ".gz"))
{
- return lisp_read_from_gzfile(filename);
+ return lisp_read_from_gzfile(filename.c_str());
#if 0
lisp_object_t* obj = 0;
gzFile in = gzopen(filename, "r");
else
{
lisp_object_t* obj = 0;
- FILE* in = fopen(filename, "r");
+ FILE* in = fopen(filename.c_str(), "r");
if (in)
{
void (*unget_char) (char c, void *data));
lisp_object_t* lisp_read (lisp_stream_t *in);
-lisp_object_t* lisp_read_from_file(const char* filename);
+lisp_object_t* lisp_read_from_file(const std::string& filename);
void lisp_free (lisp_object_t *obj);
lisp_object_t* lisp_read_from_string (const char *buf);
snprintf(path, 1024, "%s/%s/", st_dir, relative_dir);
if(mkdir(path,0755) != 0)
{
- snprintf(path, 1024, "%s/%s/", DATA_PREFIX, relative_dir);
+ snprintf(path, 1024, "%s/%s/", datadir.c_str(), relative_dir);
if(mkdir(path,0755) != 0)
{
return NO;
closedir(dirStructP);
}
- sprintf(path,"%s/%s",DATA_PREFIX,rel_path);
+ sprintf(path,"%s/%s",datadir.c_str(),rel_path);
if((dirStructP = opendir(path)) != NULL)
{
while((direntp = readdir(dirStructP)) != NULL)
closedir(dirStructP);
}
- sprintf(path,"%s/%s",DATA_PREFIX,rel_path);
+ sprintf(path,"%s/%s",datadir.c_str(),rel_path);
if((dirStructP = opendir(path)) != NULL)
{
while((direntp = readdir(dirStructP)) != NULL)
if (readlink("/proc/self/exe", exe_file, PATH_MAX) < 0)
{
puts("Couldn't read /proc/self/exe, using default path: " DATA_PREFIX);
+ datadir = DATA_PREFIX;
}
else
{
/* Load global images: */
- text_load(&black_text,DATA_PREFIX "/images/status/letters-black.png", TEXT_TEXT, 16,18);
- text_load(&gold_text,DATA_PREFIX "/images/status/letters-gold.png", TEXT_TEXT, 16,18);
- text_load(&blue_text,DATA_PREFIX "/images/status/letters-blue.png", TEXT_TEXT, 16,18);
- text_load(&red_text,DATA_PREFIX "/images/status/letters-red.png", TEXT_TEXT, 16,18);
- text_load(&white_text,DATA_PREFIX "/images/status/letters-white.png", TEXT_TEXT, 16,18);
- text_load(&white_small_text,DATA_PREFIX "/images/status/letters-white-small.png", TEXT_TEXT, 8,9);
- text_load(&white_big_text,DATA_PREFIX "/images/status/letters-white-big.png", TEXT_TEXT, 20,23);
- text_load(&yellow_nums,DATA_PREFIX "/images/status/numbers.png", TEXT_NUM, 32,32);
+ text_load(&black_text, datadir + "/images/status/letters-black.png", TEXT_TEXT, 16,18);
+ text_load(&gold_text,datadir + "/images/status/letters-gold.png", TEXT_TEXT, 16,18);
+ text_load(&blue_text,datadir + "/images/status/letters-blue.png", TEXT_TEXT, 16,18);
+ text_load(&red_text,datadir + "/images/status/letters-red.png", TEXT_TEXT, 16,18);
+ text_load(&white_text,datadir + "/images/status/letters-white.png", TEXT_TEXT, 16,18);
+ text_load(&white_small_text,datadir + "/images/status/letters-white-small.png", TEXT_TEXT, 8,9);
+ text_load(&white_big_text,datadir + "/images/status/letters-white-big.png", TEXT_TEXT, 20,23);
+ text_load(&yellow_nums,datadir + "/images/status/numbers.png", TEXT_NUM, 32,32);
/* Load GUI/menu images: */
- texture_load(&checkbox, DATA_PREFIX "/images/status/checkbox.png", USE_ALPHA);
- texture_load(&checkbox_checked, DATA_PREFIX "/images/status/checkbox-checked.png", USE_ALPHA);
- texture_load(&back, DATA_PREFIX "/images/status/back.png", USE_ALPHA);
- texture_load(&arrow_left, DATA_PREFIX "/images/icons/left.png", USE_ALPHA);
- texture_load(&arrow_right, DATA_PREFIX "/images/icons/right.png", USE_ALPHA);
+ texture_load(&checkbox, datadir + "/images/status/checkbox.png", USE_ALPHA);
+ texture_load(&checkbox_checked, datadir + "/images/status/checkbox-checked.png", USE_ALPHA);
+ texture_load(&back, datadir + "/images/status/back.png", USE_ALPHA);
+ texture_load(&arrow_left, datadir + "/images/icons/left.png", USE_ALPHA);
+ texture_load(&arrow_right, datadir + "/images/icons/right.png", USE_ALPHA);
}
/* Load icon into a surface: */
- icon = IMG_Load(DATA_PREFIX "/images/icon.png");
+ icon = IMG_Load((datadir + "/images/icon.png").c_str());
if (icon == NULL)
{
fprintf(stderr,
- "\nError: I could not load the icon image: %s\n"
+ "\nError: I could not load the icon image: %s%s\n"
"The Simple DirectMedia error that occured was:\n"
- "%s\n\n", DATA_PREFIX "/images/icon.png", SDL_GetError());
+ "%s\n\n", datadir.c_str(), "/images/icon.png", SDL_GetError());
exit(1);
}
int current_music;
char * soundfilenames[NUM_SOUNDS] = {
- DATA_PREFIX "/sounds/jump.wav",
- DATA_PREFIX "/sounds/bigjump.wav",
- DATA_PREFIX "/sounds/skid.wav",
- DATA_PREFIX "/sounds/distro.wav",
- DATA_PREFIX "/sounds/herring.wav",
- DATA_PREFIX "/sounds/brick.wav",
- DATA_PREFIX "/sounds/hurt.wav",
- DATA_PREFIX "/sounds/squish.wav",
- DATA_PREFIX "/sounds/fall.wav",
- DATA_PREFIX "/sounds/ricochet.wav",
- DATA_PREFIX "/sounds/bump-upgrade.wav",
- DATA_PREFIX "/sounds/upgrade.wav",
- DATA_PREFIX "/sounds/excellent.wav",
- DATA_PREFIX "/sounds/coffee.wav",
- DATA_PREFIX "/sounds/shoot.wav",
- DATA_PREFIX "/sounds/lifeup.wav",
- DATA_PREFIX "/sounds/stomp.wav",
- DATA_PREFIX "/sounds/kick.wav"
+ "/sounds/jump.wav",
+ "/sounds/bigjump.wav",
+ "/sounds/skid.wav",
+ "/sounds/distro.wav",
+ "/sounds/herring.wav",
+ "/sounds/brick.wav",
+ "/sounds/hurt.wav",
+ "/sounds/squish.wav",
+ "/sounds/fall.wav",
+ "/sounds/ricochet.wav",
+ "/sounds/bump-upgrade.wav",
+ "/sounds/upgrade.wav",
+ "/sounds/excellent.wav",
+ "/sounds/coffee.wav",
+ "/sounds/shoot.wav",
+ "/sounds/lifeup.wav",
+ "/sounds/stomp.wav",
+ "/sounds/kick.wav"
};
#include "screen.h"
#include "text.h"
-void text_load(text_type* ptext,const char* file, int kind, int w, int h)
+void text_load(text_type* ptext, const std::string& file, int kind, int w, int h)
{
int mx, my;
SDL_Surface *conv;
A_NONE
};
-void text_load(text_type* ptext, const char* file, int kind, int w, int h);
+void text_load(text_type* ptext, const std::string& file, int kind, int w, int h);
void text_draw(text_type* ptext, const char* text, int x, int y, int shadowsize, int update);
void text_draw_chars(text_type* ptext, texture_type* pchars, const char* text, int x, int y, int update);
void text_drawf(text_type* ptext, const char* text, int x, int y, int halign, int valign, int shadowsize, int update);
/* Load images: */
- texture_load(&bkg_title,DATA_PREFIX "/images/title/title.png", IGNORE_ALPHA);
- texture_load(&anim1,DATA_PREFIX "/images/title/title-anim2.png", IGNORE_ALPHA);
- texture_load(&anim2,DATA_PREFIX "/images/title/title-anim1.png", IGNORE_ALPHA);
- texture_load(&img_choose_subset,DATA_PREFIX "/images/status/choose-level-subset.png", USE_ALPHA);
+ texture_load(&bkg_title,datadir + "/images/title/title.png", IGNORE_ALPHA);
+ texture_load(&anim1,datadir + "/images/title/title-anim2.png", IGNORE_ALPHA);
+ texture_load(&anim2,datadir + "/images/title/title-anim1.png", IGNORE_ALPHA);
+ texture_load(&img_choose_subset,datadir + "/images/status/choose-level-subset.png", USE_ALPHA);
/* --- Main title loop: --- */
string_list_type names;
char filename[1024];
string_list_init(&names);
- sprintf(filename,"%s/CREDITS",DATA_PREFIX);
+ sprintf(filename,"%s/CREDITS", datadir.c_str());
if((fi = fopen(filename,"r")) != NULL)
{
while(fgets(temp, sizeof(temp), fi) != NULL)
#include <iostream>
#include <vector>
#include <assert.h>
+#include "globals.h"
#include "texture.h"
#include "screen.h"
#include "lispreader.h"
TileManager::TileManager()
{
- lisp_object_t* root_obj = lisp_read_from_file(DATA_PREFIX "images/worldmap/antarctica.scm");
+ lisp_object_t* root_obj = lisp_read_from_file(datadir + "images/worldmap/antarctica.scm");
assert(root_obj);
reader.read_string("image", &filename);
texture_load(&tile->sprite,
- const_cast<char*>((std::string(DATA_PREFIX "/images/worldmap/") + filename).c_str()),
+ datadir + "/images/worldmap/" + filename,
USE_ALPHA);
if (id >= int(tiles.size()))
Tux::Tux(WorldMap* worldmap_)
: worldmap(worldmap_)
{
- texture_load(&sprite, DATA_PREFIX "/images/worldmap/tux.png", USE_ALPHA);
+ texture_load(&sprite, datadir + "/images/worldmap/tux.png", USE_ALPHA);
offset = 0;
moving = false;
tile_pos.x = 0;
width = 20;
height = 15;
- texture_load(&level_sprite, DATA_PREFIX "/images/worldmap/levelmarker.png", USE_ALPHA);
+ texture_load(&level_sprite, datadir + "/images/worldmap/levelmarker.png", USE_ALPHA);
input_direction = NONE;
enter_level = false;
void
WorldMap::load_map()
{
- lisp_object_t* root_obj = lisp_read_from_file(DATA_PREFIX "levels/default/worldmap.scm");
+ lisp_object_t* root_obj = lisp_read_from_file(datadir + "levels/default/worldmap.scm");
assert(root_obj);
if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-worldmap") == 0)
{
std::cout << "Enter the current level: " << i->name << std::endl;;
halt_music();
- gameloop(const_cast<char*>((DATA_PREFIX "levels/default/" + i->name).c_str()),
+ gameloop(const_cast<char*>((datadir + "levels/default/" + i->name).c_str()),
1, ST_GL_LOAD_LEVEL_FILE);
play_music(song, 1);
break;
{
quit = false;
- song = load_song(const_cast<char*>((DATA_PREFIX "/music/" + music).c_str()));
+ song = load_song(datadir + "/music/" + music);
play_music(song, 1);
while(!quit) {