diff --git a/src/init.cpp b/src/init.cpp index 5af4c3a62..459f12659 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -430,42 +430,6 @@ int initApp(const char* title, int fullscreen) GO_SwapBuffers(screen); - // load sound effects - printlog("loading sounds...\n"); - fp = openDataFile("sound/sounds.txt", "r"); - for ( numsounds = 0; !feof(fp); numsounds++ ) - { - while ( fgetc(fp) != '\n' ) if ( feof(fp) ) - { - break; - } - } - if ( numsounds == 0 ) - { - printlog("failed to identify any sounds in sounds.txt\n"); - fclose(fp); - return 10; - } - sounds = (Sound**) malloc(sizeof(Sound*)*numsounds); - rewind(fp); - for ( c = 0; !feof(fp); c++ ) - { - fscanf(fp, "%s", name); - while ( fgetc(fp) != '\n' ) - if ( feof(fp) ) - break; - sounds[c] = createSound(name); - if (!sounds[c]) - { - printlog("warning: failed to load sound '%s' at line %d in sounds.txt", name, c+1); - } - //TODO: set sound volume? Or otherwise handle sound volume. - } - fclose(fp); - ChannelGroup_SetVolume(sound_group, sfxvolume / 128.0); - // set 3d settings? - //FMOD_System_Set3DSettings(fmod_system, 1.0, 2.0, 1.0); - return 0; } @@ -1911,24 +1875,6 @@ int deinitApp() free(polymodels); } - // free sounds - printlog("freeing sounds...\n"); - if ( sounds != NULL ) - { - for ( c = 0; c < numsounds; c++ ) - { - if (sounds[c] != NULL) - { - if (sounds[c] != NULL) - { - Sound_Release(sounds[c]); //Free the sound's FMOD sound. - } - //free(sounds[c]); //Then free the sound itself. - } - } - free(sounds); //Then free the sound array. - } - // delete opengl buffers if ( allsurfaces != NULL ) { diff --git a/src/init_game.cpp b/src/init_game.cpp index c8a841eb8..b9bc3edaf 100644 --- a/src/init_game.cpp +++ b/src/init_game.cpp @@ -374,6 +374,43 @@ int initGame() } } + // load sound effects + printlog("loading sounds...\n"); + fp = openDataFile("sound/sounds.txt", "r"); + for ( numsounds = 0; !feof(fp); numsounds++ ) + { + while ( fgetc(fp) != '\n' ) if ( feof(fp) ) + { + break; + } + } + if ( numsounds == 0 ) + { + printlog("failed to identify any sounds in sounds.txt\n"); + fclose(fp); + return 10; + } + sounds = (Sound**) malloc(sizeof(Sound*)*numsounds); + rewind(fp); + for ( c = 0; !feof(fp); c++ ) + { + fscanf(fp, "%s", name); + while ( fgetc(fp) != '\n' ) + if ( feof(fp) ) + break; + sounds[c] = createSound(name); + if (!sounds[c]) + { + printlog("warning: failed to load sound '%s' at line %d in sounds.txt", name, c+1); + } + //TODO: set sound volume? Or otherwise handle sound volume. + } + fclose(fp); + ChannelGroup_SetVolume(sound_group, sfxvolume / 128.0); + // set 3d settings? + //FMOD_System_Set3DSettings(fmod_system, 1.0, 2.0, 1.0); + + // load music #ifdef SOUND @@ -660,6 +697,24 @@ void deinitGame() list_FreeAll(&safePacketsReceived[c]); } #ifdef SOUND + // free sounds + printlog("freeing sounds...\n"); + if ( sounds != NULL ) + { + for ( c = 0; c < numsounds; c++ ) + { + if (sounds[c] != NULL) + { + if (sounds[c] != NULL) + { + Sound_Release(sounds[c]); //Free the sound's FMOD sound. + } + //free(sounds[c]); //Then free the sound itself. + } + } + free(sounds); //Then free the sound array. + } + Channel_Stop(music_channel); Channel_Stop(music_channel2); Sound_Release(intromusic); diff --git a/src/sound_null.cpp b/src/sound_null.cpp index 658bcd389..fb0acff51 100644 --- a/src/sound_null.cpp +++ b/src/sound_null.cpp @@ -1,16 +1,17 @@ #include "sound.hpp" -Channel *playSoundPlayer(int, Uint32, int) {return NULL;} Channel *playSoundPos(real_t, real_t, Uint32) {return NULL;} Channel* playSoundPosLocal(real_t x, real_t y, Uint32 snd, int vol) {return NULL;} -Channel* playSoundEntity(Entity* entity, Uint32 snd, int vol) {return NULL;} -Channel* playSoundEntityLocal(Entity* entity, Uint32 snd, int vol) {return NULL;} Channel* playSound(Uint32 snd, int vol) {return NULL;} Channel* playSoundVelocity() {return NULL;} -Uint32 numsounds = 0; -Sound** sounds = NULL; -ChannelGroup *sound_group = NULL; -bool levelmusicplaying; +Sound* CreateMusic(const char* name) {return NULL;} +void playmusic(Sound* sound, bool loop, bool crossfade, bool resume) {} +unsigned int Channel_GetPosition(Channel*) {return 0;} +void ChannelGroup_Stop(ChannelGroup*) {} +bool Channel_IsPlaying(Channel*) {return false;} +void Channel_Stop(Channel*) {} +unsigned int Sound_GetLength(Sound*) {return 0;} +void sound_update() {} void ChannelGroup_SetVolume(ChannelGroup*, float) {} void initSound() {} void deinitSound() {}