X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameInitDispose.cpp;h=79d8bd150578f9ff49b39d31471464c6d35f86b9;hb=483f57f7df7e65f1aacbee8dbcef320ede069a95;hp=02b0c93cf1124638a1cfb341bcb612991cb039ca;hpb=617a36f729718c59c2f886fd4a1d145388e7c8bc;p=lugaru.git diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index 02b0c93..79d8bd1 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -34,13 +34,11 @@ extern float gravity; extern Light light; extern Skeleton testskeleton; extern int numsounds; -extern int channels[100]; extern Terrain terrain; //extern Sprites sprites; extern int kTextureSize; extern float texdetail; extern float realtexdetail; -extern float terraindetail; extern float volume; extern Objects objects; extern int detail; @@ -51,9 +49,6 @@ extern bool ismotionblur; extern bool trilinear; extern bool osx; extern bool musictoggle; -extern Weapons weapons; -extern Person player[maxplayers]; -extern int numplayers; extern int environment; extern bool ambientsound; extern float multiplier; @@ -66,7 +61,6 @@ extern long dirID; extern int mainmenu; extern int oldmainmenu; extern bool visibleloading; -extern int loadscreencolor; extern float flashamount,flashr,flashg,flashb; extern int flashdelay; extern int whichjointstartarray[26]; @@ -74,7 +68,6 @@ extern int whichjointendarray[26]; extern int difficulty; extern float tintr,tintg,tintb; extern float slomospeed; -extern char mapname[256]; extern bool gamestarted; extern int numdialogues; @@ -100,11 +93,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); - void LOG(const std::string &fmt, ...) { // !!! FIXME: write me. @@ -141,19 +129,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,20 +145,6 @@ void Game::Dispose() } -void Game::LoadSounds() -{ - LOGFUNC; - - LOG(std::string("Loading sounds...")); - - OPENAL_3D_SetDopplerFactor(0); - - 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; @@ -450,14 +417,6 @@ void Game::LoadingScreen() glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1); - //glColor4f(1,1,1,1); - /*if(loadscreencolor==0)glColor4f(1,1,1,1); - if(loadscreencolor==1)glColor4f(1,0,0,1); - if(loadscreencolor==2)glColor4f(0,1,0,1); - if(loadscreencolor==3)glColor4f(0,0,1,1); - if(loadscreencolor==4)glColor4f(1,1,0,1); - if(loadscreencolor==5)glColor4f(1,0,1,1); - */ glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS); @@ -514,13 +473,6 @@ void Game::LoadingScreen() glEnable(GL_BLEND); //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1); glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1); - /*if(loadscreencolor==0)glColor4f(1,1,1,1); - if(loadscreencolor==1)glColor4f(1,0,0,1); - if(loadscreencolor==2)glColor4f(0,1,0,1); - if(loadscreencolor==3)glColor4f(0,0,1,1); - if(loadscreencolor==4)glColor4f(1,1,0,1); - if(loadscreencolor==5)glColor4f(1,0,1,1); - */ glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS); @@ -632,7 +584,6 @@ void Game::LoadingScreen() } swap_gl_buffers(); - loadscreencolor=0; } } @@ -673,13 +624,6 @@ void Game::FadeLoadingScreen(float howmuch) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); glColor4f(loadprogress/100,0,0,1); - /*if(loadscreencolor==0)glColor4f(1,1,1,1); - if(loadscreencolor==1)glColor4f(1,0,0,1); - if(loadscreencolor==2)glColor4f(0,1,0,1); - if(loadscreencolor==3)glColor4f(0,0,1,1); - if(loadscreencolor==4)glColor4f(1,1,0,1); - if(loadscreencolor==5)glColor4f(1,0,1,1); - */ glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS); @@ -711,7 +655,6 @@ void Game::FadeLoadingScreen(float howmuch) text.glPrint(280,125,string,1,1,640,480); */ swap_gl_buffers(); - loadscreencolor=0; } @@ -845,22 +788,12 @@ void Game::InitGame() if(detail==2){ texdetail=1; - terraindetail=1; } if(detail==1){ texdetail=2; - terraindetail=1; } if(detail==0){ texdetail=4; - terraindetail=1; - //terraindetail=2; - } - - memset(channels, 0xff, sizeof(channels)); - for (int it = 0; it < 20; ++it) - { - strm[it] = NULL; } LOG("Initializing sound system..."); @@ -901,65 +834,10 @@ void Game::InitGame() #endif OPENAL_SetSFXMasterVolume((int)(volume*255)); + loadAllSounds(); - strm[stream_music3] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music3.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=0;} -// OPENAL_Sample_SetMinMaxDistance(strm[stream_music3], 4.0f, 1000.0f); - OPENAL_Stream_SetMode(strm[stream_music3], OPENAL_LOOP_NORMAL); - - if(musictoggle){ -// PlaySoundEx( stream_music3, strm[stream_music3], NULL, true); - PlayStreamEx(stream_music3, strm[stream_music3], 0, true); - OPENAL_SetPaused(channels[stream_music3], false); - OPENAL_SetVolume(channels[stream_music3], 256); - } - - FadeLoadingScreen(20); - - if(ambientsound){ - strm[stream_wind] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:wind.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} -// OPENAL_Sample_SetMinMaxDistance(strm[stream_wind], 4.0f, 1000.0f); - OPENAL_Stream_SetMode(strm[stream_wind], OPENAL_LOOP_NORMAL); - - FadeLoadingScreen(30); - - strm[stream_desertambient] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:desertambient.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} -// OPENAL_Sample_SetMinMaxDistance(strm[stream_desertambient], 4.0f, 1000.0f); - OPENAL_Stream_SetMode(strm[stream_desertambient], OPENAL_LOOP_NORMAL); - } - - FadeLoadingScreen(40); - - 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); - - //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); - OPENAL_Stream_SetMode(strm[stream_music1grass], OPENAL_LOOP_NORMAL); - - strm[stream_music1snow] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1snow.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=2;} -// OPENAL_Sample_SetMinMaxDistance(strm[stream_music1snow], 4.0f, 1000.0f); - OPENAL_Stream_SetMode(strm[stream_music1snow], OPENAL_LOOP_NORMAL); - - FadeLoadingScreen(60); - - strm[stream_music1desert] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1desert.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=3;} -// OPENAL_Sample_SetMinMaxDistance(strm[stream_music1desert], 4.0f, 1000.0f); - OPENAL_Stream_SetMode(strm[stream_music1desert], OPENAL_LOOP_NORMAL); - - FadeLoadingScreen(80); - strm[stream_music2] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music2.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=4;} -// OPENAL_Sample_SetMinMaxDistance(strm[stream_music2], 4.0f, 1000.0f); - OPENAL_Stream_SetMode(strm[stream_music2], OPENAL_LOOP_NORMAL); - - //} - - - FadeLoadingScreen(90); - + if(musictoggle) + emit_stream_np(stream_music3); LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1); @@ -1008,11 +886,6 @@ void Game::LoadStuff() visibleloading=1; - /*musicvolume[3]=512; - PlaySoundEx( music4, samp[music4], NULL, true); - OPENAL_SetPaused(channels[music4], false); - OPENAL_SetVolume(channels[music4], 512); - */ loadtime=0; stillloading=1; @@ -1051,16 +924,12 @@ void Game::LoadStuff() if(detail==2){ texdetail=1; - terraindetail=1; } if(detail==1){ texdetail=2; - terraindetail=1; } if(detail==0){ texdetail=4; - terraindetail=1; - //terraindetail=2; } realtexdetail=texdetail; @@ -1208,7 +1077,7 @@ void Game::LoadStuff() gravity=-10; texscale=.2/megascale/viewdistdetail; - terrain.scale=3*megascale*terraindetail*viewdistdetail; + terrain.scale=3*megascale*viewdistdetail; viewer.x=terrain.size/2*terrain.scale; viewer.z=terrain.size/2*terrain.scale; @@ -1262,7 +1131,6 @@ void Game::LoadStuff() } } - loadscreencolor=4; LoadingScreen(); for(i=0;i