From 617a36f729718c59c2f886fd4a1d145388e7c8bc Mon Sep 17 00:00:00 2001 From: Alexander Monakov Date: Mon, 13 Dec 2010 00:29:54 +0300 Subject: [PATCH] Cleanup sound loading --- CMakeLists.txt | 3 + Source/Game.cpp | 1 - Source/GameDraw.cpp | 1 - Source/GameInitDispose.cpp | 199 +------------------------------------ Source/GameTick.cpp | 1 - Source/Globals.cpp | 1 - Source/OpenGL_Windows.cpp | 1 - Source/Person.cpp | 1 - Source/Skeleton.cpp | 1 - Source/Sounds.cpp | 64 ++++++++++++ Source/Sounds.def | 124 ++++++++++++----------- Source/Sounds.h | 6 +- Source/Weapons.cpp | 1 - 13 files changed, 136 insertions(+), 268 deletions(-) create mode 100644 Source/Sounds.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6943bfd..9e2f866 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,7 @@ set(LUGARU_SRCS ${SRCDIR}/Settings.cpp ${SRCDIR}/Stereo.cpp ${SRCDIR}/Animation.cpp + ${SRCDIR}/Sounds.cpp ) set(LUGARU_H @@ -115,6 +116,8 @@ set(LUGARU_H ${SRCDIR}/Stereo.h ${SRCDIR}/Animation.h ${SRCDIR}/Animation.def + ${SRCDIR}/Sounds.h + ${SRCDIR}/Sounds.def ) if(UNIX) diff --git a/Source/Game.cpp b/Source/Game.cpp index 241914c..a64803f 100644 --- a/Source/Game.cpp +++ b/Source/Game.cpp @@ -3,7 +3,6 @@ #include "SDL_thread.h" extern int mainmenu; -extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index 5286b5d..2b5ebf6 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -159,7 +159,6 @@ extern bool gamestarted; extern bool showdamagebar; -extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index e8e1682..02b0c93 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -34,7 +34,6 @@ extern float gravity; extern Light light; extern Skeleton testskeleton; extern int numsounds; -extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern Terrain terrain; //extern Sprites sprites; @@ -165,7 +164,6 @@ void Game::Dispose() } -//void Game::LoadSounds(); void Game::LoadSounds() { LOGFUNC; @@ -176,189 +174,8 @@ void Game::LoadSounds() OPENAL_SetSFXMasterVolume((int)(volume*255)); - samp[footstepsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); - - samp[footstepsound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); - - samp[footstepsound3] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); - - samp[footstepsound4] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f); - - samp[landsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:land.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[landsound], 4.0f, 1000.0f); - - samp[jumpsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:jump.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[jumpsound], 4.0f, 1000.0f); - - samp[hawksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:hawk.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[hawksound], 40.0f, 10000.0f); - - samp[whooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:whoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[whooshsound], 4.0f, 1000.0f); - OPENAL_Sample_SetMode(samp[whooshsound], OPENAL_LOOP_NORMAL); - - samp[landsound1] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:land1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[landsound1], 4.0f, 1000.0f); - - - - samp[landsound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:land2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[landsound2], 4.0f, 1000.0f); - - samp[breaksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:broken.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[breaksound], 8.0f, 2000.0f); - - samp[lowwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Lowwhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[lowwhooshsound], 8.0f, 2000.0f); - - samp[midwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:midwhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[midwhooshsound], 8.0f, 2000.0f); - - samp[highwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:highwhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[highwhooshsound], 8.0f, 2000.0f); - - samp[movewhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:movewhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[movewhooshsound], 8.0f, 2000.0f); - - samp[heavyimpactsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:heavyimpact.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[heavyimpactsound], 8.0f, 2000.0f); - - samp[whooshhitsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Whooshhit.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[whooshhitsound], 8.0f, 2000.0f); - - samp[thudsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:thud.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[thudsound], 8.0f, 2000.0f); - - samp[alarmsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:alarm.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[alarmsound], 8.0f, 2000.0f); - - samp[breaksound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:break.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[breaksound2], 8.0f, 2000.0f); - - samp[knifedrawsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifedraw.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[knifedrawsound], 8.0f, 2000.0f); - - samp[knifesheathesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifesheathe.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[knifesheathesound], 8.0f, 2000.0f); - - samp[fleshstabsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Fleshstab.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[fleshstabsound], 8.0f, 2000.0f); - - samp[fleshstabremovesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Fleshstabremove.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[fleshstabremovesound], 8.0f, 2000.0f); - - samp[knifeswishsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifeswish.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[knifeswishsound], 8.0f, 2000.0f); - - samp[knifeslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifeslice.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[knifeslicesound], 8.0f, 2000.0f); - - samp[swordslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:swordslice.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[swordslicesound], 8.0f, 2000.0f); - - samp[skidsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:skid.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[skidsound], 8.0f, 2000.0f); - - samp[snowskidsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:snowskid.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[snowskidsound], 8.0f, 2000.0f); - - samp[bushrustle] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bushrustle.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[bushrustle], 4.0f, 1000.0f); - - samp[clank1sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[clank1sound], 8.0f, 2000.0f); - - samp[clank2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[clank2sound], 8.0f, 2000.0f); - - samp[clank3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank3.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[clank3sound], 8.0f, 2000.0f); - - samp[clank4sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank4.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[clank4sound], 8.0f, 2000.0f); - - samp[consolesuccesssound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:consolesuccess.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[consolesuccesssound], 4.0f, 1000.0f); - - samp[consolefailsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:consolefail.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[consolefailsound], 4.0f, 1000.0f); - - samp[metalhitsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:MetalHit.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[metalhitsound], 8.0f, 2000.0f); - - samp[clawslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clawslice.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[clawslicesound], 8.0f, 2000.0f); - - samp[splattersound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:splatter.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[splattersound], 8.0f, 2000.0f); - - samp[growlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Growl.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[growlsound], 1000.0f, 2000.0f); - - samp[growl2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Growl2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[growl2sound], 1000.0f, 2000.0f); - - samp[barksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bark.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[barksound], 1000.0f, 2000.0f); - - samp[bark2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bark2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[bark2sound], 1000.0f, 2000.0f); - - samp[bark3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bark3.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[bark3sound], 1000.0f, 2000.0f); - - samp[snarlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:snarl.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[snarlsound], 1000.0f, 2000.0f); - - - samp[snarl2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:snarl2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[snarl2sound], 1000.0f, 2000.0f); - - samp[barkgrowlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:barkgrowl.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[barkgrowlsound], 1000.0f, 2000.0f); - - samp[rabbitattacksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[rabbitattacksound], 1000.0f, 2000.0f); - - samp[rabbitattack2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack2sound], 1000.0f, 2000.0f); - - samp[rabbitattack3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack3.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack3sound], 1000.0f, 2000.0f); - - samp[rabbitattack4sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack4.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack4sound], 1000.0f, 2000.0f); - - samp[rabbitpainsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitpain.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[rabbitpainsound], 1000.0f, 2000.0f); - - samp[rabbitpain1sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitpain2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[rabbitpain1sound], 1000.0f, 2000.0f); - - /*samp[rabbitpain2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitpain2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[rabbitpain2sound], 1000.0f, 2000.0f); - */ - samp[rabbitchitter] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitchitter.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[rabbitchitter], 1000.0f, 2000.0f); - - samp[rabbitchitter2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitchitter2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[rabbitchitter2], 1000.0f, 2000.0f); - - samp[swordstaffsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:swordstaff.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[swordstaffsound], 8.0f, 2000.0f); - - samp[staffbodysound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:staffbody.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[staffbodysound], 8.0f, 2000.0f); - - samp[staffheadsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:staffhead.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[staffheadsound], 8.0f, 2000.0f); - - samp[staffbreaksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:staffbreak.wav"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[staffbreaksound], 8.0f, 2000.0f); + if(visibleloading){LoadingScreen(); loadscreencolor=5;} + loadAllSounds(); } void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha) @@ -1040,11 +857,7 @@ void Game::InitGame() //terraindetail=2; } - for (int it = 0; it < 100; ++it) - { - channels[it] = -1; - samp[it] = NULL; - } + memset(channels, 0xff, sizeof(channels)); for (int it = 0; it < 20; ++it) { strm[it] = NULL; @@ -1116,18 +929,12 @@ void Game::InitGame() FadeLoadingScreen(40); - samp[firestartsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:firestart.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - strm[stream_firesound] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:fire.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} // OPENAL_Sample_SetMinMaxDistance(strm[stream_firesound], 8.0f, 2000.0f); OPENAL_Stream_SetMode(strm[stream_firesound], OPENAL_LOOP_NORMAL); FadeLoadingScreen(50); - samp[fireendsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:fireend.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - //if(musictoggle){ strm[stream_music1grass] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1grass.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=1;} // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1grass], 4.0f, 1000.0f); diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index bf754b6..0a6d464 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -48,7 +48,6 @@ extern XYZ viewer; extern int environment; extern float texscale; extern Terrain terrain; -extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern int kTextureSize; extern float screenwidth,screenheight; diff --git a/Source/Globals.cpp b/Source/Globals.cpp index c5cb64c..fe502d8 100644 --- a/Source/Globals.cpp +++ b/Source/Globals.cpp @@ -39,7 +39,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Animation.h" bool visibleloading = 0; -OPENAL_SAMPLE *samp[100] = {0}; OPENAL_STREAM * strm[20] = {0}; int channels[100] = {0}; diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index c0f061c..49e877e 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -772,7 +772,6 @@ int main(int argc, char **argv) // -------------------------------------------------------------------------- extern int channels[100]; -extern OPENAL_SAMPLE * samp[100]; extern OPENAL_STREAM * strm[20]; extern "C" void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused) diff --git a/Source/Person.cpp b/Source/Person.cpp index c8f9119..b9e6181 100644 --- a/Source/Person.cpp +++ b/Source/Person.cpp @@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Sounds.h" extern float multiplier; -extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern Terrain terrain; extern float gravity; diff --git a/Source/Skeleton.cpp b/Source/Skeleton.cpp index 2959e81..9683f55 100644 --- a/Source/Skeleton.cpp +++ b/Source/Skeleton.cpp @@ -29,7 +29,6 @@ extern float multiplier; extern float gravity; extern Skeleton testskeleton; extern Terrain terrain; -extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern Objects objects; extern int environment; diff --git a/Source/Sounds.cpp b/Source/Sounds.cpp new file mode 100644 index 0000000..9bf927b --- /dev/null +++ b/Source/Sounds.cpp @@ -0,0 +1,64 @@ +/* +Copyright (C) 2010 - Lugaru authors + +This file is part of Lugaru. + +Lugaru is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "Sounds.h" +#include "openal_wrapper.h" + +struct OPENAL_SAMPLE *samp[sounds_count]; + +static const char *sound_data[sounds_count] = { +#define DECLARE_SOUND(id, filename) filename, +#include "Sounds.def" +#undef DECLARE_SOUND +}; + +// FIXME: dimensionality is not a property of the sound sample. +// This should be decided at the time of playback +static int snd_mode(int snd) +{ + switch (snd) + { + case alarmsound: + case consolefailsound: + case consolesuccesssound: + case firestartsound: + case fireendsound: + return OPENAL_2D; + default: + return OPENAL_HW3D; + } +} + +void loadAllSounds() +{ + for (int i = 0; i < sounds_count; i++) + { + char buf[64]; + snprintf(buf, 64, ":Data:Sounds:%s", sound_data[i]); + samp[i] = OPENAL_Sample_Load(OPENAL_FREE, + ConvertFileName(buf), + snd_mode(i), + 0, 0); + } + // Huh? + // OPENAL_Sample_SetMode(samp[whooshsound], OPENAL_LOOP_NORMAL); +} + diff --git a/Source/Sounds.def b/Source/Sounds.def index 32c57cb..bd18779 100644 --- a/Source/Sounds.def +++ b/Source/Sounds.def @@ -19,66 +19,64 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -DECLARE_SOUND(footstepsound) -DECLARE_SOUND(footstepsound2) -DECLARE_SOUND(footstepsound3) -DECLARE_SOUND(footstepsound4) -DECLARE_SOUND(jumpsound) -DECLARE_SOUND(landsound) -DECLARE_SOUND(whooshsound) -DECLARE_SOUND(hawksound) -DECLARE_SOUND(landsound1) -DECLARE_SOUND(landsound2) -DECLARE_SOUND(breaksound) -DECLARE_SOUND(lowwhooshsound) -DECLARE_SOUND(heavyimpactsound) -DECLARE_SOUND(firestartsound) -DECLARE_SOUND(fireendsound) -DECLARE_SOUND(breaksound2) -DECLARE_SOUND(knifedrawsound) -DECLARE_SOUND(knifesheathesound) -DECLARE_SOUND(knifeswishsound) -DECLARE_SOUND(knifeslicesound) -DECLARE_SOUND(skidsound) -DECLARE_SOUND(snowskidsound) -DECLARE_SOUND(bushrustle) -DECLARE_SOUND(midwhooshsound) -DECLARE_SOUND(highwhooshsound) -DECLARE_SOUND(movewhooshsound) -DECLARE_SOUND(thudsound) -DECLARE_SOUND(whooshhitsound) -DECLARE_SOUND(clank1sound) -DECLARE_SOUND(clank2sound) -DECLARE_SOUND(clank3sound) -DECLARE_SOUND(clank4sound) -DECLARE_SOUND(consolefailsound) -DECLARE_SOUND(consolesuccesssound) -DECLARE_SOUND(swordslicesound) -DECLARE_SOUND(metalhitsound) -DECLARE_SOUND(clawslicesound) -DECLARE_SOUND(splattersound) -DECLARE_SOUND(growlsound) -DECLARE_SOUND(growl2sound) -DECLARE_SOUND(barksound) -DECLARE_SOUND(snarlsound) -DECLARE_SOUND(snarl2sound) -DECLARE_SOUND(barkgrowlsound) -DECLARE_SOUND(bark2sound) -DECLARE_SOUND(bark3sound) -DECLARE_SOUND(rabbitattacksound) -DECLARE_SOUND(rabbitattack2sound) -DECLARE_SOUND(rabbitattack3sound) -DECLARE_SOUND(rabbitattack4sound) -DECLARE_SOUND(rabbitpainsound) -DECLARE_SOUND(rabbitpain1sound) -DECLARE_SOUND(rabbitpain2sound) -DECLARE_SOUND(rabbitchitter) -DECLARE_SOUND(rabbitchitter2) -DECLARE_SOUND(fleshstabsound) -DECLARE_SOUND(fleshstabremovesound) -DECLARE_SOUND(swordstaffsound) -DECLARE_SOUND(staffbodysound) -DECLARE_SOUND(staffheadsound) -DECLARE_SOUND(alarmsound) -DECLARE_SOUND(staffbreaksound) - +DECLARE_SOUND(footstepsound, "footstepsnow1.ogg") +DECLARE_SOUND(footstepsound2, "footstepsnow2.ogg") +DECLARE_SOUND(footstepsound3, "footstepstone1.ogg") +DECLARE_SOUND(footstepsound4, "footstepstone2.ogg") +DECLARE_SOUND(landsound, "land.ogg") +DECLARE_SOUND(jumpsound, "jump.ogg") +DECLARE_SOUND(hawksound, "hawk.ogg") +DECLARE_SOUND(whooshsound, "whoosh.ogg") +DECLARE_SOUND(landsound1, "land1.ogg") +DECLARE_SOUND(landsound2, "land2.ogg") +DECLARE_SOUND(breaksound, "broken.ogg") +DECLARE_SOUND(lowwhooshsound, "lowwhoosh.ogg") +DECLARE_SOUND(midwhooshsound, "midwhoosh.ogg") +DECLARE_SOUND(highwhooshsound, "highwhoosh.ogg") +DECLARE_SOUND(movewhooshsound, "movewhoosh.ogg") +DECLARE_SOUND(heavyimpactsound, "heavyimpact.ogg") +DECLARE_SOUND(whooshhitsound, "whooshhit.ogg") +DECLARE_SOUND(thudsound, "thud.ogg") +DECLARE_SOUND(alarmsound, "alarm.ogg") +DECLARE_SOUND(breaksound2, "break.ogg") +DECLARE_SOUND(knifedrawsound, "knifedraw.ogg") +DECLARE_SOUND(knifesheathesound, "knifesheathe.ogg") +DECLARE_SOUND(fleshstabsound, "fleshstab.ogg") +DECLARE_SOUND(fleshstabremovesound, "fleshstabremove.ogg") +DECLARE_SOUND(knifeswishsound, "knifeswish.ogg") +DECLARE_SOUND(knifeslicesound, "knifeslice.ogg") +DECLARE_SOUND(swordslicesound, "swordslice.ogg") +DECLARE_SOUND(skidsound, "skid.ogg") +DECLARE_SOUND(snowskidsound, "snowskid.ogg") +DECLARE_SOUND(bushrustle, "bushrustle.ogg") +DECLARE_SOUND(clank1sound, "clank1.ogg") +DECLARE_SOUND(clank2sound, "clank2.ogg") +DECLARE_SOUND(clank3sound, "clank3.ogg") +DECLARE_SOUND(clank4sound, "clank4.ogg") +DECLARE_SOUND(consolesuccesssound, "consolesuccess.ogg") +DECLARE_SOUND(consolefailsound, "consolefail.ogg") +DECLARE_SOUND(metalhitsound, "metalhit.ogg") +DECLARE_SOUND(clawslicesound, "clawslice.ogg") +DECLARE_SOUND(splattersound, "splatter.ogg") +DECLARE_SOUND(growlsound, "growl.ogg") +DECLARE_SOUND(growl2sound, "growl2.ogg") +DECLARE_SOUND(barksound, "bark.ogg") +DECLARE_SOUND(bark2sound, "bark2.ogg") +DECLARE_SOUND(bark3sound, "bark3.ogg") +DECLARE_SOUND(snarlsound, "snarl.ogg") +DECLARE_SOUND(snarl2sound, "snarl2.ogg") +DECLARE_SOUND(barkgrowlsound, "barkgrowl.ogg") +DECLARE_SOUND(rabbitattacksound, "rabbitattack.ogg") +DECLARE_SOUND(rabbitattack2sound, "rabbitattack2.ogg") +DECLARE_SOUND(rabbitattack3sound, "rabbitattack3.ogg") +DECLARE_SOUND(rabbitattack4sound, "rabbitattack4.ogg") +DECLARE_SOUND(rabbitpainsound, "rabbitpain.ogg") +DECLARE_SOUND(rabbitpain1sound, "rabbitpain2.ogg") +DECLARE_SOUND(rabbitchitter, "rabbitchitter.ogg") +DECLARE_SOUND(rabbitchitter2, "rabbitchitter2.ogg") +DECLARE_SOUND(swordstaffsound, "swordstaff.ogg") +DECLARE_SOUND(staffbodysound, "staffbody.ogg") +DECLARE_SOUND(staffheadsound, "staffhead.ogg") +DECLARE_SOUND(staffbreaksound, "staffbreak.ogg") +DECLARE_SOUND(firestartsound, "firestart.ogg") +DECLARE_SOUND(fireendsound, "fireend.ogg") diff --git a/Source/Sounds.h b/Source/Sounds.h index 042afae..eef2b50 100644 --- a/Source/Sounds.h +++ b/Source/Sounds.h @@ -23,9 +23,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SOUNDS_H enum sound_types { -#define DECLARE_SOUND(id) id, +#define DECLARE_SOUND(id, filename) id, #include "Sounds.def" #undef DECLARE_SOUND +sounds_count }; +extern struct OPENAL_SAMPLE *samp[sounds_count]; + +extern void loadAllSounds(); #endif diff --git a/Source/Weapons.cpp b/Source/Weapons.cpp index d76103e..267bd14 100644 --- a/Source/Weapons.cpp +++ b/Source/Weapons.cpp @@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Sounds.h" extern float multiplier; -extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern Terrain terrain; extern float gravity; -- 2.39.5