- replaced a few char* with std::string
authorIngo Ruhnke <grumbel@gmx.de>
Sun, 21 Mar 2004 15:21:00 +0000 (15:21 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Sun, 21 Mar 2004 15:21:00 +0000 (15:21 +0000)
- load datafiles from 'datadir' instead of DATA_PREFIX

SVN-Revision: 293

src/button.cpp
src/gameloop.cpp
src/intro.cpp
src/sound.cpp
src/sound.h
src/texture.cpp
src/texture.h

index 6efc8c8..157dd65 100644 (file)
@@ -23,13 +23,13 @@ void button_load(button_type* pbutton,char* icon_file, char* info, SDLKey shortc
 
   if(icon_file != NULL)
     {
-      snprintf(filename, 1024, "%s/%s", DATA_PREFIX, icon_file);
+      snprintf(filename, 1024, "%s/%s", datadir.c_str(), icon_file);
       if(!faccessible(filename))
-        snprintf(filename, 1024, "%s/images/icons/default-icon.png", DATA_PREFIX);
+        snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str());
     }
   else
     {
-      snprintf(filename, 1024, "%s/images/icons/default-icon.png", DATA_PREFIX);
+      snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str());
     }
   texture_load(&pbutton->icon,filename,USE_ALPHA);
 
@@ -61,13 +61,13 @@ void button_change_icon(button_type* pbutton,char* icon_file)
 
   if(icon_file != NULL)
     {
-      snprintf(filename, 1024, "%s/%s", DATA_PREFIX, icon_file);
+      snprintf(filename, 1024, "%s/%s", datadir.c_str(), icon_file);
       if(!faccessible(filename))
-        snprintf(filename, 1024, "%s/images/icons/default-icon.png", DATA_PREFIX);
+        snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str());
     }
   else
     {
-      snprintf(filename, 1024, "%s/images/icons/default-icon.png", DATA_PREFIX);
+      snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str());
     }
   
   texture_free(&pbutton->icon);
index 72901d1..58f9593 100644 (file)
@@ -818,204 +818,202 @@ int gameloop(const char * subset, int levelnb, int mode)
 void loadshared(void)
 {
   int i;
-  char * herring_song_path; /* for loading herring song*/
 
   /* Tuxes: */
+  texture_load(&tux_right[0], datadir + "/images/shared/tux-right-0.png", USE_ALPHA);
+  texture_load(&tux_right[1], datadir + "/images/shared/tux-right-1.png", USE_ALPHA);
+  texture_load(&tux_right[2], datadir + "/images/shared/tux-right-2.png", USE_ALPHA);
 
-  texture_load(&tux_right[0],DATA_PREFIX "/images/shared/tux-right-0.png", USE_ALPHA);
-  texture_load(&tux_right[1],DATA_PREFIX "/images/shared/tux-right-1.png", USE_ALPHA);
-  texture_load(&tux_right[2],DATA_PREFIX "/images/shared/tux-right-2.png", USE_ALPHA);
+  texture_load(&tux_left[0], datadir + "/images/shared/tux-left-0.png", USE_ALPHA);
+  texture_load(&tux_left[1], datadir + "/images/shared/tux-left-1.png", USE_ALPHA);
+  texture_load(&tux_left[2], datadir + "/images/shared/tux-left-2.png", USE_ALPHA);
 
-  texture_load(&tux_left[0],DATA_PREFIX "/images/shared/tux-left-0.png", USE_ALPHA);
-  texture_load(&tux_left[1],DATA_PREFIX "/images/shared/tux-left-1.png", USE_ALPHA);
-  texture_load(&tux_left[2],DATA_PREFIX "/images/shared/tux-left-2.png", USE_ALPHA);
+  texture_load(&firetux_right[0], datadir + "/images/shared/firetux-right-0.png", USE_ALPHA);
+  texture_load(&firetux_right[1], datadir + "/images/shared/firetux-right-1.png", USE_ALPHA);
+  texture_load(&firetux_right[2], datadir + "/images/shared/firetux-right-2.png", USE_ALPHA);
 
-  texture_load(&firetux_right[0],DATA_PREFIX "/images/shared/firetux-right-0.png", USE_ALPHA);
-  texture_load(&firetux_right[1],DATA_PREFIX "/images/shared/firetux-right-1.png", USE_ALPHA);
-  texture_load(&firetux_right[2],DATA_PREFIX "/images/shared/firetux-right-2.png", USE_ALPHA);
+  texture_load(&firetux_left[0], datadir + "/images/shared/firetux-left-0.png", USE_ALPHA);
+  texture_load(&firetux_left[1], datadir + "/images/shared/firetux-left-1.png", USE_ALPHA);
+  texture_load(&firetux_left[2], datadir + "/images/shared/firetux-left-2.png", USE_ALPHA);
 
-  texture_load(&firetux_left[0],DATA_PREFIX "/images/shared/firetux-left-0.png", USE_ALPHA);
-  texture_load(&firetux_left[1],DATA_PREFIX "/images/shared/firetux-left-1.png", USE_ALPHA);
-  texture_load(&firetux_left[2],DATA_PREFIX "/images/shared/firetux-left-2.png", USE_ALPHA);
 
-
-  texture_load(&cape_right[0] ,DATA_PREFIX "/images/shared/cape-right-0.png",
+  texture_load(&cape_right[0], datadir + "/images/shared/cape-right-0.png",
                USE_ALPHA);
 
-  texture_load(&cape_right[1] ,DATA_PREFIX "/images/shared/cape-right-1.png",
+  texture_load(&cape_right[1], datadir + "/images/shared/cape-right-1.png",
                USE_ALPHA);
 
-  texture_load(&cape_left[0] ,DATA_PREFIX "/images/shared/cape-left-0.png",
+  texture_load(&cape_left[0], datadir + "/images/shared/cape-left-0.png",
                USE_ALPHA);
 
-  texture_load(&cape_left[1] ,DATA_PREFIX "/images/shared/cape-left-1.png",
+  texture_load(&cape_left[1], datadir + "/images/shared/cape-left-1.png",
                USE_ALPHA);
 
-  texture_load(&bigtux_right[0] ,DATA_PREFIX "/images/shared/bigtux-right-0.png",
+  texture_load(&bigtux_right[0], datadir + "/images/shared/bigtux-right-0.png",
                USE_ALPHA);
 
-  texture_load(&bigtux_right[1] ,DATA_PREFIX "/images/shared/bigtux-right-1.png",
+  texture_load(&bigtux_right[1], datadir + "/images/shared/bigtux-right-1.png",
                USE_ALPHA);
 
-  texture_load(&bigtux_right[2] ,DATA_PREFIX "/images/shared/bigtux-right-2.png",
+  texture_load(&bigtux_right[2], datadir + "/images/shared/bigtux-right-2.png",
                USE_ALPHA);
 
-  texture_load(&bigtux_right_jump ,DATA_PREFIX "/images/shared/bigtux-right-jump.png", USE_ALPHA);
+  texture_load(&bigtux_right_jump, datadir + "/images/shared/bigtux-right-jump.png", USE_ALPHA);
 
-  texture_load(&bigtux_left[0] ,DATA_PREFIX "/images/shared/bigtux-left-0.png",
+  texture_load(&bigtux_left[0], datadir + "/images/shared/bigtux-left-0.png",
                USE_ALPHA);
 
-  texture_load(&bigtux_left[1] ,DATA_PREFIX "/images/shared/bigtux-left-1.png",
+  texture_load(&bigtux_left[1], datadir + "/images/shared/bigtux-left-1.png",
                USE_ALPHA);
 
-  texture_load(&bigtux_left[2] ,DATA_PREFIX "/images/shared/bigtux-left-2.png",
+  texture_load(&bigtux_left[2], datadir + "/images/shared/bigtux-left-2.png",
                USE_ALPHA);
 
-  texture_load(&bigtux_left_jump ,DATA_PREFIX "/images/shared/bigtux-left-jump.png", USE_ALPHA);
+  texture_load(&bigtux_left_jump, datadir + "/images/shared/bigtux-left-jump.png", USE_ALPHA);
 
-  texture_load(&bigcape_right[0] ,DATA_PREFIX "/images/shared/bigcape-right-0.png",
+  texture_load(&bigcape_right[0], datadir + "/images/shared/bigcape-right-0.png",
                USE_ALPHA);
 
-  texture_load(&bigcape_right[1] ,DATA_PREFIX "/images/shared/bigcape-right-1.png",
+  texture_load(&bigcape_right[1], datadir + "/images/shared/bigcape-right-1.png",
                USE_ALPHA);
 
-  texture_load(&bigcape_left[0] ,DATA_PREFIX "/images/shared/bigcape-left-0.png",
+  texture_load(&bigcape_left[0], datadir + "/images/shared/bigcape-left-0.png",
                USE_ALPHA);
 
-  texture_load(&bigcape_left[1] ,DATA_PREFIX "/images/shared/bigcape-left-1.png",
+  texture_load(&bigcape_left[1], datadir + "/images/shared/bigcape-left-1.png",
                USE_ALPHA);
 
-  texture_load(&bigfiretux_right[0] ,DATA_PREFIX "/images/shared/bigfiretux-right-0.png",
+  texture_load(&bigfiretux_right[0], datadir + "/images/shared/bigfiretux-right-0.png",
                USE_ALPHA);
 
-  texture_load(&bigfiretux_right[1] ,DATA_PREFIX "/images/shared/bigfiretux-right-1.png",
+  texture_load(&bigfiretux_right[1], datadir + "/images/shared/bigfiretux-right-1.png",
                USE_ALPHA);
 
-  texture_load(&bigfiretux_right[2] ,DATA_PREFIX "/images/shared/bigfiretux-right-2.png",
+  texture_load(&bigfiretux_right[2], datadir + "/images/shared/bigfiretux-right-2.png",
                USE_ALPHA);
 
-  texture_load(&bigfiretux_right_jump ,DATA_PREFIX "/images/shared/bigfiretux-right-jump.png", USE_ALPHA);
+  texture_load(&bigfiretux_right_jump, datadir + "/images/shared/bigfiretux-right-jump.png", USE_ALPHA);
 
-  texture_load(&bigfiretux_left[0] ,DATA_PREFIX "/images/shared/bigfiretux-left-0.png",
+  texture_load(&bigfiretux_left[0], datadir + "/images/shared/bigfiretux-left-0.png",
                USE_ALPHA);
 
-  texture_load(&bigfiretux_left[1] ,DATA_PREFIX "/images/shared/bigfiretux-left-1.png",
+  texture_load(&bigfiretux_left[1], datadir + "/images/shared/bigfiretux-left-1.png",
                USE_ALPHA);
 
-  texture_load(&bigfiretux_left[2] ,DATA_PREFIX "/images/shared/bigfiretux-left-2.png",
+  texture_load(&bigfiretux_left[2], datadir + "/images/shared/bigfiretux-left-2.png",
                USE_ALPHA);
 
-  texture_load(&bigfiretux_left_jump ,DATA_PREFIX "/images/shared/bigfiretux-left-jump.png", USE_ALPHA);
+  texture_load(&bigfiretux_left_jump, datadir + "/images/shared/bigfiretux-left-jump.png", USE_ALPHA);
 
-  texture_load(&bigcape_right[0] ,DATA_PREFIX "/images/shared/bigcape-right-0.png",
+  texture_load(&bigcape_right[0], datadir + "/images/shared/bigcape-right-0.png",
                USE_ALPHA);
 
-  texture_load(&bigcape_right[1] ,DATA_PREFIX "/images/shared/bigcape-right-1.png",
+  texture_load(&bigcape_right[1], datadir + "/images/shared/bigcape-right-1.png",
                USE_ALPHA);
 
-  texture_load(&bigcape_left[0] ,DATA_PREFIX "/images/shared/bigcape-left-0.png",
+  texture_load(&bigcape_left[0], datadir + "/images/shared/bigcape-left-0.png",
                USE_ALPHA);
 
-  texture_load(&bigcape_left[1] ,DATA_PREFIX "/images/shared/bigcape-left-1.png",
+  texture_load(&bigcape_left[1], datadir + "/images/shared/bigcape-left-1.png",
                USE_ALPHA);
 
 
-  texture_load(&ducktux_right ,DATA_PREFIX
+  texture_load(&ducktux_right, datadir +
                "/images/shared/ducktux-right.png",
                USE_ALPHA);
 
-  texture_load(&ducktux_left ,DATA_PREFIX
+  texture_load(&ducktux_left, datadir +
                "/images/shared/ducktux-left.png",
                USE_ALPHA);
 
-  texture_load(&skidtux_right ,DATA_PREFIX
+  texture_load(&skidtux_right, datadir +
                "/images/shared/skidtux-right.png",
                USE_ALPHA);
 
-  texture_load(&skidtux_left ,DATA_PREFIX
+  texture_load(&skidtux_left, datadir +
                "/images/shared/skidtux-left.png",
                USE_ALPHA);
 
-  texture_load(&duckfiretux_right ,DATA_PREFIX
+  texture_load(&duckfiretux_right, datadir +
                "/images/shared/duckfiretux-right.png",
                USE_ALPHA);
 
-  texture_load(&duckfiretux_left ,DATA_PREFIX
+  texture_load(&duckfiretux_left, datadir +
                "/images/shared/duckfiretux-left.png",
                USE_ALPHA);
 
-  texture_load(&skidfiretux_right ,DATA_PREFIX
+  texture_load(&skidfiretux_right, datadir +
                "/images/shared/skidfiretux-right.png",
                USE_ALPHA);
 
-  texture_load(&skidfiretux_left ,DATA_PREFIX
+  texture_load(&skidfiretux_left, datadir +
                "/images/shared/skidfiretux-left.png",
                USE_ALPHA);
 
 
   /* Boxes: */
 
-  texture_load(&img_box_full ,DATA_PREFIX "/images/shared/box-full.png",
+  texture_load(&img_box_full, datadir + "/images/shared/box-full.png",
                IGNORE_ALPHA);
-  texture_load(&img_box_empty ,DATA_PREFIX "/images/shared/box-empty.png",
+  texture_load(&img_box_empty, datadir + "/images/shared/box-empty.png",
                IGNORE_ALPHA);
 
 
   /* Water: */
 
 
-  texture_load(&img_water ,DATA_PREFIX "/images/shared/water.png", IGNORE_ALPHA);
+  texture_load(&img_water, datadir + "/images/shared/water.png", IGNORE_ALPHA);
 
-  texture_load(&img_waves[0] ,DATA_PREFIX "/images/shared/waves-0.png",
+  texture_load(&img_waves[0], datadir + "/images/shared/waves-0.png",
                USE_ALPHA);
 
-  texture_load(&img_waves[1] ,DATA_PREFIX "/images/shared/waves-1.png",
+  texture_load(&img_waves[1], datadir + "/images/shared/waves-1.png",
                USE_ALPHA);
 
-  texture_load(&img_waves[2] ,DATA_PREFIX "/images/shared/waves-2.png",
+  texture_load(&img_waves[2], datadir + "/images/shared/waves-2.png",
                USE_ALPHA);
 
 
   /* Pole: */
 
-  texture_load(&img_pole ,DATA_PREFIX "/images/shared/pole.png", USE_ALPHA);
-  texture_load(&img_poletop ,DATA_PREFIX "/images/shared/poletop.png",
+  texture_load(&img_pole, datadir + "/images/shared/pole.png", USE_ALPHA);
+  texture_load(&img_poletop, datadir + "/images/shared/poletop.png",
                USE_ALPHA);
 
 
   /* Flag: */
 
-  texture_load(&img_flag[0] ,DATA_PREFIX "/images/shared/flag-0.png",
+  texture_load(&img_flag[0], datadir + "/images/shared/flag-0.png",
                USE_ALPHA);
-  texture_load(&img_flag[1] ,DATA_PREFIX "/images/shared/flag-1.png",
+  texture_load(&img_flag[1], datadir + "/images/shared/flag-1.png",
                USE_ALPHA);
 
 
   /* Cloud: */
 
-  texture_load(&img_cloud[0][0] ,DATA_PREFIX "/images/shared/cloud-00.png",
+  texture_load(&img_cloud[0][0], datadir + "/images/shared/cloud-00.png",
                USE_ALPHA);
 
-  texture_load(&img_cloud[0][1] ,DATA_PREFIX "/images/shared/cloud-01.png",
+  texture_load(&img_cloud[0][1], datadir + "/images/shared/cloud-01.png",
                USE_ALPHA);
 
-  texture_load(&img_cloud[0][2] ,DATA_PREFIX "/images/shared/cloud-02.png",
+  texture_load(&img_cloud[0][2], datadir + "/images/shared/cloud-02.png",
                USE_ALPHA);
 
-  texture_load(&img_cloud[0][3] ,DATA_PREFIX "/images/shared/cloud-03.png",
+  texture_load(&img_cloud[0][3], datadir + "/images/shared/cloud-03.png",
                USE_ALPHA);
 
 
-  texture_load(&img_cloud[1][0] ,DATA_PREFIX "/images/shared/cloud-10.png",
+  texture_load(&img_cloud[1][0], datadir + "/images/shared/cloud-10.png",
                USE_ALPHA);
 
-  texture_load(&img_cloud[1][1] ,DATA_PREFIX "/images/shared/cloud-11.png",
+  texture_load(&img_cloud[1][1], datadir + "/images/shared/cloud-11.png",
                USE_ALPHA);
 
-  texture_load(&img_cloud[1][2] ,DATA_PREFIX "/images/shared/cloud-12.png",
+  texture_load(&img_cloud[1][2], datadir + "/images/shared/cloud-12.png",
                USE_ALPHA);
 
-  texture_load(&img_cloud[1][3] ,DATA_PREFIX "/images/shared/cloud-13.png",
+  texture_load(&img_cloud[1][3], datadir + "/images/shared/cloud-13.png",
                USE_ALPHA);
 
 
@@ -1023,113 +1021,113 @@ void loadshared(void)
 
   /* (BSOD) */
 
-  texture_load(&img_bsod_left[0] ,DATA_PREFIX
+  texture_load(&img_bsod_left[0], datadir +
                "/images/shared/bsod-left-0.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_left[1] ,DATA_PREFIX
+  texture_load(&img_bsod_left[1], datadir +
                "/images/shared/bsod-left-1.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_left[2] ,DATA_PREFIX
+  texture_load(&img_bsod_left[2], datadir +
                "/images/shared/bsod-left-2.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_left[3] ,DATA_PREFIX
+  texture_load(&img_bsod_left[3], datadir +
                "/images/shared/bsod-left-3.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_right[0] ,DATA_PREFIX
+  texture_load(&img_bsod_right[0], datadir +
                "/images/shared/bsod-right-0.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_right[1] ,DATA_PREFIX
+  texture_load(&img_bsod_right[1], datadir +
                "/images/shared/bsod-right-1.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_right[2] ,DATA_PREFIX
+  texture_load(&img_bsod_right[2], datadir +
                "/images/shared/bsod-right-2.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_right[3] ,DATA_PREFIX
+  texture_load(&img_bsod_right[3], datadir +
                "/images/shared/bsod-right-3.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_squished_left ,DATA_PREFIX
+  texture_load(&img_bsod_squished_left, datadir +
                "/images/shared/bsod-squished-left.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_squished_right ,DATA_PREFIX
+  texture_load(&img_bsod_squished_right, datadir +
                "/images/shared/bsod-squished-right.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_falling_left ,DATA_PREFIX
+  texture_load(&img_bsod_falling_left, datadir +
                "/images/shared/bsod-falling-left.png",
                USE_ALPHA);
 
-  texture_load(&img_bsod_falling_right ,DATA_PREFIX
+  texture_load(&img_bsod_falling_right, datadir +
                "/images/shared/bsod-falling-right.png",
                USE_ALPHA);
 
 
   /* (Laptop) */
 
-  texture_load(&img_laptop_left[0] ,DATA_PREFIX
+  texture_load(&img_laptop_left[0], datadir +
                "/images/shared/laptop-left-0.png",
                USE_ALPHA);
 
-  texture_load(&img_laptop_left[1] ,DATA_PREFIX
+  texture_load(&img_laptop_left[1], datadir +
                "/images/shared/laptop-left-1.png",
                USE_ALPHA);
 
-  texture_load(&img_laptop_left[2] ,DATA_PREFIX
+  texture_load(&img_laptop_left[2], datadir +
                "/images/shared/laptop-left-2.png",
                USE_ALPHA);
 
-  texture_load(&img_laptop_right[0] ,DATA_PREFIX
+  texture_load(&img_laptop_right[0], datadir +
                "/images/shared/laptop-right-0.png",
                USE_ALPHA);
 
-  texture_load(&img_laptop_right[1] ,DATA_PREFIX
+  texture_load(&img_laptop_right[1], datadir +
                "/images/shared/laptop-right-1.png",
                USE_ALPHA);
 
-  texture_load(&img_laptop_right[2] ,DATA_PREFIX
+  texture_load(&img_laptop_right[2], datadir +
                "/images/shared/laptop-right-2.png",
                USE_ALPHA);
 
-  texture_load(&img_laptop_flat_left ,DATA_PREFIX
+  texture_load(&img_laptop_flat_left, datadir +
                "/images/shared/laptop-flat-left.png",
                USE_ALPHA);
 
-  texture_load(&img_laptop_flat_right ,DATA_PREFIX
+  texture_load(&img_laptop_flat_right, datadir +
                "/images/shared/laptop-flat-right.png",
                USE_ALPHA);
 
-  texture_load(&img_laptop_falling_left ,DATA_PREFIX
+  texture_load(&img_laptop_falling_left, datadir +
                "/images/shared/laptop-falling-left.png",
                USE_ALPHA);
 
-  texture_load(&img_laptop_falling_right ,DATA_PREFIX
+  texture_load(&img_laptop_falling_right, datadir +
                "/images/shared/laptop-falling-right.png",
                USE_ALPHA);
 
 
   /* (Money) */
 
-  texture_load(&img_money_left[0] ,DATA_PREFIX
+  texture_load(&img_money_left[0], datadir +
                "/images/shared/bag-left-0.png",
                USE_ALPHA);
 
-  texture_load(&img_money_left[1] ,DATA_PREFIX
+  texture_load(&img_money_left[1], datadir +
                "/images/shared/bag-left-1.png",
                USE_ALPHA);
 
-  texture_load(&img_money_right[0] ,DATA_PREFIX
+  texture_load(&img_money_right[0], datadir +
                "/images/shared/bag-right-0.png",
                USE_ALPHA);
 
-  texture_load(&img_money_right[1] ,DATA_PREFIX
+  texture_load(&img_money_right[1], datadir +
                "/images/shared/bag-right-1.png",
                USE_ALPHA);
 
@@ -1137,48 +1135,48 @@ void loadshared(void)
 
   /* Upgrades: */
 
-  texture_load(&img_mints ,DATA_PREFIX "/images/shared/mints.png", USE_ALPHA);
-  texture_load(&img_coffee ,DATA_PREFIX "/images/shared/coffee.png", USE_ALPHA);
+  texture_load(&img_mints, datadir + "/images/shared/mints.png", USE_ALPHA);
+  texture_load(&img_coffee, datadir + "/images/shared/coffee.png", USE_ALPHA);
 
 
   /* Weapons: */
 
-  texture_load(&img_bullet ,DATA_PREFIX "/images/shared/bullet.png", USE_ALPHA);
+  texture_load(&img_bullet, datadir + "/images/shared/bullet.png", USE_ALPHA);
 
-  texture_load(&img_red_glow ,DATA_PREFIX "/images/shared/red-glow.png",
+  texture_load(&img_red_glow, datadir + "/images/shared/red-glow.png",
                USE_ALPHA);
 
 
 
   /* Distros: */
 
-  texture_load(&img_distro[0] ,DATA_PREFIX "/images/shared/distro-0.png",
+  texture_load(&img_distro[0], datadir + "/images/shared/distro-0.png",
                USE_ALPHA);
 
-  texture_load(&img_distro[1] ,DATA_PREFIX "/images/shared/distro-1.png",
+  texture_load(&img_distro[1], datadir + "/images/shared/distro-1.png",
                USE_ALPHA);
 
-  texture_load(&img_distro[2] ,DATA_PREFIX "/images/shared/distro-2.png",
+  texture_load(&img_distro[2], datadir + "/images/shared/distro-2.png",
                USE_ALPHA);
 
-  texture_load(&img_distro[3] ,DATA_PREFIX "/images/shared/distro-3.png",
+  texture_load(&img_distro[3], datadir + "/images/shared/distro-3.png",
                USE_ALPHA);
 
 
   /* Tux life: */
 
-  texture_load(&tux_life ,DATA_PREFIX "/images/shared/tux-life.png",
+  texture_load(&tux_life, datadir + "/images/shared/tux-life.png",
                USE_ALPHA);
 
   /* Herring: */
 
-  texture_load(&img_golden_herring, DATA_PREFIX "/images/shared/golden-herring.png",
+  texture_load(&img_golden_herring, datadir + "/images/shared/golden-herring.png",
                USE_ALPHA);
 
 
   /* Super background: */
 
-  texture_load(&img_super_bkgd ,DATA_PREFIX "/images/shared/super-bkgd.png",
+  texture_load(&img_super_bkgd, datadir + "/images/shared/super-bkgd.png",
                IGNORE_ALPHA);
 
 
@@ -1195,15 +1193,7 @@ void loadshared(void)
     sounds[i] = load_sound(soundfilenames[i]);
 
   /* Herring song */
-  herring_song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
-                                      strlen("SALCON.MOD") + 8));
-
-  sprintf(herring_song_path, "%s/music/%s", DATA_PREFIX, "SALCON.MOD");
-
-  herring_song = load_song(herring_song_path);
-
-  free(herring_song_path);
-
+  herring_song = load_song(datadir + "/music/SALCON.MOD");
 }
 
 
index 451170a..69aadd9 100644 (file)
@@ -54,18 +54,18 @@ int intro(void)
   timer_type timer;
     
   /* Load sprite images: */
-  texture_load(&bkgd, DATA_PREFIX "/images/intro/intro.png", IGNORE_ALPHA);  
-  texture_load(&gown_sit, DATA_PREFIX "/images/intro/gown-sit.png", USE_ALPHA);
-  texture_load(&gown_lookup, DATA_PREFIX "/images/intro/gown-lookup.png", USE_ALPHA);
-  texture_load(&gown_upset, DATA_PREFIX "/images/intro/gown-upset.png", USE_ALPHA);
-  texture_load(&tux_sit, DATA_PREFIX "/images/intro/tux-sit.png", USE_ALPHA);
-  texture_load(&tux_upset, DATA_PREFIX "/images/intro/tux-upset.png", USE_ALPHA);
-  texture_load(&tux_mad, DATA_PREFIX "/images/intro/tux-mad.png", USE_ALPHA);
-  texture_load(&copter[0], DATA_PREFIX "/images/intro/copter1.png", USE_ALPHA);
-  texture_load(&copter[1], DATA_PREFIX "/images/intro/copter2.png", USE_ALPHA); 
-  texture_load(&copter_squish, DATA_PREFIX "/images/intro/copter-squish.png", USE_ALPHA); 
-  texture_load(&copter_stretch, DATA_PREFIX "/images/intro/copter-stretch.png", USE_ALPHA); 
-  texture_load(&beam, DATA_PREFIX "/images/intro/beam.png", USE_ALPHA); 
+  texture_load(&bkgd, datadir + "/images/intro/intro.png", IGNORE_ALPHA);  
+  texture_load(&gown_sit, datadir + "/images/intro/gown-sit.png", USE_ALPHA);
+  texture_load(&gown_lookup, datadir + "/images/intro/gown-lookup.png", USE_ALPHA);
+  texture_load(&gown_upset, datadir + "/images/intro/gown-upset.png", USE_ALPHA);
+  texture_load(&tux_sit, datadir + "/images/intro/tux-sit.png", USE_ALPHA);
+  texture_load(&tux_upset, datadir + "/images/intro/tux-upset.png", USE_ALPHA);
+  texture_load(&tux_mad, datadir + "/images/intro/tux-mad.png", USE_ALPHA);
+  texture_load(&copter[0], datadir + "/images/intro/copter1.png", USE_ALPHA);
+  texture_load(&copter[1], datadir + "/images/intro/copter2.png", USE_ALPHA); 
+  texture_load(&copter_squish, datadir + "/images/intro/copter-squish.png", USE_ALPHA); 
+  texture_load(&copter_stretch, datadir + "/images/intro/copter-stretch.png", USE_ALPHA); 
+  texture_load(&beam, datadir + "/images/intro/beam.png", USE_ALPHA); 
   
   /* Allocate buffer for height array: */
   
index 172148f..1cf63f9 100644 (file)
@@ -89,15 +89,15 @@ void close_audio( void )
 
 /* --- LOAD A SOUND --- */
 
-Mix_Chunk * load_sound(char * file)
+Mix_Chunk * load_sound(const std::string& file)
 {
   Mix_Chunk * snd;
 
-  snd = Mix_LoadWAV(file);
+  snd = Mix_LoadWAV(file.c_str());
 
   /* printf message and abort if there is an initialized audio device */
   if ((snd == NULL) && (audio_device == YES))
-    st_abort("Can't load", file);
+    st_abort("Can't load", file.c_str());
 
   return(snd);
 }
@@ -105,15 +105,15 @@ Mix_Chunk * load_sound(char * file)
 
 /* --- LOAD A SONG --- */
 
-Mix_Music * load_song(char * file)
+Mix_Music * load_song(const std::string& file)
 {
   Mix_Music * sng;
 
-  sng = Mix_LoadMUS(file);
+  sng = Mix_LoadMUS(file.c_str());
 
   /* printf message and abort if there is an initialized audio device */
   if ((sng == NULL) && (audio_device == YES))
-    st_abort("Can't load", file);
+    st_abort("Can't load", file.c_str());
   return (sng);
 }
 
index 57e17a1..a2cae99 100644 (file)
@@ -69,6 +69,7 @@ extern char* soundfilenames[NUM_SOUNDS];
 
 #ifndef NOSOUND
 
+#include <string>
 #include <SDL_mixer.h>
 
 /* variables for stocking the sound and music */
@@ -79,9 +80,9 @@ extern Mix_Music * level_song, * level_song_fast, * herring_song;
 int open_audio(int frequency, Uint16 format, int channels, int chunksize);
 void close_audio( void );
 
-Mix_Chunk * load_sound(char * file);
+Mix_Chunk * load_sound(const std::string& file);
 void play_sound(Mix_Chunk * snd, enum Sound_Speaker whichSpeaker);
-Mix_Music * load_song(char * file);
+Mix_Music * load_song(const std::string& file);
 
 int playing_music(void);
 int halt_music(void);
index b13b463..4108d10 100644 (file)
 #include "setup.h"
 #include "texture.h"
 
-void (*texture_load) (texture_type* ptexture,const  char * file, int use_alpha);
-void (*texture_load_part) (texture_type* ptexture,const  char * file, int x, int y, int w, int h, int use_alpha);
-void (*texture_free) (texture_type* ptexture);  
-void (*texture_draw) (texture_type* ptexture, float x, float y, int update);  
-void (*texture_draw_bg) (texture_type* ptexture, int update);  
-void (*texture_draw_part) (texture_type* ptexture, float sx, float sy, float x, float y, float w, float h, int update);
+void (*texture_load)     (texture_type* ptexture, const std::string& file, int use_alpha);
+void (*texture_load_part)(texture_type* ptexture, const std::string& file, int x, int y, int w, int h, int use_alpha);
+void (*texture_free)     (texture_type* ptexture);  
+void (*texture_draw)     (texture_type* ptexture, float x, float y, int update);  
+void (*texture_draw_bg)  (texture_type* ptexture, int update);  
+void (*texture_draw_part)(texture_type* ptexture, float sx, float sy, float x, float y, float w, float h, int update);
 
 
 void texture_setup(void)
@@ -58,13 +58,13 @@ void texture_setup(void)
 }
 
 #ifndef NOOPENGL
-void texture_load_gl(texture_type* ptexture,const  char * file, int use_alpha)
+void texture_load_gl(texture_type* ptexture, const std::string& file, int use_alpha)
 {
   texture_load_sdl(ptexture,file,use_alpha);
   texture_create_gl(ptexture->sdl_surface,&ptexture->gl_texture);
 }
 
-void texture_load_part_gl(texture_type* ptexture,const  char * file, int x, int y, int w, int h, int use_alpha)
+void texture_load_part_gl(texture_type* ptexture, const std::string& file, int x, int y, int w, int h, int use_alpha)
 {
   texture_load_part_sdl(ptexture,file,x,y,w,h,use_alpha);
   texture_create_gl(ptexture->sdl_surface,&ptexture->gl_texture);
@@ -218,14 +218,14 @@ float ph = power_of_two(ptexture->h);
 }
 #endif
 
-void texture_load_sdl(texture_type* ptexture,const  char * file, int use_alpha)
+void texture_load_sdl(texture_type* ptexture, const std::string& file, int use_alpha)
 {
   SDL_Surface * temp;
   
-  temp = IMG_Load(file);
+  temp = IMG_Load(file.c_str());
 
   if (temp == NULL)
-    st_abort("Can't load", file);
+    st_abort("Can't load", file.c_str());
 
   if(use_alpha == IGNORE_ALPHA && !use_gl)
   ptexture->sdl_surface = SDL_DisplayFormat(temp);
@@ -233,7 +233,7 @@ void texture_load_sdl(texture_type* ptexture,const  char * file, int use_alpha)
   ptexture->sdl_surface = SDL_DisplayFormatAlpha(temp);
   
   if (ptexture->sdl_surface == NULL)
-    st_abort("Can't covert to display format", file);
+    st_abort("Can't covert to display format", file.c_str());
 
   if (use_alpha == IGNORE_ALPHA && !use_gl)
     SDL_SetAlpha(ptexture->sdl_surface, 0, 0);
@@ -245,17 +245,17 @@ void texture_load_sdl(texture_type* ptexture,const  char * file, int use_alpha)
   
 }
 
-void texture_load_part_sdl(texture_type* ptexture,const  char * file, int x, int y, int w, int h,  int use_alpha)
+void texture_load_part_sdl(texture_type* ptexture, const std::string& file, int x, int y, int w, int h,  int use_alpha)
 {
 
   SDL_Rect src;
   SDL_Surface * temp;
   SDL_Surface * conv;
 
-  temp = IMG_Load(file);
+  temp = IMG_Load(file.c_str());
 
   if (temp == NULL)
-    st_abort("Can't load", file);
+    st_abort("Can't load", file.c_str());
 
   /* Set source rectangle for conv: */
 
@@ -286,7 +286,7 @@ void texture_load_part_sdl(texture_type* ptexture,const  char * file, int x, int
   ptexture->sdl_surface = SDL_DisplayFormatAlpha(conv);
 
   if (ptexture->sdl_surface == NULL)
-    st_abort("Can't covert to display format", file);
+    st_abort("Can't covert to display format", file.c_str());
 
   if (use_alpha == IGNORE_ALPHA && !use_gl)
     SDL_SetAlpha(ptexture->sdl_surface, 0, 0);
index 2fcc5a1..68fa4bc 100644 (file)
@@ -13,6 +13,8 @@
 #ifndef SUPERTUX_TEXTURE_H
 #define SUPERTUX_TEXTURE_H
 
+#include <string>
+
 #include "SDL.h"
 #ifndef NOOPENGL
 #include "SDL_opengl.h"
@@ -28,22 +30,22 @@ typedef struct texture_type
   } texture_type;
 
 void texture_setup(void);
-extern void (*texture_load) (texture_type* ptexture,const  char * file, int use_alpha);  
-extern void (*texture_load_part) (texture_type* ptexture,const  char * file, int x, int y, int w, int h, int use_alpha);
+extern void (*texture_load) (texture_type* ptexture, const std::string& file, int use_alpha);  
+extern void (*texture_load_part) (texture_type* ptexture, const std::string& file, int x, int y, int w, int h, int use_alpha);
 extern void (*texture_free) (texture_type* ptexture);  
 extern void (*texture_draw) (texture_type* ptexture, float x, float y, int update);  
 extern void (*texture_draw_bg) (texture_type* ptexture, int update);  
 extern void (*texture_draw_part) (texture_type* ptexture, float sx, float sy, float x, float y, float w, float h, int update);
-void texture_load_sdl(texture_type* ptexture,const  char * file, int use_alpha);
-void texture_load_part_sdl(texture_type* ptexture,const  char * file, int x, int y, int w, int h, int use_alpha);
+void texture_load_sdl(texture_type* ptexture, const std::string&, int use_alpha);
+void texture_load_part_sdl(texture_type* ptexture, const std::string& file, int x, int y, int w, int h, int use_alpha);
 void texture_free_sdl(texture_type* ptexture);
 void texture_draw_sdl(texture_type* ptexture, float x, float y, int update);
 void texture_draw_bg_sdl(texture_type* ptexture, int update);
 void texture_draw_part_sdl(texture_type* ptexture,float sx, float sy, float x, float y, float w, float h, int update);
 void texture_from_sdl_surface(texture_type* ptexture, SDL_Surface * sdl_surf, int use_alpha);
 #ifndef NOOPENGL
-void texture_load_gl(texture_type* ptexture,const  char * file, int use_alpha);
-void texture_load_part_gl(texture_type* ptexture,const  char * file, int x, int y, int w, int h, int use_alpha);
+void texture_load_gl(texture_type* ptexture, const std::string& file, int use_alpha);
+void texture_load_part_gl(texture_type* ptexture, const std::string& file, int x, int y, int w, int h, int use_alpha);
 void texture_free_gl(texture_type* ptexture);
 void texture_draw_gl(texture_type* ptexture, float x, float y, int update);
 void texture_draw_bg_gl(texture_type* ptexture, int update);