- for (i = 0; i < 4; i++)
- {
- texture_free(&img_solid[i]);
- texture_free(&img_bkgd_tile[0][i]);
- texture_free(&img_bkgd_tile[1][i]);
- }
-
- texture_free(&img_bkgd);
-}
-
-/* Load a level-specific graphic... */
-
-void level_load_image(texture_type* ptexture, string theme,const char * file, int use_alpha)
-{
- char fname[1024];
-
- snprintf(fname, 1024, "%s/themes/%s/%s", st_dir, theme.c_str(), file);
- if(!faccessible(fname))
- snprintf(fname, 1024, "%s/images/themes/%s/%s", datadir.c_str(), theme.c_str(), file);
-
- texture_load(ptexture, fname, use_alpha);
-}
-
-void tilemap_change_size(unsigned int** tilemap[15], int w, int old_w)
-{
- int j,y;
- for(y = 0; y < 15; ++y)
- {
- *tilemap[y] = (unsigned int*) realloc(*tilemap[y],(w+1)*sizeof(unsigned int));
- if(w > old_w)
- for(j = 0; j < w - old_w; ++j)
- *tilemap[y][old_w+j] = 0;
- *tilemap[y][w] = 0;
- }
-}
-
-/* Change the size of a level (width) */
-void level_change_size (st_level* plevel, int new_width)
-{
- if(new_width < 21)
- new_width = 21;
- tilemap_change_size((unsigned int***)&plevel->ia_tiles,new_width,plevel->width);
- tilemap_change_size((unsigned int***)&plevel->dn_tiles,new_width,plevel->width);
- tilemap_change_size((unsigned int***)&plevel->bg_tiles,new_width,plevel->width);
- tilemap_change_size((unsigned int***)&plevel->fg_tiles,new_width,plevel->width);
- plevel->width = new_width;
-
-}
-
-/* Edit a piece of the map! */
-
-void level_change(st_level* plevel, float x, float y, int tm, unsigned int c)
-{
- int xx, yy;
-
- yy = ((int)y / 32);
- xx = ((int)x / 32);
-
- if (yy >= 0 && yy < 15 && xx >= 0 && xx <= plevel->width)
- {
- switch(tm)
- {
- case 0:
- plevel->bg_tiles[yy][xx] = c;
- case 1:
- plevel->ia_tiles[yy][xx] = c;
- case 2:
- plevel->dn_tiles[yy][xx] = c;
- case 4:
- plevel->fg_tiles[yy][xx] = c;
- }
- }
-}
-
-/* Free music data for this level: */
-
-void level_free_song(void)
-{
- free_music(level_song);
- free_music(level_song_fast);
-}
-
-/* Load music: */
-
-void level_load_song(st_level* plevel)
-{
-
- char * song_path;
- char * song_subtitle;
-
- level_song = load_song(datadir + "/music/" + plevel->song_title);
-
- 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", datadir.c_str(), song_subtitle, strstr(plevel->song_title.c_str(), "."));
- level_song_fast = load_song(song_path);
- free(song_subtitle);
- free(song_path);