X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameInitDispose.cpp;h=ec56bca6ff460f9f97280c59c2b28d2955e324d9;hb=76798663af96758c0894d583ca0e1aa7b58728c3;hp=f1091c0d1cd5c65b7f10263b6f7af3534fe2b8f6;hpb=43f08119f2408a487dbefcf670bb6c8f47d4c49b;p=lugaru.git diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index f1091c0..ec56bca 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -89,7 +89,7 @@ extern float accountcampaigntime[10]; extern int accountcampaignchoicesmade[10]; extern int accountcampaignchoices[10][5000]; -extern FSOUND_STREAM * strm[10]; +extern FSOUND_STREAM * strm[20]; extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); @@ -169,6 +169,9 @@ void Game::Dispose() FSOUND_StopSound(FSOUND_ALL); +// 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 @@ -188,6 +191,7 @@ void Game::Dispose() free(texture.data); } texture.data = 0; +#endif } @@ -1004,8 +1008,14 @@ void Game::InitGame() longnum=num2+num1*100000000; char tempstring[256]; + #if defined(__APPLE__) + sprintf (tempstring, "%s", registrationname); + #elif defined(_MSC_VER) || defined(__linux__) sprintf (tempstring, "%s-windows", registrationname); - longnuma = MD5_string ( tempstring); + #else + #error Please make sure you have the right registration key stuff here! + #endif + longnuma = MD5_string ( tempstring); num1a = longnuma/100000000; num2a = longnuma%100000000; //if(num1a==num1&&num2a==num2)registered=1; @@ -1191,7 +1201,40 @@ void Game::InitGame() LOG("Initializing sound system..."); + int output = -1; + + #if PLATFORM_LINUX + extern bool cmdline(const char *cmd); + unsigned char rc = 0; + output = FSOUND_OUTPUT_ALSA; // Try alsa first... + if (cmdline("forceoss")) // ...but let user override that. + output = FSOUND_OUTPUT_OSS; + else if (cmdline("nosound")) + output = FSOUND_OUTPUT_NOSOUND; + + FSOUND_SetOutput(output); + if ((rc = FSOUND_Init(44100, 32, 0)) == FALSE) + { + // if we tried ALSA and failed, fall back to OSS. + if ( (output == FSOUND_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) + { + FSOUND_Close(); + output = FSOUND_OUTPUT_OSS; + FSOUND_SetOutput(output); + rc = FSOUND_Init(44100, 32, 0); + } + } + + if (rc == FALSE) + { + FSOUND_Close(); + output = FSOUND_OUTPUT_NOSOUND; // we tried! just do silence. + FSOUND_SetOutput(output); + rc = FSOUND_Init(44100, 32, 0); + } + #else FSOUND_Init(44100, 32, 0); + #endif FSOUND_SetSFXMasterVolume((int)(volume*255));