Index: /orxonox/trunk/src/lib/sound/sound_engine.cc
===================================================================
--- /orxonox/trunk/src/lib/sound/sound_engine.cc	(revision 4959)
+++ /orxonox/trunk/src/lib/sound/sound_engine.cc	(revision 4960)
@@ -22,4 +22,5 @@
 
 //#include <AL/alc.h> // maybe later
+#include "class_list.h"
 
 #include "p_node.h"
@@ -81,5 +82,5 @@
 SoundBuffer::~SoundBuffer()
 {
-  SoundEngine::getInstance()->removeBuffer(this);
+//  SoundEngine::getInstance()->removeBuffer(this);
   alDeleteBuffers(1, &this->bufferID);
 }
@@ -118,5 +119,5 @@
 SoundSource::~SoundSource()
 {
-  SoundEngine::getInstance()->removeSource(this);
+  //SoundEngine::getInstance()->removeSource(this);
   alDeleteSources(1, &this->sourceID);
 }
@@ -192,6 +193,6 @@
 
   this->listener = NULL;
-  this->bufferList = new tList<SoundBuffer>;
-  this->sourceList = new tList<SoundSource>;
+  this->bufferList = NULL;
+  this->sourceList = NULL;
 }
 
@@ -210,23 +211,28 @@
 
   // deleting all the SoundSources
-  tIterator<SoundSource>* sourceIterator = this->sourceList->getIterator();
-  SoundSource* enumSource = sourceIterator->nextElement();
-  while (enumSource)
-    {
-      delete enumSource;
-      enumSource = sourceIterator->nextElement();
-    }
-  delete sourceIterator;
+  if(this->sourceList != NULL)
+  {
+    tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
+    SoundSource* enumSource = (SoundSource*)sourceIterator->nextElement();
+    while (enumSource)
+    {
+        delete enumSource;
+        enumSource = (SoundSource*)sourceIterator->nextElement();
+    }
+    delete sourceIterator;
+  }
 
   // deleting all the SoundBuffers
-  tIterator<SoundBuffer>* bufferIterator = this->bufferList->getIterator();
-  SoundBuffer* enumBuffer = bufferIterator->nextElement();
-  while (enumBuffer)
+  if (this->bufferList != NULL)
+  {
+    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
+    SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
+    while (enumBuffer)
     {
       ResourceManager::getInstance()->unload(enumBuffer);
-      enumBuffer = bufferIterator->nextElement();
-    }
-  delete bufferIterator;
-
+      enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
+    }
+    delete bufferIterator;
+  }
   // removing openAL from AudioResource
   alutExit();
@@ -273,5 +279,6 @@
 void SoundEngine::addBuffer(SoundBuffer* buffer)
 {
-  this->bufferList->add(buffer);
+  if (unlikely(this->bufferList == NULL))
+    this->bufferList = ClassList::getList(CL_SOUND_BUFFER);
 }
 
@@ -283,16 +290,13 @@
 {
   // look if there are any sources that have the buffer still loaded
-  tIterator<SoundSource>* sourceIterator = this->sourceList->getIterator();
-  SoundSource* enumSource = sourceIterator->nextElement();
+  tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
+  SoundSource* enumSource = (SoundSource*)sourceIterator->nextElement();
   while (enumSource)
     {
       if (buffer == enumSource->getBuffer())
         delete enumSource;
-      enumSource = sourceIterator->nextElement();
+      enumSource = (SoundSource*)sourceIterator->nextElement();
     }
   delete sourceIterator;
-
-  // remove the Buffer
-  this->bufferList->remove(buffer);
 }
 
@@ -303,16 +307,6 @@
 void SoundEngine::addSource(SoundSource* source)
 {
-  this->sourceList->add(source);
-}
-
-/**
- *  removes a SoundSource from the sourceList of the SoundEngine
- * @param source The source to delete from the SoundEngine
-*/
-void SoundEngine::removeSource(SoundSource* source)
-{
-  this->sourceList->remove(source);
-}
-
+  this->sourceList = ClassList::getList(CL_SOUND_SOURCE);
+}
 
 /**
@@ -341,7 +335,9 @@
 
   // updating all the Sources positions
-  tIterator<SoundSource>* iterator = this->sourceList->getIterator();
-  SoundSource* enumSource = iterator->nextElement();
-  while (enumSource)
+  if (likely(this->sourceList != NULL))
+  {
+    tIterator<BaseObject>* iterator = this->sourceList->getIterator();
+    SoundSource* enumSource = (SoundSource*)iterator->nextElement();
+    while (enumSource)
     {
       if (likely(enumSource->getNode()!=NULL))
@@ -356,7 +352,8 @@
                    enumSource->getNode()->getVelocity().z);
       }
-      enumSource = iterator->nextElement();
-    }
-  delete iterator;
+      enumSource = (SoundSource*)iterator->nextElement();
+    }
+    delete iterator;
+  }
 }
 
@@ -366,22 +363,25 @@
 void SoundEngine::flushUnusedBuffers()
 {
-  tIterator<SoundBuffer>* bufferIterator = this->bufferList->getIterator();
-  SoundBuffer* enumBuffer = bufferIterator->nextElement();
-  while (enumBuffer)
-    {
-      tIterator<SoundSource>* sourceIterator = this->sourceList->getIterator();
-      SoundSource* enumSource = sourceIterator->nextElement();
+  if(this->sourceList && this->bufferList)
+  {
+    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
+    SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
+    while (enumBuffer)
+    {
+      tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
+      SoundSource* enumSource = (SoundSource*)sourceIterator->nextElement();
       while (enumSource)
-        {
-          if (enumBuffer == enumSource->getBuffer())
-            break;
-          enumSource = sourceIterator->nextElement();
-        }
+      {
+        if (enumBuffer == enumSource->getBuffer())
+          break;
+        enumSource = (SoundSource*)sourceIterator->nextElement();
+      }
       delete sourceIterator;
       if (enumSource == NULL)
         ResourceManager::getInstance()->unload(enumBuffer);
-      enumBuffer = bufferIterator->nextElement();
-    }
-  delete bufferIterator;
+      enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
+    }
+    delete bufferIterator;
+  }
 }
 
@@ -391,12 +391,15 @@
 void SoundEngine::flushAllBuffers()
 {
-  tIterator<SoundBuffer>* bufferIterator = this->bufferList->getIterator();
-  SoundBuffer* enumBuffer = bufferIterator->nextElement();
-  while (enumBuffer)
+  if (this->bufferList)
+  {
+    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
+    SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
+    while (enumBuffer)
     {
       ResourceManager::getInstance()->unload(enumBuffer, RP_LEVEL);
-      enumBuffer = bufferIterator->nextElement();
-    }
-  delete bufferIterator;
+      enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
+    }
+    delete bufferIterator;
+  }
 }
 
@@ -406,14 +409,16 @@
 void SoundEngine::flushAllSources()
 {
-  tIterator<SoundSource>* Iterator = this->sourceList->getIterator();
-  SoundSource* enumSource = Iterator->nextElement();
-  while (enumSource)
+  if (this->sourceList)
   {
-    delete enumSource;
-    enumSource = Iterator->nextElement();
+    tIterator<BaseObject>* Iterator = this->sourceList->getIterator();
+    SoundSource* enumSource = (SoundSource*)Iterator->nextElement();
+    while (enumSource)
+    {
+      delete enumSource;
+      enumSource = (SoundSource*)Iterator->nextElement();
+    }
+    delete Iterator;
   }
-  delete Iterator;
-}
-
+}
 
 /**
Index: /orxonox/trunk/src/lib/sound/sound_engine.h
===================================================================
--- /orxonox/trunk/src/lib/sound/sound_engine.h	(revision 4959)
+++ /orxonox/trunk/src/lib/sound/sound_engine.h	(revision 4960)
@@ -9,5 +9,4 @@
 #include "base_object.h"
 #include "alincl.h"
-
 
 #define SOUND_DOPPLER_FACTOR       0.001          //!< A factor for the audible doppler effect
@@ -85,5 +84,4 @@
     void removeBuffer(SoundBuffer* buffer);
     void addSource(SoundSource* source);
-    void removeSource(SoundSource* source);
 
     void update();
@@ -109,6 +107,6 @@
 
     PNode*                   listener;                 //!< The listener of the Scene
-    tList<SoundBuffer>*      bufferList;               //!< A list of buffers
-    tList<SoundSource>*      sourceList;               //!< A list for all the sources in the scene.
+    tList<BaseObject>*       bufferList;               //!< A list of buffers
+    tList<BaseObject>*       sourceList;               //!< A list for all the sources in the scene.
 
 };
