]> git.jsancho.org Git - lugaru.git/commitdiff
Unify strms and samps
authorAlexander Monakov <amonakov@gmail.com>
Sat, 18 Dec 2010 11:20:09 +0000 (14:20 +0300)
committerAlexander Monakov <amonakov@gmail.com>
Sat, 18 Dec 2010 11:20:09 +0000 (14:20 +0300)
Source/Constants.h
Source/Game.h
Source/GameInitDispose.cpp
Source/GameTick.cpp
Source/Globals.cpp
Source/Person.cpp
Source/Sounds.cpp
Source/Sounds.def
Source/openal_wrapper.cpp

index 31738b9feb1f931391fccf90446db776cf4227ae..4d50145921a653f5455ec892ac630120f07da843 100644 (file)
@@ -126,17 +126,6 @@ const int max_dialoguelength = 20;
 const int max_model_vertex = 3000;             // maximum number of vertexs
 const int max_textured_triangle = 3000;                // maximum number of texture-filled triangles in a model
 
-const int stream_music1desert = 0;
-const int stream_music1grass = 1;
-const int stream_music1snow = 2;
-const int stream_music2 = 3;
-const int stream_music3 = 4;
-const int stream_music4 = 5;
-const int stream_menumusic = 6;
-const int stream_desertambient = 7;
-const int stream_firesound = 8;
-const int stream_wind = 9;
-
 const int normalmode = 0;
 const int motionblurmode = 1;
 const int radialzoommode = 2;
index 58b0a42870ddfd3b63e02604ad28ba0b74c794fa..d501b8c7e78906775932b5d8e0cd7f50797a8f47 100644 (file)
@@ -249,7 +249,6 @@ class Game
                void SetUpLighting();
                void Loadlevel(int which);
                void Loadlevel(char *name);
-               void LoadSounds();
                void Setenvironment(int which);
                GLvoid ReSizeGLScene(float fov, float near);
                int findPathDist(int start,int end);
index cdc8b9bfa5603eef98ade32c15ac3901b77c8ff8..da5516cb1abf2352a270386ba6660681a3770025 100644 (file)
@@ -100,8 +100,6 @@ extern float accountcampaigntime[10];
 extern int accountcampaignchoicesmade[10];
 extern int accountcampaignchoices[10][5000];
 
-extern OPENAL_STREAM * strm[20];
-
 extern "C"     void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
 
@@ -141,19 +139,12 @@ void Game::Dispose()
 // this is causing problems on Linux, but we'll force an _exit() a little
 //  later in the shutdown process.  --ryan.
 #if !PLATFORM_LINUX
-#define streamcount 20
-#define samplecount 100
 
-       for (i=0; i < samplecount; ++i)
+       for (i=0; i < sounds_count; ++i)
        {
                OPENAL_Sample_Free(samp[i]);
        }
 
-       for (i=0; i < streamcount; ++i)
-       {
-               OPENAL_Stream_Close(strm[i]);
-       }
-
        OPENAL_Close();
        if (texture.data)
        {
@@ -164,18 +155,6 @@ void Game::Dispose()
 }
 
 
-void Game::LoadSounds()
-{
-       LOGFUNC;
-
-       LOG(std::string("Loading sounds..."));
-
-       OPENAL_SetSFXMasterVolume((int)(volume*255));
-
-       if(visibleloading){LoadingScreen(); loadscreencolor=5;}
-       loadAllSounds();
-}
-
 void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha)
 {
        GLuint          type;
@@ -856,10 +835,6 @@ void Game::InitGame()
        }
 
        memset(channels, 0xff, sizeof(channels));
-       for (int it = 0; it < 20; ++it)
-       {
-               strm[it] = NULL;
-       }
 
        LOG("Initializing sound system...");
 
@@ -899,58 +874,14 @@ void Game::InitGame()
     #endif
 
        OPENAL_SetSFXMasterVolume((int)(volume*255));
-
-       strm[stream_music3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:music3.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=0;}
-       OPENAL_Stream_SetMode(strm[stream_music3], OPENAL_LOOP_NORMAL);
+       loadAllSounds();
 
        if(musictoggle){
-//             PlaySoundEx( stream_music3, strm[stream_music3], NULL, true);
-               PlayStreamEx(stream_music3, strm[stream_music3], 0, true);
+               PlayStreamEx(stream_music3, samp[stream_music3], 0, true);
                OPENAL_SetPaused(channels[stream_music3], false);
                OPENAL_SetVolume(channels[stream_music3], 256);
        }
 
-       FadeLoadingScreen(20);
-
-       if(ambientsound){
-               strm[stream_wind] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:wind.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
-               OPENAL_Stream_SetMode(strm[stream_wind], OPENAL_LOOP_NORMAL);
-
-               FadeLoadingScreen(30);
-
-               strm[stream_desertambient] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:desertambient.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
-               OPENAL_Stream_SetMode(strm[stream_desertambient], OPENAL_LOOP_NORMAL);
-       }
-
-       FadeLoadingScreen(40);
-
-       strm[stream_firesound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:fire.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
-       OPENAL_Stream_SetMode(strm[stream_firesound], OPENAL_LOOP_NORMAL);
-
-       FadeLoadingScreen(50);
-
-       //if(musictoggle){
-       strm[stream_music1grass] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:music1grass.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=1;}
-       OPENAL_Stream_SetMode(strm[stream_music1grass], OPENAL_LOOP_NORMAL);
-
-       strm[stream_music1snow] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:music1snow.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=2;}
-       OPENAL_Stream_SetMode(strm[stream_music1snow], OPENAL_LOOP_NORMAL);
-
-       FadeLoadingScreen(60);
-
-       strm[stream_music1desert] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:music1desert.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=3;}
-       OPENAL_Stream_SetMode(strm[stream_music1desert], OPENAL_LOOP_NORMAL);
-
-       FadeLoadingScreen(80);
-       strm[stream_music2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:music2.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=4;}
-       OPENAL_Stream_SetMode(strm[stream_music2], OPENAL_LOOP_NORMAL);
-
-       //}
-
-
-       FadeLoadingScreen(90);
-
-
        LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
 
        LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
@@ -1330,14 +1261,7 @@ void Game::LoadStuff()
 
                glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
        }
-       //}
 
-       LoadSounds();
-
-       /*PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
-       OPENAL_SetVolume(channels[consolesuccesssound], 256);
-       OPENAL_SetPaused(channels[consolesuccesssound], false);
-       */
        if(targetlevel!=7){
                float gLoc[3]={0,0,0};
                float vel[3]={0,0,0};
index e9c2461999a92aa3a01c2bba8844f9b2313e1b3f..5670dc3bc5eb12430461b8e4ef8c86b13adcfb0a 100644 (file)
@@ -241,7 +241,6 @@ static bool stripfx(const char *str, const char *pfx)
   return !strncasecmp(str, pfx, strlen(pfx));
 }
 
-extern OPENAL_STREAM * strm[20];
 extern "C"     void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
 
@@ -1388,7 +1387,7 @@ void      Game::Setenvironment(int which)
                windvector.z=3;
                if(ambientsound){
                        //PlaySoundEx( wind, samp[wind], NULL, true);
-                       PlayStreamEx(stream_wind, strm[stream_wind], 0, true);
+                       PlayStreamEx(stream_wind, samp[stream_wind], 0, true);
                        OPENAL_SetPaused(channels[stream_wind], false);
                        OPENAL_SetVolume(channels[stream_wind], 256);
                }
@@ -1439,7 +1438,7 @@ void      Game::Setenvironment(int which)
 
                if(ambientsound){
                        //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
-                       PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true);
+                       PlayStreamEx( stream_desertambient, samp[stream_desertambient], NULL, true);
                        OPENAL_SetPaused(channels[stream_desertambient], false);
                        OPENAL_SetVolume(channels[stream_desertambient], 256);
                }
@@ -1482,7 +1481,7 @@ void      Game::Setenvironment(int which)
                LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
 
                if(ambientsound){
-                       PlayStreamEx( stream_wind, strm[stream_wind], NULL, true);
+                       PlayStreamEx( stream_wind, samp[stream_wind], NULL, true);
                        OPENAL_SetPaused(channels[stream_wind], false);
                        OPENAL_SetVolume(channels[stream_wind], 100);
                }
@@ -2271,7 +2270,7 @@ void      Game::Loadlevel(char *name){
                {
                        if(ambientsound)
                        {
-                               PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
+                               PlayStreamEx(stream_wind, samp[stream_wind], NULL, true);
                                OPENAL_SetPaused(channels[stream_wind], false);
                                OPENAL_SetVolume(channels[stream_wind], 256);
                        }
@@ -2283,7 +2282,7 @@ void      Game::Loadlevel(char *name){
                                //PlaySoundEx(desertambient,
                                //      samp[desertambient], NULL, true);
                                PlayStreamEx(stream_desertambient,
-                                       strm[stream_desertambient], NULL, true);
+                                       samp[stream_desertambient], NULL, true);
                                OPENAL_SetPaused(channels[stream_desertambient], false);
                                OPENAL_SetVolume(channels[stream_desertambient], 256);
                        }
@@ -2293,7 +2292,7 @@ void      Game::Loadlevel(char *name){
                        if(ambientsound)
                        {
                                //PlaySoundEx(wind, samp[wind], NULL, true);
-                               PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
+                               PlayStreamEx(stream_wind, samp[stream_wind], NULL, true);
                                OPENAL_SetPaused(channels[stream_wind], false);
                                OPENAL_SetVolume(channels[stream_wind], 100);
                        }
@@ -2391,7 +2390,7 @@ void      Game::Tick()
                                if(mainmenu&&musictoggle){
                                        if(mainmenu==1||mainmenu==2||mainmenu==100){
                                                OPENAL_SetFrequency(OPENAL_ALL, 0.001);
-                                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                                               PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
                                                OPENAL_SetPaused(channels[stream_music3], false);
                                                OPENAL_SetVolume(channels[stream_music3], 256);
                                                OPENAL_SetPaused(channels[music1], true);
@@ -2598,7 +2597,7 @@ void      Game::Tick()
                                }
 
                                if(musictoggle){
-                                       PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                                       PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
                                        OPENAL_SetPaused(channels[stream_music3], false);
                                        OPENAL_SetVolume(channels[stream_music3], 256);
                                }
@@ -7667,7 +7666,7 @@ void      Game::Tick()
                                                                                OPENAL_StopSound(OPENAL_ALL);  // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
                                                                                OPENAL_SetFrequency(OPENAL_ALL, 0.001);
 
-                                                                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                                                                               PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
                                                                                OPENAL_SetPaused(channels[stream_music3], false);
                                                                                OPENAL_SetVolume(channels[stream_music3], 256);
 
@@ -7881,15 +7880,15 @@ void    Game::TickOnceAfter(){
 
                if(musictoggle){
                        if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
-                               PlayStreamEx( music1, strm[music1], NULL, true);
+                               PlayStreamEx( music1, samp[music1], NULL, true);
                                OPENAL_SetPaused(channels[music1], false);
                        }
                        if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
-                               PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
+                               PlayStreamEx( stream_music2, samp[stream_music2], NULL, true);
                                OPENAL_SetPaused(channels[stream_music2], false);
                        }
                        if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
-                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                               PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
                                OPENAL_SetPaused(channels[stream_music3], false);
                        }
                        if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
index fe502d82db7db8c5a4c9f57c6ccdd7a12888a5c0..44281cb896f07f1cd3f5c6864e9685e6d6ed9fd4 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_STREAM * strm[20] = {0};
 int channels[100] = {0};
 
 float volume = 0;
index b9e61813b4c34900d6da5d67fc3922efca118018..5f2a2d94815126ddd59fd9bd74bbc40e2ac3f316 100644 (file)
@@ -106,7 +106,6 @@ extern int indialogue;
 
 extern bool gamestarted;
 
-extern OPENAL_STREAM * strm[20];
 extern "C"     void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
 
@@ -221,7 +220,7 @@ void Person::CatchFire(){
        vel[1]=velocity.y;
        vel[2]=velocity.z;
        //PlaySoundEx( firesound, samp[firesound], NULL, true);
-       PlayStreamEx( stream_firesound, strm[stream_firesound], NULL, true);
+       PlayStreamEx( stream_firesound, samp[stream_firesound], NULL, true);
        OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
        OPENAL_SetVolume(channels[stream_firesound], 256);
        OPENAL_SetPaused(channels[stream_firesound], false);
index 365c6d36cb1c3a6d6c693418940a9c2afa8b30d8..c82f42ed3a4a58a5ccb10b5fcd3dfe29eba50cde 100644 (file)
@@ -66,5 +66,7 @@ void loadAllSounds()
   footstepsound4 = footstepst2;
   // Huh?
   // OPENAL_Sample_SetMode(samp[whooshsound], OPENAL_LOOP_NORMAL);
+  for (int i = stream_firesound; i <= stream_music3; i++)
+    OPENAL_Stream_SetMode(samp[i], OPENAL_LOOP_NORMAL);
 }
 
index d0e2744d553f8d01578d506cf7ed4aa62c56af43..c85ab8456a26a076f029ecb6d33067471a0ca02a 100644 (file)
@@ -82,3 +82,11 @@ DECLARE_SOUND(staffheadsound, "staffhead.ogg")
 DECLARE_SOUND(staffbreaksound, "staffbreak.ogg")
 DECLARE_SOUND(firestartsound, "firestart.ogg")
 DECLARE_SOUND(fireendsound, "fireend.ogg")
+DECLARE_SOUND(stream_firesound, "fire.ogg")
+DECLARE_SOUND(stream_music1grass, "music1grass.ogg")
+DECLARE_SOUND(stream_music1snow, "music1snow.ogg")
+DECLARE_SOUND(stream_music1desert, "music1desert.ogg")
+DECLARE_SOUND(stream_wind, "wind.ogg")
+DECLARE_SOUND(stream_desertambient, "desertambient.ogg")
+DECLARE_SOUND(stream_music2, "music2.ogg")
+DECLARE_SOUND(stream_music3, "music3.ogg")
index b4f526682a2405c27ee9c901db91cb8b01423f9c..c3849a859f9cb7fce9042030e639301e17a4a957 100644 (file)
@@ -634,7 +634,6 @@ AL_API signed char OPENAL_SetOutput(int outputtype)
 }
 
 extern int channels[100];
-extern OPENAL_STREAM * strm[20];
 
 extern "C" void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
 {