[Super-tux-commit] supertux/src gameloop.cpp,1.93,1.94 level.cpp,1.45,1.46 resources.cpp,1.14,1.15 s
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-04-22 11:17:52
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23341/src Modified Files: gameloop.cpp level.cpp resources.cpp sound.cpp title.cpp world.cpp worldmap.cpp Log Message: Applied MatzeB (Ryan?) patch that fixes crash and also improves music. Ingo, you seem to have forgotten to add two files to cvs: smalltux-gameover-0.png smalltux-gameover-1.png Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.93 retrieving revision 1.94 diff -u -d -r1.93 -r1.94 --- gameloop.cpp 22 Apr 2004 00:00:58 -0000 1.93 +++ gameloop.cpp 22 Apr 2004 11:17:34 -0000 1.94 @@ -474,7 +474,6 @@ GameSession::run() { Menu::set_current(0); - Player* tux = world->get_tux(); current_ = this; int fps_cnt = 0; @@ -504,7 +503,7 @@ } /* Handle events: */ - tux->input.old_fire = tux->input.fire; + world->get_tux()->input.old_fire = world->get_tux()->input.fire; process_events(); process_menu(); @@ -555,11 +554,11 @@ } /* Handle time: */ - if (!time_left.check() && tux->dying == DYING_NOT) - tux->kill(KILL); + if (!time_left.check() && world->get_tux()->dying == DYING_NOT) + world->get_tux()->kill(KILL); /* Handle music: */ - if(tux->invincible_timer.check()) + if(world->get_tux()->invincible_timer.check()) { if(world->get_music_type() != HERRING_MUSIC) world->play_music(HERRING_MUSIC); Index: sound.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sound.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- sound.cpp 21 Apr 2004 23:38:04 -0000 1.10 +++ sound.cpp 22 Apr 2004 11:17:34 -0000 1.11 @@ -102,7 +102,6 @@ snd = Mix_LoadWAV(file.c_str()); - /* printf message and abort if there is an initialized audio device */ if ((snd == NULL) && audio_device) st_abort("Can't load", file); @@ -115,17 +114,10 @@ Mix_Music * load_song(const std::string& file) { if(!audio_device) - return 0; + return (Mix_Music*) ~0; - Mix_Music * sng; - - sng = Mix_LoadMUS(file.c_str()); - - /* printf message and abort if there is an initialized audio device */ - if (sng == NULL) - st_abort("Can't load", file); - - return (sng); + Mix_Music* song = Mix_LoadMUS(file.c_str()); + return song; } @@ -160,7 +152,6 @@ { if (chunk != NULL) { - DEBUG_MSG( __PRETTY_FUNCTION__ ); Mix_FreeChunk( chunk ); chunk = NULL; } @@ -180,6 +171,8 @@ { if (!audio_device) return; + if(music == current_song) + return; if (use_music && Mix_PlayMusic(music, -1) < 0) st_abort("Couldn't play music: ", Mix_GetError()); @@ -190,6 +183,9 @@ void free_music(Mix_Music *music) { + if(!audio_device) + return; + Mix_FreeMusic( music ); } Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- title.cpp 22 Apr 2004 00:13:33 -0000 1.55 +++ title.cpp 22 Apr 2004 11:17:34 -0000 1.56 @@ -139,6 +139,7 @@ { index -= 1; // FIXME: Hack std::cout << "Sarting level: " << index << std::endl; + halt_music(); GameSession session(current_contrib_subset, index, ST_GL_PLAY); session.run(); Menu::set_current(main_menu); @@ -159,6 +160,8 @@ //World* world = session->get_world(); Level* plevel = session->get_level(); Player* tux = session->get_world()->get_tux(); + + session->get_world()->play_music(LEVEL_MUSIC); /* FIXME: // update particle systems @@ -248,9 +251,6 @@ update_time = st_get_ticks(); random_timer.start(rand() % 2000 + 2000); - Mix_Music* music = load_song(datadir + "/music/theme.mod"); - play_music(music); - Menu::set_current(main_menu); while (Menu::current()) { @@ -357,14 +357,11 @@ /* Pause: */ frame++; SDL_Delay(25); - - play_music(music); } /* Free surfaces: */ delete bkg_title; delete logo; - free_music(music); } #define MAX_VEL 10 Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- worldmap.cpp 21 Apr 2004 23:38:14 -0000 1.42 +++ worldmap.cpp 22 Apr 2004 11:17:34 -0000 1.43 @@ -726,6 +726,9 @@ quit = false; song = load_song(datadir + "/music/" + music); + if(!song) + st_abort("Couldn't load song ", music.c_str()); + play_music(song); while(!quit) { Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- world.cpp 21 Apr 2004 23:38:08 -0000 1.35 +++ world.cpp 22 Apr 2004 11:17:34 -0000 1.36 @@ -68,8 +68,6 @@ activate_bad_guys(); activate_particle_systems(); get_level()->load_song(); - - play_music(LEVEL_MUSIC); } World::~World() Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- level.cpp 21 Apr 2004 23:37:39 -0000 1.45 +++ level.cpp 22 Apr 2004 11:17:34 -0000 1.46 @@ -199,18 +199,18 @@ } Level::Level() - : level_song(0), level_song_fast(0) + : img_bkgd(0), level_song(0), level_song_fast(0) { } Level::Level(const std::string& subset, int level) - : level_song(0), level_song_fast(0) + : img_bkgd(0), level_song(0), level_song_fast(0) { load(subset, level); } Level::Level(const std::string& filename) - : level_song(0), level_song_fast(0) + : img_bkgd(0), level_song(0), level_song_fast(0) { load(filename); } @@ -696,10 +696,13 @@ void Level::free_song(void) { + if(level_song_fast != level_song) { + free_music(level_song_fast); + level_song_fast = 0; + } + free_music(level_song); level_song = 0; - free_music(level_song_fast); - level_song_fast = 0; } void @@ -711,6 +714,8 @@ char* song_subtitle; level_song = ::load_song(datadir + "/music/" + song_title); + if(!level_song) + st_abort("Couldn't load song: " , song_title.c_str()); song_path = (char *) malloc(sizeof(char) * datadir.length() + strlen(song_title.c_str()) + 8 + 5); @@ -719,6 +724,9 @@ sprintf(song_path, "%s/music/%s-fast%s", datadir.c_str(), song_subtitle, strstr(song_title.c_str(), ".")); level_song_fast = ::load_song(song_path); + if(!level_song_fast) { + level_song_fast = level_song; + } free(song_subtitle); free(song_path); } Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- resources.cpp 22 Apr 2004 00:13:33 -0000 1.14 +++ resources.cpp 22 Apr 2004 11:17:34 -0000 1.15 @@ -25,6 +25,7 @@ #include "special.h" #include "resources.h" #include "sprite_manager.h" +#include "setup.h" Surface* img_waves[3]; Surface* img_water; @@ -289,6 +290,8 @@ /* Herring song */ herring_song = load_song(datadir + "/music/SALCON.MOD"); + if(!herring_song) + st_abort("Couldn't load song ", "/music/SALCON.MOD"); } |