r115 - trunk/src

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Jun 12 09:42:03 EDT 2005


Author: jonas
Date: 2005-06-12 09:42:03 -0400 (Sun, 12 Jun 2005)
New Revision: 115

Modified:
   trunk/src/sfxeng.h
   trunk/src/sndcache.cpp
Log:
better handling of disabled sfxeng (no error message)

Modified: trunk/src/sfxeng.h
===================================================================
--- trunk/src/sfxeng.h	2005-06-12 13:38:00 UTC (rev 114)
+++ trunk/src/sfxeng.h	2005-06-12 13:42:03 UTC (rev 115)
@@ -16,6 +16,9 @@
         void stopMusic();
         void pauseMusic();
         void resumeMusic();
+        bool isEnabled() {
+            return (!disabled);
+        }
     private:
         /// Music: Theme of the current map
         Mix_Music* theme;

Modified: trunk/src/sndcache.cpp
===================================================================
--- trunk/src/sndcache.cpp	2005-06-12 13:38:00 UTC (rev 114)
+++ trunk/src/sndcache.cpp	2005-06-12 13:42:03 UTC (rev 115)
@@ -1,5 +1,6 @@
 #include "common.h"
 #include "sndcache.h"
+#include "sfxeng.h"
 
 
 SoundCache::SoundCache() { }
@@ -12,22 +13,26 @@
 }
 
 Mix_Chunk* SoundCache::loadWAV(string soundfile) {
-    map<string, Mix_Chunk*>::iterator sndit=sndcache.find(soundfile);
+    if (sfxeng->isEnabled()) {
+        map<string, Mix_Chunk*>::iterator sndit=sndcache.find(soundfile);
     
-    //load new sound
-    if (sndit==sndcache.end()) {
-        #ifdef SDL_MIXER
-            string loadfile=config.datadir+soundfile;
-            Mix_Chunk* tmpwav=NULL;
-            if ((tmpwav=Mix_LoadWAV(loadfile.c_str())) == NULL) {
-                cout << "Couldn't load the wav file: " << soundfile << " (" << Mix_GetError() << ")" << endl;
+        //load new sound
+        if (sndit==sndcache.end()) {
+            #ifdef SDL_MIXER
+                string loadfile=config.datadir+soundfile;
+                Mix_Chunk* tmpwav=NULL;
+                if ((tmpwav=Mix_LoadWAV(loadfile.c_str())) == NULL) {
+                    cout << "Couldn't load the wav file: " << soundfile << " (" << Mix_GetError() << ")" << endl;
+                    return NULL;
+                }
+                sndcache.insert(make_pair(soundfile,tmpwav));
+                return tmpwav;
+            #else
                 return NULL;
-            }
-            sndcache.insert(make_pair(soundfile,tmpwav));
-            return tmpwav;
-        #else
-            return NULL;
-        #endif
-    //already there
-    } else return (*sndit).second;
+            #endif
+        //already there
+        } else return (*sndit).second;
+    } else {
+        return NULL;
+    }
 }




More information about the lostpenguins-commits mailing list