Index: trunk/src/util/loading/resource_manager.cc
===================================================================
--- trunk/src/util/loading/resource_manager.cc	(revision 6152)
+++ trunk/src/util/loading/resource_manager.cc	(revision 6222)
@@ -19,4 +19,6 @@
 
 #include "debug.h"
+
+#include <algorithm>
 
 // different resource Types
@@ -40,7 +42,4 @@
 #endif /* NO_SHADERS */
 
-#include "list.h"
-#include "sdlincl.h"
-
 // File Handling Includes
 #include <sys/types.h>
@@ -61,6 +60,4 @@
   strcpy(this->dataDir, "./");
   this->tryDataDir("./data");
-  this->imageDirs = new tList<char>;
-  this->resourceList = new tList<Resource>;
 }
 
@@ -76,18 +73,13 @@
   this->unloadAllByPriority(RP_GAME);
 
-  if (this->resourceList->getSize() > 0)
-    PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList->getSize());
-
-  delete this->resourceList;
+  if (!this->resourceList.empty())
+    PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size());
+
   // deleting the Directorie Lists
-  tIterator<char>* tmpIt = imageDirs->getIterator();
-  char* tmpDir = tmpIt->firstElement();
-  while(tmpDir)
-    {
-      delete[] tmpDir;
-      tmpDir = tmpIt->nextElement();
-    }
-  delete tmpIt;
-  delete this->imageDirs;
+  while (!this->imageDirs.empty())
+    {
+      delete[] this->imageDirs.front();
+      this->imageDirs.pop_front();
+    }
 
   delete[] this->dataDir;
@@ -211,21 +203,16 @@
     {
       // check if the Directory has been added before
-      tIterator<char>* tmpImageDirs = imageDirs->getIterator();
-      char* tmpDir = tmpImageDirs->firstElement();
-      while(tmpDir)
-        {
-          if (!strcmp(tmpDir, newDir))
-            {
-              PRINTF(3)("Path %s already loaded\n", newDir);
-              delete[] newDir;
-              delete tmpImageDirs;
-              return true;
-            }
-          tmpDir = tmpImageDirs->nextElement();
-        }
-      delete tmpImageDirs;
-
+      std::list<char*>::const_iterator imageDir;
+      for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
+      {
+         if (!strcmp(*imageDir, newDir))
+         {
+           PRINTF(3)("Path %s already loaded\n", newDir);
+           delete[] newDir;
+           return true;
+         }
+      }
       // adding the directory to the List
-      this->imageDirs->add(newDir);
+      this->imageDirs.push_back(newDir);
       return true;
     }
@@ -389,5 +376,7 @@
               else
                 tmpResource->secFileName = NULL;
-              tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName);
+                tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName);
+//               tmpResource->pointer = new MD2Model(fullName, tmpResource->secFileName);
+
             }
               break;
@@ -425,11 +414,9 @@
           else
             {
-              char* tmpDir;
-              tIterator<char>* iterator = imageDirs->getIterator();
-              tmpDir = iterator->firstElement();
-              while(tmpDir)
+              std::list<char*>::iterator imageDir;
+              for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
                 {
-                  char* imgName = new char[strlen(tmpDir)+strlen(fileName)+1];
-                  sprintf(imgName, "%s%s", tmpDir, fileName);
+                  char* imgName = new char[strlen(*imageDir)+strlen(fileName)+1];
+                  sprintf(imgName, "%s%s", *imageDir, fileName);
                   if(isFile(imgName))
                     {
@@ -440,7 +427,5 @@
                     }
                   delete[] imgName;
-                  tmpDir = iterator->nextElement();
                 }
-              delete iterator;
             }
           if(!tmpResource)
@@ -477,5 +462,5 @@
         }
       if (tmpResource->pointer != NULL)
-        this->resourceList->add(tmpResource);
+        this->resourceList.push_back(tmpResource);
       delete[] fullName;
     }
@@ -572,5 +557,6 @@
           PRINTF(4)("Resource %s safely removed.\n", resource->name);
           delete[] resource->name;
-          this->resourceList->remove(resource);
+          std::list<Resource*>::iterator resourceIT = std::find(this->resourceList.begin(), this->resourceList.end(), resource);
+          this->resourceList.erase(resourceIT);
           delete resource;
         }
@@ -590,18 +576,28 @@
 bool ResourceManager::unloadAllByPriority(ResourcePriority prio)
 {
-  tIterator<Resource>* iterator = resourceList->getIterator();
-  Resource* enumRes = iterator->lastElement();
-  while (enumRes)
-    {
-      if (enumRes->prio <= prio)
-        if (enumRes->count == 0)
-          unload(enumRes, prio);
-        else
-          PRINTF(2)("unable to unload %s because there are still %d references to it\n",
-                   enumRes->name, enumRes->count);
-      //enumRes = resourceList->nextElement();
-      enumRes = iterator->prevElement();
-    }
-  delete iterator;
+  std::list<Resource*>::iterator resource, pre;
+  pre = --this->resourceList.end();
+  unsigned int removeCount;
+  for (unsigned int round = 0; round < 3; round++)
+  {
+    removeCount = 0;
+    while (pre != resourceList.end())
+    {
+      resource = pre;
+      pre--;
+        if ((*resource)->prio <= prio)
+        {
+          if ((*resource)->count == 0)
+            unload((*resource), prio);
+          else
+          {
+            PRINTF(2)("unable to unload %s because there are still %d references to it\n",
+                     (*resource)->name, (*resource)->count);
+            removeCount++;
+          }
+        }
+     }
+     if (removeCount == 0) break;
+  }
 }
 
@@ -619,10 +615,8 @@
                                                 void* param1, void* param2, void* param3) const
 {
-  //  Resource* enumRes = resourceList->enumerate();
-  tIterator<Resource>* iterator = resourceList->getIterator();
-  Resource* enumRes = iterator->firstElement();
-  while (enumRes)
-    {
-      if (enumRes->type == type && !strcmp(fileName, enumRes->name))
+  std::list<Resource*>::const_iterator resource;
+  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
+  {
+    if ((*resource)->type == type && !strcmp(fileName, (*resource)->name))
         {
           bool match = false;
@@ -635,8 +629,8 @@
               if (!param1)
                 {
-                  if (enumRes->modelSize == 1.0)
+                  if ((*resource)->modelSize == 1.0)
                     match = true;
                 }
-              else if (enumRes->modelSize == *(float*)param1)
+              else if ((*resource)->modelSize == *(float*)param1)
                 match = true;
               break;
@@ -644,8 +638,8 @@
               if (!param1)
                 {
-                  if (enumRes->secFileName == NULL)
+                  if ((*resource)->secFileName == NULL)
                     match = true;
                 }
-              else if (!strcmp(enumRes->secFileName, (const char*)param1))
+              else if (!strcmp((*resource)->secFileName, (const char*)param1))
                 match = true;
               break;
@@ -655,8 +649,8 @@
               if (param1 == NULL)
                 {
-                  if (enumRes->ttfSize == FONT_DEFAULT_RENDER_SIZE)
+                  if ((*resource)->ttfSize == FONT_DEFAULT_RENDER_SIZE)
                     match = true;
                 }
-              else if (enumRes->ttfSize == *(unsigned int*)param1)
+              else if ((*resource)->ttfSize == *(unsigned int*)param1)
                 match = true;
               break;
@@ -666,8 +660,8 @@
                 if (!param1)
                 {
-                  if (enumRes->secFileName == NULL)
+                  if ((*resource)->secFileName == NULL)
                     match = true;
                 }
-                else if (!strcmp(enumRes->secFileName, (const char*)param1))
+                else if (!strcmp((*resource)->secFileName, (const char*)param1))
                   match = true;
 #endif /* NO_SHADERS */
@@ -678,11 +672,8 @@
           if (match)
             {
-              delete iterator;
-              return enumRes;
+              return (*resource);
             }
         }
-      enumRes = iterator->nextElement();
-    }
-  delete iterator;
+    }
   return NULL;
 }
@@ -696,16 +687,8 @@
 {
   //  Resource* enumRes = resourceList->enumerate();
-  tIterator<Resource>* iterator = resourceList->getIterator();
-  Resource* enumRes = iterator->firstElement();
-  while (enumRes)
-    {
-      if (pointer == enumRes->pointer)
-        {
-          delete iterator;
-          return enumRes;
-        }
-      enumRes = iterator->nextElement();
-    }
-  delete iterator;
+  std::list<Resource*>::const_iterator resource;
+  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
+    if (pointer == (*resource)->pointer)
+        return (*resource);
   return NULL;
 }
@@ -920,24 +903,19 @@
   PRINT(0)(" Data-Directory is: %s\n", this->dataDir);
   PRINT(0)(" List of Image-Directories: ");
-  tIterator<char>* tmpIt = imageDirs->getIterator();
-  char* tmpDir = tmpIt->firstElement();
-  while(tmpDir)
-    {
-      PRINT(0)("%s ",tmpDir);
-      tmpDir = tmpIt->nextElement();
-    }
-  delete tmpIt;
+  std::list<char*>::const_iterator imageDir;
+  for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
+      PRINT(0)("%s ", (*imageDir));
   PRINT(0)("\n");
 
   PRINT(0)("List of all stored Resources:\n");
-  tIterator<Resource>* iterator = resourceList->getIterator();
-  Resource* enumRes = iterator->firstElement();
-  while (enumRes)
+  std::list<Resource*>::const_iterator resource;
+  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
+
     {
       PRINT(0)("-----------------------------------------\n");
-      PRINT(0)("Name: %s; References: %d; Type: %s ", enumRes->name, enumRes->count, ResourceManager::ResourceTypeToChar(enumRes->type));
+      PRINT(0)("Name: %s; References: %d; Type: %s ", (*resource)->name, (*resource)->count, ResourceManager::ResourceTypeToChar((*resource)->type));
 
       PRINT(0)("gets deleted at ");
-      switch(enumRes->prio)
+      switch((*resource)->prio)
         {
         default:
@@ -955,7 +933,5 @@
           break;
         }
-      enumRes = iterator->nextElement();
-    }
-  delete iterator;
+    }
 
 
Index: trunk/src/util/loading/resource_manager.h
===================================================================
--- trunk/src/util/loading/resource_manager.h	(revision 6152)
+++ trunk/src/util/loading/resource_manager.h	(revision 6222)
@@ -21,8 +21,6 @@
 #include "base_object.h"
 
-#include "stdlibincl.h"
 
-// FORWARD DECLARATION
-template<class T> class tList;
+#include <list>
 
 //! An eumerator for different fileTypes the resourceManager supports
@@ -144,6 +142,6 @@
 
   char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
-  tList<Resource>*         resourceList;       //!< The List of Resources, that has already been loaded.
-  tList<char>*             imageDirs;          //!< A list of directories in which images are stored.
+  std::list<Resource*>     resourceList;       //!< The List of Resources, that has already been loaded.
+  std::list<char*>         imageDirs;          //!< A list of directories in which images are stored.
 
 };
