]> git.jsancho.org Git - lugaru.git/commitdiff
Cleanup sound loading
authorAlexander Monakov <amonakov@gmail.com>
Sun, 12 Dec 2010 21:29:54 +0000 (00:29 +0300)
committerAlexander Monakov <amonakov@gmail.com>
Sun, 12 Dec 2010 21:29:54 +0000 (00:29 +0300)
13 files changed:
CMakeLists.txt
Source/Game.cpp
Source/GameDraw.cpp
Source/GameInitDispose.cpp
Source/GameTick.cpp
Source/Globals.cpp
Source/OpenGL_Windows.cpp
Source/Person.cpp
Source/Skeleton.cpp
Source/Sounds.cpp [new file with mode: 0644]
Source/Sounds.def
Source/Sounds.h
Source/Weapons.cpp

index 6943bfd39bd7daf2014713736451548eb729690d..9e2f8661431961aa6de9f68c322b716552841f3d 100644 (file)
@@ -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)
index 241914c63b716d0734d25cd5fa0c0dcf390134df..a64803fe605e762101920485f6adcb21eafd69e5 100644 (file)
@@ -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);
 
index 5286b5ddf6585f18b27680b92838ab041cbbc858..2b5ebf681c4ffafbb0d2a586ff5125f0ccd949b4 100644 (file)
@@ -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);
 
index e8e16827b762168ca06d531ba8f13a0975072ac8..02b0c93cf1124638a1cfb341bcb612991cb039ca 100644 (file)
@@ -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);
index bf754b6f6a71f135f2eaa6fe6ddfd9876ad48e66..0a6d464d221d1e551ce1cc7cfdb6617d8f506acf 100644 (file)
@@ -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;
index c5cb64cc371766471c4e44c3806479086b0f10ce..fe502d82db7db8c5a4c9f57c6ccdd7a12888a5c0 100644 (file)
@@ -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};
 
index c0f061cf2a56a89dc545d991894c26ea24456901..49e877e8838d3919351dc0c44f791882d5974408 100644 (file)
@@ -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)
index c8f91191108d48455cf37d4f1dbf6fb9b4eeb6d6..b9e61813b4c34900d6da5d67fc3922efca118018 100644 (file)
@@ -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;
index 2959e8157ab33281b0a96369c0fc8cdff5e67a15..9683f5572cd983f5a20fb319a89dbcfd3a6ed9cf 100644 (file)
@@ -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 (file)
index 0000000..9bf927b
--- /dev/null
@@ -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);
+}
+
index 32c57cbfd064eccbc5caec155ce739003226704c..bd18779c888bbba7e9dfdb4cef3da75b1d652077 100644 (file)
@@ -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")
index 042afae6f0395d670b81c32a5c78da0fe37f42ae..eef2b5078f05352bc50705b25bbbc4c0a1fbc897 100644 (file)
@@ -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
index d76103e9db81d427e662aa239c4ce0dd22243296..267bd149d1ea2547fd5fa8ad64586d92cedc48ce 100644 (file)
@@ -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;